// ignore_for_file: non_constant_identifier_names

import 'package:flyinsono/architecture/define.dart';
import 'package:flyinsono/architecture/middlewares/index.dart';
import 'package:flyinsono/architecture/router/index.dart';
import 'package:flyinsono/architecture/router/types.dart';
import 'package:flyinsono/architecture/values/features.dart';
import 'package:flyinsono/lab/pages/lab_login/index.dart';
import 'package:flyinsono/lab/pages/lab_main/index.dart';
import 'package:flyinsono/pages/auth/auth_board/bindings.dart';
import 'package:flyinsono/pages/auth/auth_board/view.dart';
import 'package:flyinsono/pages/auth/retrieve_password/bindings.dart';
import 'package:flyinsono/pages/auth/retrieve_password/view.dart';
import 'package:flyinsono/pages/auth/sign_in/bindings.dart';
import 'package:flyinsono/pages/auth/sign_in/view.dart';
import 'package:flyinsono/pages/auth/sign_up/bindings.dart';
import 'package:flyinsono/pages/auth/sign_up/view.dart';
import 'package:flyinsono/pages/college/index.dart';
import 'package:flyinsono/pages/college/widgets/exam_page.dart';
import 'package:flyinsono/pages/consultation/bindings.dart';
import 'package:flyinsono/pages/consultation/consultation_detail/index.dart';
import 'package:flyinsono/pages/consultation/view.dart';
import 'package:flyinsono/pages/index.dart';
import 'package:flyinsono/pages/live_course/bindings.dart';
import 'package:flyinsono/pages/live_course/view.dart';
import 'package:flyinsono/pages/measure/index.dart';
import 'package:flyinsono/pages/others/second_splash/bindings.dart';
import 'package:flyinsono/pages/others/second_splash/view.dart';
import 'package:flyinsono/pages/remedical/consultation/bindings.dart';
import 'package:flyinsono/pages/remedical/consultation/view.dart';
import 'package:flyinsono/pages/remedical/consultation_record_view/index.dart';
import 'package:flyinsono/pages/remedical/consultation_record_view/widgets/mobile/record_detail_page.dart';
import 'package:flyinsono/pages/remedical/image_pool/bindings.dart';
import 'package:flyinsono/pages/remedical/image_pool/view.dart';
import 'package:flyinsono/pages/remedical/report/report_edit/bindings.dart';
import 'package:flyinsono/pages/remedical/report/report_edit/view.dart';
import 'package:flyinsono/pages/remedical/report_preview/bindings.dart';
import 'package:flyinsono/pages/remedical/report_preview/view.dart';
import 'package:flyinsono/pages/remote_controller/controller.dart';
import 'package:flyinsono/pages/remote_controller/view.dart';
import 'package:flyinsono/pages/third_party_page/Feedback/bindings.dart';
import 'package:flyinsono/pages/third_party_page/feedback/view.dart';
import 'package:flyinsono/pages/user/group_chat/index.dart';
import 'package:flyinsono/pages/user/group_list/bindings.dart';
import 'package:flyinsono/pages/user/group_list/view.dart';
import 'package:flyinsono/pages/user/report_template/index.dart';
import 'package:flyinsono/pages/user/report_template/widgets/report_designer_page.dart';
import 'package:flyinsono/pages/user/user_center/widgets/change_password_page.dart';
import 'package:flyinsono/pages/user/user_center/widgets/qr_login_view.dart';
import 'package:flyinsono/pages/user/user_device/bindings.dart';
import 'package:flyinsono/pages/user/user_device/index.dart';
import 'package:flyinsono/pages/user/user_device/widgets/add_or_edit_terminal.dart';
import 'package:flyinsono/views/common/device_live/device_live_list/controller.dart';
import 'package:flyinsono/views/desktop/real_time_consultation/live_consultation/bindings.dart';
import 'package:flyinsono/views/desktop/real_time_consultation/live_consultation/view.dart';
import 'package:flyinsono/views/desktop/real_time_consultation/widgets/real_time_consultation_list.dart';
import 'package:flyinsono/views/desktop/user_setting/index.dart';
import 'package:flyinsono/views/mobile/confirm_application_page/bindings.dart';
import 'package:flyinsono/views/mobile/confirm_application_page/view.dart';
import 'package:flyinsono/views/mobile/device_live/device_live_detail/index.dart';
import 'package:flyinsono/views/mobile/device_live/device_live_list/index.dart';
import 'package:flyinsono/views/mobile/mobile_calendar/index.dart';
import 'package:flyinsono/views/mobile/past_video_player/index.dart';
import 'package:flyinsono/views/mobile/past_videos/index.dart';
import 'package:flyinsono/views/wechat_mini_program/wx_account_linking/bindings.dart';
import 'package:flyinsono/views/wechat_mini_program/wx_account_linking/view.dart';
import 'package:flyinsono/views/wechat_mini_program/wx_consultation/index.dart';
import 'package:flyinsono/views/wechat_mini_program/wx_consultation_create/index.dart';
import 'package:flyinsono/views/wechat_mini_program/wx_consultation_detail/index.dart';
import 'package:flyinsono/views/wechat_mini_program/wx_consultation_room/index.dart';
import 'package:flyinsono/views/wechat_mini_program/wx_debug/index.dart';
import 'package:flyinsono/views/wechat_mini_program/wx_diagnosis/bindings.dart';
import 'package:flyinsono/views/wechat_mini_program/wx_diagnosis/view.dart';
import 'package:flyinsono/views/wechat_mini_program/wx_diagnosis_detail/index.dart';
import 'package:flyinsono/views/wechat_mini_program/wx_home/index.dart';
import 'package:flyinsono/views/wechat_mini_program/wx_image_preview/index.dart';
import 'package:flyinsono/views/wechat_mini_program/wx_images_list/index.dart';
import 'package:flyinsono/views/wechat_mini_program/wx_report_preview/index.dart';
import 'package:flyinsono/views/wechat_mini_program/wx_reports_list/index.dart';
import 'package:get/get.dart';

