import 'package:comwell_key_app/hotel_information/cubit/hotel_information_cubit.dart';
import 'package:comwell_key_app/hotel_information/hotel_information_page.dart';
import 'package:comwell_key_app/hotel_information/models/facilities.dart';
import 'package:comwell_key_app/hotel_information/pages/facility_page.dart';
import 'package:comwell_key_app/hotel_information/pages/hotel_information_menu.dart';
import 'package:comwell_key_app/overview/models/booking.dart';
import 'package:comwell_key_app/routing/app_router.dart';
import 'package:comwell_key_app/routing/app_routes.dart';
import 'package:comwell_key_app/utils/locator.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';

final _shellNavigatorKey = GlobalKey<NavigatorState>();

final hotelInformationRoute = ShellRoute(
  navigatorKey: _shellNavigatorKey,
  parentNavigatorKey: rootNavigatorKey,
  pageBuilder: (context, state, child) {
    return NoTransitionPage(
      child: BlocProvider(
        create: (_) => HotelInformationCubit(
          hotelInformationRepository: locator(),
          booking: state.extra as Booking,
        ),
        child: HotelInformationPage(child: child),
      ),
    );
  },
  routes: [
    GoRoute(
      path: AppRoutes.hotelInformation,
      builder: (context, state) {
        return const HotelInformationMenu();
      },
    ),
    GoRoute(
      path: "${AppRoutes.hotelInformation}${AppRoutes.facility}",
      name: "${AppRoutes.hotelInformation}${AppRoutes.facility}",
      builder: (context, state) {
        return FacilityPage(facility: state.extra as Facility);
      },
    ),
  ],
);