membre add

This commit is contained in:
d6soft
2025-06-11 09:27:25 +02:00
parent 511be5a535
commit ace38d4025
34 changed files with 72757 additions and 73229 deletions

View File

@@ -6,6 +6,7 @@ class MembreRowWidget extends StatelessWidget {
final Function(MembreModel)? onEdit;
final Function(MembreModel)? onDelete;
final bool isAlternate;
final VoidCallback? onTap;
const MembreRowWidget({
super.key,
@@ -13,6 +14,7 @@ class MembreRowWidget extends StatelessWidget {
this.onEdit,
this.onDelete,
this.isAlternate = false,
this.onTap,
});
@override
@@ -20,43 +22,45 @@ class MembreRowWidget extends StatelessWidget {
final theme = Theme.of(context);
// Couleur de fond alternée
final backgroundColor = isAlternate ? theme.colorScheme.surface : theme.colorScheme.surface;
final backgroundColor = isAlternate ? theme.colorScheme.primary.withValues(alpha: 0.05) : Colors.transparent;
return InkWell(
onTap: () => _showMembreDetails(context),
// Envelopper le contenu dans un InkWell
onTap: onTap, // Utiliser le callback onTap
hoverColor: theme.colorScheme.primary.withValues(alpha: 0.15),
child: Container(
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0),
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
decoration: BoxDecoration(
color: backgroundColor,
),
child: Row(
children: [
// ... existing row content ...
// ID
Expanded(
flex: 1,
child: Text(
membre.id.toString(),
membre.id.toString() ?? '',
style: theme.textTheme.bodyMedium,
),
),
// Prénom (firstName)
// Prénom
Expanded(
flex: 2,
child: Text(
membre.firstName ?? '',
style: theme.textTheme.bodyMedium,
overflow: TextOverflow.ellipsis,
),
),
// Nom (name)
// Nom
Expanded(
flex: 2,
child: Text(
membre.name ?? '',
style: theme.textTheme.bodyMedium,
overflow: TextOverflow.ellipsis,
),
),
@@ -64,13 +68,12 @@ class MembreRowWidget extends StatelessWidget {
Expanded(
flex: 3,
child: Text(
membre.email,
membre.email ?? '',
style: theme.textTheme.bodyMedium,
overflow: TextOverflow.ellipsis,
),
),
// Rôle (role au lieu de fkRole)
// Rôle
Expanded(
flex: 1,
child: Text(
@@ -79,22 +82,19 @@ class MembreRowWidget extends StatelessWidget {
),
),
// Statut (isActive au lieu de chkActive)
// Statut
Expanded(
flex: 1,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
decoration: BoxDecoration(
color: membre.isActive ? Colors.green.withOpacity(0.1) : Colors.red.withOpacity(0.1),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: membre.isActive ? Colors.green.withOpacity(0.3) : Colors.red.withOpacity(0.3),
),
color: _getStatusColor(membre.isActive),
borderRadius: BorderRadius.circular(12.0),
),
child: Text(
membre.isActive ? 'Actif' : 'Inactif',
membre.isActive == true ? 'Actif' : 'Inactif',
style: theme.textTheme.bodySmall?.copyWith(
color: membre.isActive ? Colors.green[700] : Colors.red[700],
color: Colors.white,
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.center,
@@ -109,43 +109,12 @@ class MembreRowWidget extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
// Bouton Edit
if (onEdit != null)
IconButton(
icon: Icon(
Icons.edit,
size: 20,
color: theme.colorScheme.primary,
),
onPressed: () => onEdit!(membre),
tooltip: 'Modifier',
constraints: const BoxConstraints(
minWidth: 36,
minHeight: 36,
),
padding: EdgeInsets.zero,
visualDensity: VisualDensity.compact,
),
// Espacement entre les boutons
if (onEdit != null && onDelete != null) const SizedBox(width: 8),
// Bouton Delete
if (onDelete != null)
IconButton(
icon: Icon(
Icons.delete,
size: 20,
color: theme.colorScheme.error,
),
icon: const Icon(Icons.delete, size: 22),
onPressed: () => onDelete!(membre),
tooltip: 'Supprimer',
constraints: const BoxConstraints(
minWidth: 36,
minHeight: 36,
),
padding: EdgeInsets.zero,
visualDensity: VisualDensity.compact,
color: theme.colorScheme.error,
),
],
),
@@ -212,14 +181,18 @@ class MembreRowWidget extends StatelessWidget {
);
}
Color _getStatusColor(bool? isActive) {
return isActive == true ? Colors.green : Colors.red;
}
// Méthode pour convertir l'ID de rôle en nom lisible
String _getRoleName(int roleId) {
switch (roleId) {
case 1:
return 'User';
return 'Membre';
case 2:
return 'Admin';
case 3:
case 9:
return 'Super';
default:
return roleId.toString();