import 'package:auto_route/auto_route.dart';
import 'package:cpt_main/router/page/main_page_router.dart';
import 'package:cpt_profile/router/page/profile_page_router.dart';
import 'package:flutter/material.dart';
import 'package:plugin_basic/router/basic_page_router.dart';
import 'package:router/path/router_path.dart';
import 'package:cpt_auth/router/page/auth_page_router.dart';
import 'package:cpt_community/router/page/community_page_router.dart';
import 'package:cpt_facility/router/page/facility_page_router.dart';
import 'package:cpt_form/router/page/form_page_router.dart';
import 'package:cpt_notice_board/router/page/notice_board_page_router.dart';
import 'package:cpt_payment/router/page/payment_page_router.dart';
import 'package:cpt_property/router/page/property_page_router.dart';
import 'package:cpt_rewards/router/page/rewards_page_router.dart';
import 'package:cpt_services/router/page/services_page_router.dart';

import '../../modules/splash/page/splash_page.dart';

part 'app_page_router.gr.dart';

@AutoRouterConfig(replaceInRouteName: 'Page|Screen,PageRoute')
class AppRouter extends _$AppRouter {
  @override
  List<AutoRoute> get routes => [
        AutoRoute(page: SplashPageRoute.page, initial: true, path: RouterPath.splash),
        // 合并子模块的路由配置
        ...BasicPageRouter().routes,
        ...AuthPageRouter().routes,
        ...MainPageRouter().routes,
        ...CommunityPageRouter().routes,
        ...FacilityPageRouter().routes,
        ...FormPageRouter().routes,
        ...NoticeBoardPageRouter().routes,
        ...PaymentPageRouter().routes,
        ...PaymentPageRouter().routes,
        ...PropertyPageRouter().routes,
        ...RewardsPageRouter().routes,
        ...ServicesPageRouter().routes,
        ...ProfilePageRouter().routes,
      ];

  @override
  Map<String, PageFactory> get pagesMap => {
        ...super.pagesMap,
        // 合并子模块的 pagesMap
        ...BasicPageRouter().pagesMap,
        ...AuthPageRouter().pagesMap,
        ...MainPageRouter().pagesMap,
        ...CommunityPageRouter().pagesMap,
        ...FacilityPageRouter().pagesMap,
        ...FacilityPageRouter().pagesMap,
        ...FormPageRouter().pagesMap,
        ...NoticeBoardPageRouter().pagesMap,
        ...PaymentPageRouter().pagesMap,
        ...PropertyPageRouter().pagesMap,
        ...RewardsPageRouter().pagesMap,
        ...ServicesPageRouter().pagesMap,
        ...ProfilePageRouter().pagesMap,
      };
}

final appRouter = AppRouter();
