Merge pull request 'CORRECT_GRAMMARY' (#73) from CORRECT_GRAMMARY into master
continuous-integration/drone/push Build is passing Details

Reviewed-on: #73
master
Rayhân HASSOU 1 year ago
commit a2eb549ba2

@ -1,310 +1,310 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_signin_button/button_list.dart'; import 'package:flutter_signin_button/button_list.dart';
import 'package:flutter_signin_button/button_view.dart'; import 'package:flutter_signin_button/button_view.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:justmusic/main.dart'; import 'package:justmusic/main.dart';
import 'package:justmusic/values/constants.dart'; import 'package:justmusic/values/constants.dart';
import '../components/login_button.dart'; import '../components/login_button.dart';
import '../exceptions/user_exception.dart'; import '../exceptions/user_exception.dart';
class LoginScreen extends StatefulWidget { class LoginScreen extends StatefulWidget {
const LoginScreen({Key? key}) : super(key: key); const LoginScreen({Key? key}) : super(key: key);
@override @override
State<LoginScreen> createState() => _LoginScreenState(); State<LoginScreen> createState() => _LoginScreenState();
} }
class _LoginScreenState extends State<LoginScreen> { class _LoginScreenState extends State<LoginScreen> {
bool passenable = true; bool passenable = true;
final _formKey = GlobalKey<FormState>(); final _formKey = GlobalKey<FormState>();
final _userMailTextField = TextEditingController(); final _userMailTextField = TextEditingController();
final _passwordTextField = TextEditingController(); final _passwordTextField = TextEditingController();
handleLogin() async { handleLogin() async {
if (_formKey.currentState!.validate()) { if (_formKey.currentState!.validate()) {
try { try {
await MyApp.userViewModel.login(_userMailTextField.text, _passwordTextField.text); await MyApp.userViewModel.login(_userMailTextField.text, _passwordTextField.text);
Navigator.pushNamed(context, '/feed'); Navigator.pushNamed(context, '/feed');
} catch (e) { } catch (e) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: Text( content: Text(
e.toString(), e.toString(),
style: GoogleFonts.plusJakartaSans(color: Colors.white, fontWeight: FontWeight.w400, fontSize: 20.h), style: GoogleFonts.plusJakartaSans(color: Colors.white, fontWeight: FontWeight.w400, fontSize: 20.h),
), ),
backgroundColor: Colors.red, backgroundColor: Colors.red,
), ),
); );
} }
} }
} }
signInWithGoogle() async { signInWithGoogle() async {
try { try {
await MyApp.userViewModel.signInWithGoogle(); await MyApp.userViewModel.signInWithGoogle();
} on UserException catch (e) { } on UserException catch (e) {
if (e.code == 'user-created') { if (e.code == 'user-created') {
Navigator.pushNamed(context, '/explanation'); Navigator.pushNamed(context, '/explanation');
} else if (e.code == 'user-already-exist') { } else if (e.code == 'user-already-exist') {
Navigator.pushNamed(context, '/feed'); Navigator.pushNamed(context, '/feed');
} }
} }
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return GestureDetector(
onTap: () => FocusManager.instance.primaryFocus?.unfocus(), onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
child: Scaffold( child: Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
backgroundColor: bgColor, backgroundColor: bgColor,
body: Align( body: Align(
child: SizedBox( child: SizedBox(
height: double.infinity, height: double.infinity,
width: 600, width: 600,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Expanded( Expanded(
child: Padding( child: Padding(
padding: EdgeInsets.only(left: 40, right: 40), padding: EdgeInsets.only(left: 40, right: 40),
child: Form( child: Form(
key: _formKey, key: _formKey,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Flexible( Flexible(
flex: 4, flex: 4,
child: Padding( child: Padding(
padding: EdgeInsets.only(bottom: 60), padding: EdgeInsets.only(bottom: 60),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
Text( Text(
"Te revoilà!", "Te revoilà !",
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
color: Colors.white, fontWeight: FontWeight.w600, fontSize: 38.h), color: Colors.white, fontWeight: FontWeight.w600, fontSize: 38.h),
), ),
SizedBox( SizedBox(
height: 10, height: 10,
), ),
SizedBox( SizedBox(
width: 230.w, width: 230.w,
child: Text( child: Text(
"Bon retour parmis nous tu nous as manqué!", "Bon retour parmis nous. Tu nous as manqué !",
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
color: Colors.white, fontWeight: FontWeight.w400, fontSize: 20.h), color: Colors.white, fontWeight: FontWeight.w400, fontSize: 20.h),
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
), ),
], ],
), ),
), ),
), ),
Expanded( Expanded(
flex: 5, flex: 5,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
TextFormField( TextFormField(
controller: _userMailTextField, controller: _userMailTextField,
keyboardAppearance: Brightness.dark, keyboardAppearance: Brightness.dark,
validator: (value) { validator: (value) {
if (value == null || value.isEmpty) { if (value == null || value.isEmpty) {
return 'entrez un email valide'; return 'Entrez un email valide';
} }
return null; return null;
}, },
cursorColor: primaryColor, cursorColor: primaryColor,
keyboardType: TextInputType.emailAddress, keyboardType: TextInputType.emailAddress,
style: GoogleFonts.plusJakartaSans(color: primaryColor), style: GoogleFonts.plusJakartaSans(color: primaryColor),
decoration: InputDecoration( decoration: InputDecoration(
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: strokeTextField), borderSide: BorderSide(width: 1, color: strokeTextField),
borderRadius: BorderRadius.all(Radius.circular(10))), borderRadius: BorderRadius.all(Radius.circular(10))),
prefix: const Padding(padding: EdgeInsets.only(left: 20.0)), prefix: const Padding(padding: EdgeInsets.only(left: 20.0)),
suffix: const Padding(padding: EdgeInsets.only(left: 20.0)), suffix: const Padding(padding: EdgeInsets.only(left: 20.0)),
fillColor: bgTextField, fillColor: bgTextField,
filled: true, filled: true,
errorStyle: TextStyle(fontSize: 9, height: 0.3), errorStyle: TextStyle(fontSize: 9, height: 0.3),
focusColor: Color.fromRGBO(255, 255, 255, 0.30), focusColor: Color.fromRGBO(255, 255, 255, 0.30),
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: strokeTextField), borderSide: BorderSide(width: 1, color: strokeTextField),
borderRadius: BorderRadius.all(Radius.circular(10))), borderRadius: BorderRadius.all(Radius.circular(10))),
hintText: 'Email', hintText: 'Email',
hintStyle: GoogleFonts.plusJakartaSans(color: strokeTextField)), hintStyle: GoogleFonts.plusJakartaSans(color: strokeTextField)),
), ),
SizedBox( SizedBox(
height: 18, height: 18,
), ),
TextFormField( TextFormField(
controller: _passwordTextField, controller: _passwordTextField,
keyboardAppearance: Brightness.dark, keyboardAppearance: Brightness.dark,
obscureText: passenable, obscureText: passenable,
validator: (value) { validator: (value) {
if (value == null || value.isEmpty) { if (value == null || value.isEmpty) {
return 'entrez un mot de passe valide'; return 'Entrez un mot de passe valide';
} }
return null; return null;
}, },
cursorColor: primaryColor, cursorColor: primaryColor,
style: GoogleFonts.plusJakartaSans(color: primaryColor), style: GoogleFonts.plusJakartaSans(color: primaryColor),
decoration: InputDecoration( decoration: InputDecoration(
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: strokeTextField), borderSide: BorderSide(width: 1, color: strokeTextField),
borderRadius: BorderRadius.all(Radius.circular(10))), borderRadius: BorderRadius.all(Radius.circular(10))),
fillColor: bgTextField, fillColor: bgTextField,
filled: true, filled: true,
focusColor: Color.fromRGBO(255, 255, 255, 0.30), focusColor: Color.fromRGBO(255, 255, 255, 0.30),
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: strokeTextField), borderSide: BorderSide(width: 1, color: strokeTextField),
borderRadius: BorderRadius.all(Radius.circular(10))), borderRadius: BorderRadius.all(Radius.circular(10))),
hintText: 'Mot de passe', hintText: 'Mot de passe',
hintStyle: GoogleFonts.plusJakartaSans(color: strokeTextField), hintStyle: GoogleFonts.plusJakartaSans(color: strokeTextField),
prefix: const Padding(padding: EdgeInsets.only(left: 20.0)), prefix: const Padding(padding: EdgeInsets.only(left: 20.0)),
suffixIcon: Container( suffixIcon: Container(
padding: EdgeInsets.only(right: 10), padding: EdgeInsets.only(right: 10),
margin: EdgeInsets.all(5), margin: EdgeInsets.all(5),
height: 3, height: 3,
child: InkWell( child: InkWell(
onTap: () { onTap: () {
setState(() { setState(() {
if (passenable) { if (passenable) {
passenable = false; passenable = false;
} else { } else {
passenable = true; passenable = true;
} }
}); });
}, },
// Image tapped // Image tapped
splashColor: Colors.white10, splashColor: Colors.white10,
// Splash color over image // Splash color over image
child: Image( child: Image(
image: passenable image: passenable
? AssetImage("assets/images/show_icon.png") ? AssetImage("assets/images/show_icon.png")
: AssetImage("assets/images/hide_icon.png"), : AssetImage("assets/images/hide_icon.png"),
height: 2, height: 2,
), ),
)), )),
errorStyle: TextStyle(fontSize: 9, height: 0.3), errorStyle: TextStyle(fontSize: 9, height: 0.3),
), ),
), ),
GestureDetector( GestureDetector(
behavior: HitTestBehavior.translucent, behavior: HitTestBehavior.translucent,
onTap: () { onTap: () {
Navigator.pushNamed(context, '/forgetPassword'); Navigator.pushNamed(context, '/forgetPassword');
}, },
child: Padding( child: Padding(
padding: EdgeInsets.only(top: 10), padding: EdgeInsets.only(top: 10),
child: Text( child: Text(
"Mot de passe oublié?", "Mot de passe oublié ?",
style: GoogleFonts.plusJakartaSans(color: Colors.white), style: GoogleFonts.plusJakartaSans(color: Colors.white),
), ),
)), )),
SizedBox( SizedBox(
height: defaultPadding, height: defaultPadding,
), ),
SizedBox( SizedBox(
width: 600, width: 600,
child: LoginButton( child: LoginButton(
callback: handleLogin, callback: handleLogin,
text: "Se connecter", text: "Se connecter",
)), )),
Align( Align(
child: GestureDetector( child: GestureDetector(
behavior: HitTestBehavior.translucent, behavior: HitTestBehavior.translucent,
onTap: () { onTap: () {
Navigator.pushNamed(context, '/register'); Navigator.pushNamed(context, '/register');
}, },
child: Padding( child: Padding(
padding: EdgeInsets.only(top: 20), padding: EdgeInsets.only(top: 20),
child: RichText( child: RichText(
textAlign: TextAlign.center, textAlign: TextAlign.center,
text: TextSpan( text: TextSpan(
text: 'Pas encore inscrit?', text: 'Pas encore inscrit ?',
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
fontSize: 15), fontSize: 15),
children: <TextSpan>[ children: <TextSpan>[
TextSpan( TextSpan(
text: " Sinscire", text: " Sinscrire",
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
fontSize: 15, fontSize: 15,
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
color: primaryColor)), color: primaryColor)),
], ],
), ),
), ),
), ),
), ),
), ),
], ],
), ),
), ),
Expanded( Expanded(
flex: 3, flex: 3,
child: Padding( child: Padding(
padding: EdgeInsets.only(top: 20), padding: EdgeInsets.only(top: 20),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
ConstrainedBox( ConstrainedBox(
constraints: BoxConstraints(maxWidth: 600), constraints: BoxConstraints(maxWidth: 600),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
Expanded( Expanded(
child: Container( child: Container(
color: Color(0xFF3D3D3D), color: Color(0xFF3D3D3D),
height: 1, height: 1,
), ),
), ),
Padding( Padding(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
left: defaultPadding, right: defaultPadding), left: defaultPadding, right: defaultPadding),
child: Text( child: Text(
'Ou', 'Ou',
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
color: Colors.white, fontWeight: FontWeight.bold), color: Colors.white, fontWeight: FontWeight.bold),
), ),
), ),
Expanded( Expanded(
child: Container( child: Container(
height: 1, height: 1,
color: Color(0xFF3D3D3D), color: Color(0xFF3D3D3D),
)), )),
], ],
), ),
), ),
SizedBox(height: defaultPadding), SizedBox(height: defaultPadding),
ConstrainedBox( ConstrainedBox(
constraints: BoxConstraints(maxWidth: 540), constraints: BoxConstraints(maxWidth: 540),
child: SizedBox( child: SizedBox(
width: 300.sp, width: 300.sp,
height: 50, height: 50,
child: SignInButton( child: SignInButton(
Buttons.Google, Buttons.Google,
text: "Login with Google", text: "Login with Google",
onPressed: signInWithGoogle, onPressed: signInWithGoogle,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20))), borderRadius: BorderRadius.all(Radius.circular(20))),
), ),
), ),
), ),
], ],
), ),
)) ))
], ],
)))) ))))
], ],
)), )),
))); )));
} }
} }

