From 78eb5bb64d90d7991197819623ec3f65fb1f071b Mon Sep 17 00:00:00 2001 From: khyatisaini Date: Fri, 20 Nov 2020 22:36:27 +0530 Subject: [PATCH 1/3] authentication ui modified --- .../lib/authentication/forgot_password.dart | 64 ++- star_in_me_app/lib/authentication/login.dart | 143 ++++-- star_in_me_app/lib/authentication/signup.dart | 452 ++++++++++++++++-- star_in_me_app/lib/main.dart | 28 +- star_in_me_app/lib/screens/landing.dart | 2 + star_in_me_app/pubspec.lock | 63 +-- star_in_me_app/pubspec.yaml | 6 +- 7 files changed, 633 insertions(+), 125 deletions(-) diff --git a/star_in_me_app/lib/authentication/forgot_password.dart b/star_in_me_app/lib/authentication/forgot_password.dart index 44ca8e3..9fe6529 100644 --- a/star_in_me_app/lib/authentication/forgot_password.dart +++ b/star_in_me_app/lib/authentication/forgot_password.dart @@ -1,8 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:star_in_me_app/authentication/login.dart'; +import 'package:star_in_me_app/authentication/signup.dart'; import 'animations/fadeanimations.dart'; import 'package:modal_progress_hud/modal_progress_hud.dart'; import 'package:email_validator/email_validator.dart'; import 'package:firebase_auth/firebase_auth.dart'; +import 'package:fluttertoast/fluttertoast.dart'; final _auth = FirebaseAuth.instance; @@ -35,23 +38,23 @@ class _ForgotPasswordState extends State { 'Forgot Password', style: TextStyle( fontWeight: FontWeight.bold, - fontSize: 30.0, - color: Colors.purple[800]), + fontSize: 25.0, + color: Colors.deepPurple[500]), ), SizedBox( - height: 30.0, + height: 20.0, ), Text( 'Enter your email address that you used to ', - style: TextStyle(color: Colors.grey), + style: TextStyle(color: Colors.grey, fontWeight: FontWeight.bold), ), Text( "register. We'll send you an email with a link to ", - style: TextStyle(color: Colors.grey), + style: TextStyle(color: Colors.grey, fontWeight: FontWeight.bold), ), Text( 'reset your password. ', - style: TextStyle(color: Colors.grey), + style: TextStyle(color: Colors.grey, fontWeight: FontWeight.bold), ), SizedBox(height: 30.0), TextFormField( @@ -72,13 +75,38 @@ class _ForgotPasswordState extends State { }, decoration: InputDecoration( labelText: "Enter your registered email", + labelStyle: TextStyle( + color: Colors.grey, + ), border: const OutlineInputBorder(), + focusedBorder: + OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius.circular( + 10)), + borderSide: new BorderSide( + width: 1, + color: Colors.deepPurple), + ), + enabledBorder: + OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius.circular( + 10)), + borderSide: new BorderSide( + width: 1, + color: + Colors.grey), + ), ), ), SizedBox(height: 20.0), Container( width: double.infinity, - padding: const EdgeInsets.only(left: 5.0, right: 5.0), + height: 40, + // padding: const EdgeInsets.only(left: 5.0, right: 5.0), child: new RaisedButton( splashColor: Colors.lightBlueAccent, elevation: 10.0, @@ -86,7 +114,7 @@ class _ForgotPasswordState extends State { child: const Text('SUBMIT'), color: Colors.deepPurple[500], textColor: Colors.white, - onPressed: () { + onPressed: () async { bool isUser = true; if (_formKey.currentState.validate()) { @@ -94,7 +122,16 @@ class _ForgotPasswordState extends State { setState(() { showSpinner = true; }); - _auth.sendPasswordResetEmail(email: email); + await _auth.sendPasswordResetEmail(email: email); + Fluttertoast.showToast( + msg: "Reset link sent", + gravity: ToastGravity.BOTTOM, + toastLength: Toast.LENGTH_SHORT, + timeInSecForIosWeb: 1, + backgroundColor: Colors.deepPurple, + fontSize: 16, + textColor: Colors.white + ); } on FirebaseAuthException catch (e) { if (e.code == 'user-not-found') { isUser = false; @@ -105,19 +142,22 @@ class _ForgotPasswordState extends State { showSpinner = false; }); if (!isUser) { - Navigator.pushNamed(context, "signup"); + Navigator.pushNamed(context, SignupPage.signUpPageId); } } } }, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + ), )), SizedBox(height: 20.0), Material( color: Colors.white.withOpacity(0.0), child: InkWell( child: Text('Back to login', - style: TextStyle(color: Colors.purple[700])), - onTap: () => Navigator.pushNamed(context, "login"), + style: TextStyle(color: Colors.deepPurple[500])), + onTap: () => Navigator.pushNamed(context, LoginPage.loginPageId), ), ), ]), diff --git a/star_in_me_app/lib/authentication/login.dart b/star_in_me_app/lib/authentication/login.dart index a7bef42..a849709 100644 --- a/star_in_me_app/lib/authentication/login.dart +++ b/star_in_me_app/lib/authentication/login.dart @@ -55,28 +55,32 @@ class _LoginPageState extends State { child: ListView( shrinkWrap: true, children: [ - Center( - child: Text( + Align( + alignment: Alignment.topLeft, + child: Text( 'Welcome Back', style: TextStyle( - color: Colors.purple, + color: Colors.deepPurple[500], fontWeight: FontWeight.bold, - fontSize: 30.0), + fontSize: 28.0), )), SizedBox( - height: 20.0, + height: 15.0, ), - Column( - children: [ - Text( - 'Stay connected, be informed and keep', - style: TextStyle(color: Colors.grey), - ), - Text( - 'inspiring.', - style: TextStyle(color: Colors.grey), - ), - ], + Align( + alignment: Alignment.topLeft, + child: Text( + 'Stay connected, be informed and keep', + style: TextStyle(color: Colors.black45, fontWeight: FontWeight.bold, fontSize: 15), + ), + ), + // SizedBox(height: 5), + Align( + alignment: Alignment.topLeft, + child: Text( + 'inspiring.', + style: TextStyle(color: Colors.black45, fontWeight: FontWeight.bold, fontSize: 15), + ), ), SizedBox( height: 20.0, @@ -99,7 +103,32 @@ class _LoginPageState extends State { }, decoration: InputDecoration( labelText: "Email Address", + labelStyle: TextStyle( + color: Colors.grey, + fontSize: 15 + ), border: const OutlineInputBorder(), + focusedBorder: + OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius.circular( + 10)), + borderSide: new BorderSide( + width: 1, + color: Colors.deepPurple), + ), + enabledBorder: + OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius.circular( + 10)), + borderSide: new BorderSide( + width: 1, + color: + Colors.grey), + ), ), ), SizedBox( @@ -109,17 +138,52 @@ class _LoginPageState extends State { controller: passController, decoration: InputDecoration( labelText: "Password", + labelStyle: TextStyle( + color: Colors.grey, + fontSize: 15 + ), suffixIcon: FlatButton( onPressed: () { setState(() { toggle(); }); }, - child: Icon( - Icons.remove_red_eye, - color: Colors.black12, - )), + child: _secureText + ? Icon( + Icons + .visibility_off, + color: Colors.grey + .withOpacity( + 0.5)) + : Icon( + Icons + .remove_red_eye, + color: Colors.grey + .withOpacity( + 0.5)), + ), border: const OutlineInputBorder(), + focusedBorder: + OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius.circular( + 10)), + borderSide: new BorderSide( + width: 1, + color: Colors.deepPurple), + ), + enabledBorder: + OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius.circular( + 10)), + borderSide: new BorderSide( + width: 1, + color: + Colors.grey), + ), ), validator: (value) => value.length < 6 ? 'Password too short.' : null, @@ -133,11 +197,13 @@ class _LoginPageState extends State { ), Row( children: [ - Padding( - padding: const EdgeInsets.only(right: 5.0), + Container( child: Checkbox( value: _isChecked, tristate: false, + activeColor: Colors.deepPurple, + checkColor: Colors.white, + onChanged: (bool isChecked) { setState(() { _isChecked = isChecked; @@ -149,7 +215,6 @@ class _LoginPageState extends State { 'Remember password', style: TextStyle( fontSize: 16.0, - fontWeight: FontWeight.bold, color: Colors.grey, ), ), @@ -160,8 +225,8 @@ class _LoginPageState extends State { child: Material( color: Colors.white.withOpacity(0.0), child: InkWell( - child: Text('Forgot Password? ', - style: TextStyle(color: Colors.black38)), + child: Text('Forgot Password?', + style: TextStyle(color: Colors.black45, fontWeight: FontWeight.bold, fontSize: 16.0)), onTap: () => Navigator.pushNamed( context, ForgotPassword.forgotPassword), ), @@ -170,13 +235,17 @@ class _LoginPageState extends State { SizedBox(height: 10.0), Container( width: double.infinity, + height: 40, padding: const EdgeInsets.only(left: 5.0, right: 5.0), - child: RaisedButton( + child: MaterialButton( splashColor: Colors.lightBlueAccent, - elevation: 10.0, - highlightElevation: 30.0, - child: const Text('LOGIN'), + // elevation: 10.0, + // highlightElevation: 30.0, + child: const Text('LOGIN', + style: TextStyle( + fontSize: 15, + )), color: Colors.deepPurple[500], textColor: Colors.white, onPressed: () async { @@ -213,6 +282,9 @@ class _LoginPageState extends State { } } }, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + ), )), SizedBox(height: 15.0), Padding( @@ -228,8 +300,9 @@ class _LoginPageState extends State { child: InkWell( child: Text('Sign up now!', style: TextStyle( - color: Colors.purple[700], - fontSize: 15.0)), + color: Colors.deepPurple[400], + fontSize: 15.0, + fontWeight: FontWeight.bold)), onTap: () => Navigator.pushNamed( context, SignupPage.signUpPageId), ), @@ -243,7 +316,9 @@ class _LoginPageState extends State { Padding( padding: EdgeInsets.only(left: 5.0), child: Text('Login with', - style: TextStyle(color: Colors.purple[700])), + style: TextStyle(color: Colors.deepPurple[400], + fontSize: 18, + fontWeight: FontWeight.bold)), ), SizedBox(height: 10.0), Row( @@ -359,7 +434,7 @@ Future _signInWithGoogle() async { Future facebookLogin(BuildContext context) async { User currentUser; // fbLogin.loginBehavior = FacebookLoginBehavior.webViewOnly; - // remove above comment then facebook login will take username and pasword for login in Webview + // remove above comment then facebook login will take username and password for login in WebView try { final FacebookLoginResult facebookLoginResult = await fbLogin.logIn(['email', 'public_profile']); @@ -369,7 +444,7 @@ Future facebookLogin(BuildContext context) async { final AuthCredential credential = FacebookAuthProvider.getCredential( facebookAccessToken.token); final User user = (await _auth.signInWithCredential(credential)).user; - assert(user.email != null); + assert(user.email != null); assert(user.displayName != null); assert(!user.isAnonymous); assert(await user.getIdToken() != null); diff --git a/star_in_me_app/lib/authentication/signup.dart b/star_in_me_app/lib/authentication/signup.dart index 69c076e..f8a7d17 100644 --- a/star_in_me_app/lib/authentication/signup.dart +++ b/star_in_me_app/lib/authentication/signup.dart @@ -32,7 +32,202 @@ class _SignupPageState extends State { final emailController = TextEditingController(); final passController = TextEditingController(); final confirmPassCOntroller = TextEditingController(); - String firstName, lastName, email, pass, confirmPass; + String firstName, lastName, email, pass, confirmPass, selectedCountry; + List countries = ["Afghanistan", + "Albania", + "Algeria", + "Andorra", + "Angola", + "Antigua and Barbuda", + "Argentina", + "Armenia", + "Australia", + "Austria", + "Azerbaijan", + "Bahamas", + "Bahrain", + "Bangladesh", + "Barbados", + "Belarus", + "Belgium", + "Belize", + "Benin", + "Bhutan", + "Bolivia", + "Bosnia and Herzegovina", + "Botswana", + "Brazil", + "Brunei", + "Bulgaria", + "Burkina Faso", + "Burundi", + "Côte d'Ivoire", + "Cabo Verde", + "Cambodia", + "Cameroon", + "Canada", + "Central African Republic", + "Chad", + "Chile", + "China", + "Colombia", + "Comoros", + "Congo (Congo-Brazzaville)", + "Costa Rica", + "Croatia", + "Cuba", + "Cyprus", + "Czechia (Czech Republic)", + "Democratic Republic of the Congo", + "Denmark", + "Djibouti", + "Dominica", + "Dominican Republic", + "Ecuador", + "Egypt", + "El Salvador", + "Equatorial Guinea", + "Eritrea", + "Estonia", + "Eswatini (fmr. Swaziland)", + "Ethiopia", + "Fiji", + "Finland", + "France", + "Gabon", + "Gambia", + "Georgia", + "Germany", + "Ghana", + "Greece", + "Grenada", + "Guatemala", + "Guinea", + "Guinea-Bissau", + "Guyana", + "Haiti", + "Holy See", + "Honduras", + "Hungary", + "Iceland", + "India", + "Indonesia", + "Iran", + "Iraq", + "Ireland", + "Israel", + "Italy", + "Jamaica", + "Japan", + "Jordan", + "Kazakhstan", + "Kenya", + "Kiribati", + "Kuwait", + "Kyrgyzstan", + "Laos", + "Latvia", + "Lebanon", + "Lesotho", + "Liberia", + "Libya", + "Liechtenstein", + "Lithuania", + "Luxembourg", + "Madagascar", + "Malawi", + "Malaysia", + "Maldives", + "Mali", + "Malta", + "Marshall Islands", + "Mauritania", + "Mauritius", + "Mexico", + "Micronesia", + "Moldova", + "Monaco", + "Mongolia", + "Montenegro", + "Morocco", + "Mozambique", + "Myanmar", + "Namibia", + "Nauru", + "Nepal", + "Netherlands", + "New Zealand", + "Nicaragua", + "Niger", + "Nigeria", + "North Korea", + "North Macedonia", + "Norway", + "Oman", + "Pakistan", + "Palau", + "Palestine State", + "Panama", + "Papua New Guinea", + "Paraguay", + "Peru", + "Philippines", + "Poland", + "Portugal", + "Qatar", + "Romania", + "Russia", + "Rwanda", + "Saint Kitts and Nevis", + "Saint Lucia", + "Saint Vincent and the Grenadines", + "Samoa", + "San Marino", + "Sao Tome and Principe", + "Saudi Arabia", + "Senegal", + "Serbia", + "Seychelles", + "Sierra Leone", + "Singapore", + "Slovakia", + "Slovenia", + "Solomon Islands", + "Somalia", + "South Africa", + "South Korea", + "South Sudan", + "Spain", + "Sri Lanka", + "Sudan", + "Suriname", + "Sweden", + "Switzerland", + "Syria", + "Tajikistan", + "Tanzania", + "Thailand", + "Timor-Leste", + "Togo", + "Tonga", + "Trinidad and Tobago", + "Tunisia", + "Turkey", + "Turkmenistan", + "Tuvalu", + "Uganda", + "Ukraine", + "United Arab Emirates", + "United Kingdom", + "United States of America", + "Uruguay", + "Uzbekistan", + "Vanuatu", + "Venezuela", + "Vietnam", + "Yemen", + "Zambia", + "Zimbabwe"]; bool showSpinner = false; bool _isChecked = false; @@ -90,6 +285,8 @@ class _SignupPageState extends State { child: Checkbox( value: _isChecked, tristate: false, + activeColor: Colors.deepPurple, + checkColor: Colors.white, onChanged: (bool isChecked) { setState(() { _isChecked = isChecked; @@ -110,40 +307,60 @@ class _SignupPageState extends State { ], ), SizedBox(height: 10.0), - DropdownSearch( - hint:"Please select your country", - mode: Mode.MENU, - showSelectedItem: true, - items: ["India","Indonesia","Brazil", "Italy", "Tunisia", 'Canada'], - - onChanged: print, + hint:"Please select your country", + mode: Mode.MENU, + showSelectedItem: true, + items: countries, + onChanged: (value) => setState(() { + selectedCountry = value; + print(selectedCountry); + }), ), SizedBox(height: 10.0), - Row( children: [ Expanded( + flex: 1, child: ButtonTheme( height: 40.0, minWidth: 10.0, padding: EdgeInsets.only(left: 5.0, right: 5.0), child: RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + ), splashColor: Colors.lightBlue, elevation: 10.0, highlightElevation: 50.0, child: Row(children: [ Padding( padding: const EdgeInsets.only( - left: 5.0, right: 5.0), - child: Image.asset( - 'images/linkedin_logo.png', - height: 40.0, - width: 15.0, + right: 5.0), + // child: Image.asset( + // 'images/linkedin_logo.png', + // height: 40.0, + // width: 15.0, + // ), + child: Container( + height: 20, + width: 20, + child: Text('in', + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.deepPurple[500], + fontWeight: FontWeight.bold, + fontSize: 16, + )), + decoration: BoxDecoration( + color: Colors.white, + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(4), + ), ), ), - Text('Sign up with LinkedIn '), + Text('Sign up with LinkedIn'), ]), color: Colors.deepPurple[500], textColor: Colors.white, @@ -183,23 +400,43 @@ class _SignupPageState extends State { width: 5.0, ), Expanded( + flex: 1, child: ButtonTheme( height: 40.0, minWidth: 10.0, padding: EdgeInsets.only(left: 5.0, right: 5.0), child: RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + ), splashColor: Colors.red, - elevation: 10.0, - highlightElevation: 50.0, + // elevation: 10.0, + // highlightElevation: 50.0, child: Row(children: [ Padding( padding: const EdgeInsets.only( left: 5.0, right: 5.0), - child: Image.asset( - 'images/google_logo.png', - height: 40.0, - width: 10.0, + // child: Image.asset( + // 'images/google_logo.png', + // height: 40.0, + // width: 15.0, + // ), + child: Container( + height: 20, + width: 20, + child: Text('G', + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.deepPurple[500], + fontWeight: FontWeight.bold, + fontSize: 16, + )), + decoration: BoxDecoration( + color: Colors.white, + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(4), + ), ), ), Text('Sign up with Google'), @@ -244,6 +481,30 @@ class _SignupPageState extends State { decoration: InputDecoration( labelText: "First Name", border: const OutlineInputBorder(), + labelStyle: TextStyle( + color: Colors.grey, + ), + focusedBorder: + OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius.circular( + 10)), + borderSide: new BorderSide( + width: 1, + color: Colors.deepPurple), + ), + enabledBorder: + OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius.circular( + 10)), + borderSide: new BorderSide( + width: 1, + color: + Colors.grey), + ), ), ), SizedBox( @@ -266,6 +527,30 @@ class _SignupPageState extends State { decoration: InputDecoration( labelText: "Last Name", border: const OutlineInputBorder(), + labelStyle: TextStyle( + color: Colors.grey, + ), + focusedBorder: + OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius.circular( + 10)), + borderSide: new BorderSide( + width: 1, + color: Colors.deepPurple), + ), + enabledBorder: + OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius.circular( + 10)), + borderSide: new BorderSide( + width: 1, + color: + Colors.grey), + ), ), ), SizedBox( @@ -289,6 +574,30 @@ class _SignupPageState extends State { }, decoration: InputDecoration( labelText: "Email Address", + labelStyle: TextStyle( + color: Colors.grey, + ), + focusedBorder: + OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius.circular( + 10)), + borderSide: new BorderSide( + width: 1, + color: Colors.deepPurple), + ), + enabledBorder: + OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius.circular( + 10)), + borderSide: new BorderSide( + width: 1, + color: + Colors.grey), + ), border: const OutlineInputBorder(), ), ), @@ -298,17 +607,51 @@ class _SignupPageState extends State { TextFormField( controller: passController, decoration: InputDecoration( - labelText: "New Password (Min 6 Characters) ", + labelText: "New Password (Min 6 Characters)", + labelStyle: TextStyle( + color: Colors.grey, + ), + focusedBorder: + OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius.circular( + 10)), + borderSide: new BorderSide( + width: 1, + color: Colors.deepPurple), + ), + enabledBorder: + OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius.circular( + 10)), + borderSide: new BorderSide( + width: 1, + color: + Colors.grey), + ), suffixIcon: FlatButton( onPressed: () { setState(() { toggle(); }); }, - child: Icon( - Icons.remove_red_eye, - color: Colors.black12, - )), + child: _secureText + ? Icon( + Icons + .visibility_off, + color: Colors.grey + .withOpacity( + 0.5)) + : Icon( + Icons + .remove_red_eye, + color: Colors.grey + .withOpacity( + 0.5)), + ), border: const OutlineInputBorder(), ), validator: (value) => value.length < 6 @@ -326,16 +669,50 @@ class _SignupPageState extends State { controller: confirmPassCOntroller, decoration: InputDecoration( labelText: "Confirm Password", + labelStyle: TextStyle( + color: Colors.grey, + ), + focusedBorder: + OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius.circular( + 10)), + borderSide: new BorderSide( + width: 1, + color: Colors.deepPurple), + ), + enabledBorder: + OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius.circular( + 10)), + borderSide: new BorderSide( + width: 1, + color: + Colors.grey), + ), suffixIcon: FlatButton( onPressed: () { setState(() { toggle(); }); }, - child: Icon( - Icons.remove_red_eye, - color: Colors.black12, - )), + child: _secureText + ? Icon( + Icons + .visibility_off, + color: Colors.grey + .withOpacity( + 0.5)) + : Icon( + Icons + .remove_red_eye, + color: Colors.grey + .withOpacity( + 0.5)), + ), border: const OutlineInputBorder(), ), validator: (value) { @@ -351,7 +728,7 @@ class _SignupPageState extends State { }, obscureText: _secureText, ), - SizedBox(height: 7.0), + SizedBox(height: 15), Padding( padding: const EdgeInsets.only(left: 5.0), child: Row(children: [ @@ -368,8 +745,9 @@ class _SignupPageState extends State { )), ]), ), - SizedBox(height: 7.0), + SizedBox(height: 15), Container( + height: 40, width: double.infinity, padding: const EdgeInsets.only( left: 5.0, right: 5.0), @@ -377,6 +755,9 @@ class _SignupPageState extends State { splashColor: Colors.lightBlueAccent, elevation: 10.0, highlightElevation: 30.0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + ), child: const Text('SIGN UP NOW'), color: Colors.deepPurple[500], textColor: Colors.white, @@ -441,14 +822,15 @@ class _SignupPageState extends State { 'The Star in me? ', style: TextStyle( color: Colors.purple[300], - fontWeight: FontWeight.bold), + fontWeight: FontWeight.w400), ), Material( color: Colors.white.withOpacity(0.0), child: InkWell( child: Text('Log in', style: TextStyle( - color: Colors.purple[700])), + fontWeight: FontWeight.bold, + color: Colors.deepPurple[500])), onTap: () => Navigator.pushNamed( context, LoginPage.loginPageId), ), @@ -506,7 +888,7 @@ class Drawhorizontalline extends CustomPainter { Drawhorizontalline(this.reverse) { _paint = Paint() - ..color = Colors.black + ..color = Colors.grey ..strokeWidth = 1 ..strokeCap = StrokeCap.round; } diff --git a/star_in_me_app/lib/main.dart b/star_in_me_app/lib/main.dart index 592069d..2c0f865 100644 --- a/star_in_me_app/lib/main.dart +++ b/star_in_me_app/lib/main.dart @@ -1,23 +1,23 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'my_app.dart'; -import 'package:star_in_me_app/onboarding/imageupload.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); runApp(MyApp()); } -class MyApp extends StatefulWidget { - @override - _MyAppState createState() => _MyAppState(); -} - -class _MyAppState extends State { - @override - Widget build(BuildContext context) { - return MaterialApp( - home : Image_Upload(), - ); - } -} +// class MyApp extends StatefulWidget { +// @override +// _MyAppState createState() => _MyAppState(); +// } +// +// class _MyAppState extends State { +// @override +// Widget build(BuildContext context) { +// return MaterialApp( +// debugShowCheckedModeBanner: false, +// home : LandingPage(), +// ); +// } +// } diff --git a/star_in_me_app/lib/screens/landing.dart b/star_in_me_app/lib/screens/landing.dart index 69eb32f..81f6da0 100644 --- a/star_in_me_app/lib/screens/landing.dart +++ b/star_in_me_app/lib/screens/landing.dart @@ -5,6 +5,8 @@ import 'package:star_in_me_app/authentication/signup.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'package:star_in_me_app/model/slide.dart'; import 'package:star_in_me_app/components/roundRechtangleButton.dart'; +import '../authentication/login.dart'; +import '../authentication/signup.dart'; class LandingPage extends StatefulWidget { static final String landingPageId = '/landing'; diff --git a/star_in_me_app/pubspec.lock b/star_in_me_app/pubspec.lock index 41eda00..f1e1e9c 100644 --- a/star_in_me_app/pubspec.lock +++ b/star_in_me_app/pubspec.lock @@ -63,21 +63,21 @@ packages: name: cloud_firestore url: "https://pub.dartlang.org" source: hosted - version: "0.14.2" + version: "0.14.3" cloud_firestore_platform_interface: dependency: transitive description: name: cloud_firestore_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "2.2.0" cloud_firestore_web: dependency: transitive description: name: cloud_firestore_web url: "https://pub.dartlang.org" source: hosted - version: "0.2.0+5" + version: "0.2.1" collection: dependency: transitive description: @@ -119,14 +119,14 @@ packages: name: dotted_border url: "https://pub.dartlang.org" source: hosted - version: "1.0.6" + version: "1.0.7" dropdown_search: dependency: "direct dev" description: name: dropdown_search url: "https://pub.dartlang.org" source: hosted - version: "0.4.5" + version: "0.4.8" email_validator: dependency: "direct dev" description: @@ -155,41 +155,34 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "5.2.1" - firebase: - dependency: transitive - description: - name: firebase - url: "https://pub.dartlang.org" - source: hosted - version: "7.3.2" firebase_auth: dependency: "direct dev" description: name: firebase_auth url: "https://pub.dartlang.org" source: hosted - version: "0.18.2" + version: "0.18.3" firebase_auth_platform_interface: dependency: transitive description: name: firebase_auth_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.3" firebase_auth_web: dependency: transitive description: name: firebase_auth_web url: "https://pub.dartlang.org" source: hosted - version: "0.3.1+2" + version: "0.3.2" firebase_core: dependency: "direct dev" description: name: firebase_core url: "https://pub.dartlang.org" source: hosted - version: "0.5.1" + version: "0.5.2" firebase_core_platform_interface: dependency: transitive description: @@ -203,7 +196,7 @@ packages: name: firebase_core_web url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.2.1" firebase_storage: dependency: "direct dev" description: @@ -216,6 +209,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_counter: + dependency: "direct dev" + description: + name: flutter_counter + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_facebook_login: dependency: "direct dev" description: @@ -254,6 +254,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.3.11" + fluttertoast: + dependency: "direct dev" + description: + name: fluttertoast + url: "https://pub.dartlang.org" + source: hosted + version: "7.1.1" font_awesome_flutter: dependency: "direct dev" description: @@ -267,7 +274,7 @@ packages: name: google_sign_in url: "https://pub.dartlang.org" source: hosted - version: "4.5.5" + version: "4.5.6" google_sign_in_platform_interface: dependency: transitive description: @@ -309,7 +316,7 @@ packages: name: image_picker url: "https://pub.dartlang.org" source: hosted - version: "0.6.7+12" + version: "0.6.7+14" image_picker_platform_interface: dependency: transitive description: @@ -337,7 +344,7 @@ packages: name: linkedin_login url: "https://pub.dartlang.org" source: hosted - version: "1.2.2" + version: "1.3.1" loading: dependency: "direct dev" description: @@ -407,14 +414,14 @@ packages: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "1.0.4" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "0.0.4+1" + version: "0.0.4+3" pedantic: dependency: transitive description: @@ -463,28 +470,28 @@ packages: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.1.4+1" + version: "2.1.5" shared_preferences: dependency: "direct dev" description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.12+2" + version: "0.5.12+4" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.2+2" + version: "0.0.2+4" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+10" + version: "0.0.1+11" shared_preferences_platform_interface: dependency: transitive description: @@ -505,7 +512,7 @@ packages: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+1" + version: "0.0.1+3" simple_animations: dependency: "direct dev" description: @@ -594,7 +601,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "1.7.3" + version: "1.7.4" xdg_directories: dependency: transitive description: diff --git a/star_in_me_app/pubspec.yaml b/star_in_me_app/pubspec.yaml index bed28a6..7314740 100644 --- a/star_in_me_app/pubspec.yaml +++ b/star_in_me_app/pubspec.yaml @@ -34,6 +34,8 @@ dev_dependencies: image_cropper: ^1.3.1 image_picker: ^0.6.7+12 flutter_counter: ^1.0.3 +# flutter_spinkit: ^4.1.2+1 + fluttertoast: ^7.1.1 dotted_border: ^1.0.6 @@ -43,8 +45,8 @@ dev_dependencies: dropdown_search: ^0.4.4 - firebase_core: ^0.5.0 - firebase_auth: ^0.18.0+1 + firebase_core: ^0.5.0+1 + firebase_auth: ^0.18.1+2 cloud_firestore: ^0.14.0+2 firebase_storage: ^4.0.1 toast: ^0.1.5 From f23b59bc0791f39edd211b9c95abba805f6341ff Mon Sep 17 00:00:00 2001 From: khyatisaini Date: Sat, 21 Nov 2020 22:56:40 +0530 Subject: [PATCH 2/3] displaying name in thankyou screen --- .../android/app/google-services.json | 8 + star_in_me_app/lib/authentication/login.dart | 12 +- star_in_me_app/lib/authentication/signup.dart | 251 +++--------------- star_in_me_app/lib/components/countries.dart | 196 ++++++++++++++ .../lib/screens/thankyou_screen.dart | 54 ++-- 5 files changed, 290 insertions(+), 231 deletions(-) create mode 100644 star_in_me_app/lib/components/countries.dart diff --git a/star_in_me_app/android/app/google-services.json b/star_in_me_app/android/app/google-services.json index 6a60cf3..40ef158 100644 --- a/star_in_me_app/android/app/google-services.json +++ b/star_in_me_app/android/app/google-services.json @@ -14,6 +14,14 @@ } }, "oauth_client": [ + { + "client_id": "714256145906-cnhre7hk1eu2gudmir7gsrq9furn5sb5.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "com.example.star_in_me_app", + "certificate_hash": "57350a5ad158b3ed8338889479896768d91652bc" + } + }, { "client_id": "714256145906-kvcbj5vpmr9k1dms92t8esij1haqpndc.apps.googleusercontent.com", "client_type": 1, diff --git a/star_in_me_app/lib/authentication/login.dart b/star_in_me_app/lib/authentication/login.dart index a849709..b797d80 100644 --- a/star_in_me_app/lib/authentication/login.dart +++ b/star_in_me_app/lib/authentication/login.dart @@ -10,6 +10,7 @@ import 'package:flutter_facebook_login/flutter_facebook_login.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:google_sign_in/google_sign_in.dart'; +import 'package:fluttertoast/fluttertoast.dart'; final _auth = FirebaseAuth.instance; final _firestore = FirebaseFirestore.instance; @@ -269,6 +270,15 @@ class _LoginPageState extends State { isUser = false; } print('${e.code}'); + Fluttertoast.showToast( + msg: e.message, + gravity: ToastGravity.BOTTOM, + toastLength: Toast.LENGTH_SHORT, + timeInSecForIosWeb: 1, + backgroundColor: Colors.deepPurple[500], + fontSize: 16, + textColor: Colors.white + ); } catch (e) { print(e.toString()); } finally { @@ -417,7 +427,7 @@ Future _signInWithGoogle() async { idToken: googleSignInAuthentication.idToken); final result = await _auth.signInWithCredential(credential); - final User user = result.user; + final user = result.user; assert(!user.isAnonymous); assert(await user.getIdToken() != null); diff --git a/star_in_me_app/lib/authentication/signup.dart b/star_in_me_app/lib/authentication/signup.dart index f8a7d17..4bae960 100644 --- a/star_in_me_app/lib/authentication/signup.dart +++ b/star_in_me_app/lib/authentication/signup.dart @@ -9,6 +9,8 @@ import 'package:google_sign_in/google_sign_in.dart'; import 'package:linkedin_login/linkedin_login.dart'; import 'package:star_in_me_app/screens/thankyou_screen.dart'; import 'package:dropdown_search/dropdown_search.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import '../components/countries.dart'; final _auth = FirebaseAuth.instance; final _firestore = FirebaseFirestore.instance; @@ -33,201 +35,6 @@ class _SignupPageState extends State { final passController = TextEditingController(); final confirmPassCOntroller = TextEditingController(); String firstName, lastName, email, pass, confirmPass, selectedCountry; - List countries = ["Afghanistan", - "Albania", - "Algeria", - "Andorra", - "Angola", - "Antigua and Barbuda", - "Argentina", - "Armenia", - "Australia", - "Austria", - "Azerbaijan", - "Bahamas", - "Bahrain", - "Bangladesh", - "Barbados", - "Belarus", - "Belgium", - "Belize", - "Benin", - "Bhutan", - "Bolivia", - "Bosnia and Herzegovina", - "Botswana", - "Brazil", - "Brunei", - "Bulgaria", - "Burkina Faso", - "Burundi", - "Côte d'Ivoire", - "Cabo Verde", - "Cambodia", - "Cameroon", - "Canada", - "Central African Republic", - "Chad", - "Chile", - "China", - "Colombia", - "Comoros", - "Congo (Congo-Brazzaville)", - "Costa Rica", - "Croatia", - "Cuba", - "Cyprus", - "Czechia (Czech Republic)", - "Democratic Republic of the Congo", - "Denmark", - "Djibouti", - "Dominica", - "Dominican Republic", - "Ecuador", - "Egypt", - "El Salvador", - "Equatorial Guinea", - "Eritrea", - "Estonia", - "Eswatini (fmr. Swaziland)", - "Ethiopia", - "Fiji", - "Finland", - "France", - "Gabon", - "Gambia", - "Georgia", - "Germany", - "Ghana", - "Greece", - "Grenada", - "Guatemala", - "Guinea", - "Guinea-Bissau", - "Guyana", - "Haiti", - "Holy See", - "Honduras", - "Hungary", - "Iceland", - "India", - "Indonesia", - "Iran", - "Iraq", - "Ireland", - "Israel", - "Italy", - "Jamaica", - "Japan", - "Jordan", - "Kazakhstan", - "Kenya", - "Kiribati", - "Kuwait", - "Kyrgyzstan", - "Laos", - "Latvia", - "Lebanon", - "Lesotho", - "Liberia", - "Libya", - "Liechtenstein", - "Lithuania", - "Luxembourg", - "Madagascar", - "Malawi", - "Malaysia", - "Maldives", - "Mali", - "Malta", - "Marshall Islands", - "Mauritania", - "Mauritius", - "Mexico", - "Micronesia", - "Moldova", - "Monaco", - "Mongolia", - "Montenegro", - "Morocco", - "Mozambique", - "Myanmar", - "Namibia", - "Nauru", - "Nepal", - "Netherlands", - "New Zealand", - "Nicaragua", - "Niger", - "Nigeria", - "North Korea", - "North Macedonia", - "Norway", - "Oman", - "Pakistan", - "Palau", - "Palestine State", - "Panama", - "Papua New Guinea", - "Paraguay", - "Peru", - "Philippines", - "Poland", - "Portugal", - "Qatar", - "Romania", - "Russia", - "Rwanda", - "Saint Kitts and Nevis", - "Saint Lucia", - "Saint Vincent and the Grenadines", - "Samoa", - "San Marino", - "Sao Tome and Principe", - "Saudi Arabia", - "Senegal", - "Serbia", - "Seychelles", - "Sierra Leone", - "Singapore", - "Slovakia", - "Slovenia", - "Solomon Islands", - "Somalia", - "South Africa", - "South Korea", - "South Sudan", - "Spain", - "Sri Lanka", - "Sudan", - "Suriname", - "Sweden", - "Switzerland", - "Syria", - "Tajikistan", - "Tanzania", - "Thailand", - "Timor-Leste", - "Togo", - "Tonga", - "Trinidad and Tobago", - "Tunisia", - "Turkey", - "Turkmenistan", - "Tuvalu", - "Uganda", - "Ukraine", - "United Arab Emirates", - "United Kingdom", - "United States of America", - "Uruguay", - "Uzbekistan", - "Vanuatu", - "Venezuela", - "Vietnam", - "Yemen", - "Zambia", - "Zimbabwe"]; bool showSpinner = false; bool _isChecked = false; @@ -449,7 +256,7 @@ class _SignupPageState extends State { user = await _signUpWithGoogle(); } on FirebaseAuthException catch (e) { - print('${e.code}'); + print('${e.code} 787878'); } catch (e) { print(e.toString()); } @@ -774,18 +581,43 @@ class _SignupPageState extends State { .createUserWithEmailAndPassword( email: email, password: pass); if (userCredential != null) { + // adding display name + String userName = firstName + " " + lastName; + print('user is $userName'); + _auth.currentUser.updateProfile(displayName: userName); _firestore.collection("users").add({ "firstName": firstName, "lastName": lastName, - "email": email + "email": email, }); + Navigator.pushNamed( + context, ThankYou.thankYouPage, arguments: {'name': userName}); } + } on FirebaseAuthException catch (e) { if (e.code == 'weak-password') { print("${e.code}"); + Fluttertoast.showToast( + msg: e.message, + gravity: ToastGravity.BOTTOM, + toastLength: Toast.LENGTH_SHORT, + timeInSecForIosWeb: 1, + backgroundColor: Colors.deepPurple[500], + fontSize: 16, + textColor: Colors.white + ); } else if (e.code == 'email-already-in-use') { print("${e.code}"); + Fluttertoast.showToast( + msg: e.message, + gravity: ToastGravity.BOTTOM, + toastLength: Toast.LENGTH_SHORT, + timeInSecForIosWeb: 1, + backgroundColor: Colors.deepPurple[500], + fontSize: 16, + textColor: Colors.white + ); isUser = true; } } catch (e) { @@ -794,16 +626,15 @@ class _SignupPageState extends State { setState(() { showSpinner = false; }); - if (isUser) { - Navigator.pushNamed( - context, ThankYou.thankYouPage); - } - } - - if (userCredential != null) { - Navigator.pushNamed( - context, SignupPage.signUpPageId); + // if (isUser) { + // Navigator.pushNamed( + // context, ThankYou.thankYouPage); + // } } + // if (userCredential != null) { + // Navigator.pushNamed( + // context, SignupPage.signUpPageId); + // } } }, )), @@ -848,12 +679,13 @@ class _SignupPageState extends State { } Future _signUpWithGoogle() async { + // if the user has signed in using google sign-in, logging that one out bool isSignedIn = await googleSignIn.isSignedIn(); print(isSignedIn); if (isSignedIn) { - final user = _auth.currentUser; - return user; - } else { + googleSignIn.signOut(); + } + final GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn(); final GoogleSignInAuthentication googleSignInAuthentication = await googleSignInAccount.authentication; @@ -877,7 +709,6 @@ Future _signUpWithGoogle() async { print(currentUser.email); return user; - } } //Horizontal lIne diff --git a/star_in_me_app/lib/components/countries.dart b/star_in_me_app/lib/components/countries.dart new file mode 100644 index 0000000..4a6e806 --- /dev/null +++ b/star_in_me_app/lib/components/countries.dart @@ -0,0 +1,196 @@ +List countries = [ + "Afghanistan", + "Albania", + "Algeria", + "Andorra", + "Angola", + "Antigua and Barbuda", + "Argentina", + "Armenia", + "Australia", + "Austria", + "Azerbaijan", + "Bahamas", + "Bahrain", + "Bangladesh", + "Barbados", + "Belarus", + "Belgium", + "Belize", + "Benin", + "Bhutan", + "Bolivia", + "Bosnia and Herzegovina", + "Botswana", + "Brazil", + "Brunei", + "Bulgaria", + "Burkina Faso", + "Burundi", + "Côte d'Ivoire", + "Cabo Verde", + "Cambodia", + "Cameroon", + "Canada", + "Central African Republic", + "Chad", + "Chile", + "China", + "Colombia", + "Comoros", + "Congo (Congo-Brazzaville)", + "Costa Rica", + "Croatia", + "Cuba", + "Cyprus", + "Czechia (Czech Republic)", + "Democratic Republic of the Congo", + "Denmark", + "Djibouti", + "Dominica", + "Dominican Republic", + "Ecuador", + "Egypt", + "El Salvador", + "Equatorial Guinea", + "Eritrea", + "Estonia", + "Eswatini (fmr. Swaziland)", + "Ethiopia", + "Fiji", + "Finland", + "France", + "Gabon", + "Gambia", + "Georgia", + "Germany", + "Ghana", + "Greece", + "Grenada", + "Guatemala", + "Guinea", + "Guinea-Bissau", + "Guyana", + "Haiti", + "Holy See", + "Honduras", + "Hungary", + "Iceland", + "India", + "Indonesia", + "Iran", + "Iraq", + "Ireland", + "Israel", + "Italy", + "Jamaica", + "Japan", + "Jordan", + "Kazakhstan", + "Kenya", + "Kiribati", + "Kuwait", + "Kyrgyzstan", + "Laos", + "Latvia", + "Lebanon", + "Lesotho", + "Liberia", + "Libya", + "Liechtenstein", + "Lithuania", + "Luxembourg", + "Madagascar", + "Malawi", + "Malaysia", + "Maldives", + "Mali", + "Malta", + "Marshall Islands", + "Mauritania", + "Mauritius", + "Mexico", + "Micronesia", + "Moldova", + "Monaco", + "Mongolia", + "Montenegro", + "Morocco", + "Mozambique", + "Myanmar", + "Namibia", + "Nauru", + "Nepal", + "Netherlands", + "New Zealand", + "Nicaragua", + "Niger", + "Nigeria", + "North Korea", + "North Macedonia", + "Norway", + "Oman", + "Pakistan", + "Palau", + "Palestine State", + "Panama", + "Papua New Guinea", + "Paraguay", + "Peru", + "Philippines", + "Poland", + "Portugal", + "Qatar", + "Romania", + "Russia", + "Rwanda", + "Saint Kitts and Nevis", + "Saint Lucia", + "Saint Vincent and the Grenadines", + "Samoa", + "San Marino", + "Sao Tome and Principe", + "Saudi Arabia", + "Senegal", + "Serbia", + "Seychelles", + "Sierra Leone", + "Singapore", + "Slovakia", + "Slovenia", + "Solomon Islands", + "Somalia", + "South Africa", + "South Korea", + "South Sudan", + "Spain", + "Sri Lanka", + "Sudan", + "Suriname", + "Sweden", + "Switzerland", + "Syria", + "Tajikistan", + "Tanzania", + "Thailand", + "Timor-Leste", + "Togo", + "Tonga", + "Trinidad and Tobago", + "Tunisia", + "Turkey", + "Turkmenistan", + "Tuvalu", + "Uganda", + "Ukraine", + "United Arab Emirates", + "United Kingdom", + "United States of America", + "Uruguay", + "Uzbekistan", + "Vanuatu", + "Venezuela", + "Vietnam", + "Yemen", + "Zambia", + "Zimbabwe"]; \ No newline at end of file diff --git a/star_in_me_app/lib/screens/thankyou_screen.dart b/star_in_me_app/lib/screens/thankyou_screen.dart index 9f7be08..27a2d9d 100644 --- a/star_in_me_app/lib/screens/thankyou_screen.dart +++ b/star_in_me_app/lib/screens/thankyou_screen.dart @@ -1,5 +1,8 @@ import 'package:flutter/material.dart'; +import 'package:star_in_me_app/authentication/signup.dart'; import 'package:star_in_me_app/onboarding/onbordingPage.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_auth/firebase_auth.dart'; class ThankYou extends StatefulWidget { static final String thankYouPage = '/login/thankyou'; @@ -13,9 +16,12 @@ class _ThankYouState extends State { @override Widget build(BuildContext context) { final Map arguments = ModalRoute.of(context).settings.arguments as Map; + name = FirebaseAuth.instance.currentUser.displayName; + print(name); - if (arguments != null) { - name=arguments['name']; + if (name == "" || arguments != null) { + name = arguments['name']; + print(name); } return SafeArea( child: Scaffold( @@ -29,19 +35,19 @@ class _ThankYouState extends State { Row(children: [ Text('Welcome to ', style: - TextStyle(color: Colors.purple[700], fontSize: 25.0)), + TextStyle(color: Colors.deepPurple[500], fontSize: 25.0, fontWeight: FontWeight.bold)), Text( 'The star in me,', - style: TextStyle(color: Colors.purple[300], fontSize: 25.0), + style: TextStyle(color: Colors.purple[300], fontSize: 25.0, fontWeight: FontWeight.bold), ) ]), Row( children: [ Padding( padding: const EdgeInsets.only(top: 10.0), - child: Text(name, + child: Text(name + "!", style: TextStyle( - color: Colors.purple[700], fontSize: 25.0)), + color: Colors.deepPurple[500], fontSize: 25.0, fontWeight: FontWeight.bold)), ), ], ), @@ -50,7 +56,7 @@ class _ThankYouState extends State { children: [ Text( "You're almost done", - style: TextStyle(color: Colors.grey), + style: TextStyle(color: Colors.black45, fontWeight: FontWeight.bold, fontSize: 17), ), ], ), @@ -59,15 +65,16 @@ class _ThankYouState extends State { children: [ Text( "Thank you for joining.We may reach out to you for", - style: TextStyle(color: Colors.grey), + style: TextStyle(fontSize: 15), ), ], ), + SizedBox(height: 3), Row( children: [ Text( "additional validation, if required .", - style: TextStyle(color: Colors.grey), + style: TextStyle(fontSize: 15), ), ], ), @@ -76,22 +83,29 @@ class _ThankYouState extends State { children: [ Text( "Let us help you create an outstanding profile", - style: TextStyle(color: Colors.grey), + style: TextStyle(fontSize: 15), ), ], ), SizedBox(height: 20.0), - RaisedButton( - onPressed: () { - Navigator.pushNamed(context, onboardingPage.onboarding); - }, - color: Colors.purple[700], - splashColor: Colors.blueAccent, - child: Text( - 'START BUILDING YOUR PROFILE', - style: TextStyle(color: Colors.white), + Container( + width: double.infinity, + height: 40, + child: RaisedButton( + onPressed: () { + Navigator.pushNamed(context, onboardingPage.onboarding); + }, + color: Colors.deepPurple[500], + splashColor: Colors.blueAccent, + child: Text( + 'START BUILDING YOUR PROFILE', + style: TextStyle(color: Colors.white), + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + ), ), - ) + ), ])), ), ), From 78196183c2a89e82f86c8e5cb9e5ac6dca5ecbb2 Mon Sep 17 00:00:00 2001 From: khyatisaini Date: Sun, 22 Nov 2020 23:17:58 +0530 Subject: [PATCH 3/3] user profile details --- star_in_me_app/lib/onboarding/UI4.dart | 588 +++++++++++------- star_in_me_app/lib/onboarding/UI5.dart | 74 ++- .../lib/onboarding/onbordingPage.dart | 68 +- 3 files changed, 423 insertions(+), 307 deletions(-) diff --git a/star_in_me_app/lib/onboarding/UI4.dart b/star_in_me_app/lib/onboarding/UI4.dart index ba65469..3f52b12 100644 --- a/star_in_me_app/lib/onboarding/UI4.dart +++ b/star_in_me_app/lib/onboarding/UI4.dart @@ -1,280 +1,346 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - -final TextEditingController clg = TextEditingController(); -final TextEditingController mail = TextEditingController(); -final TextEditingController designation = TextEditingController(); -final TextEditingController linkedin = TextEditingController(); +import 'dart:async'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:star_in_me_app/onboarding/UI5.dart'; +import 'package:star_in_me_app/onboarding/imageupload.dart'; class UI4 extends StatelessWidget { static final onboardingUi4 = '/onboardingUI4'; + + final TextEditingController collegeController = TextEditingController(); + final TextEditingController mailController = TextEditingController(); + final TextEditingController designationController = TextEditingController(); + final TextEditingController linkedInController = TextEditingController(); + + String organizationName, mailId, designation, linkedInProfile; + final _formKey = GlobalKey(); + bool showSpinner = false; + @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - backgroundColor: Colors.white, - leading: Padding( - padding: const EdgeInsets.all(10.0), + backgroundColor: Colors.deepPurple[500], + leading: Container( + margin: EdgeInsets.all(10.0), + // padding: const EdgeInsets.all(10.0), child: Image( image: AssetImage("images/logo.png"), ), ), elevation: 15, actions: [ - Center( + Container( + margin: EdgeInsets.all(10), + padding: EdgeInsets.all(10), child: Text( "STEP 1", style: TextStyle( - color: Colors.black, - fontSize: 20.0, + color: Colors.deepPurple[500], + fontSize: 17.0, fontWeight: FontWeight.w500), ), + decoration: BoxDecoration( + color: Colors.white, + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(20), + ), ) ], ), body: SingleChildScrollView( child: Container( - padding: EdgeInsets.symmetric(horizontal: 25.0, vertical: 8.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - SizedBox( - height: 30.0, - ), - - Text( - "Let's Complete your profile ", - style: TextStyle( - color: Color(0xff4f439a), - fontSize: 30.0, - fontWeight: FontWeight.bold, - ), - textAlign: TextAlign.start, - ), - //), - // ), - // Padding( - // padding: const EdgeInsets.only(top: 10.0, left: 22.0), - // child: - //Expanded( - //flex: 1, - //child: - Padding( - padding: const EdgeInsets.symmetric(vertical: 15.0), - child: Text( - "This will help us know your professional experience for connections.", - style: TextStyle( - color: Colors.grey.shade600, - fontSize: 20.0, - fontWeight: FontWeight.bold), - ), - ), - SizedBox( - height: 20.0, - ), - Padding( - padding: const EdgeInsets.only(top: 10.0, bottom: 5.0), - child: TextFormField( - controller: clg, - maxLines: 1, - cursorColor: Color(0xff4f439a), - keyboardType: TextInputType.text, - autofocus: false, - decoration: InputDecoration( - - labelText: 'College/Company/Organization', - labelStyle: TextStyle( - color: Color(0xff4f439a), - fontSize: 16.0 - ), - focusedBorder: OutlineInputBorder( - - borderRadius: BorderRadius.circular(15.0), - borderSide: BorderSide( - color: Color(0xff4f439a) - ) - ), - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(15.0), - borderSide: BorderSide( - // color: Colors.deepPurple, - //width: 2.0 - ) - ) + padding: EdgeInsets.all(10.0), + margin: EdgeInsets.all(10.0), + child: Form( + key: _formKey, + // color: Colors.white, + // padding: EdgeInsets.symmetric(horizontal: 25.0, vertical: 8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox( + height: 30.0, ), - ), - ), - Padding( - padding: const EdgeInsets.only(top: 10.0, bottom: 5.0), - child: TextFormField( - controller: mail, - maxLines: 1, - cursorColor: Color(0xff4f439a), - keyboardType: TextInputType.text, - autofocus: false, - decoration: InputDecoration( - labelText: 'pratiksha.g@xelp.com', - labelStyle: TextStyle( - color: Color(0xff4f439a), - fontSize: 16.0 - ), - - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(15.0), - borderSide: BorderSide( - color: Color(0xff4f439a) - ) - ), - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(15.0), - borderSide: BorderSide())), - ), - ), - Padding( - padding: const EdgeInsets.only(top: 10.0, bottom: 5.0), - child: TextFormField( - controller: designation, - cursorColor: Color(0xff4f439a), - maxLines: 1, - keyboardType: TextInputType.text, - autofocus: false, - decoration: InputDecoration( - labelText: 'Designation', - labelStyle: TextStyle( - color: Color(0xff4f439a), - fontSize: 16.0 - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(15.0), - borderSide: BorderSide( - color: Color(0xff4f439a) + Text( + "Let's Complete your profile ", + style: TextStyle( + color: Colors.deepPurple[500], + fontSize: 28.0, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.start, + ), + //), + // ), + // Padding( + // padding: const EdgeInsets.only(top: 10.0, left: 22.0), + // child: + //Expanded( + //flex: 1, + //child: + Padding( + padding: const EdgeInsets.symmetric(vertical: 15.0), + child: Text( + "This will help us know your professional experience for connections.", + style: TextStyle( + color: Colors.grey.shade600, + fontSize: 18.0, + fontWeight: FontWeight.bold), + ), + ), + SizedBox( + height: 15.0, + ), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 5.0), + child: TextFormField( + controller: collegeController, + maxLines: 1, + cursorColor: Colors.deepPurple[500], + keyboardType: TextInputType.text, + autofocus: false, + decoration: InputDecoration( + labelText: 'College/Company/Organization', + labelStyle: TextStyle( + color: Colors.deepPurple[500], + fontSize: 16.0 + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(15.0), + borderSide: BorderSide( + color: Colors.deepPurple[500] + ) + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(15.0), + borderSide: BorderSide( + color: Colors.deepPurple[500], + //width: 2.0 + ) ) ), - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(15.0), - borderSide: BorderSide())), - ), - ), - Padding( - padding: const EdgeInsets.only(top: 10.0, bottom: 5.0), - child: TextFormField( - controller: linkedin, - maxLines: 1, - cursorColor: Color(0xff4f439a), - keyboardType: TextInputType.text, - autofocus: false, - decoration: InputDecoration( - labelText: 'Linkedin Profile', - labelStyle: TextStyle( - color: Color(0xff4f439a), - fontSize: 16.0 + onChanged: (value) { + organizationName = value; + }, + validator: (value) { + if (value.isEmpty) { + return "Enter Your Organization Name"; + } + return null; + }, + ), + ), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 5.0), + child: TextFormField( + controller: mailController, + maxLines: 1, + cursorColor: Colors.deepPurple[500], + keyboardType: TextInputType.text, + autofocus: false, + decoration: InputDecoration( + labelText: 'pratiksha.g@xelp.com', + labelStyle: TextStyle( + color: Colors.deepPurple[500], + fontSize: 16.0 + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(15.0), + borderSide: BorderSide( + color: Colors.deepPurple[500] + ) + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(15.0), + borderSide: BorderSide())), + onChanged: (value) { + mailId = value; + }, + validator: (value) { + if (value.isEmpty) { + return "Enter Your Email ID"; + } + return null; + }, + ), + ), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 5.0), + child: TextFormField( + controller: designationController, + cursorColor: Colors.deepPurple[500], + maxLines: 1, + keyboardType: TextInputType.text, + autofocus: false, + decoration: InputDecoration( + labelText: 'Designation', + labelStyle: TextStyle( + color: Colors.deepPurple[500], + fontSize: 16.0 + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(15.0), + borderSide: BorderSide( + color: Colors.deepPurple[500], + ) + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(15.0), + borderSide: BorderSide())), + onChanged: (value) { + designation = value; + }, + validator: (value) { + if (value.isEmpty) { + return "Enter Your Designation"; + } + return null; + }, + ), + ), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 5.0), + child: TextFormField( + controller: linkedInController, + maxLines: 1, + cursorColor: Colors.deepPurple[500], + keyboardType: TextInputType.text, + autofocus: false, + decoration: InputDecoration( + labelText: 'Linkedin Profile', + labelStyle: TextStyle( + color: Colors.deepPurple[500], + fontSize: 16.0 + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(15.0), + borderSide: BorderSide( + color: Colors.deepPurple[500] + ) + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(15.0), + borderSide: BorderSide())), + onChanged: (value) { + linkedInProfile = value; + }, + validator: (value) { + if (value.isEmpty) { + return "Enter Your LinkedIn Profile URL"; + } + return null; + }, + ), + ), + SizedBox( + height: 50.0, + ), + Padding( + padding: const EdgeInsets.only(top: 8.0, bottom: 10.0), + child: Text( + "Upload a professional headshot", + style: TextStyle( + color: Colors.purple[300], + fontSize: 25.0, + fontWeight: FontWeight.bold, ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(15.0), - borderSide: BorderSide( - color: Color(0xff4f439a) - ) + ), + ), + Padding( + padding: const EdgeInsets.only(top: 8.0, bottom: 10.0), + child: Text( + "Your picture is logo of your personal brand!", + style: TextStyle( + color: Colors.grey, + fontSize: 18.0, + fontWeight: FontWeight.w700, ), - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(15.0), - borderSide: BorderSide())), - ), - ), - SizedBox( - height: 50.0, - ), - Padding( - padding: const EdgeInsets.only(top: 8.0, bottom: 10.0), - child: Text( - "Upload a professional headshot ", - style: TextStyle( - color: Colors.black, - fontSize: 25.0, - fontWeight: FontWeight.bold, + ), ), - ), - ), - Padding( - padding: const EdgeInsets.only(top: 8.0, bottom: 10.0), - child: Text( - "Your picture is logo of your personal brand! ", - style: TextStyle( - color: Colors.grey, - fontSize: 19.0, - fontWeight: FontWeight.w700, + SizedBox( + height: 20.0, ), - ), - ), - SizedBox( - height: 20.0, - ), - Row( - textBaseline: TextBaseline.alphabetic, - mainAxisAlignment: MainAxisAlignment.start, - //scrossAxisAlignment: CrossAxisAlignment.center, - children: [ - Icon( - Icons.play_arrow, - size: 35.0, - color: Color(0xff4f439a), + Center( + child: Row( + textBaseline: TextBaseline.alphabetic, + mainAxisAlignment: MainAxisAlignment.start, + //crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox(width: 5), + Icon( + Icons.play_arrow, + size: 35.0, + color: Colors.deepPurple[500], + ), + SizedBox(width: 10), + Text( + 'WATCH DEMO VIDEO', + style: TextStyle( + color: Colors.deepPurple[500], + fontSize: 23.0, + fontWeight: FontWeight.bold), + ) + ], + ), ), - Text( - 'WATCH DEMO VIDEO', - style: TextStyle( - color: Color(0xff4f439a), - fontSize: 23.0, - fontWeight: FontWeight.bold), - ) - ], - ), - SizedBox( - height: 15.0, - ), - ButtonTheme( - minWidth: double.infinity, - height: 50.0, - child: OutlineButton( - onPressed: () => print("BUTTON PRESSED"), - child: Text( - "ADD PHOTO OR VIDEO", - style: TextStyle(color:Color(0xff4f439a), fontSize: 17.0), + SizedBox( + height: 15.0, ), - borderSide: BorderSide( - color: Color(0xff4f439a), - width: 1, + ButtonTheme( + minWidth: double.infinity, + height: 50.0, + child: OutlineButton( + onPressed: () { + Navigator.pushNamed(context, Image_Upload.imageupload); + }, + child: Text( + "ADD PHOTO OR VIDEO", + style: TextStyle( + color: Colors.deepPurple[500], fontSize: 17.0), + ), + borderSide: BorderSide( + color: Colors.deepPurple[500], + width: 1, + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5.0), + ), + ), ), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5.0), + Padding( + padding: const EdgeInsets.only(top: 8.0, bottom: 10.0), + child: Text( + "You can upload upto 5 photos or videos", + style: TextStyle( + color: Colors.grey, + fontSize: 19.0, + fontWeight: FontWeight.w400, + ), + ), ), - ), - ), - Padding( - padding: const EdgeInsets.only(top: 8.0, bottom: 10.0), - child: Text( - "You can uplaod upto 5 photos or videos", - style: TextStyle( - color: Colors.grey, - fontSize: 19.0, - fontWeight: FontWeight.w400, + Divider(thickness: 1), + ButtonTheme( + height: 50, + minWidth: 150, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5.0)), + child: RaisedButton( + onPressed: () => uploadDetails(context), + child: Text("NEXT", style: TextStyle( + color: Colors.white, + fontSize: 20.0 + ),), + color: Colors.deepPurple[500], + ), ), - ), + SizedBox(height: 30), + ], ), - Divider(thickness: 1), - ButtonTheme( - height: 50, - minWidth: 150, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0) ), - child: RaisedButton( - onPressed:()=> print("NEXT button pressed"), - child: Text("NEXT", style: TextStyle( - color: Colors.white, - fontSize: 20.0 - ),), - color: Color(0xff4f439a), - ), - ) - ], - ), - ), + )), ), // bottomNavigationBar: BottomAppBar( // color: Colors.grey, @@ -295,4 +361,46 @@ class UI4 extends StatelessWidget { // ), ); } + + void uploadDetails(BuildContext context) async { + if (_formKey.currentState.validate()) { + showSpinner = true; + final snapshot = await FirebaseFirestore.instance.collection( + "user_profile").doc(mailId).get(); + if (snapshot == null || snapshot.exists) { + Navigator.pushNamed(context, UI5.onboardingUi5); + } + else { + try { + FirebaseFirestore.instance.collection("user_profile").add({ + "mail_id": mailId, + "designation": designation, + "organization": organizationName, + "linked_in_profile": linkedInProfile + }); + Fluttertoast.showToast( + msg: "Data added successfully", + gravity: ToastGravity.BOTTOM, + toastLength: Toast.LENGTH_SHORT, + timeInSecForIosWeb: 1, + backgroundColor: Colors.deepPurple[500], + fontSize: 16, + textColor: Colors.white + ); + Navigator.pushNamed(context, UI5.onboardingUi5); + } catch (e) { + print(e); + Fluttertoast.showToast( + msg: e.message, + gravity: ToastGravity.BOTTOM, + toastLength: Toast.LENGTH_SHORT, + timeInSecForIosWeb: 1, + backgroundColor: Colors.deepPurple[500], + fontSize: 16, + textColor: Colors.white + ); + } + } + } + } } diff --git a/star_in_me_app/lib/onboarding/UI5.dart b/star_in_me_app/lib/onboarding/UI5.dart index 2cdf90e..49bd99c 100644 --- a/star_in_me_app/lib/onboarding/UI5.dart +++ b/star_in_me_app/lib/onboarding/UI5.dart @@ -1,7 +1,10 @@ import 'package:flutter/material.dart'; +import 'package:star_in_me_app/onboarding/UI6.dart'; +import 'package:star_in_me_app/onboarding/UI7.dart'; class UI5 extends StatelessWidget { static final onboardingUi5 = '/onboardingUI5'; + @override Widget build(BuildContext context) { return new MaterialApp( @@ -19,7 +22,7 @@ class UI5 extends StatelessWidget { title: Text( 'I am a', style: TextStyle( - color: Color(0xFF4F439A), + color: Colors.deepPurple[500], fontSize: 30.0, fontWeight: FontWeight.bold, ), @@ -29,42 +32,47 @@ class UI5 extends StatelessWidget { ), SliverFillRemaining( hasScrollBody: false, - child: Column( - children: [ - SizedBox( - height: 60.0, - ), - FlatButton( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 70.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Icon(Icons.account_circle_outlined, size: 40,), - Text(' Student', style: TextStyle(fontSize: 16),), - ], + child: Center( + child: Column( + children: [ + SizedBox( + height: 60.0, + ), + FlatButton( + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 50.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Icon(Icons.account_circle_outlined, size: 40,), + Text(' Student', style: TextStyle(fontSize: 16),), + ], + ), ), + onPressed: () { + Navigator.pushNamed(context, UI6.onboardingUi6); + }, ), - onPressed: () {}, - ), - SizedBox( - height: 50.0, - ), - FlatButton( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 70.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - - Icon(Icons.account_circle_sharp, size: 40,), - Text(' Working Professional', style: TextStyle(fontSize: 16),), - ], + SizedBox( + height: 30.0, + ), + FlatButton( + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 50.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Icon(Icons.account_circle_sharp, size: 40,), + Text(' Working Professional', style: TextStyle(fontSize: 16),), + ], + ), ), + onPressed: () { + Navigator.pushNamed(context, UI7.onboardingUi7); + }, ), - onPressed: () {}, - ), - ], + ], + ), ), ), ], diff --git a/star_in_me_app/lib/onboarding/onbordingPage.dart b/star_in_me_app/lib/onboarding/onbordingPage.dart index 0c2d538..457513b 100644 --- a/star_in_me_app/lib/onboarding/onbordingPage.dart +++ b/star_in_me_app/lib/onboarding/onbordingPage.dart @@ -26,30 +26,29 @@ class _onboardingPageState extends State { UI3(), ]; - @override Widget build(BuildContext context) { final height = MediaQuery.of(context).size.height; return SafeArea( child: Scaffold( - backgroundColor: Colors.white, - body: SafeArea( - child: ListView( - children: [ - Container( - color: Color(0xff4f439a), - child: Row( - children: [ - Padding( - padding: const EdgeInsets.fromLTRB(10.0, 5.0, 0.0, 0.0), - child: Image.asset('images/logo.png', + backgroundColor: Colors.white, + body: SafeArea( + child: ListView( + children: [ + Container( + color: Color(0xff4f439a), + child: Row( + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(10.0, 5.0, 0.0, 0.0), + child: Image.asset('images/logo.png', height: 50.0, width: 50.0), ), ], ), ), - Container( - child: CarouselSlider( - options: CarouselOptions( + Container( + child: CarouselSlider( + options: CarouselOptions( height: 0.70 * height, viewportFraction: 1.0, enlargeCenterPage: false, @@ -72,29 +71,30 @@ class _onboardingPageState extends State { } }); }), - items: pageList.map((item) { - return Builder(builder: (BuildContext context) { - return item; - }); - }).toList(), + items: pageList.map((item) { + return Builder(builder: (BuildContext context) { + return item; + }); + }).toList(), + ), ), - ), - Padding( - padding: const EdgeInsets.only(top: 30), - child: Center( - child: DotsIndicator( - dotsCount: 3, - position: _currentPage.toDouble(), - decorator: DotsDecorator( - color: Color(0xff999999), // Inactive color - activeColor: Color(0xff4f439a), + Padding( + padding: const EdgeInsets.only(top: 30), + child: Center( + child: DotsIndicator( + dotsCount: 3, + position: _currentPage.toDouble(), + decorator: DotsDecorator( + color: Color(0xff999999), // Inactive color + activeColor: Color(0xff4f439a), + ), ), ), ), - ), - ], + ], + ), ), - ), - )); + ) + ); } }