import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.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<StatefulWidget> createState() => _DeliveryOverviewPageState();
}

class _DeliveryOverviewPageState extends State<DeliveryOverviewPage> {
  @override
  Widget build(BuildContext context) {
    return BlocBuilder<TourBloc, TourState>(
      builder: (context, state) {
        if (state is TourLoaded) {
          final currentState = state;

          return Center(
            child: DeliveryOverview(
              tour: currentState.tour,
              distances: currentState.distances ?? {},
            ),
          );
        }

        return Container();
      },
    );
  }
}
