Skip to content

Commit

Permalink
UI and orthography
Browse files Browse the repository at this point in the history
  • Loading branch information
FeloxleF committed Apr 16, 2024
1 parent d83b20a commit 17530ed
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 129 deletions.
54 changes: 34 additions & 20 deletions lib/Screens/forgot_password.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
),
);
return true;
}
else {
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Erreur lors de la réinitialisation du mot de passe: ${response.statusCode}'),
content: Text(
'Erreur lors de la réinitialisation du mot de passe: ${response.statusCode}'),
backgroundColor: Colors.red,
),
);
Expand All @@ -61,7 +61,8 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Une erreur s\'est produite. Veuillez réessayer plus tard.'),
content:
Text('Une erreur s\'est produite. Veuillez réessayer plus tard.'),
backgroundColor: Colors.red,
),
);
Expand Down Expand Up @@ -113,30 +114,21 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
icon: Icons.person,
hintName: 'Email',
inputtype: TextInputType.text),
const SizedBox(height: 5.0),
const SizedBox(height: 10.0),
GetTextFormField(
controller: _conpassword,
icon: Icons.lock,
hintName: 'mot de passe',
isObscureText: true,
),
const SizedBox(height: 5.0),
const SizedBox(height: 10.0),
GetTextFormField(
controller: _conconfpassword,
icon: Icons.lock,
hintName: 'confirmer mot de passe',
isObscureText: true,
),
const SizedBox(height: 20.0),
TextButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const LoginForm()),
);
},
child: const Text('Retourner à la page de connexion'),
),
const SizedBox(height: 15.0),
Container(
margin: const EdgeInsets.all(30.0),
width: double.infinity,
Expand All @@ -146,17 +138,39 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
child: TextButton(
onPressed: () async {
if (await resetPassword()) {
await Future.delayed(const Duration(seconds: 1)); // Attendez 1 seconde
onResetPasswordSuccess(context); // Redirigez vers LoginForm uniquement si la réinitialisation du mot de passe a réussi
await Future.delayed(
const Duration(seconds: 1)); // Attendez 1 seconde
onResetPasswordSuccess(
context); // Redirigez vers LoginForm uniquement si la réinitialisation du mot de passe a réussi
}
},
child: const Text(
'Reinitialiser le mot de passe',
style: TextStyle(
color: Color.fromARGB(255, 197, 198, 243)),
style:
TextStyle(color: Color.fromARGB(255, 197, 198, 243),
fontSize: 18.0,
),
),
),
),
const SizedBox(height: 80.0),
TextButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const LoginForm()),
);
},
child: const Text(
'Retour à la page de connexion',
style: TextStyle(
fontSize: 20.0,
color: Colors.white70,
),
),
),

],
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/Screens/inscrire.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class _InscrireFormState extends State<InscrireForm> {
width: 100.0,
),
const Text(
"s'inscrire",
"Inscrivez-vous",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
Expand Down
100 changes: 64 additions & 36 deletions lib/Screens/login_form.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ignore_for_file: avoid_print

import 'package:activmind_app/Screens/HomeForm.dart';

// import 'package:activmind_app/Screens/home.dart';
import 'package:activmind_app/Screens/signup_form.dart';
import 'package:activmind_app/Screens/Calendar.dart';
Expand Down Expand Up @@ -39,17 +40,18 @@ class _LoginFormState extends State<LoginForm> {
final BuildContext currentContext = context;
if (response.statusCode == 200) {
// Save token to local storage
final token = jsonDecode(response.body)['token'];
await saveToken(token);
final token = jsonDecode(response.body)['token'];
await saveToken(token);

// Extract username from response
final Map<String, dynamic> userData = jsonDecode(response.body);
final String username = userData['username'];

// Extract username from response
final Map<String, dynamic> userData = jsonDecode(response.body);
final String username = userData['username'];
// Update global variable with the username
var globalVariables =
Provider.of<GlobalVariables>(context, listen: false);
globalVariables.user = username;

// Update global variable with the username
var globalVariables = Provider.of<GlobalVariables>(context, listen: false);
globalVariables.user = username;

// ignore: use_build_context_synchronously
Navigator.pushReplacement(
currentContext, MaterialPageRoute(builder: (_) => const HomeForm()));
Expand All @@ -70,11 +72,10 @@ class _LoginFormState extends State<LoginForm> {
// }
}


Future<void> saveToken(String token) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString('token', token);
}
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString('token', token);
}

@override
Widget build(BuildContext context) {
Expand All @@ -100,33 +101,43 @@ class _LoginFormState extends State<LoginForm> {
height: 100.0,
width: 100.0,
),
const SizedBox(height: 20.0),
const Text(
'se connecter',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 25.0),
),
const SizedBox(height: 10.0),
GetTextFormField(
controller: _conemail,
icon: Icons.person,
hintName: 'Email',
inputtype: TextInputType.text),
const SizedBox(height: 5.0),
const SizedBox(height: 10.0),
GetTextFormField(
controller: _conpassword,
icon: Icons.lock,
hintName: 'mot de passe',
isObscureText: true,
),
const SizedBox(height: 15.0),
TextButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const ForgotPasswordForm()),
MaterialPageRoute(
builder: (context) => const ForgotPasswordForm()),
);
},
child: Text('Mot de passe oublié ?'),
child: const Text(
'Mot de passe oublié ?',
style: TextStyle(
color: Colors.white,
fontSize: 18.0,
fontWeight: FontWeight.bold),
),
),
Container(
margin: const EdgeInsets.all(30.0),
Expand All @@ -135,28 +146,45 @@ class _LoginFormState extends State<LoginForm> {
color: const Color.fromARGB(255, 76, 77, 166),
borderRadius: BorderRadius.circular(30.0)),
child: TextButton(
onPressed: login,
onPressed: login,
child: const Text(
'connexion',
style: TextStyle(
color: Colors.white70,
fontSize: 20.0,
),
),
),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
// Centre les éléments verticalement
children: [
const SizedBox(height: 100.0),
const Text(
"Vous n'avez pas encore de compte ?",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 76, 77, 166),
fontSize: 18.0),
),
TextButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const SignupForm()));
},
child: const Text(
'connexion',
"Inscrivez-vous",
style: TextStyle(
color: Color.fromARGB(255, 197, 198, 243)),
)),
),
Center(
child: Container(
child: TextButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const SignupForm()));
},
child: const Text(
'Inscrivez-vous',
style: TextStyle(
color: Color.fromARGB(255, 197, 198, 243)),
))),
),
color: Colors.white70,
fontSize: 18.0,
),
),
),
],
)
],
),
),
Expand Down
Loading

0 comments on commit 17530ed

Please sign in to comment.