///Fis的路由错误页面配置
class FErrorRouteSettings {
  static final NotFount = FRouteSetting(
    RouteNames.Error.NotFound,
    () => NotFoundPage(),
    binding: NotFoundBinding(),
  );

  FErrorRouteSettings._();
}

/// FIS的路由表构建器
class FRoutesMobileBuilder {
  final List<FRouteSetting<dynamic>> _routes = [];

  /// 构建路由表
  List<FRouteSetting<dynamic>> build() {
    _buildCommonRoutes();
    _buildHomeRoutes();
    _buildAuthRoutes();
    _buildUserRoutes();
    _buildOrgRoutes();
    _buildRemedicalRoutes();
    _buildRealTimeRemedicalRoutes();
    _buildCalendarRoutes();
    _buildCollegeRouters();
    _buildThirdpartyPage();
    _buildWechatMiniProgramPage();
    _buildLiveRoutes();
    _buildLabRouters();
    return _routes;
  }

  void _buildAuthRoutes() {
    _routes.addAll([
      FRouteSetting(
        RouteNames.Auth.AuthBoard,
        () => AuthBoardPage(),
        binding: AuthBoardBinding(),
        fullscreenDialog: true,
      ),
      FRouteSetting(
        RouteNames.Auth.SignIn,
        () => SignInPage(),
        binding: SignInBinding(),
        fullscreenDialog: true,
        transitionDuration: Duration(milliseconds: 0),
      ),
      FRouteSetting(
        RouteNames.Auth.SignUp,
        () => SignUpPage(),
        binding: SignUpBinding(),
        transitionDuration: Duration(milliseconds: 0),
      ),
      FRouteSetting(
        RouteNames.Auth.RetrievePwd,
        () => RetrievePasswordPage(),
        binding: RetrievePasswordBinding(),
        transitionDuration: Duration(milliseconds: 0),
      ),
    ]);
  }

