import 'dart:math';

import 'package:get/get.dart';
import 'package:making_school_asignment_app/page/global_widget/other_page.dart';
import 'package:making_school_asignment_app/page/global_widget/start_page.dart';
import 'package:making_school_asignment_app/page/home_page/children/annotate_class/annotate_class_binding.dart';
import 'package:making_school_asignment_app/page/home_page/children/annotate_class/annotate_class_view.dart';
import 'package:making_school_asignment_app/page/home_page/children/answer_trajectory/answer_trajectory_binding.dart';
import 'package:making_school_asignment_app/page/home_page/children/answer_trajectory/answer_trajectory_view.dart';
import 'package:making_school_asignment_app/page/home_page/children/answer_trajectory_detail/answer_trajectory_detail_binding.dart';
import 'package:making_school_asignment_app/page/home_page/children/answer_trajectory_detail/answer_trajectory_detail_view.dart';
import 'package:making_school_asignment_app/page/home_page/children/class_student/class_student_binding.dart';
import 'package:making_school_asignment_app/page/home_page/children/class_student/class_student_view.dart';
import 'package:making_school_asignment_app/page/home_page/children/fav_student/fav_student_binding.dart';
import 'package:making_school_asignment_app/page/home_page/children/fav_student/fav_student_view.dart';
import 'package:making_school_asignment_app/page/home_page/children/homework_review/configuration_files/index.dart';
import 'package:making_school_asignment_app/page/home_page/children/homework_review/configuration_files/zoom_logic.dart';
import 'package:making_school_asignment_app/page/home_page/children/homework_review/index.dart';
import 'package:making_school_asignment_app/page/home_page/children/job_report/job_report_binding.dart';
import 'package:making_school_asignment_app/page/home_page/children/job_report/job_report_view.dart';
import 'package:making_school_asignment_app/page/home_page/children/knowledge_points_grasp/knowledge_points_grasp_binding.dart';
import 'package:making_school_asignment_app/page/home_page/children/knowledge_points_grasp/knowledge_points_grasp_view.dart';
import 'package:making_school_asignment_app/page/home_page/children/knowledge_points_grasp_detail/knowledge_points_grasp_detail_binding.dart';
import 'package:making_school_asignment_app/page/home_page/children/knowledge_points_grasp_detail/knowledge_points_grasp_detail_view.dart';
import 'package:making_school_asignment_app/page/home_page/children/my_info.dart';
import 'package:making_school_asignment_app/page/home_page/children/quick_data_check/quick_data_check_binding.dart';
import 'package:making_school_asignment_app/page/home_page/children/quick_data_check/quick_data_check_view.dart';
import 'package:making_school_asignment_app/page/home_page/children/read_over/read_over_binding.dart';
import 'package:making_school_asignment_app/page/home_page/children/read_over/read_over_view.dart';
import 'package:making_school_asignment_app/page/home_page/children/student_history_work/student_history_work_binding.dart';
import 'package:making_school_asignment_app/page/home_page/children/student_history_work/student_history_work_view.dart';
import 'package:making_school_asignment_app/page/home_page/children/student_personal/student_personal_binding.dart';
import 'package:making_school_asignment_app/page/home_page/children/student_personal/student_personal_view.dart';
import 'package:making_school_asignment_app/page/home_page/children/student_work_detail/student_work_detail_binding.dart';
import 'package:making_school_asignment_app/page/home_page/children/student_work_detail/student_work_detail_view.dart';
import 'package:making_school_asignment_app/page/home_page/home_binding.dart';
import 'package:making_school_asignment_app/page/home_page/home_view.dart';
import 'package:making_school_asignment_app/page/login_page/children/agreement_page.dart';
import 'package:making_school_asignment_app/page/login_page/children/register.dart';
import 'package:making_school_asignment_app/page/login_page/login_binding.dart';
import 'package:making_school_asignment_app/page/login_page/login_view.dart';
import 'package:making_school_asignment_app/page/work_page/work_binding.dart';
import 'package:making_school_asignment_app/page/work_page/work_view.dart';
part 'app_routes.dart';

