feat: ajout de la gestion de la préparation d'un événement avec page permettant de le gérer

This commit is contained in:
ElPoyo
2026-01-06 10:53:23 +01:00
parent fa1d6a4295
commit 25d395b41a
18 changed files with 2121 additions and 500 deletions

View File

@@ -0,0 +1,161 @@
import 'package:flutter/material.dart';
import 'package:em2rp/models/equipment_model.dart';
import 'package:em2rp/models/event_model.dart';
import 'package:em2rp/utils/colors.dart';
/// Type d'étape pour le checklist
enum ChecklistStep {
preparation,
loading,
unloading,
return_,
}
/// Widget pour afficher un équipement dans une checklist de préparation/retour
class EquipmentChecklistItem extends StatelessWidget {
final EquipmentModel equipment;
final EventEquipment eventEquipment;
final ChecklistStep step;
final bool isValidated; // État de validation (passé depuis le parent)
final VoidCallback onToggle;
final ValueChanged<int>? onReturnedQuantityChanged;
const EquipmentChecklistItem({
super.key,
required this.equipment,
required this.eventEquipment,
this.step = ChecklistStep.preparation,
required this.isValidated,
required this.onToggle,
this.onReturnedQuantityChanged,
});
@override
Widget build(BuildContext context) {
final hasQuantity = equipment.hasQuantity;
final showQuantityInput = step == ChecklistStep.return_ && hasQuantity;
return Card(
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 0),
elevation: 1,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide(
color: isValidated ? Colors.green : Colors.grey.shade300,
width: isValidated ? 2 : 1,
),
),
child: ListTile(
leading: Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: isValidated ? Colors.green.shade100 : Colors.grey.shade100,
borderRadius: BorderRadius.circular(8),
),
child: IconButton(
icon: Icon(
isValidated ? Icons.check_circle : Icons.radio_button_unchecked,
color: isValidated ? Colors.green : Colors.grey,
),
onPressed: onToggle,
padding: EdgeInsets.zero,
),
),
title: Text(
equipment.name,
style: TextStyle(
fontWeight: FontWeight.w600,
decoration: isValidated ? TextDecoration.lineThrough : null,
color: isValidated ? Colors.grey : null,
),
),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (equipment.model != null)
Text(
equipment.model!,
style: TextStyle(
fontSize: 12,
color: Colors.grey.shade600,
),
),
if (hasQuantity) ...[
const SizedBox(height: 4),
Row(
children: [
Text(
'Quantité : ${eventEquipment.quantity}',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: AppColors.bleuFonce,
),
),
if (showQuantityInput && onReturnedQuantityChanged != null) ...[
const SizedBox(width: 16),
const Icon(Icons.arrow_forward, size: 12, color: Colors.grey),
const SizedBox(width: 8),
Text(
'Retourné : ',
style: TextStyle(
fontSize: 12,
color: Colors.grey.shade600,
),
),
SizedBox(
width: 80,
child: TextField(
decoration: InputDecoration(
isDense: true,
contentPadding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(4),
),
hintText: '${eventEquipment.quantity}',
),
keyboardType: TextInputType.number,
onChanged: (value) {
final qty = int.tryParse(value) ?? eventEquipment.quantity;
onReturnedQuantityChanged!(qty);
},
style: const TextStyle(fontSize: 12),
),
),
],
],
),
],
],
),
trailing: isValidated
? Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: Colors.green.shade100,
borderRadius: BorderRadius.circular(12),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: const [
Icon(Icons.check, size: 16, color: Colors.green),
SizedBox(width: 4),
Text(
'Validé',
style: TextStyle(
color: Colors.green,
fontSize: 12,
fontWeight: FontWeight.bold,
),
),
],
),
)
: null,
),
);
}
}

View File

@@ -0,0 +1,192 @@
import 'package:flutter/material.dart';
import 'package:em2rp/models/equipment_model.dart';
import 'package:em2rp/models/event_model.dart';
import 'package:em2rp/utils/colors.dart';
/// Dialog affichant les équipements manquants lors de la préparation/retour
class MissingEquipmentDialog extends StatelessWidget {
final List<EquipmentModel> missingEquipment;
final List<EventEquipment> eventEquipment;
final bool isReturnMode;
const MissingEquipmentDialog({
super.key,
required this.missingEquipment,
required this.eventEquipment,
this.isReturnMode = false,
});
@override
Widget build(BuildContext context) {
return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
child: Container(
constraints: const BoxConstraints(maxWidth: 600, maxHeight: 600),
padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// En-tête avec icône warning
Row(
children: [
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.orange.shade100,
shape: BoxShape.circle,
),
child: Icon(
Icons.warning_amber_rounded,
size: 32,
color: Colors.orange.shade700,
),
),
const SizedBox(width: 16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
isReturnMode
? 'Équipements manquants au retour'
: 'Équipements manquants',
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 4),
Text(
'${missingEquipment.length} équipement(s) non validé(s)',
style: TextStyle(
fontSize: 14,
color: Colors.grey.shade700,
),
),
],
),
),
],
),
const SizedBox(height: 16),
const Divider(),
const SizedBox(height: 8),
// Liste des équipements manquants
Flexible(
child: ListView.builder(
shrinkWrap: true,
itemCount: missingEquipment.length,
itemBuilder: (context, index) {
final equipment = missingEquipment[index];
final eventEq = eventEquipment.firstWhere(
(eq) => eq.equipmentId == equipment.id,
orElse: () => EventEquipment(equipmentId: equipment.id),
);
return Card(
margin: const EdgeInsets.only(bottom: 8),
child: ListTile(
leading: CircleAvatar(
backgroundColor: Colors.orange.shade100,
child: equipment.category.getIcon(
size: 20,
color: Colors.orange.shade700,
),
),
title: Text(
equipment.name,
style: const TextStyle(fontWeight: FontWeight.w600),
),
subtitle: equipment.hasQuantity
? Text('Quantité : ${eventEq.quantity}')
: Text(equipment.model ?? equipment.category.label),
trailing: Icon(
Icons.error_outline,
color: Colors.orange.shade700,
),
),
);
},
),
),
const SizedBox(height: 16),
const Divider(),
const SizedBox(height: 8),
// Actions
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Bouton principal : Confirmer malgré les manquants
ElevatedButton(
onPressed: () => Navigator.of(context).pop('confirm_anyway'),
style: ElevatedButton.styleFrom(
backgroundColor: AppColors.rouge,
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: Text(
isReturnMode
? 'Confirmer le retour malgré les manquants'
: 'Confirmer malgré les manquants',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(height: 12),
// Bouton secondaire : Marquer comme validés
OutlinedButton(
onPressed: () => Navigator.of(context).pop('mark_as_validated'),
style: OutlinedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 16),
side: BorderSide(color: AppColors.bleuFonce, width: 2),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: Text(
'Indiquer les manquants comme validés',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: AppColors.bleuFonce,
),
),
),
const SizedBox(height: 12),
// Bouton tertiaire : Retourner à la liste
TextButton(
onPressed: () => Navigator.of(context).pop('return_to_list'),
style: TextButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 16),
),
child: const Text(
'Retourner à la liste',
style: TextStyle(
fontSize: 16,
color: Colors.grey,
),
),
),
],
),
],
),
),
);
}
}