
import 'package:flutter/material.dart';

import '../screen/home/home_screen.dart';
import '../screen/transaksi/transaksi_screen.dart';
import '../screen/login/login_screen.dart';
import '../screen/splash/splash_screen.dart';
import '../screen/test_file_picker/test_file_picker.dart';
import '../screen/report/report_screen.dart';
import '../screen/user/user_screen.dart';

const loginRoute = "/loginRoute";
const menuRoute = "/menuRoute";
const splashScreen = "/splashScreen";
const homeRoute = "/homeRoute";
const transaksiRoute = "/transaksiRoute";
const userRoute = "/userRoute";
const reportRoute = "/reportRoute";

// test screen
const testFilePickerRoute = "/testFilePickerRoute";

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

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

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

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

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

    // test file picker screen
    if (settings.name == testFilePickerRoute) {
      return MaterialPageRoute(builder: (context) {
        return MediaQuery(
          data: MediaQuery.of(context).copyWith(
            textScaleFactor: 1.0,
            padding: EdgeInsets.all(0),
          ),
          child: TestFilePicker(),
        );
      });
    }

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