Skip to content

Commit

Permalink
Adição da tela de register
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilherme200 committed Dec 11, 2020
1 parent 05ee00b commit 3842022
Show file tree
Hide file tree
Showing 11 changed files with 336 additions and 156 deletions.
1 change: 1 addition & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
Binary file added assets/logos/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
115 changes: 12 additions & 103 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,117 +1,26 @@
import 'package:ecommerce_flutter/providers/providers.dart';
import 'package:ecommerce_flutter/routes/routes.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(MyApp());
}

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
// This makes the visual density adapt to the platform that you run
// the app on. For desktop platforms, the controls will be smaller and
// closer together (more dense) than on mobile platforms.
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);

// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.

// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".

final String title;

@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;

void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}

@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
return FutureBuilder(
builder: (ctx, snapshot) => MultiProvider(
providers: providers,
child: MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.purple),
routes: routes,
initialRoute: "/splash",
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
18 changes: 18 additions & 0 deletions lib/models/user_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class UserModel {
String id;
String firstName;
String lastName;
String email;
String password;

UserModel({this.id, this.email});

Map<String, dynamic> toMap() {
return {
"firstName": this.firstName,
"lastName": this.lastName,
"email": this.email,
"password": this.password
};
}
}
7 changes: 7 additions & 0 deletions lib/providers/providers.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'package:ecommerce_flutter/providers/user_provider.dart';
import 'package:provider/single_child_widget.dart';
import 'package:provider/provider.dart';

final List<SingleChildWidget> providers = [
Provider<UserProvider>(create: (_) => UserProvider())
];
24 changes: 24 additions & 0 deletions lib/providers/user_provider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:ecommerce_flutter/models/user_model.dart';
import 'package:flutter/cupertino.dart';

class UserProvider extends ChangeNotifier {

UserProvider() {
loadCurrentUser();
}

Future<void> loadCurrentUser() async {
notifyListeners();
}

Future<void> register(UserModel userModel,
{Function onSuccess, Function onFail}) async {
try {
print('success');
onSuccess();
} catch (e) {
print('error' + e);
onFail(e);
}
}
}
8 changes: 8 additions & 0 deletions lib/routes/routes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'package:ecommerce_flutter/screens/register_screen.dart';
import 'package:ecommerce_flutter/screens/splashScreen.dart';
import 'package:flutter/cupertino.dart';

final Map<String, WidgetBuilder> routes = {
"/splash": (_) => SplashScreen(),
"/register": (_) => RegisterScreen()
};
Loading

0 comments on commit 3842022

Please sign in to comment.