|
@@ -1,11 +1,14 @@
|
|
|
+import 'package:cpt_main/router/component/main_service_provider.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:flutter/services.dart';
|
|
|
import 'package:initializer/app_initializer.dart';
|
|
|
import 'package:plugin_basic/basic_export.dart';
|
|
|
import 'package:plugin_basic/provider/app_config/app_config_service.dart';
|
|
|
-import 'package:plugin_basic/provider/global_provider_container.dart';
|
|
|
|
|
|
import 'package:cs_resources/local/theme/theme_config.dart';
|
|
|
+import 'package:plugin_basic/provider/global_provider_container.dart';
|
|
|
+import 'package:router/componentRouter/component_service_manager.dart';
|
|
|
+import 'package:cpt_profile/router/component/profile_service_provider.dart';
|
|
|
|
|
|
import 'package:widgets/dialog/custom_toast_widget.dart';
|
|
|
import 'package:widgets/dialog/custom_error_widget.dart';
|
|
@@ -14,8 +17,10 @@ import 'package:widgets/dialog/custom_success_widget.dart';
|
|
|
import 'package:widgets/dialog/custom_loading_widget.dart';
|
|
|
import 'package:widgets/widget_export.dart';
|
|
|
|
|
|
-import 'router/app_page_router.dart';
|
|
|
-import 'rp_obs/riverpod_observer.dart';
|
|
|
+import 'obs/my_navigator_observer.dart';
|
|
|
+import 'router/page/app_page_router.dart';
|
|
|
+import 'obs/riverpod_observer.dart';
|
|
|
+import 'router/component/app_service_provider.dart';
|
|
|
|
|
|
void main() async {
|
|
|
//运行App
|
|
@@ -23,7 +28,14 @@ void main() async {
|
|
|
//交给初始化构造器去统一初始化
|
|
|
await AppInitializer.initializeRunalone();
|
|
|
|
|
|
+ //组件路由的注入
|
|
|
+ final serviceManager = ComponentServiceManager()
|
|
|
+ ..addServiceProvider(mainServiceProvider)
|
|
|
+ ..addServiceProvider(appServiceProvider)
|
|
|
+ ..addServiceProvider(profileServiceProvider);
|
|
|
+
|
|
|
runApp(ProviderScope(
|
|
|
+ parent: globalContainer,
|
|
|
observers: [RiverpodObserver()],
|
|
|
child: MyApp(),
|
|
|
));
|
|
@@ -87,76 +99,18 @@ class MyApp extends StatelessWidget {
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
- // Future.microtask(() {
|
|
|
- // globalContainer.read(appConfigServiceProvider.notifier).initSize(context);
|
|
|
- // });
|
|
|
-
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
- globalContainer.read(appConfigServiceProvider.notifier).initSize(context);
|
|
|
+ AppConfigService.getInstance().initSize(context);
|
|
|
});
|
|
|
|
|
|
//设置全局的状态栏文本样式
|
|
|
SystemChrome.setSystemUIOverlayStyle(ThemeConfig.systemUiOverlayStyleLightThemeWhite);
|
|
|
- final appRouter = AppRouter();
|
|
|
|
|
|
//路由管理,状态管理,依赖管理一切都始于GetMaterialApp
|
|
|
return KeyboardVisibilityBuilder(builder: (context, isKeyboardVisible) {
|
|
|
return KeyboardDismissOnTap(
|
|
|
dismissOnCapturedTaps: false,
|
|
|
- child:
|
|
|
- // MaterialApp(
|
|
|
- // //顶部是否展示Debug图标
|
|
|
- // debugShowCheckedModeBanner: true,
|
|
|
- // //是否展示Log
|
|
|
- // enableLog: true,
|
|
|
- // //默认路由与路由表的加载
|
|
|
- // initialRoute: RouterPath.splash,
|
|
|
- // getPages: PageRouter.routes + BasicPageRouter.routes + AuthPageRouter.routes + JobPageRouter.routes + LabourPageRouter.routes +
|
|
|
- // ReportPageRouter.routes + LabourSGPageRouter.routes + JobPageSGRouter.routes,
|
|
|
- // //对原生导航的兼容;SmartDialog路由配置生命周期处理
|
|
|
- // navigatorObservers: [GetXRouterObserver(), FlutterSmartDialog.observer, routeObserver],
|
|
|
- // //默认页面动画
|
|
|
- // defaultTransition: Transition.rightToLeft,
|
|
|
- // smartManagement: SmartManagement.keepFactory,
|
|
|
- // //网页Title显示
|
|
|
- // title: 'YY Employer',
|
|
|
- // //样式相关
|
|
|
- // theme: ThemeConfig.lightTheme,
|
|
|
- // darkTheme: ThemeConfig.darkTheme,
|
|
|
- // themeMode: ThemeMode.light,
|
|
|
- // //本地化相关
|
|
|
- // locale: TranslationService.locale,
|
|
|
- // fallbackLocale: TranslationService.fallbackLocale,
|
|
|
- // localizationsDelegates: const [
|
|
|
- // GlobalMaterialLocalizations.delegate,
|
|
|
- // GlobalWidgetsLocalizations.delegate,
|
|
|
- // GlobalCupertinoLocalizations.delegate,
|
|
|
- // ],
|
|
|
- // supportedLocales: const [
|
|
|
- // Locale('en', 'US'),
|
|
|
- // Locale('zh', ''),
|
|
|
- // Locale('vi', ''),
|
|
|
- // ],
|
|
|
- // translations: TranslationService(),
|
|
|
- // //SmartDialog初始化默认Loading与Toast
|
|
|
- // builder: FlutterSmartDialog.init(
|
|
|
- // toastBuilder: (String msg) {
|
|
|
- // return CustomToastWidget(msg: msg);
|
|
|
- // },
|
|
|
- // loadingBuilder: (String msg) {
|
|
|
- // return CustomLoadingWidget(msg: msg == 'loading...' ? 'Loading...'.tr : msg);
|
|
|
- // },
|
|
|
- // notifyStyle: FlutterSmartNotifyStyle(
|
|
|
- // successBuilder: (String msg) => CustomSuccessWidget(msg: msg),
|
|
|
- // failureBuilder: (String msg) => CustomFailureWidget(msg: msg),
|
|
|
- // errorBuilder: (String msg) => CustomErrorWidget(msg: msg),
|
|
|
- // alertBuilder: (String msg) => CustomErrorWidget(msg: msg),
|
|
|
- // warningBuilder: (String msg) => CustomErrorWidget(msg: msg),
|
|
|
- // ),
|
|
|
- // ),
|
|
|
- // ),
|
|
|
-
|
|
|
- MaterialApp.router(
|
|
|
+ child: MaterialApp.router(
|
|
|
title: 'PropertyManagementSystem',
|
|
|
debugShowCheckedModeBanner: true,
|
|
|
theme: ThemeData(
|
|
@@ -164,7 +118,11 @@ class MyApp extends StatelessWidget {
|
|
|
useMaterial3: false,
|
|
|
),
|
|
|
//AutoRouter的配置
|
|
|
- routerConfig: appRouter.config(),
|
|
|
+ routerConfig: appRouter.config(
|
|
|
+ navigatorObservers: () => [
|
|
|
+ MyNavigatorObserver(),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
//SmartDialog初始化默认Loading与Toast
|
|
|
builder: FlutterSmartDialog.init(
|
|
|
toastBuilder: (String msg) {
|