import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:hl_lieferservice/feature/car_selection/bloc/bloc.dart'; import 'package:hl_lieferservice/feature/car_selection/bloc/state.dart'; import 'package:hl_lieferservice/feature/delivery/overview/presentation/delivery_fail_page.dart'; import 'package:hl_lieferservice/feature/delivery/overview/presentation/delivery_overview.dart'; import '../../bloc/tour_bloc.dart'; import '../../bloc/tour_state.dart'; class DeliveryOverviewPage extends StatefulWidget { const DeliveryOverviewPage({super.key}); @override State createState() => _DeliveryOverviewPageState(); } class _DeliveryOverviewPageState extends State { @override Widget build(BuildContext context) { final carState = context.watch().state; return Scaffold( appBar: AppBar( title: const Text("Auslieferung"), centerTitle: false, backgroundColor: Theme.of(context).primaryColor, foregroundColor: Theme.of(context).colorScheme.onSecondary, actions: [ if (carState is CarSelectComplete) Padding( padding: const EdgeInsets.only(right: 16), child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( Icons.local_shipping, color: Theme.of(context).colorScheme.onSecondary, size: 20, ), const SizedBox(width: 6), Text( carState.selectedCar.plate, style: TextStyle( color: Theme.of(context).colorScheme.onSecondary, fontWeight: FontWeight.bold, ), ), ], ), ), ], ), body: BlocBuilder( builder: (context, state) { if (state is TourLoaded) { return DeliveryOverview( tour: state.tour, distances: state.distances ?? {}, ); } if (state is TourLoadingFailed) { return DeliveryLoadingFailedPage(); } return const Center(child: CircularProgressIndicator()); }, ), ); } }