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:
@@ -293,7 +293,6 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
||||
},
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
// Filtres par catégorie
|
||||
Padding(
|
||||
padding:
|
||||
@@ -353,44 +352,34 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
||||
}
|
||||
|
||||
List<Widget> _buildCategoryChips() {
|
||||
final categories = [
|
||||
(EquipmentCategory.lighting, Icons.light_mode, 'Lumière'),
|
||||
(EquipmentCategory.sound, Icons.volume_up, 'Son'),
|
||||
(EquipmentCategory.video, Icons.videocam, 'Vidéo'),
|
||||
(EquipmentCategory.effect, Icons.auto_awesome, 'Effets'),
|
||||
(EquipmentCategory.structure, Icons.construction, 'Structure'),
|
||||
(EquipmentCategory.consumable, Icons.inventory_2, 'Consommable'),
|
||||
(EquipmentCategory.cable, Icons.cable, 'Câble'),
|
||||
(EquipmentCategory.other, Icons.more_horiz, 'Autre'),
|
||||
];
|
||||
return EquipmentCategory.values.map((category) {
|
||||
final isSelected = _selectedCategory == category;
|
||||
final color = isSelected ? Colors.white : AppColors.rouge;
|
||||
|
||||
return categories.map((cat) {
|
||||
final isSelected = _selectedCategory == cat.$1;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
child: ChoiceChip(
|
||||
label: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
cat.$2,
|
||||
category.getIcon(
|
||||
size: 16,
|
||||
color: isSelected ? Colors.white : AppColors.rouge,
|
||||
color: color,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(cat.$3),
|
||||
Text(category.label),
|
||||
],
|
||||
),
|
||||
selected: isSelected,
|
||||
onSelected: (selected) {
|
||||
if (selected) {
|
||||
setState(() => _selectedCategory = cat.$1);
|
||||
context.read<EquipmentProvider>().setSelectedCategory(cat.$1);
|
||||
setState(() => _selectedCategory = category);
|
||||
context.read<EquipmentProvider>().setSelectedCategory(category);
|
||||
}
|
||||
},
|
||||
selectedColor: AppColors.rouge,
|
||||
labelStyle: TextStyle(
|
||||
color: isSelected ? Colors.white : AppColors.rouge,
|
||||
color: color,
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
@@ -399,26 +388,17 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
||||
}
|
||||
|
||||
List<Widget> _buildCategoryListTiles() {
|
||||
final categories = [
|
||||
(EquipmentCategory.lighting, Icons.light_mode, 'Lumière'),
|
||||
(EquipmentCategory.sound, Icons.volume_up, 'Son'),
|
||||
(EquipmentCategory.video, Icons.videocam, 'Vidéo'),
|
||||
(EquipmentCategory.effect, Icons.auto_awesome, 'Effets'),
|
||||
(EquipmentCategory.structure, Icons.construction, 'Structure'),
|
||||
(EquipmentCategory.consumable, Icons.inventory_2, 'Consommable'),
|
||||
(EquipmentCategory.cable, Icons.cable, 'Câble'),
|
||||
(EquipmentCategory.other, Icons.more_horiz, 'Autre'),
|
||||
];
|
||||
return EquipmentCategory.values.map((category) {
|
||||
final isSelected = _selectedCategory == category;
|
||||
final color = isSelected ? AppColors.rouge : Colors.grey[600]!;
|
||||
|
||||
return categories.map((cat) {
|
||||
final isSelected = _selectedCategory == cat.$1;
|
||||
return ListTile(
|
||||
leading: Icon(
|
||||
cat.$2,
|
||||
color: isSelected ? AppColors.rouge : Colors.grey[600],
|
||||
leading: category.getIcon(
|
||||
size: 24,
|
||||
color: color,
|
||||
),
|
||||
title: Text(
|
||||
cat.$3,
|
||||
category.label,
|
||||
style: TextStyle(
|
||||
color: isSelected ? AppColors.rouge : Colors.black87,
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
@@ -427,8 +407,8 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
||||
selected: isSelected,
|
||||
selectedTileColor: AppColors.rouge.withOpacity(0.1),
|
||||
onTap: () {
|
||||
setState(() => _selectedCategory = cat.$1);
|
||||
context.read<EquipmentProvider>().setSelectedCategory(cat.$1);
|
||||
setState(() => _selectedCategory = category);
|
||||
context.read<EquipmentProvider>().setSelectedCategory(category);
|
||||
},
|
||||
);
|
||||
}).toList();
|
||||
@@ -506,10 +486,10 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
||||
)
|
||||
: CircleAvatar(
|
||||
backgroundColor:
|
||||
_getStatusColor(equipment.status).withOpacity(0.2),
|
||||
child: Icon(
|
||||
_getCategoryIcon(equipment.category),
|
||||
color: _getStatusColor(equipment.status),
|
||||
equipment.status.color.withOpacity(0.2),
|
||||
child: equipment.category.getIcon(
|
||||
size: 20,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
title: Row(
|
||||
@@ -659,67 +639,24 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
||||
}
|
||||
|
||||
Widget _buildStatusBadge(EquipmentStatus status) {
|
||||
final statusInfo = _getStatusInfo(status);
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: statusInfo.$2.withOpacity(0.2),
|
||||
color: status.color.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: statusInfo.$2),
|
||||
border: Border.all(color: status.color),
|
||||
),
|
||||
child: Text(
|
||||
statusInfo.$1,
|
||||
status.label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: statusInfo.$2,
|
||||
color: status.color,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
(String, Color) _getStatusInfo(EquipmentStatus status) {
|
||||
switch (status) {
|
||||
case EquipmentStatus.available:
|
||||
return ('Disponible', Colors.green);
|
||||
case EquipmentStatus.inUse:
|
||||
return ('En prestation', Colors.blue);
|
||||
case EquipmentStatus.rented:
|
||||
return ('Loué', Colors.orange);
|
||||
case EquipmentStatus.lost:
|
||||
return ('Perdu', Colors.red);
|
||||
case EquipmentStatus.outOfService:
|
||||
return ('HS', Colors.red[900]!);
|
||||
case EquipmentStatus.maintenance:
|
||||
return ('Maintenance', Colors.amber);
|
||||
}
|
||||
}
|
||||
|
||||
Color _getStatusColor(EquipmentStatus status) {
|
||||
return _getStatusInfo(status).$2;
|
||||
}
|
||||
|
||||
IconData _getCategoryIcon(EquipmentCategory category) {
|
||||
switch (category) {
|
||||
case EquipmentCategory.lighting:
|
||||
return Icons.light_mode;
|
||||
case EquipmentCategory.sound:
|
||||
return Icons.volume_up;
|
||||
case EquipmentCategory.video:
|
||||
return Icons.videocam;
|
||||
case EquipmentCategory.effect:
|
||||
return Icons.auto_awesome;
|
||||
case EquipmentCategory.structure:
|
||||
return Icons.construction;
|
||||
case EquipmentCategory.consumable:
|
||||
return Icons.inventory_2;
|
||||
case EquipmentCategory.cable:
|
||||
return Icons.cable;
|
||||
case EquipmentCategory.other:
|
||||
return Icons.more_horiz;
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
void _createNewEquipment() {
|
||||
Navigator.push(
|
||||
|
||||
Reference in New Issue
Block a user