  void _buildCollegeRouters() {
    _routes.addAll([
      FRouteSetting(
        MobileRouteNames.College.FlyinsonoCollege,
        () => FlyinsonoCollege(),
        binding: FlyinsonoCollegeBinding(),
      ),
      FRouteSetting(
        MobileRouteNames.College.LiveCourseDetail,
        () => LiveCoursePage(),
        binding: LiveCourseBinding(),
      ),
      FRouteSetting(
        MobileRouteNames.College.ExamPage,
        () => ExamPage(),
      ),
      FRouteSetting(
        MobileRouteNames.College.PastVideos,
        () => PastVideosPage(),
        binding: PastVideosBinding(),
      ),
      FRouteSetting(
        MobileRouteNames.College.PastVideoPlayer,
        () => PastVideoPlayerPage(),
        binding: PastVideoPlayerBinding(),
      )
    ]);
  }

  void _buildCalendarRoutes() {
    _routes.addAll([
      FRouteSetting(
        MobileRouteNames.Calendar.Calendar,
        // () => HardwareDetectionPage(),
        // binding: HardwareDetectionBinding(),
        () => MobileCalendarPage(),
        binding: MobileCalendarBinding(),
      ),
    ]);
  }

  void _buildLabRouters() {
    _routes.addAll([
      FRouteSetting(
        RouteNames.Lab.Login,
        () => QuickFWidget(LabLoginPage()),
        binding: LabLoginBinding(),
      ),
      FRouteSetting(
        RouteNames.Lab.Main,
        () => QuickFWidget(LabMainPage()),
        binding: LabMainBinding(),
      ),
    ]);
  }

  void _buildCommonRoutes() {
    _routes.add(
      FRouteSetting(
        RouteNames.App.Splash,
        () => SplashPage(),
        binding: SplashBinding(),
        transition: Transition.fade,
      ),
    );
    _routes.add(
      FRouteSetting(
        RouteNames.App.SecondSplash,
        () => SecondSplashPage(),
        binding: SecondSplashBinding(),
        transition: Transition.fade,
      ),
    );
    _routes.add(FErrorRouteSettings.NotFount);
    _routes.add(
      FRouteSetting(
        RouteNames.Error.Unauthorized,
        () => UnauthorizedPage(),
        transition: Transition.fade,
      ),
    );
  }

  void _buildHomeRoutes() {
    _routes.addAll([
      FRouteSetting(
        RouteNames.Home.Home,
        () => HomePage(),
        binding: HomeBinding(),
        middlewares: [RouteLoginMiddleware()],
      ),
      FRouteSetting(
        RouteNames.Home.Profile,
        () => ProfileCompletePage(),
        binding: ProfileCompleteBinding(),
      ),
      FRouteSetting(
        RouteNames.Home.MainPage,
        () => HomePagePage(),
        binding: HomePageBinding(),
      ),
    ]);
  }

  /// 直播相关页面
  void _buildLiveRoutes() {
    _routes.addAll([
      FRouteSetting(
        RouteNames.Live.DeviceList,
        () => DeviceLiveListMobilePage(),
        binding: BindingsBuilder(() {
          final controller = DeviceLiveListMobileController();
          Get.put<DeviceLiveListController>(controller);
          Get.put<DeviceLiveListMobileController>(controller);
        }),
      ),
      FRouteSetting(
        RouteNames.Live.DeviceDetail,
        () => DeviceLiveDetailMobilePage(),
        binding: BindingsBuilder(() {
          Get.put(DeviceLiveDetailMobileController());
        }),
      ),
      FRouteSetting(
        RouteNames.Live.RemoteController,
        () => RemoteControllerPage(),
        binding: BindingsBuilder(() {
          Get.put(RemoteControllerController());
        }),
      ),
    ]);
  }

  void _buildOrgRoutes() {
    _routes.addAll([
      FRouteSetting(
        RouteNames.Org.Info,
        () => OrgInfoPage(),
        binding: OrgInfoBinding(),
      ),
      FRouteSetting(
        RouteNames.Org.Personnel,
        () => OrgPesonnelPage(),
        binding: OrgPesonnelBinding(),
      ),
      FRouteSetting(
        RouteNames.Org.Device,
        () => UserDevicePage(),
        binding: UserDevicerBinding(),
      ),
      FRouteSetting(
        RouteNames.Org.AddDevice,
        () => AddorEditMobileTerminalPage(),
        binding: UserDevicerBinding(),
      ),
      FRouteSetting(
        RouteNames.Org.Entry,
        () => VocabularyEntryPage(),
        binding: VocabularyEntryBinding(),
      ),
      FRouteSetting(
        RouteNames.Org.ReportTemplate,
        () => ReportTemplatePage(),
        binding: ReportTemplateBinding(),
      ),
    ]);
  }

