Refactor: Centralisation des labels et icônes pour les enums

Centralise la gestion des libellés, couleurs et icônes pour `EquipmentStatus`, `EquipmentCategory`, et `ContainerType` en utilisant des extensions Dart.

- Ajout de nouvelles icônes SVG pour `flight-case`, `truss` et `tape`.
- Refactorisation des vues pour utiliser les nouvelles extensions, supprimant ainsi la logique d'affichage dupliquée.
- Mise à jour des `ChoiceChip` et des listes de filtres pour afficher les icônes à côté des labels.
This commit is contained in:
ElPoyo
2025-10-29 18:43:24 +01:00
parent 3fab69cb00
commit df6d54a007
16 changed files with 441 additions and 307 deletions

View File

@@ -190,7 +190,7 @@ class _ContainerManagementPageState extends State<ContainerManagementPage>
...ContainerType.values.map((type) {
return Padding(
padding: const EdgeInsets.only(right: 8),
child: _buildTypeChip(type, containerTypeLabel(type)),
child: _buildTypeChip(type, type.label),
);
}),
],
@@ -201,8 +201,19 @@ class _ContainerManagementPageState extends State<ContainerManagementPage>
Widget _buildTypeChip(ContainerType? type, String label) {
final isSelected = _selectedType == type;
final color = isSelected ? Colors.white : AppColors.noir;
return ChoiceChip(
label: Text(label),
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (type != null) ...[
type.getIcon(size: 16, color: color),
const SizedBox(width: 8),
],
Text(label),
],
),
selected: isSelected,
onSelected: (selected) {
setState(() {
@@ -212,7 +223,7 @@ class _ContainerManagementPageState extends State<ContainerManagementPage>
},
selectedColor: AppColors.rouge,
labelStyle: TextStyle(
color: isSelected ? Colors.white : AppColors.noir,
color: color,
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
),
);
@@ -244,7 +255,7 @@ class _ContainerManagementPageState extends State<ContainerManagementPage>
const SizedBox(height: 8),
_buildFilterOption(null, 'Tous les types'),
...ContainerType.values.map((type) {
return _buildFilterOption(type, containerTypeLabel(type));
return _buildFilterOption(type, type.label);
}),
const Divider(height: 32),
@@ -403,8 +414,7 @@ class _ContainerManagementPageState extends State<ContainerManagementPage>
),
// Icône du type de container
Icon(
_getTypeIcon(container.type),
container.type.getIcon(
size: 40,
color: AppColors.rouge,
),
@@ -434,7 +444,7 @@ class _ContainerManagementPageState extends State<ContainerManagementPage>
Row(
children: [
_buildInfoChip(
containerTypeLabel(container.type),
container.type.label,
Icons.category,
),
const SizedBox(width: 8),
@@ -534,42 +544,17 @@ class _ContainerManagementPageState extends State<ContainerManagementPage>
}
Widget _buildStatusBadge(EquipmentStatus status) {
Color color;
String label;
switch (status) {
case EquipmentStatus.available:
color = Colors.green;
label = 'Disponible';
break;
case EquipmentStatus.inUse:
color = Colors.orange;
label = 'En prestation';
break;
case EquipmentStatus.maintenance:
color = Colors.blue;
label = 'Maintenance';
break;
case EquipmentStatus.outOfService:
color = Colors.red;
label = 'Hors service';
break;
default:
color = Colors.grey;
label = 'Autre';
}
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: color.withOpacity(0.1),
color: status.color.withOpacity(0.1),
borderRadius: BorderRadius.circular(16),
border: Border.all(color: color),
border: Border.all(color: status.color),
),
child: Text(
label,
status.label,
style: TextStyle(
color: color,
color: status.color,
fontWeight: FontWeight.bold,
fontSize: 12,
),
@@ -577,21 +562,6 @@ class _ContainerManagementPageState extends State<ContainerManagementPage>
);
}
IconData _getTypeIcon(ContainerType type) {
switch (type) {
case ContainerType.flightCase:
return Icons.work;
case ContainerType.pelicase:
return Icons.work_outline;
case ContainerType.bag:
return Icons.shopping_bag;
case ContainerType.openCrate:
return Icons.inventory_2;
case ContainerType.toolbox:
return Icons.handyman;
}
}
void _handleMenuAction(String action, ContainerModel container) {
switch (action) {