Added fail pages to retry the failed operation to delivery overview, notes and cars. Furthermore, I added better handling if the user is finished scanning articles.

This commit is contained in:
Dennis Nemec
2026-01-29 16:45:29 +01:00
parent 366a3560dc
commit 8cf0ea4e9a
11 changed files with 319 additions and 223 deletions

View File

@ -13,9 +13,11 @@ import 'package:hl_lieferservice/model/article.dart';
import 'package:hl_lieferservice/model/car.dart';
import 'package:hl_lieferservice/model/delivery.dart';
import 'package:hl_lieferservice/model/tour.dart';
import 'package:hl_lieferservice/widget/home/bloc/navigation_event.dart';
import 'package:hl_lieferservice/widget/operations/bloc/operation_bloc.dart';
import 'package:hl_lieferservice/widget/operations/bloc/operation_event.dart';
import '../../../widget/home/bloc/navigation_bloc.dart';
import '../../delivery/bloc/tour_bloc.dart';
class ArticleScanningScreen extends StatefulWidget {
@ -287,7 +289,9 @@ class _ArticleScanningScreenState extends State<ArticleScanningScreen> {
isExpanded: true,
items:
deliveries
.where((delivery) => delivery.state != DeliveryState.finished)
.where(
(delivery) => delivery.state != DeliveryState.finished,
)
.mapIndexed(
(index, delivery) => DropdownMenuItem(
value: index,
@ -343,6 +347,45 @@ class _ArticleScanningScreenState extends State<ArticleScanningScreen> {
}
}
// Also count aborted or hold deliveries as "delivered"
final allDeliveredOrAllScanned = tour.deliveries
.where((delivery) => delivery.state != DeliveryState.finished)
.every((delivery) => delivery.allArticlesScanned());
if (allDeliveredOrAllScanned) {
return Padding(
padding: const EdgeInsets.all(25),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 25),
child: Icon(
Icons.check_circle_outline,
size: 72,
color: Theme.of(context).colorScheme.primary,
),
),
Text("Alles erledigt - es gibt nichts mehr zu scannen!"),
Padding(
padding: const EdgeInsets.only(top: 25),
child: FilledButton(
onPressed: () {
Navigator.of(context).pop();
context.read<NavigationBloc>().add(
NavigateToIndex(index: 1),
);
},
child: Text("Tour starten"),
),
),
],
),
),
);
}
return Padding(
padding: const EdgeInsets.all(0),
child: Column(
@ -363,34 +406,57 @@ class _ArticleScanningScreenState extends State<ArticleScanningScreen> {
if (state is TourLoaded) {
Delivery delivery = state.tour.deliveries[_selectedDelivery];
// Also count aborted or hold deliveries as "delivered"
final allDeliveredOrAllScanned = state.tour.deliveries
.where((delivery) => delivery.state != DeliveryState.finished)
.every((delivery) => delivery.allArticlesScanned());
return Scaffold(
appBar: AppBar(
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
delivery.customer.name,
style: TextStyle(
color: Theme.of(context).colorScheme.onSecondary,
fontWeight: FontWeight.w500,
),
),
Text(
delivery.customer.address.toString(),
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.normal,
color: Theme.of(context).colorScheme.onSecondary,
),
),
],
),
title:
allDeliveredOrAllScanned
? Text(
"Artikel scannen",
style: TextStyle(
color: Theme.of(context).colorScheme.onSecondary,
),
)
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
delivery.customer.name,
style: TextStyle(
color: Theme.of(context).colorScheme.onSecondary,
fontWeight: FontWeight.w500,
),
),
Text(
delivery.customer.address.toString(),
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.normal,
color: Theme.of(context).colorScheme.onSecondary,
),
),
],
),
backgroundColor: Theme.of(context).primaryColor,
),
bottomNavigationBar: Padding(
padding: const EdgeInsets.all(25),
child: _navigation(state.tour.deliveries),
),
bottomNavigationBar:
allDeliveredOrAllScanned
? Text("")
: Padding(
padding: const EdgeInsets.all(25),
child: _navigation(
state.tour.deliveries
.where(
(delivery) =>
delivery.state == DeliveryState.ongoing,
)
.toList(),
),
),
body: KeyboardListener(
focusNode: _focusNode,
onKeyEvent: _handleKey,