Modifs MVVM
This commit is contained in:
@ -1,15 +1,14 @@
|
||||
import 'package:em2rp/providers/local_auth_provider.dart';
|
||||
import 'package:em2rp/providers/local_user_provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../view_model/user_management_view_model.dart';
|
||||
|
||||
class UserManagementPage extends StatelessWidget {
|
||||
const UserManagementPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final userViewModel = Provider.of<UserManagementViewModel>(context);
|
||||
final authProvider = Provider.of<LocalAuthProvider>(context);
|
||||
// final userViewModel = Provider.of<UserManagementViewModel>(context);
|
||||
final authProvider = Provider.of<LocalUserProvider>(context);
|
||||
|
||||
if (authProvider.role != 'ADMIN') {
|
||||
return Scaffold(
|
||||
@ -22,46 +21,46 @@ class UserManagementPage extends StatelessWidget {
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Gestion des Utilisateurs')),
|
||||
body: userViewModel.isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: ListView.builder(
|
||||
itemCount: userViewModel.users.length,
|
||||
itemBuilder: (context, index) {
|
||||
final user = userViewModel.users[index];
|
||||
return ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundImage: NetworkImage(user.profilePhotoUrl)),
|
||||
title: Text('${user.firstName} ${user.lastName}'),
|
||||
subtitle: Text(user.email),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.edit),
|
||||
onPressed: () {
|
||||
// Afficher la pop-up d'édition
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.lock_reset),
|
||||
onPressed: () =>
|
||||
userViewModel.resetPassword(user.email),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete, color: Colors.red),
|
||||
onPressed: () => userViewModel.deleteUser(user.uid),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
// Ajouter un utilisateur
|
||||
},
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
// body: userViewModel.isLoading
|
||||
// ? const Center(child: CircularProgressIndicator())
|
||||
// : ListView.builder(
|
||||
// itemCount: userViewModel.users.length,
|
||||
// itemBuilder: (context, index) {
|
||||
// final user = userViewModel.users[index];
|
||||
// return ListTile(
|
||||
// leading: CircleAvatar(
|
||||
// backgroundImage: NetworkImage(user.profilePhotoUrl)),
|
||||
// title: Text('${user.firstName} ${user.lastName}'),
|
||||
// subtitle: Text(user.email),
|
||||
// trailing: Row(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// IconButton(
|
||||
// icon: const Icon(Icons.edit),
|
||||
// onPressed: () {
|
||||
// // Afficher la pop-up d'édition
|
||||
// },
|
||||
// ),
|
||||
// IconButton(
|
||||
// icon: const Icon(Icons.lock_reset),
|
||||
// onPressed: () =>
|
||||
// userViewModel.resetPassword(user.email),
|
||||
// ),
|
||||
// IconButton(
|
||||
// icon: const Icon(Icons.delete, color: Colors.red),
|
||||
// onPressed: () => userViewModel.deleteUser(user.uid),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// floatingActionButton: FloatingActionButton(
|
||||
// onPressed: () {
|
||||
// // Ajouter un utilisateur
|
||||
// },
|
||||
// child: const Icon(Icons.add),
|
||||
// ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user