From 3db09e33d81466739771fe29cb549b912c0e153b Mon Sep 17 00:00:00 2001 From: Ravi Date: Thu, 9 Dec 2021 13:43:50 +0530 Subject: [PATCH 1/9] Updated and Refactored Register.dart --- lib/Screens/Register.dart | 164 ++------------------------------------ 1 file changed, 8 insertions(+), 156 deletions(-) diff --git a/lib/Screens/Register.dart b/lib/Screens/Register.dart index 99978e0..52aa7c0 100644 --- a/lib/Screens/Register.dart +++ b/lib/Screens/Register.dart @@ -55,7 +55,7 @@ class _RegisterState extends State { @override - Widget Template1(String hint , String error , Icon icon){ + Widget EmailAndNameField(String hint , String error , Icon icon){ double _screenWidth = MediaQuery .of(context) .size @@ -95,7 +95,7 @@ class _RegisterState extends State { } - Widget Template2(String hint , String error ) { + Widget PasswordField(String hint , String error ) { passwordValidator(String cpassword) { if (cpassword.length < 6) { return '$error'; @@ -254,160 +254,12 @@ class _RegisterState extends State { // SizedBox( // height: 20, // ), - /* Container( - width: _screenWidth/1.08, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: - BorderRadius.all(Radius.circular(10)), - ), - padding: EdgeInsets.all(8), - margin: EdgeInsets.all(0), - child: TextFormField( - controller: _nameTextController, - decoration: InputDecoration( - hintText: "Enter Name", - prefixIcon: Icon(Icons.person)), - validator: (val) => - val.isEmpty ? 'Enter a name' : null, - textAlignVertical: TextAlignVertical.bottom, - ), - ), - SizedBox( - height: 20, - ),*/ - Template1("Enter Name" , 'Enter a name' , Icon(Icons.person)), - /* Container( - width: _screenWidth/1.08, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: - BorderRadius.all(Radius.circular(10)), - ), - padding: EdgeInsets.all(8), - margin: EdgeInsets.all(0), - child: TextFormField( - controller: _emailTextController, - decoration: InputDecoration( - hintText: "Enter email", - prefixIcon: Icon(Icons.email)), - validator: (val) => - val.isEmpty ? 'Enter an email' : null, - textAlignVertical: TextAlignVertical.bottom, - // net ninja - onChanged: (val) { - setState(() { - email = val; - }); - }, - ), - ), - SizedBox( - height: 20, - ),*/ - Template1("Enter Email" , 'Enter an email' , Icon(Icons.email)), - /*Container( - width: _screenWidth/1.08, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: - BorderRadius.all(Radius.circular(10)), - ), - padding: EdgeInsets.all(8), - margin: EdgeInsets.all(0), - child: Container( - child: TextFormField( - controller: _passwordTextController, - decoration: InputDecoration( - hintText: "Enter Password", - prefixIcon: Icon(Icons.vpn_key), - suffixIcon: IconButton( - icon: Icon( - hidePass - ? Icons.visibility - : Icons.visibility_off, - //color: Theme.of(context).primaryColorDark, - //Icons.remove_red_eye - ), - onPressed: () { - setState(() { - hidePass = !hidePass; - }); - }), - ), - validator: (val) => val.length < 6 - ? 'Enter a password 6+ chars long' - : null, - textAlignVertical: TextAlignVertical.bottom, - obscureText: hidePass, - // net ninja - onChanged: (val) { - setState(() { - password = val; - }); - }, - ), - ), - ), - SizedBox( - height: 20, - ),*/ - - Template2("Enter Password", 'Enter a password 6+ chars long'), - - /* Container( - width: _screenWidth/1.08, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: - BorderRadius.all(Radius.circular(10)), - ), - padding: EdgeInsets.all(8), - margin: EdgeInsets.all(0), - child: Container( - child: TextFormField( - controller: _confirmPasswordController, - decoration: InputDecoration( - hintText: "Confirm Password", - prefixIcon: Icon(Icons.vpn_key), - suffixIcon: IconButton( - icon: Icon( - hidePass - ? Icons.visibility - : Icons.visibility_off, - //color: Theme.of(context).primaryColorDark, - //Icons.remove_red_eye - ), - onPressed: () { - setState(() { - hidePass = !hidePass; - }); - }), - ), - validator: (val) => val.length < 6 - ? 'Enter a password 6+ chars long' - : null, - textAlignVertical: TextAlignVertical.bottom, - obscureText: hidePass, - // net ninja - onChanged: (val) { - setState(() { - password = val; - }); - }, - //onChanged: (val) { - //setState(() { - //password = val; - //}); - //}, - ), - ), - ), - SizedBox( - height: 20, - ),*/ - - Template2("Confirm Password", 'Enter a password 6+ chars long'), + + EmailAndNameField("Enter Name" , 'Enter a name' , Icon(Icons.person)), + EmailAndNameField("Enter Email" , 'Enter an email' , Icon(Icons.email)), + + PasswordField("Enter Password", 'Enter a password 6+ chars long'), + PasswordField("Confirm Password", 'Enter a password 6+ chars long'), RaisedButton( onPressed: () async { From 7a84187895587489e7071570c221b0ac64386f8b Mon Sep 17 00:00:00 2001 From: Ravi Date: Fri, 10 Dec 2021 17:42:20 +0530 Subject: [PATCH 2/9] Updated and Fixed Home.dart --- lib/Screens/Home.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Screens/Home.dart b/lib/Screens/Home.dart index 51db1d5..88c1b4c 100644 --- a/lib/Screens/Home.dart +++ b/lib/Screens/Home.dart @@ -234,6 +234,7 @@ class _HomeState extends State { // ), Center( child: Container( + height: 537, decoration: BoxDecoration( border: Border.all( @@ -245,14 +246,15 @@ class _HomeState extends State { ), - height: MediaQuery + /*height: MediaQuery .of(context) .size - .height * 0.7, + .height * 0.9,*/ width: MediaQuery .of(context) .size - .width * 0.97, + .width * 0.98, + child: Column( children: [ @@ -274,7 +276,6 @@ class _HomeState extends State { color: Colors.pink[50] ), - height: 100.0, width: 350.0, child: Column( From 6c8da5821cd52d297551104e943e21e80d3805ff Mon Sep 17 00:00:00 2001 From: raviyadav17 <86602971+raviyadav17@users.noreply.github.com> Date: Tue, 14 Dec 2021 01:11:01 +0530 Subject: [PATCH 3/9] Updated pubspec.lock --- pubspec.lock | 225 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 158 insertions(+), 67 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index d934db6..b4a5788 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.8.1" boolean_selector: dependency: transitive description: @@ -35,7 +35,7 @@ packages: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" clock: dependency: transitive description: @@ -49,21 +49,21 @@ packages: name: cloud_firestore url: "https://pub.dartlang.org" source: hosted - version: "0.16.0+1" + version: "1.0.7" cloud_firestore_platform_interface: dependency: transitive description: name: cloud_firestore_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "3.0.2" + version: "4.0.3" cloud_firestore_web: dependency: transitive description: name: cloud_firestore_web url: "https://pub.dartlang.org" source: hosted - version: "0.3.0+2" + version: "1.0.7" collection: dependency: transitive description: @@ -71,20 +71,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.15.0" - convert: + cross_file: dependency: transitive description: - name: convert + name: cross_file url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "0.3.2" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "3.0.1" cupertino_icons: dependency: "direct main" description: @@ -98,7 +98,7 @@ packages: name: curved_navigation_bar url: "https://pub.dartlang.org" source: hosted - version: "0.3.7" + version: "1.0.1" fake_async: dependency: transitive description: @@ -126,7 +126,7 @@ packages: name: firebase url: "https://pub.dartlang.org" source: hosted - version: "7.3.3" + version: "9.0.2" firebase_admob: dependency: "direct main" description: @@ -140,91 +140,105 @@ packages: name: firebase_analytics url: "https://pub.dartlang.org" source: hosted - version: "7.0.1" + version: "8.3.4" firebase_analytics_platform_interface: dependency: transitive description: name: firebase_analytics_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "2.0.1" firebase_analytics_web: dependency: transitive description: name: firebase_analytics_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.1" + version: "0.3.0+1" firebase_auth: dependency: "direct main" description: name: firebase_auth url: "https://pub.dartlang.org" source: hosted - version: "0.20.1" + version: "3.3.0" firebase_auth_platform_interface: dependency: transitive description: name: firebase_auth_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "6.1.8" firebase_auth_web: dependency: transitive description: name: firebase_auth_web url: "https://pub.dartlang.org" source: hosted - version: "0.3.3" + version: "3.3.4" firebase_core: dependency: "direct main" description: name: firebase_core url: "https://pub.dartlang.org" source: hosted - version: "0.7.0" + version: "1.10.2" firebase_core_platform_interface: dependency: transitive description: name: firebase_core_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "4.2.2" firebase_core_web: dependency: transitive description: name: firebase_core_web url: "https://pub.dartlang.org" source: hosted - version: "0.2.1+3" + version: "1.5.2" firebase_database: dependency: "direct main" description: name: firebase_database url: "https://pub.dartlang.org" source: hosted - version: "6.0.0" + version: "8.2.0" + firebase_database_platform_interface: + dependency: transitive + description: + name: firebase_database_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.0+4" + firebase_database_web: + dependency: transitive + description: + name: firebase_database_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2+1" firebase_storage: dependency: "direct main" description: name: firebase_storage url: "https://pub.dartlang.org" source: hosted - version: "7.0.0" + version: "10.2.0" firebase_storage_platform_interface: dependency: transitive description: name: firebase_storage_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "4.0.10" firebase_storage_web: dependency: transitive description: name: firebase_storage_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.1+3" + version: "3.2.4" flutter: dependency: "direct main" description: flutter @@ -236,28 +250,28 @@ packages: name: flutter_keyboard_visibility url: "https://pub.dartlang.org" source: hosted - version: "4.0.6" + version: "5.1.0" flutter_keyboard_visibility_platform_interface: dependency: transitive description: name: flutter_keyboard_visibility_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "2.0.0" flutter_keyboard_visibility_web: dependency: transitive description: name: flutter_keyboard_visibility_web url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "2.0.0" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "1.0.11" + version: "2.0.5" flutter_spinkit: dependency: "direct main" description: @@ -276,68 +290,82 @@ packages: name: flutter_typeahead url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "3.2.3" flutter_web_plugins: dependency: transitive description: flutter source: sdk version: "0.0.0" + fluttertoast: + dependency: "direct main" + description: + name: fluttertoast + url: "https://pub.dartlang.org" + source: hosted + version: "8.0.8" google_sign_in: dependency: "direct main" description: name: google_sign_in url: "https://pub.dartlang.org" source: hosted - version: "4.5.9" + version: "5.2.1" google_sign_in_platform_interface: dependency: transitive description: name: google_sign_in_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "2.1.0" google_sign_in_web: dependency: transitive description: name: google_sign_in_web url: "https://pub.dartlang.org" source: hosted - version: "0.9.2" + version: "0.10.0+3" http: - dependency: transitive + dependency: "direct main" description: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.12.2" + version: "0.13.4" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "3.1.4" + version: "4.0.0" image_picker: dependency: "direct main" description: name: image_picker url: "https://pub.dartlang.org" source: hosted - version: "0.6.7+22" + version: "0.8.4+4" + image_picker_for_web: + dependency: transitive + description: + name: image_picker_for_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.4" image_picker_platform_interface: dependency: transitive description: name: image_picker_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "2.4.1" intl: dependency: transitive description: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "0.17.0" js: dependency: transitive description: @@ -358,7 +386,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" nested: dependency: transitive description: @@ -379,105 +407,112 @@ packages: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+2" + version: "2.1.4" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.0.1" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "0.0.5" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.11.1" + version: "2.0.4" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.0.2" + version: "3.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "2.0.2" process: dependency: transitive description: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.2.3" + version: "4.2.4" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "4.3.3" + version: "6.0.1" quiver: dependency: "direct main" description: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "3.0.0" shared_preferences: dependency: "direct main" description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.12+4" + version: "2.0.9" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.9" + shared_preferences_ios: + dependency: transitive + description: + name: shared_preferences_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.8" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.2+4" + version: "2.0.3" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+11" + version: "2.0.2" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.0.0" shared_preferences_web: dependency: transitive description: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.2+7" + version: "2.0.2" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "0.0.2+3" + version: "2.0.3" sky_engine: dependency: transitive description: flutter @@ -524,14 +559,14 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.2" transparent_image: dependency: "direct main" description: name: transparent_image url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "2.0.0" typed_data: dependency: transitive description: @@ -539,13 +574,69 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.17" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.13" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.13" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" uuid: dependency: "direct main" description: name: uuid url: "https://pub.dartlang.org" source: hosted - version: "2.2.2" + version: "3.0.5" vector_math: dependency: transitive description: @@ -559,14 +650,14 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.2.10" + version: "2.3.1" xdg_directories: dependency: transitive description: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.2.0" sdks: - dart: ">=2.13.0 <3.0.0" - flutter: ">=1.20.0" + dart: ">=2.14.0 <3.0.0" + flutter: ">=2.5.0" From f2252ed74a5e2c3dc672cb30cb724441049d598a Mon Sep 17 00:00:00 2001 From: raviyadav17 <86602971+raviyadav17@users.noreply.github.com> Date: Tue, 14 Dec 2021 01:24:32 +0530 Subject: [PATCH 4/9] Update Register.dart --- lib/Screens/Register.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Screens/Register.dart b/lib/Screens/Register.dart index 52aa7c0..4c907df 100644 --- a/lib/Screens/Register.dart +++ b/lib/Screens/Register.dart @@ -43,7 +43,7 @@ class _RegisterState extends State { String email = ''; String password = ''; - String cpassword =''; + String cpassword = ''; String error = ''; String name = ''; bool hidePass1 = true; @@ -569,4 +569,4 @@ class TheUser { TheUser({ this.uid, }); -}*/ \ No newline at end of file +}*/ From fccbb0f706f8320fe5f4d3c6bce0a8fa1ec0b165 Mon Sep 17 00:00:00 2001 From: raviyadav17 <86602971+raviyadav17@users.noreply.github.com> Date: Wed, 15 Dec 2021 17:27:29 +0530 Subject: [PATCH 5/9] Fixed Home.dart From e3613442b5684b71ec61cdd3c36f40937b8b62d2 Mon Sep 17 00:00:00 2001 From: raviyadav17 <86602971+raviyadav17@users.noreply.github.com> Date: Wed, 15 Dec 2021 17:28:11 +0530 Subject: [PATCH 6/9] Fixed Home.dart From 517ab90191cc95565aed7c93c36ed75bd0dffba8 Mon Sep 17 00:00:00 2001 From: Ravi Date: Sat, 18 Dec 2021 11:43:13 +0530 Subject: [PATCH 7/9] First Commit --- lib/Screens/Home.dart | 499 +++++++++++++------------------ lib/Screens/Register.dart | 604 ++++++++++---------------------------- 2 files changed, 363 insertions(+), 740 deletions(-) diff --git a/lib/Screens/Home.dart b/lib/Screens/Home.dart index 88c1b4c..f1f7cbb 100644 --- a/lib/Screens/Home.dart +++ b/lib/Screens/Home.dart @@ -1,37 +1,30 @@ -import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:test_app/QuizScreens/Question1.dart'; -import 'package:test_app/Screens/LoginPage.dart'; +//import 'package:test_app/Screens/LoginPage.dart'; import 'package:test_app/Screens/orders.dart'; import 'package:test_app/Screens/product_search.dart'; import 'package:test_app/Widgets.dart'; -import 'package:test_app/database.dart'; -import 'package:test_app/Screens/Register.dart'; +//import 'package:test_app/database.dart'; +//import 'package:test_app/Screens/Register.dart'; import 'package:test_app/provider/product.dart'; import 'package:test_app/provider/user.dart'; -import 'package:test_app/services/product.dart'; +//import 'package:test_app/services/product.dart'; import 'package:test_app/Screens/Favourites.dart'; import 'package:test_app/Screens/Profile.dart'; -import 'package:test_app/Screens/Quiz.dart'; +//import 'package:test_app/Screens/Quiz.dart'; import 'package:test_app/Screens/Recommendations.dart'; import 'package:test_app/Screens/BestSellers.dart'; import 'package:test_app/Screens/AboutUs.dart'; import 'package:test_app/Screens/Contact.dart'; import 'package:test_app/Screens/Report.dart'; - class Home extends StatefulWidget { @override _HomeState createState() => _HomeState(); } class _HomeState extends State { - - - final _key = GlobalKey(); - ProductServices _productServices = ProductServices(); - @override Widget build(BuildContext context) { GlobalKey _drawerKey = GlobalKey(); @@ -48,13 +41,10 @@ class _HomeState extends State { children: [ UserAccountsDrawerHeader( decoration: BoxDecoration( - gradient: LinearGradient( - colors: [ - Colors.deepOrange, - Colors.orangeAccent, - ] - ) - ), + gradient: LinearGradient(colors: [ + Colors.deepOrange, + Colors.orangeAccent, + ])), accountName: Text( userProvider.userModel?.name ?? "username loading...", ), @@ -70,21 +60,21 @@ class _HomeState extends State { CustomListTile( Icons.person, 'Profile', - () => - { - Navigator.push(context, MaterialPageRoute( - builder: (c) => UpdateProfile())) - } - ), + () => { + Navigator.push( + context, + MaterialPageRoute( + builder: (c) => UpdateProfile())) + }), CustomListTile( Icons.favorite_outlined, 'Favourites', - () => - { - Navigator.push(context, MaterialPageRoute( - builder: (c) => Favourites())) - } - ), + () => { + Navigator.push( + context, + MaterialPageRoute( + builder: (c) => Favourites())) + }), ListTile( leading: Icon( Icons.bookmark_border_rounded, @@ -103,58 +93,49 @@ class _HomeState extends State { ), onTap: () async { await userProvider.getOrders(); - Navigator.push(context, MaterialPageRoute( - builder: (c) => OrdersScreen())); + Navigator.push(context, + MaterialPageRoute(builder: (c) => OrdersScreen())); }, ), CustomListTile( Icons.contact_support_rounded, 'Contact us', - () => - { - Navigator.push(context, MaterialPageRoute( - builder: (c) => ContactUs())) - } - ), + () => { + Navigator.push( + context, + MaterialPageRoute( + builder: (c) => ContactUs())) + }), CustomListTile( Icons.home, 'About', - () => - { - Navigator.push(context, MaterialPageRoute( - builder: (c) => AboutUs())) - } - ), + () => { + Navigator.push(context, + MaterialPageRoute(builder: (c) => AboutUs())) + }), CustomListTile( Icons.error, 'Report issue', - () => - { - Navigator.push(context, MaterialPageRoute( - builder: (c) => Report())) - } - ), - CustomListTile( - Icons.logout, - 'Logout', - () { - userProvider.signOut(); - //_auth.signOut(); - /*BookApp.auth.signOut().then((c) { - Navigator.pushReplacement(context, MaterialPageRoute(builder: (c) => LoginPage()));*/ - }) + () => { + Navigator.push(context, + MaterialPageRoute(builder: (c) => Report())) + }), + CustomListTile(Icons.logout, 'Logout', () { + userProvider.signOut(); + }) ], ), ) - - ], ), ), ), appBar: AppBar( leading: IconButton( - icon: Icon(Icons.menu, color: Colors.black,), + icon: Icon( + Icons.menu, + color: Colors.black, + ), onPressed: () { _drawerKey.currentState.openDrawer(); }, @@ -169,247 +150,189 @@ class _HomeState extends State { fontSize: 18, ), ), - actions: [ - // IconButton( - // icon: Icon( - // Icons.search_rounded, - // color: Colors.black, - // ), - // onPressed:() { - // showSearch(context: context, delegate: DataSearch()); - // }, - // ), - ] - ), - + actions: []), backgroundColor: Colors.pink[50], - body: Stack( + body: Stack(children: [ + ListView( children: [ - ListView( - children: [ - // Search(), - Container( + // Search(), + Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + bottomRight: Radius.circular(20), + bottomLeft: Radius.circular(20))), + child: Padding( + padding: const EdgeInsets.only( + top: 8, left: 8, right: 8, bottom: 10), + child: Container( decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(20), - bottomLeft: Radius.circular(20))), - child: Padding( - padding: const EdgeInsets.only( - top: 8, left: 8, right: 8, bottom: 10), - child: Container( - decoration: BoxDecoration( - color: Colors.grey.withOpacity(0.2), - borderRadius: BorderRadius.circular(20), - ), - child: ListTile( - leading: Icon( - Icons.search, - color: Colors.black, - ), - title: TextField( - textInputAction: TextInputAction.search, - onSubmitted: (pattern) async { - await productProvider.search( - productName: pattern); - Navigator.push(context, MaterialPageRoute( + color: Colors.grey.withOpacity(0.2), + borderRadius: BorderRadius.circular(20), + ), + child: ListTile( + leading: Icon( + Icons.search, + color: Colors.black, + ), + title: TextField( + textInputAction: TextInputAction.search, + onSubmitted: (pattern) async { + await productProvider.search(productName: pattern); + Navigator.push( + context, + MaterialPageRoute( builder: (c) => ProductSearchScreen())); - }, - decoration: InputDecoration( - hintText: "Search your books here!", - border: InputBorder.none, - ), - ), + }, + decoration: InputDecoration( + hintText: "Search your books here!", + border: InputBorder.none, ), ), ), ), - Container( - color: Colors.pink[50], - - child: Column( - children: [ - // SizedBox( - // height: 30.0, - // ), - Center( - child: Container( - height: 537, - decoration: BoxDecoration( - - border: Border.all( - color: Colors.pink[50], - ), - borderRadius: BorderRadius.all( - Radius.circular(50)), - color: Colors.pink[200] + ), + ), + Container( + color: Colors.pink[50], + child: Column( + children: [ + // SizedBox( + // height: 30.0, + // ), + Center( + child: Container( + height: 537, + decoration: BoxDecoration( + border: Border.all( + color: Colors.pink[50], ), - - - /*height: MediaQuery - .of(context) - .size - .height * 0.9,*/ - width: MediaQuery - .of(context) - .size - .width * 0.98, - - child: Column( - + borderRadius: + BorderRadius.all(Radius.circular(50)), + color: Colors.pink[200]), + //height: MediaQuery.of(context).size.height * 0.7, + width: MediaQuery.of(context).size.width * 0.98, + child: Column( + children: [ + SizedBox( + height: 30.0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox( - height: 30.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment - .center, - children: [ - Container( - decoration: BoxDecoration( - - border: Border.all( - color: Colors.pink[900], - ), - borderRadius: BorderRadius.all( - Radius.circular(50)), - color: Colors.pink[50] - ), - - height: 100.0, - width: 350.0, - child: Column( - mainAxisAlignment: MainAxisAlignment - .center, - crossAxisAlignment: CrossAxisAlignment - .center, - children: [ - Text( - 'Welcome ${userProvider - .userModel - .name}! \nLet us pick a book for you!' - // userProvider.userModel.bio - ) - ], + Container( + decoration: BoxDecoration( + border: Border.all( + color: Colors.pink[900], ), - ) - - ], - ), - SizedBox( - height: 30.0, - ), - InkWell( - splashColor: Colors.greenAccent, - onTap: () { - Navigator.push(context, - MaterialPageRoute( - builder: (c) => Question1())); - }, - //Photo by Daniel Schludi on Unsplash - child: Container( - - height: 100, - width: 350, - child: Center( - child: Text( - 'Quiz' - ), - ), - decoration: BoxDecoration( - // image: DecorationImage( - // - // image: AssetImage( - // 'images/daniel-schludi-7JL7NdhaRd8-unsplash.jpg'), - // fit: BoxFit.fill, - // ), - color: Colors.white, - border: Border.all( - color: Colors.pink[900], - ), - borderRadius: BorderRadius.all( - Radius.circular(20)) - ), - + borderRadius: BorderRadius.all( + Radius.circular(50)), + color: Colors.pink[50]), + height: 100.0, + width: 350.0, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Welcome ${userProvider.userModel.name}! \nLet us pick a book for you!' + // userProvider.userModel.bio + ) + ], ), + ) + ], + ), + SizedBox( + height: 30.0, + ), + InkWell( + splashColor: Colors.greenAccent, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (c) => Question1())); + }, + child: Container( + height: 100, + width: 350, + child: Center( + child: Text('Quiz'), ), - SizedBox( - height: 20.0, - ), - InkWell( - splashColor: Colors.greenAccent, - onTap: () { - Navigator.push(context, - MaterialPageRoute(builder: (c) => - Recommendations())); - }, - //Photo by Daniel Schludi on Unsplash - child: Container( - height: 100, - child: Center( - child: Text( - 'Recommendations' - ), - ), - width: 350, - decoration: BoxDecoration( - color: Colors.white, - border: Border.all( - color: Colors.pink[900], - ), - borderRadius: BorderRadius.all( - Radius.circular(20)) + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.pink[900], ), - - ), - ), - SizedBox( - height: 20.0, + borderRadius: BorderRadius.all( + Radius.circular(20))), + ), + ), + SizedBox( + height: 20.0, + ), + InkWell( + splashColor: Colors.greenAccent, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (c) => Recommendations())); + }, + child: Container( + height: 100, + child: Center( + child: Text('Recommendations'), ), - Ink( - color: Colors.blueAccent, - child: InkWell( - - onTap: () { - Navigator.push(context, - MaterialPageRoute( - builder: (c) => - BestSellers())); - }, - //Photo by Daniel Schludi on Unsplash - child: Container( - height: 100, - width: 350, - child: Center( - child: Text( - 'Best Sellers' - ), - ), - decoration: BoxDecoration( - color: Colors.white, - border: Border.all( - color: Colors.pink[900], - ), - borderRadius: BorderRadius.all( - Radius.circular(20)) - ), - + width: 350, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.pink[900], ), + borderRadius: BorderRadius.all( + Radius.circular(20))), + ), + ), + SizedBox( + height: 20.0, + ), + Ink( + color: Colors.blueAccent, + child: InkWell( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (c) => BestSellers())); + }, + child: Container( + height: 100, + width: 350, + child: Center( + child: Text('Best Sellers'), ), - ) - ], + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.pink[900], + ), + borderRadius: BorderRadius.all( + Radius.circular(20))), + ), + ), ) - - ) - ), - ], - ), - ) - ], - ), - ] - ), - ) - ); + ], + ))), + ], + ), + ) + ], + ), + ]), + )); } -} +} \ No newline at end of file diff --git a/lib/Screens/Register.dart b/lib/Screens/Register.dart index 4c907df..819b016 100644 --- a/lib/Screens/Register.dart +++ b/lib/Screens/Register.dart @@ -1,46 +1,37 @@ - -import 'dart:math'; - -import 'package:firebase_database/firebase_database.dart'; import 'package:provider/provider.dart'; import 'package:test_app/Screens/Loading.dart'; //import 'package:fluttertoast/fluttertoast.dart'; import 'package:test_app/Screens/NavBar.dart'; -import 'package:test_app/Utility/auth.dart'; -import 'package:test_app/main.dart'; -import 'dart:io'; +//import 'package:test_app/Utility/auth.dart'; +//import 'package:test_app/main.dart'; +//import 'dart:io'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; -import 'package:image_picker/image_picker.dart'; -import 'package:shared_preferences/shared_preferences.dart'; -import 'package:test_app/Screens/LoginPage.dart'; -import 'package:firebase_storage/firebase_storage.dart'; +//import 'package:image_picker/image_picker.dart'; +//import 'package:shared_preferences/shared_preferences.dart'; +//import 'package:test_app/Screens/LoginPage.dart'; +//import 'package:firebase_storage/firebase_storage.dart'; import 'package:test_app/provider/user.dart'; class Register extends StatefulWidget { - final Function toggleView; - Register({ - this.toggleView - }); + Register({this.toggleView}); @override _RegisterState createState() => _RegisterState(); } class _RegisterState extends State { - //Santos final FirebaseAuth firebaseAuth = FirebaseAuth.instance; final _formKey = GlobalKey(); - final _key = GlobalKey(); + final _key = GlobalKey(); //UserServices _userServices = UserServices(); TextEditingController _emailTextController = TextEditingController(); TextEditingController _passwordTextController = TextEditingController(); TextEditingController _nameTextController = TextEditingController(); TextEditingController _confirmPasswordController = TextEditingController(); - String email = ''; String password = ''; String cpassword = ''; @@ -49,53 +40,43 @@ class _RegisterState extends State { bool hidePass1 = true; bool hidePass2 = true; String userImageUrl = ''; - File _imageFile; - - - @override - - Widget EmailAndNameField(String hint , String error , Icon icon){ - double _screenWidth = MediaQuery - .of(context) - .size - .width; + Widget emailAndNameField(String hint, String error, Icon icon) { + double _screenWidth = MediaQuery.of(context).size.width; return Column( children: [ Container( - width: _screenWidth/1.08, + width: _screenWidth / 1.08, decoration: BoxDecoration( color: Colors.white, - borderRadius: - BorderRadius.all(Radius.circular(10)), + borderRadius: BorderRadius.all(Radius.circular(10)), ), padding: EdgeInsets.all(8), margin: EdgeInsets.all(0), child: TextFormField( - controller:'$hint' == 'Enter Name' ? _nameTextController : _emailTextController, - decoration: InputDecoration( - hintText: "$hint", - prefixIcon: icon), - validator: (val) => - val.isEmpty ? '$error' : null, + controller: '$hint' == 'Enter Name' + ? _nameTextController + : _emailTextController, + decoration: InputDecoration(hintText: "$hint", prefixIcon: icon), + validator: (val) => val.isEmpty ? '$error' : null, textAlignVertical: TextAlignVertical.bottom, onChanged: (val) { - if("$hint" == "Enter Email") { + if ("$hint" == "Enter Email") { setState(() { email = val; }); } }, - ), ), - SizedBox(height: 20,) + SizedBox( + height: 20, + ) ], ); } - - Widget PasswordField(String hint , String error ) { + Widget passwordField(String hint, String error) { passwordValidator(String cpassword) { if (cpassword.length < 6) { return '$error'; @@ -104,72 +85,59 @@ class _RegisterState extends State { } return null; } - double _screenWidth = MediaQuery - .of(context) - .size - .width; - if('$hint'=='Enter Password'){ - return Column( - children: [ - Container( - width: _screenWidth / 1.08, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: - BorderRadius.all(Radius.circular(10)), - ), - padding: EdgeInsets.all(8), - margin: EdgeInsets.all(0), - child: Container( - child: TextFormField( - controller: _passwordTextController, - decoration: InputDecoration( - hintText: "$hint", - prefixIcon: Icon(Icons.vpn_key), - suffixIcon: IconButton( - icon: Icon( - hidePass1 - ? Icons.visibility - : Icons.visibility_off, - //color: Theme.of(context).primaryColorDark, - //Icons.remove_red_eye - ), - onPressed: () { - setState(() { - hidePass1 = !hidePass1; - }); - }), + + double _screenWidth = MediaQuery.of(context).size.width; + if ('$hint' == 'Enter Password') { + return Column( + children: [ + Container( + width: _screenWidth / 1.08, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(10)), + ), + padding: EdgeInsets.all(8), + margin: EdgeInsets.all(0), + child: Container( + child: TextFormField( + controller: _passwordTextController, + decoration: InputDecoration( + hintText: "$hint", + prefixIcon: Icon(Icons.vpn_key), + suffixIcon: IconButton( + icon: Icon( + hidePass1 ? Icons.visibility : Icons.visibility_off, + ), + onPressed: () { + setState(() { + hidePass1 = !hidePass1; + }); + }), + ), + validator: (val) => val.length < 6 ? '$error' : null, + textAlignVertical: TextAlignVertical.bottom, + obscureText: hidePass1, + onChanged: (val) { + setState(() { + password = val; + }); + }, ), - validator: (val) => - val.length < 6 - ? '$error' - : null, - textAlignVertical: TextAlignVertical.bottom, - obscureText: hidePass1, - // net ninja - onChanged: (val) { - setState(() { - password = val; - }); - }, ), ), - ), - SizedBox( - height: 20, - ), - ], - ); - } - else { + SizedBox( + height: 20, + ), + ], + ); + } else { return Column( children: [ Container( width: _screenWidth / 1.08, decoration: BoxDecoration( color: Colors.white, - borderRadius: - BorderRadius.all(Radius.circular(10)), + borderRadius: BorderRadius.all(Radius.circular(10)), ), padding: EdgeInsets.all(8), margin: EdgeInsets.all(0), @@ -181,11 +149,7 @@ class _RegisterState extends State { prefixIcon: Icon(Icons.vpn_key), suffixIcon: IconButton( icon: Icon( - hidePass2 - ? Icons.visibility - : Icons.visibility_off, - //color: Theme.of(context).primaryColorDark, - //Icons.remove_red_eye + hidePass2 ? Icons.visibility : Icons.visibility_off, ), onPressed: () { setState(() { @@ -193,7 +157,7 @@ class _RegisterState extends State { }); }), ), - validator: (val) => passwordValidator(val), + validator: (val) => passwordValidator(val), textAlignVertical: TextAlignVertical.bottom, obscureText: hidePass2, ), @@ -207,366 +171,102 @@ class _RegisterState extends State { } } - - Widget build(BuildContext context) { final user = Provider.of(context); - double _screenWidth = MediaQuery - .of(context) - .size - .width; - double _screenHeight = MediaQuery - .of(context) - .size - .height; - return Scaffold( - backgroundColor: Colors.yellow, - key: _key, - body: user.status == Status.Authenticating ? Loading() : Scaffold( - backgroundColor: Colors.pink[50], - body: Center( - child: SingleChildScrollView( - child: Center( - child: Column( - children: [ - Text( - 'Welcome to\n Chapter 3', - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.bold, - fontSize: 25, - ), - ), - Form( - key: _formKey, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox( - height: 60, - ), - // CircleAvatar( - // radius: 70, - // backgroundImage: user.userModel.userImage == '' - // ? Icon(Icons.add_photo_alternate) - // : NetworkImage(user.userModel.userImage), - // ), - // SizedBox( - // height: 20, - // ), - - EmailAndNameField("Enter Name" , 'Enter a name' , Icon(Icons.person)), - EmailAndNameField("Enter Email" , 'Enter an email' , Icon(Icons.email)), - - PasswordField("Enter Password", 'Enter a password 6+ chars long'), - PasswordField("Confirm Password", 'Enter a password 6+ chars long'), - - RaisedButton( - onPressed: () async { - // net ninja - //if (_formKey.currentState.validate()) { - - if (_formKey.currentState.validate()) { - if (!await user.signUp( - _nameTextController.text, - _emailTextController.text, - _passwordTextController.text)) { - _key.currentState.showSnackBar(SnackBar( - content: Text("Sign up failed"))); - return; - } - Navigator.pushReplacement( - context, - MaterialPageRoute( - builder: (c) => NavBar())); - } - - //Random - //uploadAndSaveData(); - /* net ninja - dynamic result = await registerWithEmailAndPassword( - email, password); - if (result == null) { - setState(() { - error = 'please suppy a valid email'; - }); - }*/ - }, - child: Text('Register'), - ), - - /*RaisedButton( - onPressed: () async { - Auth auth = Auth(); - User user = await auth.googleSignIn(); - if (user == null) { - _userServices.createUser({ - "name": user.displayName, - "photo": user.photoUrl, - "email": user.email, - "userId": user.uid - }); - Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => NavBar())); - } - }, - child: Text( - 'Google SignIn' - ), - ),*/ - SizedBox( - height: 15, + return Scaffold( + backgroundColor: Colors.yellow, + key: _key, + body: user.status == Status.Authenticating + ? Loading() + : Scaffold( + backgroundColor: Colors.pink[50], + body: Center( + child: SingleChildScrollView( + child: Center( + child: Column( + children: [ + Text( + 'Welcome to\n Chapter 3', + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 25, ), - InkWell( - onTap: () { - widget.toggleView(); - }, - child: Text( - 'I already have an account', - style: TextStyle(color: Colors.red, fontSize: 15), - ), + ), + Form( + key: _formKey, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + height: 60, + ), + emailAndNameField("Enter Name", + 'Enter a name', Icon(Icons.person)), + emailAndNameField("Enter Email", + 'Enter an email', Icon(Icons.email)), + passwordField("Enter Password", + 'Enter a password 6+ chars long'), + passwordField("Confirm Password", + 'Enter a password 6+ chars long'), + ElevatedButton( + onPressed: () async { + if (_formKey.currentState + .validate()) { + if (!await user.signUp( + _nameTextController.text, + _emailTextController.text, + _passwordTextController.text)) { + _key.currentState.showSnackBar( + SnackBar( + content: Text( + "Sign up failed"))); + return; + } + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (c) => NavBar())); + } + }, + child: Text('Register'), + ), + SizedBox( + height: 15, + ), + InkWell( + onTap: () { + widget.toggleView(); + }, + child: Text( + 'I already have an account', + style: TextStyle( + color: Colors.red, fontSize: 15), + ), + ), + Text( + error, + style: TextStyle( + color: Colors.red, + ), + ) + ], ), - Text( - error, - style: TextStyle( - color: Colors.red, - ), - ) - ], - ), + ), + ], ), - ], + ), ), - ), - ), - ), - ), - ); - } - -/*Santos - Future validateForm() async{ - Register register = Register(); - user = await firebaseAuth.currentUser; - Map value = { - "username": user.displayName, - "email": user.email, - "userId": user.uid, - }; - if(user == null){ - await firebaseAuth.createUserWithEmailAndPassword( - email: _emailTextController.text, - password: _passwordTextController.text).then((u) async => { - _userService.createUser(user.uid.toString(), value), - }).catchError((e) { - print(e.toString()); - }); - Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => NavBar())); - } - }*/ - - -//Random video -/*Future _selectImage(Future pickImage) async { - File tempImg = await pickImage; - setState(() => _imageFile = tempImg ); - } - Widget _displayChild1() { - if (_imageFile == null) { - return Padding( - padding: const EdgeInsets.fromLTRB(14, 70, 14, 70), - child: new Icon(Icons.add, color: Colors.grey,), - ); - } else { - return Image.file(_imageFile, fit: BoxFit.fill, width: double.infinity,); - } - } - Future uploadAndSaveData() async { - if(_imageFile == null) { - print('all the images must be provided'); - } - else { - if(_formKey.currentState.validate()) { - if(_passwordTextController.text == _confirmPasswordController.text) { - await uploadToStorage(); - } - } - } + ))); } - /*displayDialogue(String error) { - showDialog(context: context, - builder: (c) { - return AlertDialog( - content: Text( - error - ), - ); - }); - }*/ - // String url; - uploadToStorage() async { - FirebaseStorage storage = FirebaseStorage.instance; - final String picture = "${DateTime.now().millisecondsSinceEpoch.toString()}.jpg"; - Reference reference = storage.ref().child(picture); - await reference.putFile(_imageFile); - userImageUrl = await reference.getDownloadURL(); - registerUser(); - //FirebaseAuth _auth = FirebaseAuth.instance; - //void _registerUser() async{ - //User user; - //} - } - FirebaseAuth _auth = FirebaseAuth.instance; - //registration - void registerUser() async { - User firebaseUser; - await _auth.createUserWithEmailAndPassword( - email: _emailTextController.text, - password: _passwordTextController.text - ).then((auth) { - firebaseUser = auth.user; - }).catchError((error) { - Navigator.pop(context); - print(error.toString()); - }); - if (firebaseUser != null) { - saveUserInfoToFireStore(firebaseUser).then((value){ - Navigator.pushReplacement(context, MaterialPageRoute(builder: (c) => NavBar())); - }); - } - } - Future saveUserInfoToFireStore(User user) async { - //SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); - FirebaseFirestore firestore = FirebaseFirestore.instance; - firestore.collection("users").doc(user.uid).set({ - "uid": user.uid, - "email": user.email, - "name": _nameTextController.text, - "url": userImageUrl, - BookApp.userCartList: ["garbageValue"], - }); - await BookApp.sharedPreferences.setString(BookApp.userUID, user.uid); - await BookApp.sharedPreferences.setString(BookApp.userEmail, user.email); - await BookApp.sharedPreferences.setString(BookApp.userName, _nameTextController.text); - await BookApp.sharedPreferences.setString(BookApp.userPhotoUrl, userImageUrl); - await BookApp.sharedPreferences.setStringList(BookApp.userCartList, ["garbageValue"]); - }*/ - - -// Santos -/*class UserService{ - FirebaseDatabase _database = FirebaseDatabase.instance; - String ref = 'users'; - createUser(String uid, Map value){ - _database.reference().child("$ref/$uid").set( - value - ).catchError((e) { - print(e.toString()); - }); - } -}*/ - -//Santos -/*Future validateForm() async { - FormState formState = _formKey.currentState; - UserServices _userServices = UserServices(); - if (formState.validate()) { - User user = await firebaseAuth.currentUser; - //if (user == null) { - await firebaseAuth - .createUserWithEmailAndPassword( - email: _emailTextController.text, - password: _passwordTextController.text) - .then((user) => - { - _userServices.createUser( - { - "username": _nameTextController.text, - "email": _emailTextController.text, - "userId": user.uid, - } - ) - }).catchError((err) => {print('error is: ' + err.toString())}); - Navigator.pushReplacement( - context, MaterialPageRoute(builder: (context) => NavBar())); - } - //} - }*/ } -class UserServices{ +class UserServices { FirebaseFirestore _firestore = FirebaseFirestore.instance; String collection = "users"; void createUser(Map data) { _firestore.collection(collection).doc(data["userId"]).set(data); } -} - - - - - -/* ========================== Net ninja ===================== -final FirebaseAuth auth = FirebaseAuth.instance; -class AuthService{ - //create a user object based on User - TheUser userFromTheUser(User user) { - return user != null ? TheUser(uid: user.uid) : null; - } - // auth change user stream - Stream get user { - return auth.authStateChanges() - //.map((User user) => _userFromTheUser(user)); - .map(userFromTheUser); - } - //sign in anom - Future signInAnom() async{ - try{ - UserCredential result = await auth.signInAnonymously(); - User user = result.user; - return userFromTheUser(user); - } catch(e) { - print(e.toString()); - return null; - } - } - //registration - Future registerWithEmailAndPassword(String email, String password) async { - try { - UserCredential result = await auth.createUserWithEmailAndPassword( - email: email, password: password); - User user = result.user; - return userFromTheUser(user); - } catch (e) { - print(e.toString()); - return null; - } - } - //sign in - Future signInWithEmailAndPassword(String email, String password) async{ - try{ - UserCredential result = await auth.signInWithEmailAndPassword(email: email, password: password); - User user = result.user; - return userFromTheUser(user); - } catch(e) { - print(e.toString()); - return null; - } - } - //sign out - Future signOut() async{ - try{ - return await auth.signOut(); - } catch(e) { - print(e.toString()); - return null; - } - } -} -class TheUser { - final String uid; - TheUser({ - this.uid, - }); -}*/ +} \ No newline at end of file From 0badba93bd66e793d840ab8fdac69b95b0de72d9 Mon Sep 17 00:00:00 2001 From: raviyadav17 <86602971+raviyadav17@users.noreply.github.com> Date: Sat, 18 Dec 2021 12:06:07 +0530 Subject: [PATCH 8/9] Update Home.dart --- lib/Screens/Home.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/Screens/Home.dart b/lib/Screens/Home.dart index f1f7cbb..e85a3f2 100644 --- a/lib/Screens/Home.dart +++ b/lib/Screens/Home.dart @@ -202,7 +202,6 @@ class _HomeState extends State { // ), Center( child: Container( - height: 537, decoration: BoxDecoration( border: Border.all( color: Colors.pink[50], @@ -210,7 +209,7 @@ class _HomeState extends State { borderRadius: BorderRadius.all(Radius.circular(50)), color: Colors.pink[200]), - //height: MediaQuery.of(context).size.height * 0.7, + height: MediaQuery.of(context).size.height * 0.7, width: MediaQuery.of(context).size.width * 0.98, child: Column( children: [ @@ -335,4 +334,4 @@ class _HomeState extends State { ]), )); } -} \ No newline at end of file +} From 45eb6716e0be6fe3e30a398296c51f0d89985bd6 Mon Sep 17 00:00:00 2001 From: raviyadav17 <86602971+raviyadav17@users.noreply.github.com> Date: Sat, 18 Dec 2021 12:06:57 +0530 Subject: [PATCH 9/9] Update Home.dart --- lib/Screens/Home.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Screens/Home.dart b/lib/Screens/Home.dart index e85a3f2..4dde122 100644 --- a/lib/Screens/Home.dart +++ b/lib/Screens/Home.dart @@ -202,6 +202,7 @@ class _HomeState extends State { // ), Center( child: Container( + height: 537, decoration: BoxDecoration( border: Border.all( color: Colors.pink[50], @@ -209,7 +210,7 @@ class _HomeState extends State { borderRadius: BorderRadius.all(Radius.circular(50)), color: Colors.pink[200]), - height: MediaQuery.of(context).size.height * 0.7, + //height: MediaQuery.of(context).size.height * 0.7, width: MediaQuery.of(context).size.width * 0.98, child: Column( children: [