feat(frontend): add return checklist screen with shared checklist widgets
This commit is contained in:
@@ -4,10 +4,9 @@ import "../theme/ensup_colors.dart";
|
||||
import "../models/materiel_item.dart";
|
||||
import "../widgets/ensup_top_bar.dart";
|
||||
import "../widgets/brand_corners.dart";
|
||||
import "../widgets/etat_checklist.dart";
|
||||
import "confirmation_screen.dart";
|
||||
|
||||
enum _Etat { present, absent, deteriore }
|
||||
|
||||
/// Checklist de départ (RG11) : l'étudiant indique l'état de chaque accessoire
|
||||
/// attendu avant de confirmer l'emprunt.
|
||||
class ChecklistDepartScreen extends StatefulWidget {
|
||||
@@ -20,17 +19,17 @@ class ChecklistDepartScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ChecklistDepartScreenState extends State<ChecklistDepartScreen> {
|
||||
late final List<_Etat> _etats = List<_Etat>.filled(
|
||||
late final List<EtatChecklist> _etats = List<EtatChecklist>.filled(
|
||||
widget.item.accessoires.length,
|
||||
_Etat.present,
|
||||
EtatChecklist.present,
|
||||
);
|
||||
|
||||
void _valider() {
|
||||
final anomalies = <String>[];
|
||||
for (var i = 0; i < _etats.length; i++) {
|
||||
if (_etats[i] == _Etat.absent) {
|
||||
if (_etats[i] == EtatChecklist.absent) {
|
||||
anomalies.add("${widget.item.accessoires[i]} absent au départ");
|
||||
} else if (_etats[i] == _Etat.deteriore) {
|
||||
} else if (_etats[i] == EtatChecklist.deteriore) {
|
||||
anomalies.add("${widget.item.accessoires[i]} détérioré au départ");
|
||||
}
|
||||
}
|
||||
@@ -141,77 +140,12 @@ class _ChecklistDepartScreenState extends State<ChecklistDepartScreen> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_entete(),
|
||||
for (var i = 0; i < widget.item.accessoires.length; i++) _ligne(i),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _entete() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: EnsupColors.line, width: 2)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: _texteEntete("Élément")),
|
||||
_colonneEntete("Présent"),
|
||||
_colonneEntete("Absent"),
|
||||
_colonneEntete("Détérioré"),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _texteEntete(String label) {
|
||||
return Text(
|
||||
label.toUpperCase(),
|
||||
style: GoogleFonts.darkerGrotesque(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: EnsupColors.muted,
|
||||
letterSpacing: 0.6,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _colonneEntete(String label) {
|
||||
return SizedBox(width: 72, child: Center(child: _texteEntete(label)));
|
||||
}
|
||||
|
||||
Widget _ligne(int index) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: EnsupColors.line)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.item.accessoires[index],
|
||||
style: GoogleFonts.titilliumWeb(fontSize: 14, color: EnsupColors.text2),
|
||||
),
|
||||
),
|
||||
_caseEtat(index, _Etat.present),
|
||||
_caseEtat(index, _Etat.absent),
|
||||
_caseEtat(index, _Etat.deteriore),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _caseEtat(int index, _Etat type) {
|
||||
return SizedBox(
|
||||
width: 72,
|
||||
child: Center(
|
||||
child: _EtatBox(
|
||||
type: type,
|
||||
selected: _etats[index] == type,
|
||||
onTap: () => setState(() => _etats[index] = type),
|
||||
ChecklistTableau(
|
||||
accessoires: widget.item.accessoires,
|
||||
etats: _etats,
|
||||
onChanged: (index, etat) => setState(() => _etats[index] = etat),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -219,59 +153,15 @@ class _ChecklistDepartScreenState extends State<ChecklistDepartScreen> {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: EnsupColors.blue2.withValues(alpha: 0.05),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: EnsupColors.blue2.withValues(alpha: 0.15), width: 1.5),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"INSTRUCTIONS",
|
||||
style: GoogleFonts.darkerGrotesque(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: EnsupColors.muted,
|
||||
letterSpacing: 0.6,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
"Vérifiez physiquement chaque élément du kit et indiquez son état : "
|
||||
"Présent, Absent ou Détérioré. Signalez tout élément manquant ou "
|
||||
"endommagé pour éviter tout litige au retour.",
|
||||
style: GoogleFonts.titilliumWeb(
|
||||
fontSize: 13,
|
||||
color: EnsupColors.text2,
|
||||
height: 1.6,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
ChecklistInstructions(
|
||||
titre: "Instructions",
|
||||
texte:
|
||||
"Vérifiez physiquement chaque élément du kit et indiquez son état : "
|
||||
"Présent, Absent ou Détérioré. Signalez tout élément manquant ou "
|
||||
"endommagé pour éviter tout litige au retour.",
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
TextField(
|
||||
maxLines: 4,
|
||||
style: GoogleFonts.titilliumWeb(fontSize: 13, color: EnsupColors.text),
|
||||
decoration: InputDecoration(
|
||||
hintText: "Commentaire ou observation optionnelle...",
|
||||
hintStyle: GoogleFonts.titilliumWeb(fontSize: 13, color: EnsupColors.muted),
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(9),
|
||||
borderSide: const BorderSide(color: EnsupColors.line, width: 1.5),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(9),
|
||||
borderSide: const BorderSide(color: EnsupColors.cyan, width: 1.5),
|
||||
),
|
||||
),
|
||||
),
|
||||
const ChecklistCommentaire(),
|
||||
const SizedBox(height: 14),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
@@ -294,50 +184,3 @@ class _ChecklistDepartScreenState extends State<ChecklistDepartScreen> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _EtatBox extends StatelessWidget {
|
||||
const _EtatBox({required this.type, required this.selected, required this.onTap});
|
||||
|
||||
final _Etat type;
|
||||
final bool selected;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var background = Colors.white;
|
||||
var border = EnsupColors.line;
|
||||
Widget? contenu;
|
||||
|
||||
if (selected) {
|
||||
switch (type) {
|
||||
case _Etat.present:
|
||||
background = const Color(0xFFF0FDF4);
|
||||
border = const Color(0xFF86EFAC);
|
||||
contenu = const Icon(Icons.check, size: 16, color: Color(0xFF16A34A));
|
||||
case _Etat.absent:
|
||||
background = const Color(0xFFFEF2F2);
|
||||
border = const Color(0xFFFCA5A5);
|
||||
contenu = const Icon(Icons.close, size: 16, color: EnsupColors.red);
|
||||
case _Etat.deteriore:
|
||||
background = const Color(0xFFFFFBEB);
|
||||
border = const Color(0xFFFDE68A);
|
||||
contenu = const Icon(Icons.priority_high, size: 16, color: Color(0xFFD97706));
|
||||
}
|
||||
}
|
||||
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
decoration: BoxDecoration(
|
||||
color: background,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: border, width: 2),
|
||||
),
|
||||
child: contenu,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user