  void _buildRealTimeRemedicalRoutes() {
    _routes.addAll([
      FRouteSetting(
        RouteNames.RealTimeRemedical.RealTimeConsultation,
        () => FRealTimeConsultationListPage(),
      ),
      FRouteSetting(
        RouteNames.RealTimeRemedical.LiveConsultation,
        () => LiveConsulationPage(),
        binding: LiveConsultationBinding(),
      ),
      FRouteSetting(
        MobileRouteNames.RealTimeRemedical.ConsultationDetail,
        () => ConsultationDetailPage(),
        binding: ConsultationDetailBinding(),
      ),
      FRouteSetting(
        MobileRouteNames.RealTimeRemedical.ConfirmApplicationPage,
        () => FConfirmApplicationPagePage(),
        binding: ConfirmApplicationPageControllerBinding(),
      )
    ]);
  }

  void _buildRemedicalRoutes() {
    _routes.addAll([
      FRouteSetting(
        RouteNames.Remedical.Consultation,
        () => ConsultationPage(),
        binding: ConsultationBinding(),
      ),
      FRouteSetting(
        RouteNames.Remedical.ConsultationPatientView,
        () => ConsultationPage(),
        binding: ConsultationBinding(),
      ),
      FRouteSetting(
        RouteNames.RealTimeRemedical.MobileConsultation,
        () => MobileConsultationPage(),
        binding: MobileConsultationBinding(),
      ),
      FRouteSetting(
        RouteNames.Remedical.ConsultationRecordView,
        () => ConsultationRecordViewPage(),
        binding: ConsultationRecordViewBinding(),
      ),
      FRouteSetting(
        MobileRouteNames.Remedical.RecordDetail,
        () => RecordDetailPage(),
        // binding: ConsultationRecordViewBinding(),
      ),
      FRouteSetting(
        RouteNames.Remedical.ImagePool,
        () => ImagePoolPage(),
        binding: ImagePoolBinding(),
      ),
      FRouteSetting(
        RouteNames.Remedical.AddOrEditPatirntDiaLog,
        () => AddoreditPatientDialogPage(),
        binding: AddoreditpatirntdialogBinding(),
      ),
      FRouteSetting(
        RouteNames.Remedical.ReportEdit,
        () => ReporteditPage(),
        binding: ReportEditBinding(),
      ),
      FRouteSetting(
        RouteNames.Remedical.ReportPreview,
        () => ReportPreviewPage(),
        binding: ReportPreviewBinding(),
      ),
      FRouteSetting(
        RouteNames.Remedical.Measure,
        () => MeasureHomePage(),
        binding: MeasureHomeBinding(),
      ),
    ]);
  }

  ///第三方平台相关页面
  void _buildThirdpartyPage() {
    _routes.addAll([
      FRouteSetting(
        RouteNames.Thirdparty.ThirdpartyPage,
        () => ThirdpartyPage(),
        binding: FeedbackBinding(),
      ),
    ]);
  }

