Final commit.
This commit is contained in:
@ -1,23 +1,28 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hl_lieferservice/model/delivery.dart' show DeliveryState;
|
||||
import 'package:hl_lieferservice/model/tour.dart';
|
||||
import 'package:hl_lieferservice/domain/entity/delivery.dart';
|
||||
import 'package:hl_lieferservice/domain/entity/tour_details.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
/// Kopf-Karte der Auslieferungs-Übersicht. Zeigt Datum, Anzahl Lieferungen
|
||||
/// und Fortschrittsbalken — gefiltert auf das aktuell gewählte Fahrzeug,
|
||||
/// damit der Fahrer seine eigene Tagesleistung sieht.
|
||||
class DeliveryInfo extends StatelessWidget {
|
||||
final Tour tour;
|
||||
final TourDetails details;
|
||||
final String? selectedCarId;
|
||||
|
||||
const DeliveryInfo({super.key, required this.tour, this.selectedCarId});
|
||||
const DeliveryInfo({super.key, required this.details, this.selectedCarId});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final String date = DateFormat("dd.MM.yyyy").format(tour.date);
|
||||
final date = DateFormat('dd.MM.yyyy').format(details.tour.date);
|
||||
final relevantDeliveries = selectedCarId != null
|
||||
? tour.deliveries.where((d) => d.carId == selectedCarId).toList()
|
||||
: tour.deliveries;
|
||||
? details.deliveries
|
||||
.where((d) => d.assignedCarId == selectedCarId)
|
||||
.toList()
|
||||
: details.deliveries;
|
||||
final total = relevantDeliveries.length;
|
||||
final done = relevantDeliveries
|
||||
.where((d) => d.state == DeliveryState.finished)
|
||||
.where((d) => d.state == DeliveryState.completed)
|
||||
.length;
|
||||
final progress = total > 0 ? done / total : 0.0;
|
||||
final allDone = total > 0 && done == total;
|
||||
@ -37,11 +42,11 @@ class DeliveryInfo extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.calendar_month),
|
||||
const Padding(
|
||||
children: const [
|
||||
Icon(Icons.calendar_month),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 5),
|
||||
child: Text("Datum"),
|
||||
child: Text('Datum'),
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -53,15 +58,15 @@ class DeliveryInfo extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.local_shipping_outlined),
|
||||
const Padding(
|
||||
children: const [
|
||||
Icon(Icons.local_shipping_outlined),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 5),
|
||||
child: Text("Lieferungen"),
|
||||
child: Text('Lieferungen'),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text("$done / $total"),
|
||||
Text('$done / $total'),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
Reference in New Issue
Block a user