diff --git a/Sources/justMUSIC/lib/screens/login_screen.dart b/Sources/justMUSIC/lib/screens/login_screen.dart index 0cbddf1..10d3be2 100644 --- a/Sources/justMUSIC/lib/screens/login_screen.dart +++ b/Sources/justMUSIC/lib/screens/login_screen.dart @@ -1,4 +1,3 @@ -import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -27,14 +26,18 @@ class _LoginScreenState extends State { handleLogin() async { if (_formKey.currentState!.validate()) { try { - await MyApp.userViewModel.login(_userMailTextField.text, _passwordTextField.text); + await MyApp.userViewModel + .login(_userMailTextField.text, _passwordTextField.text); Navigator.pushNamed(context, '/feed'); } catch (e) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - e.toString() ?? "", - style: GoogleFonts.plusJakartaSans(color: Colors.white, fontWeight: FontWeight.w400, fontSize: 20.h), + e.toString(), + style: GoogleFonts.plusJakartaSans( + color: Colors.white, + fontWeight: FontWeight.w400, + fontSize: 20.h), ), backgroundColor: Colors.red, ), @@ -63,19 +66,25 @@ class _LoginScreenState extends State { child: Form( key: _formKey, child: Column( - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ Flexible( flex: 4, child: Padding( padding: EdgeInsets.only(bottom: 60), child: Column( - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: + MainAxisAlignment.end, children: [ Text( "Te revoilà!", - style: GoogleFonts.plusJakartaSans( - color: Colors.white, fontWeight: FontWeight.w600, fontSize: 38.h), + style: + GoogleFonts.plusJakartaSans( + color: Colors.white, + fontWeight: + FontWeight.w600, + fontSize: 38.h), ), SizedBox( height: 10, @@ -84,8 +93,12 @@ class _LoginScreenState extends State { width: 230.w, child: Text( "Bon retour parmis nous tu nous as manqué!", - style: GoogleFonts.plusJakartaSans( - color: Colors.white, fontWeight: FontWeight.w400, fontSize: 20.h), + style: GoogleFonts + .plusJakartaSans( + color: Colors.white, + fontWeight: + FontWeight.w400, + fontSize: 20.h), textAlign: TextAlign.center, ), ), @@ -96,33 +109,51 @@ class _LoginScreenState extends State { Expanded( flex: 5, child: Column( - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.end, + mainAxisAlignment: + MainAxisAlignment.center, children: [ TextFormField( controller: _userMailTextField, - keyboardAppearance: Brightness.dark, + keyboardAppearance: + Brightness.dark, validator: (value) { - if (value == null || value.isEmpty) { + if (value == null || + value.isEmpty) { return 'entrez un email valide'; } return null; }, cursorColor: primaryColor, - keyboardType: TextInputType.emailAddress, - style: GoogleFonts.plusJakartaSans(color: primaryColor), + keyboardType: + TextInputType.emailAddress, + style: + GoogleFonts.plusJakartaSans( + color: primaryColor), decoration: InputDecoration( focusedBorder: OutlineInputBorder( - borderSide: BorderSide(width: 1, color: strokeTextField), - borderRadius: BorderRadius.all(Radius.circular(10))), - prefix: const Padding(padding: EdgeInsets.only(left: 20.0)), - suffix: const Padding(padding: EdgeInsets.only(left: 20.0)), + borderSide: BorderSide( + width: 1, + color: + strokeTextField), + borderRadius: BorderRadius.all( + Radius.circular(10))), + prefix: const Padding( + padding: EdgeInsets.only( + left: 20.0)), + suffix: const Padding( + padding: EdgeInsets.only( + left: 20.0)), fillColor: bgTextField, filled: true, - errorStyle: TextStyle(fontSize: 9, height: 0.3), - focusColor: Color.fromRGBO(255, 255, 255, 0.30), + errorStyle: TextStyle( + fontSize: 9, height: 0.3), + focusColor: Color.fromRGBO( + 255, 255, 255, 0.30), enabledBorder: OutlineInputBorder( - borderSide: BorderSide(width: 1, color: strokeTextField), + borderSide: + BorderSide(width: 1, color: strokeTextField), borderRadius: BorderRadius.all(Radius.circular(10))), hintText: 'Email', hintStyle: GoogleFonts.plusJakartaSans(color: strokeTextField)), @@ -132,31 +163,55 @@ class _LoginScreenState extends State { ), TextFormField( controller: _passwordTextField, - keyboardAppearance: Brightness.dark, + keyboardAppearance: + Brightness.dark, obscureText: passenable, validator: (value) { - if (value == null || value.isEmpty) { + if (value == null || + value.isEmpty) { return 'entrez un mot de passe valide'; } return null; }, cursorColor: primaryColor, - style: GoogleFonts.plusJakartaSans(color: primaryColor), + style: + GoogleFonts.plusJakartaSans( + color: primaryColor), decoration: InputDecoration( - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(width: 1, color: strokeTextField), - borderRadius: BorderRadius.all(Radius.circular(10))), + focusedBorder: + OutlineInputBorder( + borderSide: BorderSide( + width: 1, + color: + strokeTextField), + borderRadius: + BorderRadius.all( + Radius.circular( + 10))), fillColor: bgTextField, filled: true, - focusColor: Color.fromRGBO(255, 255, 255, 0.30), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(width: 1, color: strokeTextField), - borderRadius: BorderRadius.all(Radius.circular(10))), + focusColor: Color.fromRGBO( + 255, 255, 255, 0.30), + enabledBorder: + OutlineInputBorder( + borderSide: BorderSide( + width: 1, + color: + strokeTextField), + borderRadius: + BorderRadius.all( + Radius.circular( + 10))), hintText: 'Mot de passe', - hintStyle: GoogleFonts.plusJakartaSans(color: strokeTextField), - prefix: const Padding(padding: EdgeInsets.only(left: 20.0)), + hintStyle: + GoogleFonts.plusJakartaSans( + color: strokeTextField), + prefix: const Padding( + padding: EdgeInsets.only( + left: 20.0)), suffixIcon: Container( - padding: EdgeInsets.only(right: 10), + padding: EdgeInsets.only( + right: 10), margin: EdgeInsets.all(5), height: 3, child: InkWell( @@ -170,25 +225,40 @@ class _LoginScreenState extends State { }); }, // Image tapped - splashColor: Colors.white10, + splashColor: + Colors.white10, // Splash color over image child: Image( image: passenable - ? AssetImage("assets/images/show_icon.png") - : AssetImage("assets/images/hide_icon.png"), + ? AssetImage( + "assets/images/show_icon.png") + : AssetImage( + "assets/images/hide_icon.png"), height: 2, ), )), - errorStyle: TextStyle(fontSize: 9, height: 0.3), - ), - ), - Padding( - padding: EdgeInsets.only(top: 10), - child: Text( - "Mot de passe oublié?", - style: GoogleFonts.plusJakartaSans(color: Colors.white), + errorStyle: TextStyle( + fontSize: 9, height: 0.3), ), ), + GestureDetector( + behavior: + HitTestBehavior.translucent, + onTap: () { + Navigator.pushNamed( + context, '/forgetPassword'); + }, + child: Padding( + padding: + EdgeInsets.only(top: 10), + child: Text( + "Mot de passe oublié?", + style: GoogleFonts + .plusJakartaSans( + color: + Colors.white), + ), + )), SizedBox( height: defaultPadding, ), @@ -196,30 +266,44 @@ class _LoginScreenState extends State { width: 600, child: LoginButton( callback: handleLogin, + text: "Se connecter", )), Align( child: GestureDetector( - behavior: HitTestBehavior.translucent, + behavior: + HitTestBehavior.translucent, onTap: () { - Navigator.pushNamed(context, '/register'); + Navigator.pushNamed( + context, '/register'); }, child: Padding( - padding: EdgeInsets.only(top: 20), + padding: + EdgeInsets.only(top: 20), child: RichText( textAlign: TextAlign.center, text: TextSpan( - text: 'Pas encore inscrit?', - style: GoogleFonts.plusJakartaSans( - color: Colors.white, - fontWeight: FontWeight.w400, - fontSize: 15), + text: + 'Pas encore inscrit?', + style: GoogleFonts + .plusJakartaSans( + color: + Colors.white, + fontWeight: + FontWeight + .w400, + fontSize: 15), children: [ TextSpan( text: " S’inscire", - style: GoogleFonts.plusJakartaSans( - fontSize: 15, - fontWeight: FontWeight.w400, - color: primaryColor)), + style: GoogleFonts + .plusJakartaSans( + fontSize: + 15, + fontWeight: + FontWeight + .w400, + color: + primaryColor)), ], ), ), @@ -234,38 +318,55 @@ class _LoginScreenState extends State { child: Padding( padding: EdgeInsets.only(top: 20), child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ ConstrainedBox( - constraints: BoxConstraints(maxWidth: 600), + constraints: BoxConstraints( + maxWidth: 600), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisAlignment: + MainAxisAlignment + .spaceEvenly, children: [ Expanded( child: Container( - color: Color(0xFF3D3D3D), + color: + Color(0xFF3D3D3D), height: 1, ), ), Padding( - padding: const EdgeInsets.only( - left: defaultPadding, right: defaultPadding), + padding: const EdgeInsets + .only( + left: + defaultPadding, + right: + defaultPadding), child: Text( 'Ou', - style: GoogleFonts.plusJakartaSans( - color: Colors.white, fontWeight: FontWeight.bold), + style: GoogleFonts + .plusJakartaSans( + color: Colors + .white, + fontWeight: + FontWeight + .bold), ), ), Expanded( child: Container( height: 1, - color: Color(0xFF3D3D3D), + color: + Color(0xFF3D3D3D), )), ], ), ), - SizedBox(height: defaultPadding), + SizedBox( + height: defaultPadding), SignInButton( Buttons.Google, text: "Login with Google",