abstract class AppPages {
  static final pages = [
    GetPage(name: Routes.login, page: () => const LoginPage(), binding: LoginBinding(), transition: getTransition()),
    GetPage(name: Routes.register, page: () => const Register(), transition: getTransition()),
    GetPage(name: Routes.agreementPage, page: () => const AgreementPage(), binding: LoginBinding(), transition: getTransition()),
    GetPage(name: Routes.home, page: () => const HomePage(), binding: HomeBinding(), transition: getTransition()),
    GetPage(
      name: Routes.startPage,
      page: () => const StartPage(),
      bindings: [
        HomeBinding(),
        WorkBinding(),
        StartPageIndexBinding(),
      ],
      transition: getTransition(),
    ),
    GetPage(name: Routes.myInfo, page: () => const MyInfo(), transition: getTransition()),
    GetPage(name: Routes.work, page: () => const WorkPage(), binding: WorkBinding(), transition: getTransition()),
    GetPage(name: Routes.otherPage, page: () => const OhterPage(), transition: getTransition()),
    GetPage(name: Routes.readOverPage, page: () => const ReadOverPage(), binding: ReadOverBinding(), transition: getTransition()),
    GetPage(name: Routes.studentHistoryWorkPage, page: () => const StudentHistoryWorkPage(), binding: StudentHistoryWorkBinding(), transition: getTransition()),
    GetPage(name: Routes.classStudentPage, page: () => const ClassStudentPage(), binding: ClassStudentBinding(), transition: getTransition()),
    GetPage(name: Routes.annotateClassPage, page: () => const AnnotateClassPage(), binding: AnnotateClassBinding(), transition: getTransition()),
    GetPage(name: Routes.quickDataCheckPage, page: () => const QuickDataCheckPage(), binding: QuickDataCheckBinding(), transition: getTransition()),
    GetPage(name: Routes.jobReportPage, page: () => const JobReportPage(), binding: JobReportBinding(), transition: getTransition()),
    GetPage(name: Routes.studentPersonalPage, page: () => const StudentPersonalPage(), binding: StudentPersonalBinding(), transition: getTransition()),
    GetPage(name: Routes.studentWorkDetailPage, page: () => const StudentWorkDetailPage(), binding: StudentWorkDetailBinding(), transition: getTransition()),
    GetPage(name: Routes.knowledgePointsGraspPage, page: () => const KnowledgePointsGraspPage(), binding: KnowledgePointsGraspBinding(), transition: getTransition()),
    GetPage(name: Routes.knowledgePointsGraspDetailPage, page: () => const KnowledgePointsGraspDetailPage(), binding: KnowledgePointsGraspDetailBinding(), transition: getTransition()),
    GetPage(name: Routes.answerTrajectoryPage, page: () => const AnswerTrajectoryPage(), binding: AnswerTrajectoryBinding(), transition: getTransition()),
    GetPage(name: Routes.answerTrajectoryDetailPage, page: () => const AnswerTrajectoryDetailPage(), binding: AnswerTrajectoryDetailBinding(), transition: getTransition()),
    // 批阅主页（作业、考试）
    GetPage(name: Routes.reviewHomework, page: () => const HomeworkReview(), bindings: [HomeworkReviewBinding(), HomeworkReviewZoomBinding()], transition: getTransition()),
    // GetPage(name: Routes.reviewExam, page: () => const HomeworkReview(), bindings: [HomeworkReviewBinding(), HomeworkReviewZoomBinding()], transition: getTransition()),
    GetPage(name: Routes.favStudentPage, page: () => const FavStudentPage(), binding: FavStudentBinding(), transition: getTransition()),
  ];
}

/// 获取页面随机跳转
Transition getTransition() {
  try {
    List<Transition> transitions = Transition.values;
    return transitions[getRandomNumbers(0, transitions.length - 1)];
  } catch (e) {
    return getTransition();
  }
}

/// 获取指定范围的随机数
int getRandomNumbers(int minNumber, int maxNumber) {
  int next(int min, int max) => min + Random().nextInt(max - min);
  return next(minNumber, maxNumber);
}
