import 'package:app_petty_cash/screen/change_pasword/change_password_screen.dart';

import '../screen/change_company/change_company.dart';
import 'package:app_petty_cash/screen/camera/coba_camera.dart';
import 'package:app_petty_cash/screen/camera/example.dart';
import 'package:flutter/material.dart';

import '../screen/home/home_screen.dart';
import '../screen/transaksi/history_transaksi_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";
const changeCompanyRoute = "/changeCompanyRoute";
const changePasswordRoute = "/changePasswordRoute";
const historyTransaksiRoute = "/historyTransaksiRoute";
const cameraExampleRoute = "/cameraExampleRoute";
const cobaCameraRoute = "/cobaCameraRoute";

// 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(),
        );
      });
    }

    // change Company
    if (settings.name == changeCompanyRoute) {
      return MaterialPageRoute(builder: (context) {
        return MediaQuery(
          data: MediaQuery.of(context).copyWith(
            textScaleFactor: 1.0,
            padding: EdgeInsets.all(0),
          ),
          child: ChangeCompanyScreen(),
        );
      });
    }

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

    // 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(),
        );
      });
    }
    // transaksi screen
    if (settings.name == changePasswordRoute) {
      return MaterialPageRoute(builder: (context) {
        return MediaQuery(
          data: MediaQuery.of(context).copyWith(
            textScaleFactor: 1.0,
            padding: EdgeInsets.all(0),
          ),
          child: ChangePasswordScreen(),
        );
      });
    }

    // 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(),
        );
      });
    }
    // Camera example route
    if (settings.name == cameraExampleRoute) {
      return MaterialPageRoute(builder: (context) {
        return MediaQuery(
          data: MediaQuery.of(context).copyWith(
            textScaleFactor: 1.0,
            padding: EdgeInsets.all(0),
          ),
          child: CamerExample(),
        );
      });
    }
    // Coba Camera route
    if (settings.name == cobaCameraRoute) {
      return MaterialPageRoute(builder: (context) {
        return MediaQuery(
          data: MediaQuery.of(context).copyWith(
            textScaleFactor: 1.0,
            padding: EdgeInsets.all(0),
          ),
          child: CobaCamera(),
        );
      });
    }

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