import 'package:flutter/material.dart'; import 'package:geosector_app/core/data/models/membre_model.dart'; class MembreRowWidget extends StatelessWidget { final MembreModel membre; final Function()? onEdit; final Function()? onDelete; const MembreRowWidget({ Key? key, required this.membre, this.onEdit, this.onDelete, }) : super(key: key); @override Widget build(BuildContext context) { final theme = Theme.of(context); return Container( padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(8.0), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.05), blurRadius: 4, offset: const Offset(0, 2), ), ], ), child: Row( children: [ // ID Expanded( flex: 1, child: Text( membre.id.toString(), style: theme.textTheme.bodyMedium, ), ), // Prénom (firstName) Expanded( flex: 2, child: Text( membre.firstName, style: theme.textTheme.bodyMedium, overflow: TextOverflow.ellipsis, ), ), // Nom (name) Expanded( flex: 2, child: Text( membre.name, style: theme.textTheme.bodyMedium, overflow: TextOverflow.ellipsis, ), ), // Secteur (sectName) Expanded( flex: 2, child: Text( membre.sectName ?? '', style: theme.textTheme.bodyMedium, overflow: TextOverflow.ellipsis, ), ), // Rôle (fkRole) Expanded( flex: 1, child: Text( _getRoleName(membre.fkRole), style: theme.textTheme.bodyMedium, ), ), // Actions Expanded( flex: 2, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ // Bouton Edit IconButton( icon: const Icon(Icons.edit, size: 20), color: theme.colorScheme.primary, onPressed: onEdit, tooltip: 'Modifier', constraints: const BoxConstraints(), padding: const EdgeInsets.all(8), ), // Bouton Delete IconButton( icon: const Icon(Icons.delete, size: 20), color: theme.colorScheme.error, onPressed: onDelete, tooltip: 'Supprimer', constraints: const BoxConstraints(), padding: const EdgeInsets.all(8), ), ], ), ), ], ), ); } // Méthode pour convertir l'ID de rôle en nom lisible String _getRoleName(int roleId) { switch (roleId) { case 1: return 'User'; case 2: return 'Admin'; case 3: return 'Super'; default: return roleId.toString(); } } }