|
|
|
@ -10,6 +10,7 @@ import 'package:google_fonts/google_fonts.dart';
|
|
|
|
|
import 'package:justmusic/values/constants.dart';
|
|
|
|
|
|
|
|
|
|
import '../components/login_button.dart';
|
|
|
|
|
import '../main.dart';
|
|
|
|
|
|
|
|
|
|
class RegistrationScreen extends StatefulWidget {
|
|
|
|
|
const RegistrationScreen({Key? key}) : super(key: key);
|
|
|
|
@ -20,12 +21,42 @@ class RegistrationScreen extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
|
bool passenable = true;
|
|
|
|
|
final _formKey = GlobalKey<FormState>();
|
|
|
|
|
final _userPseudoTextField = TextEditingController();
|
|
|
|
|
final _userMailTextField = TextEditingController();
|
|
|
|
|
final _passwordTextField = TextEditingController();
|
|
|
|
|
final _passwordConfirmTextField = TextEditingController();
|
|
|
|
|
|
|
|
|
|
handleRegister() async {
|
|
|
|
|
if (_formKey.currentState!.validate()) {
|
|
|
|
|
try {
|
|
|
|
|
await MyApp.userViewModel.register(_userPseudoTextField.text,
|
|
|
|
|
_passwordTextField.text, _userMailTextField.text);
|
|
|
|
|
Navigator.pushNamed(context, '/explanation');
|
|
|
|
|
} catch (e) {
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
SnackBar(
|
|
|
|
|
content: Text(
|
|
|
|
|
e.toString() ?? "",
|
|
|
|
|
style: GoogleFonts.plusJakartaSans(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
|
fontSize: 20.h),
|
|
|
|
|
),
|
|
|
|
|
backgroundColor: Colors.red,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
backgroundColor: bgColor,
|
|
|
|
|
body: Stack(
|
|
|
|
|
body: Form(
|
|
|
|
|
key: _formKey,
|
|
|
|
|
child: Stack(
|
|
|
|
|
children: [
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
child: SizedBox(
|
|
|
|
@ -51,8 +82,8 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Padding(
|
|
|
|
|
padding:
|
|
|
|
|
EdgeInsets.symmetric(horizontal: defaultPadding),
|
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
|
horizontal: defaultPadding),
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: EdgeInsets.only(bottom: 50.h),
|
|
|
|
|
child: Column(
|
|
|
|
@ -83,10 +114,11 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
|
left: defaultPadding,
|
|
|
|
|
right: defaultPadding),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _userPseudoTextField,
|
|
|
|
|
keyboardAppearance: Brightness.dark,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if (value == null || value.isEmpty) {
|
|
|
|
|
return 'TODO';
|
|
|
|
|
return 'entrez un pseudo valide';
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
@ -97,15 +129,18 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(
|
|
|
|
|
width: 1.sp, color: strokeTextField),
|
|
|
|
|
width: 1.sp,
|
|
|
|
|
color: strokeTextField),
|
|
|
|
|
borderRadius: const BorderRadius.all(
|
|
|
|
|
Radius.circular(10))),
|
|
|
|
|
contentPadding: const EdgeInsets.only(
|
|
|
|
|
top: 0, bottom: 0, left: defaultPadding),
|
|
|
|
|
prefix: const Padding(
|
|
|
|
|
padding: EdgeInsets.only(left: 20.0)),
|
|
|
|
|
suffix: const Padding(
|
|
|
|
|
padding: EdgeInsets.only(left: 20.0)),
|
|
|
|
|
fillColor: bgTextField,
|
|
|
|
|
filled: true,
|
|
|
|
|
focusColor:
|
|
|
|
|
const Color.fromRGBO(255, 255, 255, 0.30),
|
|
|
|
|
focusColor: const Color.fromRGBO(
|
|
|
|
|
255, 255, 255, 0.30),
|
|
|
|
|
enabledBorder: const OutlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(
|
|
|
|
|
width: 1, color: strokeTextField),
|
|
|
|
@ -121,10 +156,11 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
|
left: defaultPadding,
|
|
|
|
|
right: defaultPadding),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _userMailTextField,
|
|
|
|
|
keyboardAppearance: Brightness.dark,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if (value == null || value.isEmpty) {
|
|
|
|
|
return 'TODO';
|
|
|
|
|
return 'entrez un email valide';
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
@ -138,8 +174,10 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
|
width: 1, color: strokeTextField),
|
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
|
Radius.circular(10))),
|
|
|
|
|
contentPadding: EdgeInsets.only(
|
|
|
|
|
top: 0, bottom: 0, left: defaultPadding),
|
|
|
|
|
prefix: const Padding(
|
|
|
|
|
padding: EdgeInsets.only(left: 20.0)),
|
|
|
|
|
suffix: const Padding(
|
|
|
|
|
padding: EdgeInsets.only(left: 20.0)),
|
|
|
|
|
fillColor: bgTextField,
|
|
|
|
|
filled: true,
|
|
|
|
|
focusColor:
|
|
|
|
@ -159,16 +197,16 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
|
left: defaultPadding,
|
|
|
|
|
right: defaultPadding),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _passwordTextField,
|
|
|
|
|
keyboardAppearance: Brightness.dark,
|
|
|
|
|
obscureText: passenable,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if (value == null || value.isEmpty) {
|
|
|
|
|
return 'TODO';
|
|
|
|
|
return 'entrez un mot de passe valide';
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
cursorColor: primaryColor,
|
|
|
|
|
keyboardType: TextInputType.emailAddress,
|
|
|
|
|
style: GoogleFonts.plusJakartaSans(
|
|
|
|
|
color: primaryColor),
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
@ -177,8 +215,10 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
|
width: 1, color: strokeTextField),
|
|
|
|
|
borderRadius:
|
|
|
|
|
BorderRadius.all(Radius.circular(10))),
|
|
|
|
|
contentPadding: EdgeInsets.only(
|
|
|
|
|
top: 0, bottom: 0, left: defaultPadding),
|
|
|
|
|
prefix: const Padding(
|
|
|
|
|
padding: EdgeInsets.only(left: 20.0)),
|
|
|
|
|
suffix: const Padding(
|
|
|
|
|
padding: EdgeInsets.only(left: 20.0)),
|
|
|
|
|
fillColor: bgTextField,
|
|
|
|
|
filled: true,
|
|
|
|
|
focusColor: Color.fromRGBO(255, 255, 255, 0.30),
|
|
|
|
@ -203,9 +243,10 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
|
passenable = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, // Image tapped
|
|
|
|
|
splashColor: Colors
|
|
|
|
|
.white10, // Splash color over image
|
|
|
|
|
},
|
|
|
|
|
// Image tapped
|
|
|
|
|
splashColor: Colors.white10,
|
|
|
|
|
// Splash color over image
|
|
|
|
|
child: Image(
|
|
|
|
|
image: passenable
|
|
|
|
|
? AssetImage(
|
|
|
|
@ -224,11 +265,14 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
|
left: defaultPadding,
|
|
|
|
|
right: defaultPadding),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _passwordConfirmTextField,
|
|
|
|
|
keyboardAppearance: Brightness.dark,
|
|
|
|
|
obscureText: passenable,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if (value == null || value.isEmpty) {
|
|
|
|
|
return 'TODO';
|
|
|
|
|
return 'entrez un mot de passe valide';
|
|
|
|
|
} else if (_passwordTextField.text != value) {
|
|
|
|
|
return 'les mots de passes ne sont pas identiques';
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
@ -242,8 +286,10 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
|
width: 1, color: strokeTextField),
|
|
|
|
|
borderRadius:
|
|
|
|
|
BorderRadius.all(Radius.circular(10))),
|
|
|
|
|
contentPadding: EdgeInsets.only(
|
|
|
|
|
top: 0, bottom: 0, left: defaultPadding),
|
|
|
|
|
prefix: const Padding(
|
|
|
|
|
padding: EdgeInsets.only(left: 20.0)),
|
|
|
|
|
suffix: const Padding(
|
|
|
|
|
padding: EdgeInsets.only(left: 20.0)),
|
|
|
|
|
fillColor: bgTextField,
|
|
|
|
|
filled: true,
|
|
|
|
|
focusColor: Color.fromRGBO(255, 255, 255, 0.30),
|
|
|
|
@ -268,9 +314,10 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
|
passenable = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, // Image tapped
|
|
|
|
|
splashColor: Colors
|
|
|
|
|
.white10, // Splash color over image
|
|
|
|
|
},
|
|
|
|
|
// Image tapped
|
|
|
|
|
splashColor: Colors.white10,
|
|
|
|
|
// Splash color over image
|
|
|
|
|
child: Image(
|
|
|
|
|
image: passenable
|
|
|
|
|
? AssetImage(
|
|
|
|
@ -284,12 +331,12 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
|
padding:
|
|
|
|
|
EdgeInsets.symmetric(horizontal: defaultPadding),
|
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
|
horizontal: defaultPadding),
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
width: 600,
|
|
|
|
|
child: LoginButton(
|
|
|
|
|
callback: () {},
|
|
|
|
|
callback: handleRegister,
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
Align(
|
|
|
|
@ -340,7 +387,8 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
|
child: Text(
|
|
|
|
|
'Ou',
|
|
|
|
|
style: GoogleFonts.plusJakartaSans(
|
|
|
|
|
color: Colors.white, fontWeight: FontWeight.bold),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
@ -362,7 +410,8 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
|
text: "Login with Google",
|
|
|
|
|
onPressed: () {},
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(20))),
|
|
|
|
|
borderRadius:
|
|
|
|
|
BorderRadius.all(Radius.circular(20))),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
@ -403,6 +452,7 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|