user cassé
This commit is contained in:
		| @@ -1,20 +1,35 @@ | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:firebase_auth/firebase_auth.dart'; | ||||
| import 'package:em2rp/views/widgets/nav/main_drawer.dart'; | ||||
| import 'package:provider/provider.dart'; // Import Provider | ||||
| import 'package:em2rp/providers/user_provider.dart'; // Import UserProvider | ||||
| import 'package:em2rp/utils/colors.dart'; | ||||
|  | ||||
| class CalendarPage extends StatelessWidget { | ||||
|   const CalendarPage({super.key}); | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     final User? user = FirebaseAuth.instance.currentUser; | ||||
|     final String email = user?.email ?? 'Guest'; | ||||
|     final userProvider = Provider.of<UserProvider>(context); | ||||
|  | ||||
|     return Scaffold( | ||||
|       appBar: AppBar( | ||||
|         title: Text('Calendar Page'), | ||||
|       ), | ||||
|       appBar: AppBar(title: const Text('Calendrier')), | ||||
|       drawer: MainDrawer( | ||||
|           currentPage: '/calendar', | ||||
|           userProvider: userProvider), // Pass UserProvider to MainDrawer | ||||
|       body: Center( | ||||
|         child: Text( | ||||
|           'Hello $email, welcome to EM2RP', | ||||
|           style: TextStyle(fontSize: 20), | ||||
|         child: Column( | ||||
|           mainAxisAlignment: MainAxisAlignment.center, | ||||
|           children: [ | ||||
|             const Text('Page Calendrier', style: TextStyle(fontSize: 24)), | ||||
|             const SizedBox(height: 20), | ||||
|             if (userProvider.role == 'ADMIN') // Get role from UserProvider | ||||
|               const Text('Vue Admin du Calendrier', | ||||
|                   style: TextStyle(fontSize: 18, color: AppColors.rouge)) | ||||
|             else | ||||
|               const Text('Vue Utilisateur du Calendrier', | ||||
|                   style: TextStyle(fontSize: 18, color: Colors.blueGrey)), | ||||
|           ], | ||||
|         ), | ||||
|       ), | ||||
|     ); | ||||
|   | ||||
| @@ -1,3 +1,6 @@ | ||||
| import 'package:cloud_firestore/cloud_firestore.dart'; | ||||
| import 'package:em2rp/providers/user_provider.dart'; | ||||
| import 'package:em2rp/views/widgets/auth/forgot_password_dialog.dart'; | ||||
| import 'package:em2rp/views/widgets/auth/mail_textfield.dart'; | ||||
| import 'package:em2rp/views/widgets/error_message.dart'; | ||||
| import 'package:em2rp/views/widgets/auth/forgot_password_button.dart'; | ||||
| @@ -8,6 +11,7 @@ import 'package:em2rp/views/widgets/auth/password_textfield.dart'; | ||||
| import 'package:em2rp/views/widgets/auth/welcome_text.dart'; | ||||
| import 'package:firebase_auth/firebase_auth.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
|  | ||||
| class LoginPage extends StatefulWidget { | ||||
|   const LoginPage({super.key}); | ||||
| @@ -29,63 +33,127 @@ class _LoginPageState extends State<LoginPage> { | ||||
|   void dispose() { | ||||
|     _emailController.dispose(); | ||||
|     _passwordController.dispose(); | ||||
|     print("LoginPage DISPOSED"); | ||||
|     super.dispose(); | ||||
|   } | ||||
|  | ||||
|   Future<void> _signInWithEmailAndPassword() async { | ||||
|   Future<void> _loginUser() async { | ||||
|     if (!mounted) return; // Early exit if widget is unmounted | ||||
|  | ||||
|     setState(() { | ||||
|       _errorMessage = ''; | ||||
|       _isLoading = true; | ||||
|       _highlightPasswordField = false; | ||||
|       _highlightEmailField = false; | ||||
|     }); | ||||
|  | ||||
|     String email = _emailController.text.trim(); | ||||
|     String password = _passwordController.text; | ||||
|  | ||||
|     try { | ||||
|       await FirebaseAuth.instance.signInWithEmailAndPassword( | ||||
|         email: _emailController.text.trim(), | ||||
|         password: _passwordController.text, | ||||
|       ); | ||||
|       Navigator.of(context).pushReplacementNamed('/calendar'); | ||||
|       print('Connexion réussie!'); | ||||
|     } on FirebaseAuthException catch (e) { | ||||
|       setState(() { | ||||
|         _isLoading = false; | ||||
|         if (e.code == 'user-not-found' || e.code == 'wrong-password') { | ||||
|           _errorMessage = "Email ou mot de passe incorrect."; | ||||
|           _highlightPasswordField = true; | ||||
|           _highlightEmailField = true; | ||||
|         } else if (e.code == 'invalid-email') { | ||||
|           _errorMessage = "Adresse email invalide."; | ||||
|           _highlightEmailField = true; | ||||
|       // 1. Sign in with Firebase Authentication | ||||
|       UserCredential userCredential = await FirebaseAuth.instance | ||||
|           .signInWithEmailAndPassword(email: email, password: password); | ||||
|       User? user = userCredential.user; | ||||
|  | ||||
|       if (user != null) { | ||||
|         // 2. Fetch user data from Firestore | ||||
|         print( | ||||
|             "Fetching user data from Firestore..."); // Log before Firestore fetch | ||||
|         DocumentSnapshot userDoc = await FirebaseFirestore.instance | ||||
|             .collection('users') | ||||
|             .doc(user.uid) | ||||
|             .get(); | ||||
|         print("Firestore DocumentSnapshot retrieved."); // Log after fetch | ||||
|  | ||||
|         if (userDoc.exists) { | ||||
|           print("Firestore Document Exists: true"); // Log doc exists check | ||||
|           print("Document ID: ${userDoc.id}"); // Log document ID | ||||
|           print( | ||||
|               "Before data cast - userDoc.data(): ${userDoc.data()}"); // Log raw data before cast | ||||
|  | ||||
|           Map<String, dynamic> userData = | ||||
|               userDoc.data() as Map<String, dynamic>; | ||||
|  | ||||
|           print( | ||||
|               "After data cast - userData: $userData"); // Log userData after cast | ||||
|  | ||||
|           // 3. Store user data in UserProvider | ||||
|           final userProvider = | ||||
|               Provider.of<UserProvider>(context, listen: false); | ||||
|           print( | ||||
|               "Before setUserData call - userProvider: $userProvider"); // Log userProvider instance | ||||
|           userProvider.setUserData( | ||||
|               userData, user.uid); // Store user data in provider | ||||
|           print("After setUserData call"); // Log after setUserData is called | ||||
|  | ||||
|           print( | ||||
|               'Login successful! Role: ${userProvider.role}'); // Log success and role | ||||
|           if (mounted) { | ||||
|             Navigator.of(context).pushReplacementNamed( | ||||
|                 '/calendar'); // 4. Navigate to CalendarPage | ||||
|           } | ||||
|         } else { | ||||
|           _errorMessage = "Erreur de connexion. Veuillez réessayer."; | ||||
|           // User document not found in Firestore | ||||
|           print( | ||||
|               "Firestore Document Exists: false"); // Log doc exists check - false | ||||
|           if (mounted) { | ||||
|             setState(() { | ||||
|               _isLoading = false; | ||||
|               _errorMessage = | ||||
|                   "Erreur: Utilisateur non trouvé dans la base de données."; | ||||
|             }); | ||||
|           } | ||||
|           print('Login Error: Firestore user document not found'); | ||||
|         } | ||||
|       }); | ||||
|       print('Erreur de connexion: ${e.code} - ${e.message}'); | ||||
|       } | ||||
|     } on FirebaseAuthException catch (e) { | ||||
|       // Firebase Authentication error | ||||
|       if (mounted) { | ||||
|         setState(() { | ||||
|           _isLoading = false; | ||||
|           if (e.code == 'user-not-found' || e.code == 'wrong-password') { | ||||
|             _errorMessage = "Email ou mot de passe incorrect."; | ||||
|             _highlightPasswordField = true; | ||||
|             _highlightEmailField = true; | ||||
|           } else if (e.code == 'invalid-email') { | ||||
|             _errorMessage = "Adresse email invalide."; | ||||
|             _highlightEmailField = true; | ||||
|           } else { | ||||
|             _errorMessage = "Erreur de connexion. Veuillez réessayer."; | ||||
|           } | ||||
|         }); | ||||
|       } | ||||
|       print('Login Error (FirebaseAuth): ${e.code} - ${e.message}'); | ||||
|     } finally { | ||||
|       if (mounted) { | ||||
|         setState(() { | ||||
|           _isLoading = false; | ||||
|         }); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   void _togglePasswordVisibility() { | ||||
|     setState(() { | ||||
|       _obscurePassword = !_obscurePassword; | ||||
|     }); | ||||
|     if (mounted) setState(() => _obscurePassword = !_obscurePassword); | ||||
|   } | ||||
|  | ||||
|   void _forgotPassword() { | ||||
|     // TODO: Implémenter la logique de mot de passe oublié | ||||
|     print("Mot de passe oublié cliqué !"); | ||||
|     showDialog( | ||||
|       context: context, | ||||
|       builder: (BuildContext context) { | ||||
|         return const ForgotPasswordDialogWidget(); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Scaffold( | ||||
|       body: LayoutBuilder( | ||||
|         builder: (context, constraints) { | ||||
|           if (constraints.maxWidth > 900) { | ||||
|             return _buildLargeScreenLayout(context); | ||||
|           } else { | ||||
|             return _buildSmallScreenLayout(context); | ||||
|           } | ||||
|         }, | ||||
|         builder: (context, constraints) => constraints.maxWidth > 900 | ||||
|             ? _buildLargeScreenLayout(context) | ||||
|             : _buildSmallScreenLayout(context), | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| @@ -93,16 +161,11 @@ class _LoginPageState extends State<LoginPage> { | ||||
|   Widget _buildLargeScreenLayout(BuildContext context) { | ||||
|     return Row( | ||||
|       children: <Widget>[ | ||||
|         Expanded( | ||||
|           flex: 6, | ||||
|           child: | ||||
|               const ImageSectionWidget(), // Utilise le composant ImageSection | ||||
|         ), | ||||
|         const Expanded(flex: 6, child: ImageSectionWidget()), | ||||
|         Expanded( | ||||
|           flex: 4, | ||||
|           child: Padding( | ||||
|             padding: | ||||
|                 const EdgeInsets.symmetric(horizontal: 50.0, vertical: 30.0), | ||||
|             padding: const EdgeInsets.symmetric(horizontal: 50, vertical: 30), | ||||
|             child: _buildLoginForm(context), | ||||
|           ), | ||||
|         ), | ||||
| @@ -124,9 +187,9 @@ class _LoginPageState extends State<LoginPage> { | ||||
|       mainAxisAlignment: MainAxisAlignment.center, | ||||
|       crossAxisAlignment: CrossAxisAlignment.stretch, | ||||
|       children: <Widget>[ | ||||
|         const LogoWidget(), // Utilise le widget LogoWidget | ||||
|         const LogoWidget(), | ||||
|         const SizedBox(height: 30), | ||||
|         const WelcomeTextWidget(), // Utilise le widget WelcomeTextWidget | ||||
|         const WelcomeTextWidget(), | ||||
|         const SizedBox(height: 40), | ||||
|         EmailTextFieldWidget( | ||||
|           emailController: _emailController, | ||||
| @@ -137,13 +200,26 @@ class _LoginPageState extends State<LoginPage> { | ||||
|           passwordController: _passwordController, | ||||
|           obscurePassword: _obscurePassword, | ||||
|           highlightPasswordField: _highlightPasswordField, | ||||
|           onTogglePasswordVisibility: _togglePasswordVisibility, | ||||
|           onTogglePasswordVisibility: () { | ||||
|             if (!mounted) return; | ||||
|             setState(() { | ||||
|               _obscurePassword = !_obscurePassword; | ||||
|             }); | ||||
|           }, | ||||
|         ), | ||||
|         ForgotPasswordButtonWidget(onPressed: _forgotPassword), | ||||
|         ForgotPasswordButtonWidget(onPressed: () { | ||||
|           showDialog( | ||||
|             context: context, | ||||
|             builder: (BuildContext context) { | ||||
|               return const ForgotPasswordDialogWidget(); | ||||
|             }, | ||||
|           ); | ||||
|         }), | ||||
|         const SizedBox(height: 30), | ||||
|         LoginButtonWidget( | ||||
|           isLoading: _isLoading, | ||||
|           onPressed: _signInWithEmailAndPassword, | ||||
|           onPressed: () => Navigator.of(context).pushNamed( | ||||
|               '/calendar'), //Ici, remplacer par une fonction de connexion avec firebase Auth | ||||
|         ), | ||||
|         const SizedBox(height: 20), | ||||
|         ErrorMessageWidget(errorMessage: _errorMessage), | ||||
|   | ||||
							
								
								
									
										22
									
								
								em2rp/lib/views/my_account_page.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								em2rp/lib/views/my_account_page.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| import 'package:em2rp/providers/user_provider.dart'; | ||||
| import 'package:em2rp/views/widgets/nav/main_drawer.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
|  | ||||
| class MyAccountPage extends StatelessWidget { | ||||
|   const MyAccountPage({super.key}); | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     final userProvider = Provider.of<UserProvider>(context); | ||||
|  | ||||
|     return Scaffold( | ||||
|       appBar: AppBar(title: const Text('Mon Compte')), | ||||
|       drawer: | ||||
|           MainDrawer(currentPage: '/my_account', userProvider: userProvider), | ||||
|       body: const Center( | ||||
|         child: Text('Page Mon Compte', style: TextStyle(fontSize: 24)), | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| } | ||||
							
								
								
									
										39
									
								
								em2rp/lib/views/user_management_page.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								em2rp/lib/views/user_management_page.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:em2rp/views/widgets/nav/main_drawer.dart'; | ||||
| import 'package:em2rp/providers/user_provider.dart'; // Import UserProvider | ||||
| import 'package:provider/provider.dart'; // Import Provider | ||||
|  | ||||
| class UserManagementPage extends StatelessWidget { | ||||
|   const UserManagementPage({super.key}); | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     final userProvider = | ||||
|         Provider.of<UserProvider>(context); // Get UserProvider instance | ||||
|  | ||||
|     if (userProvider.role != 'ADMIN') { | ||||
|       // Get role from UserProvider | ||||
|       return Scaffold( | ||||
|         appBar: AppBar(title: const Text('Gestion des Utilisateurs')), | ||||
|         drawer: MainDrawer( | ||||
|             currentPage: '/user_management', | ||||
|             userProvider: userProvider), // Pass UserProvider to MainDrawer | ||||
|         body: const Center( | ||||
|           child: Text('Accès non autorisé pour les utilisateurs non-Admin.', | ||||
|               style: TextStyle(fontSize: 18, color: Colors.red)), | ||||
|         ), | ||||
|       ); | ||||
|     } else { | ||||
|       return Scaffold( | ||||
|         appBar: AppBar(title: const Text('Gestion des Utilisateurs (Admin)')), | ||||
|         drawer: MainDrawer( | ||||
|             currentPage: '/user_management', | ||||
|             userProvider: userProvider), // Pass UserProvider to MainDrawer | ||||
|         body: const Center( | ||||
|           child: Text('Page de Gestion des Utilisateurs (Admin)', | ||||
|               style: TextStyle(fontSize: 24)), | ||||
|         ), | ||||
|       ); | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @@ -1,3 +1,4 @@ | ||||
| import 'package:em2rp/views/widgets/auth/forgot_password_dialog.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
|  | ||||
| class ForgotPasswordButtonWidget extends StatelessWidget { | ||||
| @@ -10,7 +11,14 @@ class ForgotPasswordButtonWidget extends StatelessWidget { | ||||
|     return Align( | ||||
|       alignment: Alignment.centerRight, | ||||
|       child: TextButton( | ||||
|         onPressed: onPressed, | ||||
|         onPressed: () { | ||||
|           showDialog( | ||||
|             context: context, | ||||
|             builder: (BuildContext context) { | ||||
|               return const ForgotPasswordDialogWidget(); | ||||
|             }, | ||||
|           ); | ||||
|         }, | ||||
|         child: const Text( | ||||
|           'Mot de passe oublié ?', | ||||
|           style: TextStyle(color: Colors.grey), | ||||
|   | ||||
							
								
								
									
										103
									
								
								em2rp/lib/views/widgets/auth/forgot_password_dialog.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								em2rp/lib/views/widgets/auth/forgot_password_dialog.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,103 @@ | ||||
| import 'package:em2rp/utils/colors.dart'; | ||||
| import 'package:firebase_auth/firebase_auth.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
|  | ||||
| class ForgotPasswordDialogWidget extends StatefulWidget { | ||||
|   const ForgotPasswordDialogWidget({super.key}); | ||||
|  | ||||
|   @override | ||||
|   State<ForgotPasswordDialogWidget> createState() => | ||||
|       _ForgotPasswordDialogState(); | ||||
| } | ||||
|  | ||||
| class _ForgotPasswordDialogState extends State<ForgotPasswordDialogWidget> { | ||||
|   final _emailController = TextEditingController(); | ||||
|   String _errorMessage = ''; | ||||
|   bool _isLoading = false; | ||||
|   bool _emailSent = false; | ||||
|  | ||||
|   @override | ||||
|   void dispose() { | ||||
|     _emailController.dispose(); | ||||
|     super.dispose(); | ||||
|   } | ||||
|  | ||||
|   Future<void> _resetPassword() async { | ||||
|     setState(() { | ||||
|       _errorMessage = ''; | ||||
|       _isLoading = true; | ||||
|       _emailSent = false; | ||||
|     }); | ||||
|     try { | ||||
|       await FirebaseAuth.instance | ||||
|           .sendPasswordResetEmail(email: _emailController.text.trim()); | ||||
|       setState(() { | ||||
|         _isLoading = false; | ||||
|         _emailSent = true; | ||||
|       }); | ||||
|     } on FirebaseAuthException catch (e) { | ||||
|       setState(() { | ||||
|         _isLoading = false; | ||||
|         _errorMessage = "Erreur : ${e.message}"; | ||||
|         _emailSent = false; | ||||
|       }); | ||||
|       print( | ||||
|           "Erreur de réinitialisation du mot de passe: ${e.code} - ${e.message}"); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return AlertDialog( | ||||
|       title: const Text('Mot de passe oublié ?'), | ||||
|       content: SingleChildScrollView( | ||||
|         child: ListBody( | ||||
|           children: <Widget>[ | ||||
|             if (_emailSent) | ||||
|               const Text( | ||||
|                   "Un email de réinitialisation a été envoyé à votre adresse.", | ||||
|                   style: TextStyle(color: Colors.green)), | ||||
|             if (!_emailSent) ...[ | ||||
|               const Text( | ||||
|                   "Entrez votre adresse email pour recevoir un lien de réinitialisation."), | ||||
|               const SizedBox(height: 20), | ||||
|               TextField( | ||||
|                 controller: _emailController, | ||||
|                 keyboardType: TextInputType.emailAddress, | ||||
|                 decoration: const InputDecoration( | ||||
|                   labelText: 'Email', | ||||
|                   border: OutlineInputBorder(), | ||||
|                 ), | ||||
|               ), | ||||
|               if (_errorMessage.isNotEmpty) | ||||
|                 Padding( | ||||
|                   padding: const EdgeInsets.only(top: 10.0), | ||||
|                   child: Text(_errorMessage, | ||||
|                       style: const TextStyle(color: Colors.red)), | ||||
|                 ), | ||||
|             ] | ||||
|           ], | ||||
|         ), | ||||
|       ), | ||||
|       actions: <Widget>[ | ||||
|         TextButton( | ||||
|           child: const Text('Terminer'), | ||||
|           onPressed: () { | ||||
|             Navigator.of(context).pop(); | ||||
|           }, | ||||
|         ), | ||||
|         if (!_emailSent) | ||||
|           ElevatedButton( | ||||
|             onPressed: _isLoading ? null : _resetPassword, | ||||
|             child: _isLoading | ||||
|                 ? const SizedBox( | ||||
|                     width: 20, | ||||
|                     height: 20, | ||||
|                     child: CircularProgressIndicator(color: AppColors.blanc), | ||||
|                   ) | ||||
|                 : const Text('Envoyer'), | ||||
|           ), | ||||
|       ], | ||||
|     ); | ||||
|   } | ||||
| } | ||||
| @@ -1,6 +1,6 @@ | ||||
| // lib/views/widgets/password_text_field_widget.dart | ||||
| import 'package:em2rp/utils/colors.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:em2rp/utils/colors.dart'; | ||||
|  | ||||
| class PasswordTextFieldWidget extends StatelessWidget { | ||||
|   final TextEditingController passwordController; | ||||
|   | ||||
							
								
								
									
										129
									
								
								em2rp/lib/views/widgets/nav/main_drawer.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										129
									
								
								em2rp/lib/views/widgets/nav/main_drawer.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,129 @@ | ||||
| import 'package:em2rp/providers/user_provider.dart'; // Import UserProvider | ||||
| import 'package:em2rp/utils/colors.dart'; | ||||
| import 'package:em2rp/views/calendar_page.dart'; | ||||
| import 'package:em2rp/views/my_account_page.dart'; | ||||
| import 'package:em2rp/views/user_management_page.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:provider/provider.dart'; // Import Provider | ||||
|  | ||||
| class MainDrawer extends StatelessWidget { | ||||
|   final String currentPage; | ||||
|   final UserProvider userProvider; | ||||
|  | ||||
|   const MainDrawer( | ||||
|       {super.key, required this.currentPage, required this.userProvider}); | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Drawer( | ||||
|       child: ListView( | ||||
|         padding: EdgeInsets.zero, | ||||
|         children: <Widget>[ | ||||
|           DrawerHeader( | ||||
|             // Header du drawer amélioré | ||||
|             decoration: BoxDecoration( | ||||
|               image: DecorationImage( | ||||
|                 image: AssetImage('assets/EM2_NsurB.jpg'), | ||||
|                 fit: BoxFit.cover, | ||||
|                 colorFilter: ColorFilter.mode( | ||||
|                   AppColors.noir.withOpacity(0.4), | ||||
|                   BlendMode.darken, | ||||
|                 ), | ||||
|               ), | ||||
|             ), | ||||
|             child: Container( | ||||
|               padding: const EdgeInsets.all(16.0), | ||||
|               alignment: Alignment.bottomLeft, | ||||
|               child: Column( | ||||
|                 // Use Column to arrange logo and user name | ||||
|                 crossAxisAlignment: | ||||
|                     CrossAxisAlignment.start, // Align text to the left | ||||
|                 mainAxisAlignment: | ||||
|                     MainAxisAlignment.end, // Align content to the bottom | ||||
|                 children: [ | ||||
|                   Image.asset('assets/EM2_NsurB.jpg', | ||||
|                       height: 50), // Smaller logo in header | ||||
|                   const SizedBox(height: 8), | ||||
|                   Text( | ||||
|                     'Bonjour, ${userProvider.firstName ?? 'Erreur'}', // Display user's first name from provider | ||||
|                     style: TextStyle( | ||||
|                       color: AppColors.blanc, | ||||
|                       fontSize: 18, | ||||
|                       fontWeight: FontWeight.bold, | ||||
|                       shadows: [ | ||||
|                         Shadow( | ||||
|                           blurRadius: 3.0, | ||||
|                           color: AppColors.noir, | ||||
|                           offset: Offset(1.0, 1.0), | ||||
|                         ), | ||||
|                       ], | ||||
|                     ), | ||||
|                   ), | ||||
|                 ], | ||||
|               ), | ||||
|             ), | ||||
|           ), | ||||
|           ListTile( | ||||
|             // Lien vers la page Calendrier | ||||
|             leading: const Icon(Icons.calendar_today), | ||||
|             title: const Text('Calendrier'), | ||||
|             selected: currentPage == '/calendar', | ||||
|             selectedColor: AppColors.rouge, | ||||
|             onTap: () { | ||||
|               Navigator.pop(context); | ||||
|               Navigator.pushReplacement( | ||||
|                 context, | ||||
|                 MaterialPageRoute(builder: (context) => CalendarPage()), | ||||
|               ); | ||||
|             }, | ||||
|           ), | ||||
|           ExpansionTileTheme( | ||||
|             data: const ExpansionTileThemeData( | ||||
|               iconColor: AppColors.noir, | ||||
|               collapsedIconColor: AppColors.noir, | ||||
|             ), | ||||
|             child: ExpansionTile( | ||||
|               leading: const Icon(Icons.settings), | ||||
|               title: const Text('Paramètres'), | ||||
|               children: <Widget>[ | ||||
|                 ListTile( | ||||
|                   leading: const Icon(Icons.account_circle), | ||||
|                   // Lien vers "Mon Compte" | ||||
|                   title: const Text('Mon Compte'), | ||||
|                   selected: currentPage == '/my_acount', | ||||
|                   selectedColor: AppColors.rouge, | ||||
|                   onTap: () { | ||||
|                     Navigator.pop(context); | ||||
|                     Navigator.pushReplacement( | ||||
|                       context, | ||||
|                       MaterialPageRoute( | ||||
|                           builder: (context) => const MyAccountPage()), | ||||
|                     ); | ||||
|                   }, | ||||
|                 ), | ||||
|                 ListTile( | ||||
|                   leading: const Icon(Icons.group), | ||||
|                   // Lien vers "Gestion des Utilisateurs" | ||||
|                   title: const Text('Gestion des Utilisateurs'), | ||||
|                   selected: currentPage == | ||||
|                       '/user_management', // Check if current page is UserManagementPage | ||||
|                   selectedColor: AppColors.rouge, // Color when selected | ||||
|                   onTap: () { | ||||
|                     Navigator.pop(context); // Ferme le drawer | ||||
|                     Navigator.pushReplacement( | ||||
|                       // Navigue vers UserManagementPage | ||||
|                       context, | ||||
|                       MaterialPageRoute( | ||||
|                           builder: (context) => const UserManagementPage()), | ||||
|                     ); | ||||
|                   }, | ||||
|                 ), | ||||
|               ], | ||||
|             ), | ||||
|           ), | ||||
|           // Tu peux ajouter d'autres liens ici si besoin | ||||
|         ], | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user