import 'package:image_picker/image_picker.dart'; /// Die 6 Steps der Auslieferungs-Detail-Page. Reihenfolge ≙ Index. enum WorkflowStep { info, notes, articles, services, payment, summary, } extension WorkflowStepX on WorkflowStep { String get displayName => switch (this) { WorkflowStep.info => 'Info', WorkflowStep.notes => 'Notizen', WorkflowStep.articles => 'Artikel & Gutschriften', WorkflowStep.services => 'Checkliste', WorkflowStep.payment => 'Zahlung', WorkflowStep.summary => 'Übersicht', }; /// Kurze Bezeichnung für den Header-Step (Platz ist eng auf Mobilgeräten). String get shortName => switch (this) { WorkflowStep.info => 'Info', WorkflowStep.notes => 'Notizen', WorkflowStep.articles => 'Artikel', WorkflowStep.services => 'Checkliste', WorkflowStep.payment => 'Zahlung', WorkflowStep.summary => 'Übersicht', }; } /// Eine im Workflow geparkte Bild-Notiz, die noch nicht hochgeladen werden /// kann — wartet auf den Foto-Upload-Endpoint. class PendingImageNote { const PendingImageNote({required this.file, required this.pickedAt}); /// Das vom `image_picker` zurückgegebene File-Handle. final XFile file; final DateTime pickedAt; } /// State des Detail-Workflows. Ein State, ein Bloc — der Step-Wechsel und /// die Drafts liegen hier. Die Zahlung ist KEIN lokaler Draft mehr: Sie wird /// im Step „Zahlung" am Server protokolliert und kommt über die Tour zurück. So sieht jede /// Step-Page denselben kohärenten Zustand und ein Step kann Daten aus /// einem anderen lesen (z. B. Summary liest Article-Drafts). class DeliveryWorkflowState { const DeliveryWorkflowState({ required this.deliveryId, required this.step, required this.pendingImageNotes, }); factory DeliveryWorkflowState.initial(String deliveryId) => DeliveryWorkflowState( deliveryId: deliveryId, step: WorkflowStep.info, pendingImageNotes: const [], ); final String deliveryId; final WorkflowStep step; /// Lokal gehaltene Bild-Notizen — solange kein Upload-Endpoint da ist. final List pendingImageNotes; DeliveryWorkflowState copyWith({ WorkflowStep? step, List? pendingImageNotes, }) { return DeliveryWorkflowState( deliveryId: deliveryId, step: step ?? this.step, pendingImageNotes: pendingImageNotes ?? this.pendingImageNotes, ); } }