import 'package:flutter/cupertino.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_otp_code_login_usecase.dart';
import 'package:food_delivery_client/feature/auth/presentation/pages/forgot_password_page/forgot_password_page.dart';
import 'package:food_delivery_client/feature/auth/presentation/pages/login_page/login_page.dart';
import 'package:food_delivery_client/feature/auth/presentation/pages/register_page/register_page.dart';
import 'package:food_delivery_client/feature/auth/presentation/pages/reset_password_page/reset_password_page.dart';
import 'package:food_delivery_client/feature/auth/presentation/pages/verify_otp_code_page/verify_otp_code_page.dart';
import 'package:food_delivery_client/feature/auth/presentation/pages/verify_phone_number_page/verify_phone_page.dart';
import 'package:food_delivery_client/feature/home/presentation/pages/restaurants_by_category_page/restaurants_by_category_page.dart';

import '../../food_delivery_client.dart';

final GlobalKey<NavigatorState> navigatorKey = GlobalKey();

@singleton
class AppRoutes {
  final GoRouter router = GoRouter(
    navigatorKey: navigatorKey,
    initialLocation: Routes.splash,
    routes: [
      GoRoute(path: Routes.splash, builder: (context, state) => SplashPage()),
      GoRoute(
        path: Routes.login,
        pageBuilder: (context, state) => CupertinoPage(child: LoginPage()),
      ),

      GoRoute(
        path: Routes.register,
        pageBuilder: (context, state) => CupertinoPage(
          child: RegisterPage(phoneNumber: state.extra as String),
        ),
      ),
      GoRoute(
        path: Routes.forgotPassword,
        pageBuilder: (context, state) =>
            CupertinoPage(child: ForgotPasswordPage()),
      ),
      GoRoute(
        path: Routes.verifyPhoneNumber,
        pageBuilder: (context, state) => CupertinoPage(
          child: VerifyPhoneNumberPage(isRegister: state.extra as bool),
        ),
      ),

      GoRoute(
        path: Routes.verifyOtpCode,
        pageBuilder: (context, state) => CupertinoPage(
          child: VerifyOtpCodePage(params: state.extra as OtpCodePageParams),
        ),
      ),

      GoRoute(
        path: Routes.resetPassword,
        pageBuilder: (context, state) => CupertinoPage(
          child: ResetPasswordPage(phoneNumber: state.extra as String),
        ),
      ),

      GoRoute(
        path: Routes.main,
        pageBuilder: (context, state) => CupertinoPage(child: MainPage()),
      ),
      GoRoute(
        path: Routes.categories,
        pageBuilder: (context, state) => CupertinoPage(child: CategoriesPage()),
      ),
      GoRoute(
        path: Routes.filters,
        pageBuilder: (context, state) => CupertinoPage(
          child: FiltersPage(homeBloc: state.extra as HomeBloc),
        ),
      ),
      GoRoute(
        path: Routes.restaurantsByCategory,
        pageBuilder: (context, state) => CupertinoPage(
          child: RestaurantsByCategoryPage(categoryName: state.extra as String),
        ),
      ),
      GoRoute(
        path: Routes.browse,
        pageBuilder: (context, state) => CupertinoPage(child: BrowsePage()),
      ),
    ],
  );
}