@ -1,98 +1,98 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:justmusic/values/constants.dart'; import 'package:justmusic/values/constants.dart';
import '../components/join_button.dart'; import '../components/join_button.dart';
class WellcomeScreen extends StatelessWidget { class WellcomeScreen extends StatelessWidget {
const WellcomeScreen({Key? key}) : super(key: key); const WellcomeScreen({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
body: Container( body: Container(
padding: EdgeInsets.all(defaultPadding), padding: EdgeInsets.all(defaultPadding),
width: double.infinity, width: double.infinity,
height: double.infinity, height: double.infinity,
decoration: const BoxDecoration( decoration: const BoxDecoration(
image: DecorationImage( image: DecorationImage(
image: AssetImage("assets/images/wellcome_background.png"), image: AssetImage("assets/images/wellcome_background.png"),
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
), ),
child: Align( child: Align(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Expanded( Expanded(
flex: 10, flex: 10,
child: Padding( child: Padding(
padding: EdgeInsets.only(bottom: 100), padding: EdgeInsets.only(bottom: 100),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
"Bienvenue sur,", "Bienvenue sur,",
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 34), fontSize: 34),
), ),
Image( Image(
image: AssetImage("assets/images/logo.png"), image: AssetImage("assets/images/logo.png"),
width: 230, width: 230,
), ),
SizedBox( SizedBox(
height: 25, height: 25,
), ),
ConstrainedBox( ConstrainedBox(
constraints: BoxConstraints(maxWidth: 520), constraints: BoxConstraints(maxWidth: 520),
child: Text( child: Text(
"Explore les nouvelles découvertes musicales de tes amis, et partage leur ton mood.", "Explore les nouvelles découvertes musicales de tes amis, et partage leur ton mood.",
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.w200, fontWeight: FontWeight.w200,
fontSize: 15), fontSize: 15),
), ),
), ),
], ],
), ),
), ),
), ),
Expanded( Expanded(
flex: 3, flex: 3,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
JoinButton(), JoinButton(),
SizedBox( SizedBox(
height: defaultPadding, height: defaultPadding,
), ),
GestureDetector( GestureDetector(
onTap: () { onTap: () {
Navigator.pushNamed(context, '/login'); Navigator.pushNamed(context, '/login');
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.all(3.0), padding: const EdgeInsets.all(3.0),
child: Text( child: Text(
"Tu as déja un compte? Connexion", "Tu as déja un compte ? Connexion",
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
fontSize: 15), fontSize: 15),
), ),
), ),
), ),
], ],
), ),
), ),
], ],
), ),
) /* add child content here */, ) /* add child content here */,
), ),
); );
} }
} }

Loading…
Cancel
Save