Clean-Arch-Schichten für Cars: - lib/domain/entity/car.dart: UUID-id, accountId (Personalnummer), plate, active. Pendant zum Backend-Schema. - lib/domain/repository/cars_repository.dart: Port — listMine, create, update. Keine teamId/personalnummer-Parameter, der Account fließt serverseitig aus dem JWT. - lib/data/mapper/car_mapper.dart: API-DTO (built_value) → Domain. - lib/data/repository/cars_repository_impl.dart: konkrete Impl via generierter CarsApi (dio), mit DioException → CarsRepositoryException- Übersetzung. Feature-Cars-Refactoring: - CarsBloc nimmt jetzt die Domain-Repository-Schnittstelle. Events: CarLoad/CarAdd/CarEdit/CarDeactivate (statt CarDelete). Keine teamId-Parameter mehr. Kein authBloc-Bezug, Session-Expiry läuft über den globalen Provider-Stream. - CarsState sealed mit CarsInitial/Loading/LoadingFailed/Loaded. - Pages: car_management_page, car_management, car_card, car_fail_page, car_selection_page komplett auf die neue Entity und Event-Signaturen. - Alte lib/feature/cars/service/cars_service.dart und lib/feature/cars/repository/cars_repository.dart gelöscht. CarSelectBloc + Storage: - CarSelection.selectedCarId von int? auf String? umgestellt. - CarSelectionRepository persistiert die UUID jetzt als String; defensive Migration für noch vorhandene int-Werte (alte Pre-Migration-Installations) verwirft den Wert leise und erzwingt Neuauswahl. Konsequenz-Cleanup im Tour-Code (Phase-D-Vorbereitung): - Delivery.carId String? statt int?. - Tour.hasUndeliveredLoadedArticles / getFinishedDeliveries auf String carId. - _selectedCarId / int? carId / int selectedCarId in DeliveryOverview, LoadingCustomerPage/OverviewPage, Home, DeliverySelection/SortPage, DeliveryInfo/List, CustomSortDialog, SortableDeliveryList auf String umgestellt. - TourRepository ersetzt int.parse(carId)/int.tryParse-Zuweisungen direkt durch String. - lib/model/car.dart wird zum Re-Export der neuen Domain-Entity, damit Legacy-Imports während Phase-D-Übergang weiter compilieren. DI: - app.dart: CarsBloc bekommt CarsRepositoryImpl(locator<HolzleitnerApi>()) statt der alten CarsRepository(service: CarService()). Build (flutter build apk --debug) durch, flutter analyze ohne errors.
88 lines
3.0 KiB
Dart
88 lines
3.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:hl_lieferservice/model/delivery.dart' show DeliveryState;
|
|
import 'package:hl_lieferservice/model/tour.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
class DeliveryInfo extends StatelessWidget {
|
|
final Tour tour;
|
|
final String? selectedCarId;
|
|
|
|
const DeliveryInfo({super.key, required this.tour, this.selectedCarId});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final String date = DateFormat("dd.MM.yyyy").format(tour.date);
|
|
final relevantDeliveries = selectedCarId != null
|
|
? tour.deliveries.where((d) => d.carId == selectedCarId).toList()
|
|
: tour.deliveries;
|
|
final total = relevantDeliveries.length;
|
|
final done = relevantDeliveries
|
|
.where((d) => d.state == DeliveryState.finished)
|
|
.length;
|
|
final progress = total > 0 ? done / total : 0.0;
|
|
final allDone = total > 0 && done == total;
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 15),
|
|
child: SizedBox(
|
|
width: double.infinity,
|
|
child: Card(
|
|
color: Theme.of(context).colorScheme.onSecondary,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
const Icon(Icons.calendar_month),
|
|
const Padding(
|
|
padding: EdgeInsets.only(left: 5),
|
|
child: Text("Datum"),
|
|
),
|
|
],
|
|
),
|
|
Text(date),
|
|
],
|
|
),
|
|
const SizedBox(height: 15),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
const Icon(Icons.local_shipping_outlined),
|
|
const Padding(
|
|
padding: EdgeInsets.only(left: 5),
|
|
child: Text("Lieferungen"),
|
|
),
|
|
],
|
|
),
|
|
Text("$done / $total"),
|
|
],
|
|
),
|
|
const SizedBox(height: 10),
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.circular(4),
|
|
child: LinearProgressIndicator(
|
|
value: progress,
|
|
minHeight: 6,
|
|
backgroundColor:
|
|
Theme.of(context).colorScheme.surfaceContainerHighest,
|
|
valueColor: AlwaysStoppedAnimation<Color>(
|
|
allDone ? Colors.green : Theme.of(context).primaryColor,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|