  void _buildUserRoutes() {
    _routes.addAll([
      FRouteSetting(
        RouteNames.User.RoleApply,
        () => UserIdAuthApplyPage(),
        binding: UserIdAuthApplyBinding(),
      ),
      FRouteSetting(
        RouteNames.User.ChangePasswordPage,
        () => ChangePasswordPage(),
      ),
      FRouteSetting(
        RouteNames.User.RoleAuth,
        () => RoleAuthenticationPage(),
        binding: RoleAuthenticationBinding(),
      ),
      FRouteSetting(
        RouteNames.User.Profile,
        () => UserProfilePage(),
        binding: UserProfileBinding(),
      ),
      FRouteSetting(
        RouteNames.User.ReportTemplate,
        () => ReportTemplatePage(),
        binding: ReportTemplateBinding(),
      ),
      FRouteSetting(
        RouteNames.User.ReportTemplateDesigner,
        () => ReportDesignerPage(),
        binding: ReportTemplateBinding(),
      ),
      FRouteSetting(
        RouteNames.User.Setting,
        () => UserSettingPage(),
      ),
      FRouteSetting(
        RouteNames.User.Device,
        () => UserDevicePage(),
        binding: UserDevicerBinding(),
      ),
      FRouteSetting(
        RouteNames.User.Entry,
        () => VocabularyEntryPage(),
        binding: VocabularyEntryBinding(),
      ),
      FRouteSetting(
        RouteNames.User.ScanQRLogin,
        () => FQRScanView(),
        binding: UserCenterBinding(),
      ),
      FRouteSetting(
        RouteNames.User.Center,
        () => UserCenterPage(),
        binding: UserCenterBinding(),
        middlewares: [
          RouteAuthMiddleware(feature: FeatureKeys.OrgPersonnel + "xx")
        ],
      ),
      FRouteSetting(
        RouteNames.User.GroupList,
        () => GroupListPage(),
        binding: GroupBinding(),
      ),
      FRouteSetting(
        RouteNames.User.GroupChat,
        () => GroupChatPage(),
        binding: GroupChatBinding(),
      ),
    ]);
  }

  /// 微信小程序页面
  void _buildWechatMiniProgramPage() {
    _routes.addAll([
      FRouteSetting(
        MobileRouteNames.Wechat.MiniProgramHome,
        () => MiniProgramHomePage(),
        binding: WxHomeBinding(),
        transition: null,
        transitionDuration: Duration.zero,
        customTransition: null,
      ),
      FRouteSetting(
        MobileRouteNames.Wechat.MiniProgramDebug,
        () => WxDebugPage(),
        binding: WxDebugBinding(),
      ),
      FRouteSetting(
        MobileRouteNames.Wechat.MiniProgramBind,
        () => WxAccountLinkingPage(),
        binding: WxAccountLinkingBinding(),
        transition: null,
        transitionDuration: Duration.zero,
        customTransition: null,
      ),
      FRouteSetting(
        MobileRouteNames.Wechat.MiniProgramConsultation,
        () => WxConsultationPage(),
        binding: WxConsultationBinding(),
      ),
      FRouteSetting(
        MobileRouteNames.Wechat.MiniProgramConsultationDetail,
        () => WxConsultationDetailPage(),
        binding: WxConsultationDetailBinding(),
      ),
      FRouteSetting(
        MobileRouteNames.Wechat.MiniProgramConsultationCreate,
        () => WxConsultationCreatePage(),
        binding: WxConsultationCreateBinding(),
      ),
      FRouteSetting(
        MobileRouteNames.Wechat.MiniProgramConsultationRoom,
        () => WxConsultationRoomPage(),
        binding: WxConsultationRoomBinding(),
      ),
      FRouteSetting(
        MobileRouteNames.Wechat.MiniProgramDiagnosis,
        () => WxDiagnosisPage(),
        binding: WxDiagnosisBinding(),
      ),
      FRouteSetting(
        MobileRouteNames.Wechat.MiniProgramDiagnosisDetail,
        () => WxDiagnosisDetailPage(),
        binding: WxDiagnosisDetailBinding(),
      ),
      FRouteSetting(
        MobileRouteNames.Wechat.MiniProgramReports,
        () => WxReportsListPage(),
        binding: WxReportsListBinding(),
      ),
      FRouteSetting(
        MobileRouteNames.Wechat.MiniProgramReportDetail,
        () => WxReportPreviewPage(),
        binding: WxReportPreviewBinding(),
      ),
      FRouteSetting(
        MobileRouteNames.Wechat.MiniProgramImages,
        () => WxImagesListPage(),
        binding: WxImagesListBinding(),
      ),
      FRouteSetting(
        MobileRouteNames.Wechat.MiniProgramImageDetail,
        () => WxImagePreviewPage(),
        binding: WxImagePreviewBinding(),
      ),
    ]);
  }
}
