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:
@@ -7,7 +7,6 @@ import 'package:em2rp/providers/local_user_provider.dart';
|
||||
import 'package:em2rp/services/equipment_service.dart';
|
||||
import 'package:em2rp/services/qr_code_service.dart';
|
||||
import 'package:em2rp/utils/colors.dart';
|
||||
import 'package:em2rp/utils/permission_gate.dart';
|
||||
import 'package:em2rp/views/widgets/nav/custom_app_bar.dart';
|
||||
import 'package:em2rp/views/equipment_form_page.dart';
|
||||
import 'package:em2rp/views/widgets/equipment/equipment_parent_containers.dart';
|
||||
@@ -144,10 +143,9 @@ class _EquipmentDetailPageState extends State<EquipmentDetailPage> {
|
||||
CircleAvatar(
|
||||
backgroundColor: Colors.white,
|
||||
radius: 30,
|
||||
child: Icon(
|
||||
_getCategoryIcon(widget.equipment.category),
|
||||
color: AppColors.rouge,
|
||||
child: widget.equipment.category.getIcon(
|
||||
size: 32,
|
||||
color: AppColors.rouge,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
@@ -187,7 +185,7 @@ class _EquipmentDetailPageState extends State<EquipmentDetailPage> {
|
||||
}
|
||||
|
||||
Widget _buildStatusBadge() {
|
||||
final statusInfo = _getStatusInfo(widget.equipment.status);
|
||||
final status = widget.equipment.status;
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
@@ -201,17 +199,17 @@ class _EquipmentDetailPageState extends State<EquipmentDetailPage> {
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: BoxDecoration(
|
||||
color: statusInfo.$2,
|
||||
color: status.color,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
statusInfo.$1,
|
||||
status.label,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: statusInfo.$2,
|
||||
color: status.color,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -240,14 +238,14 @@ class _EquipmentDetailPageState extends State<EquipmentDetailPage> {
|
||||
],
|
||||
),
|
||||
const Divider(height: 24),
|
||||
_buildInfoRow('Catégorie', _getCategoryName(widget.equipment.category)),
|
||||
_buildInfoRow('Catégorie', widget.equipment.category.label),
|
||||
if (widget.equipment.brand != null && widget.equipment.brand!.isNotEmpty)
|
||||
_buildInfoRow('Marque', widget.equipment.brand!),
|
||||
if (widget.equipment.model != null && widget.equipment.model!.isNotEmpty)
|
||||
_buildInfoRow('Modèle', widget.equipment.model!),
|
||||
if (widget.equipment.category != EquipmentCategory.consumable &&
|
||||
widget.equipment.category != EquipmentCategory.cable)
|
||||
_buildInfoRow('Statut', _getStatusInfo(widget.equipment.status).$1),
|
||||
_buildInfoRow('Statut', widget.equipment.status.label),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -808,65 +806,6 @@ class _EquipmentDetailPageState extends State<EquipmentDetailPage> {
|
||||
);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
String _getCategoryName(EquipmentCategory category) {
|
||||
switch (category) {
|
||||
case EquipmentCategory.lighting:
|
||||
return 'Lumière';
|
||||
case EquipmentCategory.sound:
|
||||
return 'Son';
|
||||
case EquipmentCategory.video:
|
||||
return 'Vidéo';
|
||||
case EquipmentCategory.effect:
|
||||
return 'Effets';
|
||||
case EquipmentCategory.structure:
|
||||
return 'Structure';
|
||||
case EquipmentCategory.consumable:
|
||||
return 'Consommable';
|
||||
case EquipmentCategory.cable:
|
||||
return 'Câble';
|
||||
case EquipmentCategory.other:
|
||||
return 'Autre';
|
||||
}
|
||||
}
|
||||
|
||||
(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);
|
||||
}
|
||||
}
|
||||
|
||||
(String, IconData) _getMaintenanceTypeInfo(MaintenanceType type) {
|
||||
switch (type) {
|
||||
case MaintenanceType.preventive:
|
||||
|
||||
Reference in New Issue
Block a user