Modif user provider, ajout photo de profil
This commit is contained in:
parent
e5f7d8d2fd
commit
611c95d73b
@ -5,38 +5,29 @@ class UserProvider extends ChangeNotifier {
|
||||
String? _firstName;
|
||||
String? _lastName;
|
||||
String? _role;
|
||||
// String? _profilePictureUrl;
|
||||
String? _profilePictureUrl;
|
||||
String? _email;
|
||||
// String? _phoneNumber;
|
||||
String? _phoneNumber;
|
||||
|
||||
String? get uid => _uid;
|
||||
String? get firstName => _firstName;
|
||||
String? get lastName => _lastName;
|
||||
String? get role => _role;
|
||||
// String? get profilePhotoUrl => _profilePictureUrl;
|
||||
String? get profilePhotoUrl => _profilePictureUrl;
|
||||
String? get email => _email;
|
||||
// String? get phoneNumber => _phoneNumber;
|
||||
String? get phoneNumber => _phoneNumber;
|
||||
|
||||
// void setUserData(Map<String, dynamic> userData, String uid) {
|
||||
// _uid = uid;
|
||||
// _firstName = userData['firstName'];
|
||||
// _lastName = userData['lastName'];
|
||||
// _role = userData['role'] ?? 'USER'; // Default role if not provided
|
||||
// // _profilePictureUrl = userData['profilePhotoUrl'];
|
||||
// _email = userData['email'];
|
||||
// // _phoneNumber = userData['phoneNumber'];
|
||||
// notifyListeners(); // Notify listeners that state has changed
|
||||
// }
|
||||
void setUserData(Map<String, dynamic> userData, String uid) {
|
||||
_uid = uid;
|
||||
_firstName = userData['firstName'];
|
||||
_lastName = userData['lastName'];
|
||||
_role = userData['role'] ?? 'USER'; // Default role if not provided
|
||||
if (userData['profilePhotoUrl'] != "") {
|
||||
_profilePictureUrl = userData['profilePhotoUrl'];
|
||||
}
|
||||
_email = userData['email'];
|
||||
|
||||
print("User data set: $_firstName $_lastName ($_email)");
|
||||
|
||||
notifyListeners();
|
||||
_phoneNumber = userData['phoneNumber'];
|
||||
notifyListeners(); // Notify listeners that state has changed
|
||||
}
|
||||
|
||||
void clearUserData() {
|
||||
@ -44,9 +35,9 @@ class UserProvider extends ChangeNotifier {
|
||||
_firstName = null;
|
||||
_lastName = null;
|
||||
_role = null;
|
||||
// _profilePictureUrl = null;
|
||||
_profilePictureUrl = null;
|
||||
_email = null;
|
||||
// _phoneNumber = null;
|
||||
_phoneNumber = null;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ class _LoginPageState extends State<LoginPage> {
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 6,
|
||||
child: const ImageSectionWidget(), // Affiche l'image de gauche
|
||||
child: const BigLeftImageWidget(),
|
||||
),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
|
@ -1,8 +1,8 @@
|
||||
import 'package:em2rp/utils/colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ImageSectionWidget extends StatelessWidget {
|
||||
const ImageSectionWidget({super.key});
|
||||
class BigLeftImageWidget extends StatelessWidget {
|
||||
const BigLeftImageWidget({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -1,10 +1,9 @@
|
||||
import 'package:em2rp/providers/user_provider.dart'; // Import UserProvider
|
||||
import 'package:em2rp/providers/user_provider.dart';
|
||||
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 Provider
|
||||
|
||||
class MainDrawer extends StatelessWidget {
|
||||
final String currentPage;
|
||||
@ -20,7 +19,7 @@ class MainDrawer extends StatelessWidget {
|
||||
padding: EdgeInsets.zero,
|
||||
children: <Widget>[
|
||||
DrawerHeader(
|
||||
// Header du drawer amélioré
|
||||
// Header du drawer
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/EM2_NsurB.jpg'),
|
||||
@ -36,16 +35,19 @@ class MainDrawer extends StatelessWidget {
|
||||
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
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Image.asset('assets/EM2_NsurB.jpg',
|
||||
height: 50), // Smaller logo in header
|
||||
CircleAvatar(
|
||||
radius: 25,
|
||||
backgroundImage: NetworkImage(
|
||||
userProvider.profilePhotoUrl ??
|
||||
'https://firebasestorage.googleapis.com/v0/b/em2rp-951dc/o/EM2_NsurB.jpg?alt=media&token=530479c3-5f8c-413b-86a2-53ec4a4ed734', //TODO: Remplacer par logo EM2
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Bonjour, ${userProvider.firstName ?? 'Erreur'}', // Display user's first name from provider
|
||||
'Bonjour, ${userProvider.firstName ?? 'Erreur'}',
|
||||
style: TextStyle(
|
||||
color: AppColors.blanc,
|
||||
fontSize: 18,
|
||||
@ -107,7 +109,7 @@ class MainDrawer extends StatelessWidget {
|
||||
title: const Text('Gestion des Utilisateurs'),
|
||||
selected: currentPage ==
|
||||
'/user_management', // Check if current page is UserManagementPage
|
||||
selectedColor: AppColors.rouge, // Color when selected
|
||||
selectedColor: AppColors.rouge,
|
||||
onTap: () {
|
||||
Navigator.pop(context); // Ferme le drawer
|
||||
Navigator.pushReplacement(
|
||||
@ -121,7 +123,6 @@ class MainDrawer extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
// Tu peux ajouter d'autres liens ici si besoin
|
||||
],
|
||||
),
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user