import 'package:flutter/material.dart';
import 'package:tour_travel_agr/page/forgot_password/forgot_password.dart';
import 'package:tour_travel_agr/page/login/login.dart';
import 'package:tour_travel_agr/page/otp_verification/otp_verification.dart';
import 'package:tour_travel_agr/page/home/home.dart';
import 'package:tour_travel_agr/page/register/register.dart';
import 'package:tour_travel_agr/page/reset_password/reset_password.dart';
import 'package:tour_travel_agr/page/splash/splash.dart';

class Routes {
  static const String splashRoute = "/";
  static const String loginRoute = "/login";
  static const String registerRoute = "/register";
  static const String verificationRoute = "/verification";
  static const String forgotPasswordRoute = "/forgot-password";
  static const String resetPasswordRoute = "/reset-password";
  static const String homeRoute = "/home";
  static const String profileRoute = "/profile";
  static const String reimburseRoute = "/reimbursement";
  static const String historyRoute = "/history";
}

class RouteGenerator {
  static Route<dynamic> getRoute(RouteSettings routeSettings) {
    switch (routeSettings.name) {
      case Routes.splashRoute:
        return pageRouteCustom(const SplashView());
      case Routes.loginRoute:
        return pageRouteCustom(LoginView());
      case Routes.registerRoute:
        return pageRouteCustom(const RegisterView());
      case Routes.verificationRoute:
        return pageRouteCustom(const OtpVerificationView());
      case Routes.forgotPasswordRoute:
        return pageRouteCustom(const ForgotPasswordView());
      case Routes.resetPasswordRoute:
        return pageRouteCustom(const ResetPasswordView());
      case Routes.homeRoute:
        return pageRouteCustom(const HomeView());
      default:
        return unDefinedRoute();
    }
  }

  static PageRouteBuilder<dynamic> pageRouteCustom(Widget target) {
    return PageRouteBuilder(
      pageBuilder: (context, a, b) => target,
      transitionDuration: Duration.zero,
      reverseTransitionDuration: Duration.zero,
    );
  }

  static Route<dynamic> unDefinedRoute() {
    return MaterialPageRoute(
      builder: (_) => Scaffold(
        appBar: AppBar(
          title: const Text("No Route Found"),
        ),
        body: const Center(
          child: Text("No Route Found"),
        ),
      ),
    );
  }
}
