import 'package:absensi_sas/screen/approval/approval_screen.dart';
import 'package:absensi_sas/screen/approval_detail/approval_detail_screen.dart';
import 'package:absensi_sas/screen/home/home_screen_v1.dart';
import 'package:absensi_sas/screen/presensi/presensi_screen.dart';
import 'package:absensi_sas/screen/presensi/presensi_selfie_screen.dart';
import 'package:flutter/material.dart';
import '../screen/home/home_screen.dart';
import '../test_flutter_map.dart';
import '../screen/login/login_screen.dart';
import '../screen/splash/splash_screen.dart';

const loginRoute = "/loginRoute";
const splashRoute = "/splashRoute";
const testFlutterMapRoute = "/testFlutterMapRoute";
const homeRoute = "/homeRoute";
const presensiRoute = "/presensiRoute";
const presensiSelfieRoute = "/presensiSelfieRoute";
const approvalRoute = "/approvalRoute";
const approvalDetailRoute = "/approvalDetailRoute";

class AppRoute {
  static Route<dynamic> generateRoute(RouteSettings settings) {
    // test flutter map
    if (settings.name == testFlutterMapRoute) {
      return MaterialPageRoute(builder: (context) {
        return MediaQuery(
          data: MediaQuery.of(context)
              .copyWith(textScaleFactor: 1.0, padding: EdgeInsets.all(0)),
          child: TestFlutterMap(),
        );
      });
    }

    // home route
    if (settings.name == homeRoute) {
      return MaterialPageRoute(builder: (context) {
        return MediaQuery(
          data: MediaQuery.of(context)
              .copyWith(textScaleFactor: 1.0, padding: EdgeInsets.all(0)),
          child: HomeScreen(),
        );
      });
    }

    // presensi route
    if (settings.name == presensiRoute) {
      return MaterialPageRoute(builder: (context) {
        return MediaQuery(
          data: MediaQuery.of(context)
              .copyWith(textScaleFactor: 1.0, padding: EdgeInsets.all(0)),
          child: PresensiScreen(),
        );
      });
    }

    // presensi selfie route
    if (settings.name == presensiSelfieRoute) {
      return MaterialPageRoute(builder: (context) {
        return MediaQuery(
          data: MediaQuery.of(context)
              .copyWith(textScaleFactor: 1.0, padding: EdgeInsets.all(0)),
          child: PresensiSelfieScreen(),
        );
      });
    }

    // splash screen
    if (settings.name == splashRoute) {
      return MaterialPageRoute(builder: (context) {
        return MediaQuery(
          data: MediaQuery.of(context)
              .copyWith(textScaleFactor: 1.0, padding: EdgeInsets.all(0)),
          child: SplashScreen(),
        );
      });
    }

    // login
    if (settings.name == loginRoute) {
      return MaterialPageRoute(builder: (context) {
        return MediaQuery(
          data: MediaQuery.of(context)
              .copyWith(textScaleFactor: 1.0, padding: EdgeInsets.all(0)),
          child: LoginScreen(),
        );
      });
    }
    // approval
    if (settings.name == approvalRoute) {
      return MaterialPageRoute(builder: (context) {
        return MediaQuery(
          data: MediaQuery.of(context)
              .copyWith(textScaleFactor: 1.0, padding: EdgeInsets.all(0)),
          child: ApprovalScreen(),
        );
      });
    }
    // approvalDetail
    if (settings.name == approvalDetailRoute) {
      return MaterialPageRoute(builder: (context) {
        return MediaQuery(
          data: MediaQuery.of(context)
              .copyWith(textScaleFactor: 1.0, padding: EdgeInsets.all(0)),
          child: ApprovalDetailScreen(),
        );
      });
    }

    return MaterialPageRoute(builder: (context) {
      return MediaQuery(
        data: MediaQuery.of(context)
            .copyWith(textScaleFactor: 1.0, padding: const EdgeInsets.all(0)),
        child: LoginScreen(),
      );
    });
  }
}
