/*
*@Author: XianKaiQun
*@Date: 2020-04-20 00:57:53
 * @LastEditors: wuwei
 * @LastEditTime: 2024-04-25 15:10:59
*@Descripttion: 
*/
import 'package:app_package/src/pages/community/index.dart';
import 'package:app_package/src/pages/login/index.dart';
import 'package:app_package/src/pages/main/index.dart';
import 'package:app_package/src/pages/message/add/index.dart';
import 'package:app_package/src/pages/message/detail/index.dart';
import 'package:app_package/src/pages/message/list/index.dart';
import 'package:app_package/src/pages/mine/version_detail/index.dart';
import 'package:app_package/src/pages/notice/detail/index.dart';
import 'package:app_package/src/pages/notice/index.dart';
import 'package:app_package/src/pages/splash/index.dart';
import 'package:app_package/src/pages/work/components/notice_detail.dart';
import 'package:app_package/src/pages/work/components/notice_list.dart';
import 'package:app_package/src/pages/work/components/menu_drag_list.dart';
import 'package:app_package/src/view.dart';
import 'package:flutter/cupertino.dart';

import 'pages/message/index.dart';

Map<String, WidgetBuilder> appRoutes = {
  '404': (context) => Page404(),

  ///开屏页
  'splash': (context) => SplashPage(),

  ///登录
  'login': (context) => LoginPage(),

  ///
  'community': (context) => CommunityPage(),

  ///首页汇总
  'main': (context) => MainPage(),

  ///我的消息
  'notice': (context) => NoticePage(),

  /// 消息具体分类列表
  'notice_list': (context) => NoticeListDetailPage(),

  ///公告消息
  'notice_index': (context) => NoticeIndexPage(),

  ///公告消息详情
  'notice_detail': (context) => NoticeDetailPage(),

  /// 智能填表
  'message_index': (context) => MessagePage(),

  /// 填报表单列表
  'message_list': (context) => MessageListPage(),

  /// 填报表单详情
  'message_detail': (context) => MessageDetailPage(),

  /// 新建填表
  'message_add': (context) => MessageAddPage(),

  /// 版本介绍
  'version_detail': (context) => VersionDetail(),

  'menu_order': (context) => Menu_drag_list(),
};

///路由拦截
Route onGenerateRoute<T extends Object>(RouteSettings settings) {
  return CupertinoPageRoute<T>(
    settings: settings,
    builder: (context) {
      ///多package开发，如果传值是自定义实体类，那在业务间跳转不通用
      assert(settings.arguments == null || settings.arguments is Map,
          '路由传值必须是Map');

      String? name = settings.name;
      if (appRoutes[settings.name!] == null) {
        debugPrint('$name 不存在 跳转404');
        name = '404';
      }

      Widget widget = appRoutes[name!]!(context);
      debugPrint('[route] => $name');
      debugPrint('[args]  => ${settings.arguments}');
      return widget;
    },
  );
}
