Final commit.
This commit is contained in:
@ -1,173 +1,257 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:easy_stepper/easy_stepper.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_bloc.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_event.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/presentation/delivery_sign.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/presentation/steps/step.dart';
|
||||
|
||||
import 'package:hl_lieferservice/domain/entity/delivery.dart';
|
||||
import 'package:hl_lieferservice/domain/entity/payment_method.dart';
|
||||
import 'package:hl_lieferservice/domain/entity/tour_details.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/bloc/tour_bloc.dart';
|
||||
import 'package:hl_lieferservice/feature/payment_methods/bloc/payment_methods_cubit.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/bloc/tour_event.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/bloc/tour_state.dart';
|
||||
import 'package:hl_lieferservice/model/delivery.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/presentation/delivery_sign.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/bloc/workflow_bloc.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/bloc/workflow_event.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/bloc/workflow_state.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/presentation/steps/step_articles.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/presentation/steps/step_info.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/presentation/steps/step_notes.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/presentation/steps/step_services.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/presentation/steps/step_summary.dart';
|
||||
|
||||
class DeliveryDetail extends StatefulWidget {
|
||||
final String deliveryId;
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Backend-TODOs (siehe Roadmap unten in diesem File)
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
//
|
||||
// Die folgenden UI-Features sind aktuell als lokaler Stub im
|
||||
// `DeliveryWorkflowBloc` gebaut. Sie persistieren nichts am Server und
|
||||
// gehen verloren, sobald die Detail-Page geschlossen wird:
|
||||
//
|
||||
// * **B1 Bild-Notizen**: Foto-Upload-Endpoint fehlt. Domain-Feld
|
||||
// `DeliveryNote.image_attachment` existiert bereits als
|
||||
// Storage-Key — wir brauchen einen Endpoint, der Multipart-Upload
|
||||
// entgegennimmt und den Key zurückgibt, dann hier
|
||||
// `tourBloc.add(AddDeliveryNote(imageAttachment: key))` aufrufen.
|
||||
//
|
||||
// * ~~B4 Zahlungsmethode beim Abschluss ändern~~ — ERLEDIGT: Die im
|
||||
// Summary gewählte Methode (`paymentMethodOverrideId` im Workflow-State)
|
||||
// reist beim Abschluss am `/complete`-Endpoint mit und wird atomar auf
|
||||
// der Lieferung persistiert (Server prüft existiert + aktiv).
|
||||
//
|
||||
// * **B5 Unterschrift**: Signature-Pad-Bilder (Kunde + Fahrer)
|
||||
// hochladen + auf der Lieferung speichern. Backend hat dafür weder
|
||||
// Felder noch Endpoint. Explizit „nach der Session" verschoben.
|
||||
//
|
||||
// * **B6 Notiz-Templates**: Stammdaten (vordefinierte Notiz-Texte
|
||||
// zum Auswählen). Im alten Stand schon UI-seitig im NoteAddDialog
|
||||
// vorbereitet; aktuell zeigen wir nur das freie Textfeld.
|
||||
//
|
||||
// * **B7 `completeDelivery` im Frontend**: Repository-Methode +
|
||||
// Bloc-Event fehlt. Backend-Endpoint existiert (parameterlos).
|
||||
// Trigger: „Unterschreiben"-Button im Summary-Step — derzeit
|
||||
// SnackBar-Stub.
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
/// Multi-Step Detail-Page einer einzelnen Lieferung. Hülle für 5 Steps;
|
||||
/// jeder Step bekommt die aktuelle `Delivery` + `TourDetails` als Props,
|
||||
/// damit die Steps keine eigenen Bloc-Subscriptions auf die Tour brauchen.
|
||||
///
|
||||
/// Lifetime: die Page bringt ihren eigenen `DeliveryWorkflowBloc` mit
|
||||
/// (siehe `BlocProvider` unten). Beim Pop wird der Bloc samt Drafts
|
||||
/// disposed — gewollt, denn ein neuer Besuch der Detail-Page startet
|
||||
/// frisch im Step „Info".
|
||||
class DeliveryDetail extends StatelessWidget {
|
||||
const DeliveryDetail({super.key, required this.deliveryId});
|
||||
|
||||
final String deliveryId;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _DeliveryDetailState();
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (_) => DeliveryWorkflowBloc(deliveryId: deliveryId),
|
||||
child: _DeliveryDetailScaffold(deliveryId: deliveryId),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _DeliveryDetailState extends State<DeliveryDetail> {
|
||||
late int _step;
|
||||
late List<EasyStep> _steps;
|
||||
class _DeliveryDetailScaffold extends StatelessWidget {
|
||||
const _DeliveryDetailScaffold({required this.deliveryId});
|
||||
|
||||
final String deliveryId;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// Reset Note BLOC
|
||||
// otherwise the notes of the previously
|
||||
// opened delivery would be loaded
|
||||
context.read<NoteBloc>().add(ResetNotes());
|
||||
|
||||
// Initialize steps
|
||||
_step = 0;
|
||||
_steps = [
|
||||
EasyStep(
|
||||
icon: const Icon(Icons.info),
|
||||
customTitle: Text("Info", textAlign: TextAlign.center),
|
||||
),
|
||||
EasyStep(
|
||||
icon: const Icon(Icons.book),
|
||||
customTitle: Text("Notizen", textAlign: TextAlign.center),
|
||||
),
|
||||
EasyStep(
|
||||
icon: const Icon(Icons.shopping_cart),
|
||||
customTitle: Text("Artikel/Gutschriften", textAlign: TextAlign.center),
|
||||
),
|
||||
EasyStep(
|
||||
icon: const Icon(Icons.settings),
|
||||
customTitle: Text("Optionen", textAlign: TextAlign.center),
|
||||
),
|
||||
EasyStep(
|
||||
icon: const Icon(Icons.check_box),
|
||||
customTitle: Text(
|
||||
"Überprüfen",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.clip,
|
||||
),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
Widget _stepInfo() {
|
||||
return DecoratedBox(
|
||||
decoration: const BoxDecoration(),
|
||||
child: SizedBox(
|
||||
height: 115,
|
||||
child: EasyStepper(
|
||||
activeStep: _step,
|
||||
showLoadingAnimation: false,
|
||||
activeStepTextColor: Theme.of(context).primaryColor,
|
||||
activeStepBorderType: BorderType.dotted,
|
||||
finishedStepBorderType: BorderType.normal,
|
||||
unreachedStepBorderType: BorderType.normal,
|
||||
activeStepBackgroundColor: Colors.white,
|
||||
borderThickness: 2,
|
||||
internalPadding: 0.0,
|
||||
enableStepTapping: true,
|
||||
stepRadius: 25.0,
|
||||
onStepReached:
|
||||
(index) => {
|
||||
setState(() {
|
||||
_step = index;
|
||||
}),
|
||||
},
|
||||
steps: _steps,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _stepMissingWarning() {
|
||||
return Center(
|
||||
child: Text("Kein Inhalt für den aktuellen Step $_step gefunden."),
|
||||
);
|
||||
}
|
||||
|
||||
void _clickForward() {
|
||||
if (_step < _steps.length) {
|
||||
setState(() {
|
||||
_step += 1;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _clickBack() {
|
||||
if (_step > 0) {
|
||||
setState(() {
|
||||
_step -= 1;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _openSignatureView(Delivery delivery) {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (_) {
|
||||
return BlocProvider.value(
|
||||
value: context.read<NoteBloc>(),
|
||||
child: SignatureView(onSigned: _onSign, delivery: delivery),
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return BlocBuilder<TourBloc, TourState>(
|
||||
builder: (context, tourState) {
|
||||
if (tourState is! TourLoaded) {
|
||||
return const Scaffold(
|
||||
body: Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _onSign(Uint8List customer, Uint8List driver) async {
|
||||
context.read<TourBloc>().add(
|
||||
FinishDeliveryEvent(
|
||||
deliveryId: widget.deliveryId,
|
||||
customerSignature: customer,
|
||||
driverSignature: driver,
|
||||
),
|
||||
);
|
||||
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
Widget _stepsNavigation(Delivery delivery) {
|
||||
return SafeArea(
|
||||
top: false,
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
height: 90,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
OutlinedButton(
|
||||
onPressed: _step == 0 ? null : _clickBack,
|
||||
child: const Text("zurück"),
|
||||
}
|
||||
final details = tourState.details;
|
||||
final delivery = _findDelivery(details);
|
||||
if (delivery == null) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Lieferung')),
|
||||
body: Center(
|
||||
child: Text('Lieferung $deliveryId nicht in der Tour gefunden.'),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20),
|
||||
child: FilledButton(
|
||||
onPressed: () {
|
||||
if (_step == _steps.length - 1) {
|
||||
_openSignatureView(delivery);
|
||||
} else {
|
||||
_clickForward();
|
||||
}
|
||||
},
|
||||
child:
|
||||
_step == _steps.length - 1
|
||||
? const Text("Unterschreiben")
|
||||
: const Text("weiter"),
|
||||
);
|
||||
}
|
||||
final customer = details.customerOf(delivery);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: theme.primaryColor,
|
||||
foregroundColor: theme.colorScheme.onPrimary,
|
||||
title: Text(customer?.name ?? 'Lieferung'),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
const _StepHeader(),
|
||||
const Divider(height: 1),
|
||||
Expanded(
|
||||
child: _StepBody(delivery: delivery, details: details),
|
||||
),
|
||||
const Divider(height: 1),
|
||||
_BottomNav(delivery: delivery, details: details),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Delivery? _findDelivery(TourDetails details) {
|
||||
for (final d in details.deliveries) {
|
||||
if (d.id == deliveryId) return d;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Step-Header (Pills) ────────────────────────────────────────────────
|
||||
|
||||
class _StepHeader extends StatelessWidget {
|
||||
const _StepHeader();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<DeliveryWorkflowBloc, DeliveryWorkflowState>(
|
||||
builder: (context, state) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(8, 10, 8, 10),
|
||||
child: Row(
|
||||
children: [
|
||||
for (int i = 0; i < WorkflowStep.values.length; i++) ...[
|
||||
Expanded(
|
||||
child: _StepPill(
|
||||
index: i,
|
||||
step: WorkflowStep.values[i],
|
||||
isActive: state.step.index == i,
|
||||
isPassed: state.step.index > i,
|
||||
onTap: () => context
|
||||
.read<DeliveryWorkflowBloc>()
|
||||
.add(WorkflowGoToStep(WorkflowStep.values[i])),
|
||||
),
|
||||
),
|
||||
if (i < WorkflowStep.values.length - 1)
|
||||
_StepConnector(isPassed: state.step.index > i),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _StepPill extends StatelessWidget {
|
||||
const _StepPill({
|
||||
required this.index,
|
||||
required this.step,
|
||||
required this.isActive,
|
||||
required this.isPassed,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
final int index;
|
||||
final WorkflowStep step;
|
||||
final bool isActive;
|
||||
final bool isPassed;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final primary = theme.colorScheme.primary;
|
||||
|
||||
final Color circleColor;
|
||||
final Color circleFg;
|
||||
final Color labelColor;
|
||||
final FontWeight labelWeight;
|
||||
|
||||
if (isActive) {
|
||||
circleColor = primary;
|
||||
circleFg = theme.colorScheme.onPrimary;
|
||||
labelColor = primary;
|
||||
labelWeight = FontWeight.w700;
|
||||
} else if (isPassed) {
|
||||
circleColor = primary.withValues(alpha: 0.85);
|
||||
circleFg = theme.colorScheme.onPrimary;
|
||||
labelColor = primary;
|
||||
labelWeight = FontWeight.w600;
|
||||
} else {
|
||||
circleColor = theme.colorScheme.surfaceContainerHighest;
|
||||
circleFg = theme.colorScheme.onSurfaceVariant;
|
||||
labelColor = theme.colorScheme.onSurfaceVariant;
|
||||
labelWeight = FontWeight.w500;
|
||||
}
|
||||
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 30,
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: circleColor,
|
||||
shape: BoxShape.circle,
|
||||
border: isActive
|
||||
? Border.all(color: primary, width: 2)
|
||||
: null,
|
||||
),
|
||||
child: Center(
|
||||
child: isPassed && !isActive
|
||||
? Icon(Icons.check, color: circleFg, size: 16)
|
||||
: Text(
|
||||
'${index + 1}',
|
||||
style: TextStyle(
|
||||
color: circleFg,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
step.shortName,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: labelColor,
|
||||
fontSize: 11,
|
||||
fontWeight: labelWeight,
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -175,37 +259,186 @@ class _DeliveryDetailState extends State<DeliveryDetail> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _StepConnector extends StatelessWidget {
|
||||
const _StepConnector({required this.isPassed});
|
||||
final bool isPassed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<TourBloc, TourState>(
|
||||
builder: (context, state) {
|
||||
Delivery? delivery;
|
||||
if (state is TourLoaded) {
|
||||
delivery = state.tour.deliveries.firstWhere(
|
||||
(d) => d.id == widget.deliveryId,
|
||||
);
|
||||
}
|
||||
final theme = Theme.of(context);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 18),
|
||||
child: Container(
|
||||
width: 10,
|
||||
height: 2,
|
||||
color: isPassed
|
||||
? theme.colorScheme.primary
|
||||
: theme.colorScheme.surfaceContainerHighest,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text("Auslieferungsdetails")),
|
||||
body: delivery == null
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: Column(
|
||||
children: [
|
||||
_stepInfo(),
|
||||
const Divider(),
|
||||
Expanded(
|
||||
child:
|
||||
StepFactory().make(_step, delivery) ??
|
||||
_stepMissingWarning(),
|
||||
),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar:
|
||||
delivery == null ? null : _stepsNavigation(delivery),
|
||||
);
|
||||
// ─── Step-Body Router ───────────────────────────────────────────────────
|
||||
|
||||
class _StepBody extends StatelessWidget {
|
||||
const _StepBody({required this.delivery, required this.details});
|
||||
|
||||
final Delivery delivery;
|
||||
final TourDetails details;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<DeliveryWorkflowBloc, DeliveryWorkflowState>(
|
||||
buildWhen: (prev, curr) => prev.step != curr.step,
|
||||
builder: (context, state) {
|
||||
switch (state.step) {
|
||||
case WorkflowStep.info:
|
||||
return StepInfo(delivery: delivery, details: details);
|
||||
case WorkflowStep.notes:
|
||||
return StepNotes(delivery: delivery, details: details);
|
||||
case WorkflowStep.articles:
|
||||
return StepArticles(delivery: delivery, details: details);
|
||||
case WorkflowStep.services:
|
||||
return StepServices(delivery: delivery, details: details);
|
||||
case WorkflowStep.summary:
|
||||
return StepSummary(delivery: delivery, details: details);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Bottom-Navigation ──────────────────────────────────────────────────
|
||||
|
||||
class _BottomNav extends StatelessWidget {
|
||||
const _BottomNav({required this.delivery, required this.details});
|
||||
|
||||
final Delivery delivery;
|
||||
final TourDetails details;
|
||||
|
||||
/// Öffnet den zweistufigen Unterschrift-Flow (Kunde → Fahrer). Erst nach
|
||||
/// beiden Unterschriften triggert die View den Backend-Abschluss via
|
||||
/// `CompleteDelivery`; danach poppt sie zurück auf die Detail-Page, die
|
||||
/// dann den `completed`-Status zeigt.
|
||||
void _onSign(BuildContext context) {
|
||||
final tourBloc = context.read<TourBloc>();
|
||||
// Die im Summary-Step gewählte Zahlungsmethode lebt im Workflow-State.
|
||||
// Beim Abschluss reisen wir sie mit ans Backend (atomar mit der Signatur);
|
||||
// `null` = die am Beleg hinterlegte Methode bleibt.
|
||||
final paymentMethodOverrideId =
|
||||
context.read<DeliveryWorkflowBloc>().state.paymentMethodOverrideId;
|
||||
|
||||
// Offener Betrag = Warenwert − Anzahlung − Gutschrift (≥ 0). EXAKT die
|
||||
// Formel aus StepSummary und dem Backend-Inkasso-Gate.
|
||||
final creditEuros =
|
||||
(details.creditOf(delivery.id)?.amountCents ?? 0) / 100.0;
|
||||
final warenwert =
|
||||
delivery.items.fold<double>(0, (acc, item) => acc + item.lineTotal);
|
||||
final open = (warenwert - delivery.prepaidAmount - creditEuros)
|
||||
.clamp(0.0, double.infinity)
|
||||
.toDouble();
|
||||
|
||||
// Effektive Methode (Override > Beleg) auflösen, um Vor-Ort-Inkasso
|
||||
// (Bar/EC) von „Auf Rechnung" zu unterscheiden.
|
||||
final effectiveMethodId =
|
||||
paymentMethodOverrideId ?? delivery.paymentMethodId;
|
||||
final pmState = context.read<PaymentMethodsCubit>().state;
|
||||
PaymentMethod? method;
|
||||
if (pmState is PaymentMethodsLoaded) {
|
||||
for (final m in pmState.methods) {
|
||||
if (m.id == effectiveMethodId) {
|
||||
method = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Inkasso-Pflicht: offener Betrag > 0 UND Bar/EC. „Auf Rechnung" → nein.
|
||||
final requiresCollection =
|
||||
open > 0 && (method?.code == 'cash' || method?.code == 'ec_card');
|
||||
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute<void>(
|
||||
builder: (routeContext) => SignatureView(
|
||||
delivery: delivery,
|
||||
details: details,
|
||||
requiresCollection: requiresCollection,
|
||||
openAmount: open,
|
||||
paymentMethodLabel: method?.name ?? '',
|
||||
onSigned: (result) {
|
||||
tourBloc.add(CompleteDelivery(
|
||||
deliveryId: delivery.id,
|
||||
customerSignaturePng: result.customerSignaturePng,
|
||||
driverSignaturePng: result.driverSignaturePng,
|
||||
receiptConfirmed: result.receiptConfirmed,
|
||||
notesAcknowledged: result.notesAcknowledged,
|
||||
acknowledgedNoteIds: result.acknowledgedNoteIds,
|
||||
paymentMethodId: paymentMethodOverrideId,
|
||||
paymentCollected: result.paymentCollected,
|
||||
));
|
||||
Navigator.of(routeContext).pop();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
top: false,
|
||||
child: BlocBuilder<DeliveryWorkflowBloc, DeliveryWorkflowState>(
|
||||
builder: (context, state) {
|
||||
final isFirst = state.step.index == 0;
|
||||
final isLast = state.step.index == WorkflowStep.values.length - 1;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 10, 16, 10),
|
||||
child: Row(
|
||||
children: [
|
||||
OutlinedButton.icon(
|
||||
onPressed: isFirst
|
||||
? null
|
||||
: () => context
|
||||
.read<DeliveryWorkflowBloc>()
|
||||
.add(const WorkflowPreviousStep()),
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
label: const Text('Zurück'),
|
||||
),
|
||||
const Spacer(),
|
||||
if (isLast)
|
||||
// Unterschreiben/Abschließen nur bei aktiver Lieferung.
|
||||
// Ist sie bereits abgeschlossen (oder pausiert/abgebrochen),
|
||||
// bleibt der Button gesperrt.
|
||||
Builder(builder: (context) {
|
||||
final isActive =
|
||||
delivery.state == DeliveryState.active;
|
||||
final isCompleted =
|
||||
delivery.state == DeliveryState.completed;
|
||||
return FilledButton.icon(
|
||||
onPressed: isActive ? () => _onSign(context) : null,
|
||||
icon: Icon(isCompleted
|
||||
? Icons.check_circle_outline
|
||||
: Icons.draw_outlined),
|
||||
label: Text(
|
||||
isCompleted ? 'Abgeschlossen' : 'Unterschreiben',
|
||||
),
|
||||
);
|
||||
})
|
||||
else
|
||||
FilledButton.icon(
|
||||
onPressed: () => context
|
||||
.read<DeliveryWorkflowBloc>()
|
||||
.add(const WorkflowNextStep()),
|
||||
icon: const Icon(Icons.arrow_forward),
|
||||
label: const Text('Weiter'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user