| 
									
										
										
										
											2024-01-26 00:24:33 +08:00
										 |  |  | import 'dart:io'; | 
					
						
							| 
									
										
										
										
											2024-01-24 15:15:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-20 10:13:59 +02:00
										 |  |  | import 'package:flutter/material.dart'; | 
					
						
							|  |  |  | import 'package:flutter/services.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-08 15:04:09 +02:00
										 |  |  | import 'package:appflowy/mobile/application/mobile_router.dart'; | 
					
						
							| 
									
										
										
										
											2024-02-25 16:46:13 +01:00
										 |  |  | import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart'; | 
					
						
							| 
									
										
										
										
											2024-04-23 15:46:57 +02:00
										 |  |  | import 'package:appflowy/shared/feature_flags.dart'; | 
					
						
							| 
									
										
										
										
											2023-10-24 13:39:05 +08:00
										 |  |  | import 'package:appflowy/startup/startup.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/user/application/user_settings_service.dart'; | 
					
						
							| 
									
										
										
										
											2024-04-12 10:21:41 +02:00
										 |  |  | import 'package:appflowy/workspace/application/action_navigation/action_navigation_bloc.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/workspace/application/action_navigation/navigation_action.dart'; | 
					
						
							| 
									
										
										
										
											2024-04-23 15:46:57 +02:00
										 |  |  | import 'package:appflowy/workspace/application/command_palette/command_palette_bloc.dart'; | 
					
						
							| 
									
										
										
										
											2024-04-12 10:21:41 +02:00
										 |  |  | import 'package:appflowy/workspace/application/notification/notification_service.dart'; | 
					
						
							| 
									
										
										
										
											2023-10-24 13:39:05 +08:00
										 |  |  | import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart'; | 
					
						
							| 
									
										
										
										
											2023-10-12 06:54:08 +02:00
										 |  |  | import 'package:appflowy/workspace/application/settings/notifications/notification_settings_cubit.dart'; | 
					
						
							| 
									
										
										
										
											2024-01-29 20:55:37 +01:00
										 |  |  | import 'package:appflowy/workspace/application/sidebar/rename_view/rename_view_bloc.dart'; | 
					
						
							| 
									
										
										
										
											2024-06-05 04:05:51 +02:00
										 |  |  | import 'package:appflowy/workspace/application/tabs/tabs_bloc.dart'; | 
					
						
							| 
									
										
										
										
											2024-01-24 15:15:57 +01:00
										 |  |  | import 'package:appflowy/workspace/application/view/view_ext.dart'; | 
					
						
							| 
									
										
										
										
											2024-04-12 10:21:41 +02:00
										 |  |  | import 'package:appflowy/workspace/presentation/command_palette/command_palette.dart'; | 
					
						
							| 
									
										
										
										
											2023-09-28 01:17:38 -05:00
										 |  |  | import 'package:appflowy_backend/log.dart'; | 
					
						
							|  |  |  | import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart'; | 
					
						
							| 
									
										
										
										
											2024-01-24 15:15:57 +01:00
										 |  |  | import 'package:appflowy_editor/appflowy_editor.dart' hide Log; | 
					
						
							| 
									
										
										
										
											2023-10-24 13:39:05 +08:00
										 |  |  | import 'package:easy_localization/easy_localization.dart'; | 
					
						
							| 
									
										
										
										
											2023-08-22 22:41:52 +08:00
										 |  |  | import 'package:flowy_infra/theme.dart'; | 
					
						
							| 
									
										
										
										
											2021-07-29 22:22:35 +08:00
										 |  |  | import 'package:flowy_infra_ui/flowy_infra_ui.dart'; | 
					
						
							| 
									
										
										
										
											2023-10-24 13:39:05 +08:00
										 |  |  | import 'package:flutter_bloc/flutter_bloc.dart'; | 
					
						
							|  |  |  | import 'package:go_router/go_router.dart'; | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-24 13:39:05 +08:00
										 |  |  | import 'prelude.dart'; | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-20 16:10:50 +08:00
										 |  |  | class InitAppWidgetTask extends LaunchTask { | 
					
						
							| 
									
										
										
										
											2023-05-17 11:03:33 +08:00
										 |  |  |   const InitAppWidgetTask(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  |   @override | 
					
						
							|  |  |  |   LaunchTaskType get type => LaunchTaskType.appLauncher; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2022-01-28 18:34:21 +08:00
										 |  |  |   Future<void> initialize(LaunchContext context) async { | 
					
						
							| 
									
										
										
										
											2023-10-02 09:12:24 +02:00
										 |  |  |     WidgetsFlutterBinding.ensureInitialized(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await NotificationService.initialize(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  |     final widget = context.getIt<EntryPoint>().create(context.config); | 
					
						
							| 
									
										
										
										
											2023-02-26 16:27:17 +08:00
										 |  |  |     final appearanceSetting = | 
					
						
							|  |  |  |         await UserSettingsBackendService().getAppearanceSetting(); | 
					
						
							| 
									
										
										
										
											2023-10-02 09:12:24 +02:00
										 |  |  |     final dateTimeSettings = | 
					
						
							|  |  |  |         await UserSettingsBackendService().getDateTimeSettings(); | 
					
						
							| 
									
										
										
										
											2023-08-08 09:08:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // If the passed-in context is not the same as the context of the
 | 
					
						
							|  |  |  |     // application widget, the application widget will be rebuilt.
 | 
					
						
							| 
									
										
										
										
											2022-01-28 18:34:21 +08:00
										 |  |  |     final app = ApplicationWidget( | 
					
						
							| 
									
										
										
										
											2023-08-08 09:08:24 +08:00
										 |  |  |       key: ValueKey(context), | 
					
						
							| 
									
										
										
										
											2022-10-25 17:30:57 +08:00
										 |  |  |       appearanceSetting: appearanceSetting, | 
					
						
							| 
									
										
										
										
											2023-10-02 09:12:24 +02:00
										 |  |  |       dateTimeSettings: dateTimeSettings, | 
					
						
							| 
									
										
										
										
											2023-08-22 22:41:52 +08:00
										 |  |  |       appTheme: await appTheme(appearanceSetting.theme), | 
					
						
							| 
									
										
										
										
											2022-08-31 09:19:31 +08:00
										 |  |  |       child: widget, | 
					
						
							| 
									
										
										
										
											2022-01-28 18:34:21 +08:00
										 |  |  |     ); | 
					
						
							| 
									
										
										
										
											2023-05-17 16:33:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-31 11:15:35 +08:00
										 |  |  |     Bloc.observer = ApplicationBlocObserver(); | 
					
						
							|  |  |  |     runApp( | 
					
						
							|  |  |  |       EasyLocalization( | 
					
						
							|  |  |  |         supportedLocales: const [ | 
					
						
							|  |  |  |           // In alphabetical order
 | 
					
						
							| 
									
										
										
										
											2023-10-24 17:41:46 +08:00
										 |  |  |           Locale('am', 'ET'), | 
					
						
							| 
									
										
										
										
											2023-06-03 10:06:05 +05:30
										 |  |  |           Locale('ar', 'SA'), | 
					
						
							| 
									
										
										
										
											2022-08-31 11:15:35 +08:00
										 |  |  |           Locale('ca', 'ES'), | 
					
						
							| 
									
										
										
										
											2024-03-09 05:25:04 +01:00
										 |  |  |           Locale('cs', 'CZ'), | 
					
						
							| 
									
										
										
										
											2024-02-19 13:13:01 +03:30
										 |  |  |           Locale('ckb', 'KU'), | 
					
						
							| 
									
										
										
										
											2022-08-31 11:15:35 +08:00
										 |  |  |           Locale('de', 'DE'), | 
					
						
							|  |  |  |           Locale('en'), | 
					
						
							|  |  |  |           Locale('es', 'VE'), | 
					
						
							| 
									
										
										
										
											2023-01-18 10:20:42 +01:00
										 |  |  |           Locale('eu', 'ES'), | 
					
						
							| 
									
										
										
										
											2024-03-16 10:53:34 +07:00
										 |  |  |           Locale('el', 'GR'), | 
					
						
							| 
									
										
										
										
											2022-08-31 11:15:35 +08:00
										 |  |  |           Locale('fr', 'FR'), | 
					
						
							|  |  |  |           Locale('fr', 'CA'), | 
					
						
							|  |  |  |           Locale('hu', 'HU'), | 
					
						
							|  |  |  |           Locale('id', 'ID'), | 
					
						
							|  |  |  |           Locale('it', 'IT'), | 
					
						
							|  |  |  |           Locale('ja', 'JP'), | 
					
						
							| 
									
										
										
										
											2022-10-11 10:27:20 +09:00
										 |  |  |           Locale('ko', 'KR'), | 
					
						
							| 
									
										
										
										
											2022-08-31 11:15:35 +08:00
										 |  |  |           Locale('pl', 'PL'), | 
					
						
							|  |  |  |           Locale('pt', 'BR'), | 
					
						
							|  |  |  |           Locale('ru', 'RU'), | 
					
						
							| 
									
										
										
										
											2023-11-28 11:46:11 +08:00
										 |  |  |           Locale('sv', 'SE'), | 
					
						
							| 
									
										
										
										
											2023-11-23 11:40:09 +07:00
										 |  |  |           Locale('th', 'TH'), | 
					
						
							| 
									
										
										
										
											2022-08-31 11:15:35 +08:00
										 |  |  |           Locale('tr', 'TR'), | 
					
						
							| 
									
										
										
										
											2023-10-09 09:19:35 +05:00
										 |  |  |           Locale('uk', 'UA'), | 
					
						
							| 
									
										
										
										
											2023-09-20 21:01:17 +05:30
										 |  |  |           Locale('ur'), | 
					
						
							| 
									
										
										
										
											2023-10-11 21:15:59 +11:00
										 |  |  |           Locale('vi', 'VN'), | 
					
						
							| 
									
										
										
										
											2022-08-31 11:15:35 +08:00
										 |  |  |           Locale('zh', 'CN'), | 
					
						
							| 
									
										
										
										
											2023-04-03 12:53:54 +08:00
										 |  |  |           Locale('zh', 'TW'), | 
					
						
							| 
									
										
										
										
											2023-08-22 11:18:42 +03:30
										 |  |  |           Locale('fa'), | 
					
						
							| 
									
										
										
										
											2023-10-15 19:43:14 +05:30
										 |  |  |           Locale('hin'), | 
					
						
							| 
									
										
										
										
											2022-08-31 11:15:35 +08:00
										 |  |  |         ], | 
					
						
							|  |  |  |         path: 'assets/translations', | 
					
						
							|  |  |  |         fallbackLocale: const Locale('en'), | 
					
						
							| 
									
										
										
										
											2022-09-08 11:29:43 +08:00
										 |  |  |         useFallbackTranslations: true, | 
					
						
							| 
									
										
										
										
											2022-08-31 11:15:35 +08:00
										 |  |  |         child: app, | 
					
						
							|  |  |  |       ), | 
					
						
							| 
									
										
										
										
											2021-12-07 22:58:50 +05:30
										 |  |  |     ); | 
					
						
							| 
									
										
										
										
											2021-07-12 23:27:58 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-02 09:12:24 +02:00
										 |  |  |     return; | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2023-10-24 23:13:51 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   Future<void> dispose() async {} | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-28 01:17:38 -05:00
										 |  |  | class ApplicationWidget extends StatefulWidget { | 
					
						
							| 
									
										
										
										
											2021-07-22 11:23:15 +08:00
										 |  |  |   const ApplicationWidget({ | 
					
						
							| 
									
										
										
										
											2023-10-02 09:12:24 +02:00
										 |  |  |     super.key, | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  |     required this.child, | 
					
						
							| 
									
										
										
										
											2023-08-22 22:41:52 +08:00
										 |  |  |     required this.appTheme, | 
					
						
							| 
									
										
										
										
											2022-10-25 17:30:57 +08:00
										 |  |  |     required this.appearanceSetting, | 
					
						
							| 
									
										
										
										
											2023-10-02 09:12:24 +02:00
										 |  |  |     required this.dateTimeSettings, | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   final Widget child; | 
					
						
							|  |  |  |   final AppTheme appTheme; | 
					
						
							| 
									
										
										
										
											2023-10-12 06:54:08 +02:00
										 |  |  |   final AppearanceSettingsPB appearanceSetting; | 
					
						
							| 
									
										
										
										
											2023-10-02 09:12:24 +02:00
										 |  |  |   final DateTimeSettingsPB dateTimeSettings; | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2023-09-28 01:17:38 -05:00
										 |  |  |   State<ApplicationWidget> createState() => _ApplicationWidgetState(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class _ApplicationWidgetState extends State<ApplicationWidget> { | 
					
						
							|  |  |  |   late final GoRouter routerConfig; | 
					
						
							| 
									
										
										
										
											2022-11-10 14:22:18 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-23 15:46:57 +02:00
										 |  |  |   final _commandPaletteNotifier = ValueNotifier<bool>(false); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-28 01:17:38 -05:00
										 |  |  |   @override | 
					
						
							|  |  |  |   void initState() { | 
					
						
							|  |  |  |     super.initState(); | 
					
						
							| 
									
										
										
										
											2024-04-23 15:46:57 +02:00
										 |  |  |     // Avoid rebuild routerConfig when the appTheme is changed.
 | 
					
						
							| 
									
										
										
										
											2023-09-28 01:17:38 -05:00
										 |  |  |     routerConfig = generateRouter(widget.child); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-23 15:46:57 +02:00
										 |  |  |   @override | 
					
						
							|  |  |  |   void dispose() { | 
					
						
							|  |  |  |     _commandPaletteNotifier.dispose(); | 
					
						
							|  |  |  |     super.dispose(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-28 01:17:38 -05:00
										 |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							| 
									
										
										
										
											2023-07-04 14:30:38 -07:00
										 |  |  |     return MultiBlocProvider( | 
					
						
							|  |  |  |       providers: [ | 
					
						
							| 
									
										
										
										
											2024-04-23 15:46:57 +02:00
										 |  |  |         if (FeatureFlag.search.isOn) | 
					
						
							|  |  |  |           BlocProvider<CommandPaletteBloc>(create: (_) => CommandPaletteBloc()), | 
					
						
							| 
									
										
										
										
											2023-09-28 01:17:38 -05:00
										 |  |  |         BlocProvider<AppearanceSettingsCubit>( | 
					
						
							|  |  |  |           create: (_) => AppearanceSettingsCubit( | 
					
						
							|  |  |  |             widget.appearanceSetting, | 
					
						
							| 
									
										
										
										
											2023-10-02 09:12:24 +02:00
										 |  |  |             widget.dateTimeSettings, | 
					
						
							| 
									
										
										
										
											2023-09-28 01:17:38 -05:00
										 |  |  |             widget.appTheme, | 
					
						
							|  |  |  |           )..readLocaleWhenAppLaunch(context), | 
					
						
							|  |  |  |         ), | 
					
						
							| 
									
										
										
										
											2023-10-12 06:54:08 +02:00
										 |  |  |         BlocProvider<NotificationSettingsCubit>( | 
					
						
							| 
									
										
										
										
											2023-11-09 00:32:10 +01:00
										 |  |  |           create: (_) => NotificationSettingsCubit(), | 
					
						
							| 
									
										
										
										
											2023-10-12 06:54:08 +02:00
										 |  |  |         ), | 
					
						
							| 
									
										
										
										
											2023-07-04 14:30:38 -07:00
										 |  |  |         BlocProvider<DocumentAppearanceCubit>( | 
					
						
							|  |  |  |           create: (_) => DocumentAppearanceCubit()..fetch(), | 
					
						
							|  |  |  |         ), | 
					
						
							| 
									
										
										
										
											2024-01-29 20:55:37 +01:00
										 |  |  |         BlocProvider.value(value: getIt<RenameViewBloc>()), | 
					
						
							| 
									
										
										
										
											2024-04-23 15:46:57 +02:00
										 |  |  |         BlocProvider.value(value: getIt<ActionNavigationBloc>()), | 
					
						
							| 
									
										
										
										
											2023-07-04 14:30:38 -07:00
										 |  |  |       ], | 
					
						
							| 
									
										
										
										
											2024-04-12 10:21:41 +02:00
										 |  |  |       child: BlocListener<ActionNavigationBloc, ActionNavigationState>( | 
					
						
							| 
									
										
										
										
											2024-01-24 15:15:57 +01:00
										 |  |  |         listenWhen: (_, curr) => curr.action != null, | 
					
						
							| 
									
										
										
										
											2023-12-08 15:04:09 +02:00
										 |  |  |         listener: (context, state) { | 
					
						
							| 
									
										
										
										
											2024-01-24 15:15:57 +01:00
										 |  |  |           final action = state.action; | 
					
						
							|  |  |  |           WidgetsBinding.instance.addPostFrameCallback((_) { | 
					
						
							|  |  |  |             if (action?.type == ActionType.openView && | 
					
						
							|  |  |  |                 PlatformExtension.isDesktop) { | 
					
						
							|  |  |  |               final view = action!.arguments?[ActionArgumentKeys.view]; | 
					
						
							| 
									
										
										
										
											2024-06-05 04:05:51 +02:00
										 |  |  |               final nodePath = action.arguments?[ActionArgumentKeys.nodePath]; | 
					
						
							| 
									
										
										
										
											2023-12-08 15:04:09 +02:00
										 |  |  |               if (view != null) { | 
					
						
							| 
									
										
										
										
											2024-06-05 04:05:51 +02:00
										 |  |  |                 getIt<TabsBloc>().openPlugin( | 
					
						
							|  |  |  |                   view.plugin(), | 
					
						
							|  |  |  |                   arguments: {PluginArgumentKeys.selection: nodePath}, | 
					
						
							|  |  |  |                 ); | 
					
						
							| 
									
										
										
										
											2023-12-08 15:04:09 +02:00
										 |  |  |               } | 
					
						
							| 
									
										
										
										
											2024-01-24 15:15:57 +01:00
										 |  |  |             } else if (action?.type == ActionType.openRow && | 
					
						
							|  |  |  |                 PlatformExtension.isMobile) { | 
					
						
							|  |  |  |               final view = action!.arguments?[ActionArgumentKeys.view]; | 
					
						
							|  |  |  |               if (view != null) { | 
					
						
							|  |  |  |                 final view = action.arguments?[ActionArgumentKeys.view]; | 
					
						
							|  |  |  |                 final rowId = action.arguments?[ActionArgumentKeys.rowId]; | 
					
						
							|  |  |  |                 AppGlobals.rootNavKey.currentContext?.pushView(view, { | 
					
						
							|  |  |  |                   PluginArgumentKeys.rowId: rowId, | 
					
						
							|  |  |  |                 }); | 
					
						
							|  |  |  |               } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           }); | 
					
						
							| 
									
										
										
										
											2023-12-08 15:04:09 +02:00
										 |  |  |         }, | 
					
						
							|  |  |  |         child: BlocBuilder<AppearanceSettingsCubit, AppearanceSettingsState>( | 
					
						
							| 
									
										
										
										
											2024-01-26 00:24:33 +08:00
										 |  |  |           builder: (context, state) { | 
					
						
							|  |  |  |             _setSystemOverlayStyle(state); | 
					
						
							|  |  |  |             return MaterialApp.router( | 
					
						
							|  |  |  |               builder: (context, child) => MediaQuery( | 
					
						
							|  |  |  |                 // use the 1.0 as the textScaleFactor to avoid the text size
 | 
					
						
							|  |  |  |                 //  affected by the system setting.
 | 
					
						
							|  |  |  |                 data: MediaQuery.of(context).copyWith( | 
					
						
							| 
									
										
										
										
											2024-02-22 08:50:24 +07:00
										 |  |  |                   textScaler: TextScaler.linear(state.textScaleFactor), | 
					
						
							| 
									
										
										
										
											2024-01-26 00:24:33 +08:00
										 |  |  |                 ), | 
					
						
							| 
									
										
										
										
											2024-04-12 10:21:41 +02:00
										 |  |  |                 child: overlayManagerBuilder( | 
					
						
							|  |  |  |                   context, | 
					
						
							| 
									
										
										
										
											2024-05-02 02:10:56 +02:00
										 |  |  |                   !PlatformExtension.isMobile && FeatureFlag.search.isOn | 
					
						
							| 
									
										
										
										
											2024-04-23 15:46:57 +02:00
										 |  |  |                       ? CommandPalette( | 
					
						
							| 
									
										
										
										
											2024-05-02 02:10:56 +02:00
										 |  |  |                           notifier: _commandPaletteNotifier, | 
					
						
							| 
									
										
										
										
											2024-04-23 15:46:57 +02:00
										 |  |  |                           child: child, | 
					
						
							|  |  |  |                         ) | 
					
						
							|  |  |  |                       : child, | 
					
						
							| 
									
										
										
										
											2024-04-12 10:21:41 +02:00
										 |  |  |                 ), | 
					
						
							| 
									
										
										
										
											2023-12-19 22:31:23 +08:00
										 |  |  |               ), | 
					
						
							| 
									
										
										
										
											2024-01-26 00:24:33 +08:00
										 |  |  |               debugShowCheckedModeBanner: false, | 
					
						
							|  |  |  |               theme: state.lightTheme, | 
					
						
							|  |  |  |               darkTheme: state.darkTheme, | 
					
						
							|  |  |  |               themeMode: state.themeMode, | 
					
						
							|  |  |  |               localizationsDelegates: context.localizationDelegates, | 
					
						
							|  |  |  |               supportedLocales: context.supportedLocales, | 
					
						
							|  |  |  |               locale: state.locale, | 
					
						
							|  |  |  |               routerConfig: routerConfig, | 
					
						
							|  |  |  |             ); | 
					
						
							|  |  |  |           }, | 
					
						
							| 
									
										
										
										
											2022-11-10 14:22:18 +08:00
										 |  |  |         ), | 
					
						
							|  |  |  |       ), | 
					
						
							| 
									
										
										
										
											2022-06-01 15:22:18 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2024-01-26 00:24:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   void _setSystemOverlayStyle(AppearanceSettingsState state) { | 
					
						
							|  |  |  |     if (Platform.isAndroid) { | 
					
						
							| 
									
										
										
										
											2024-06-13 07:58:05 +08:00
										 |  |  |       SystemChrome.setEnabledSystemUIMode( | 
					
						
							|  |  |  |         SystemUiMode.edgeToEdge, | 
					
						
							|  |  |  |         overlays: [], | 
					
						
							|  |  |  |       ); | 
					
						
							| 
									
										
										
										
											2024-01-26 00:24:33 +08:00
										 |  |  |       SystemChrome.setSystemUIOverlayStyle( | 
					
						
							| 
									
										
										
										
											2024-06-13 07:58:05 +08:00
										 |  |  |         const SystemUiOverlayStyle( | 
					
						
							| 
									
										
										
										
											2024-01-26 00:24:33 +08:00
										 |  |  |           systemNavigationBarColor: Colors.transparent, | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class AppGlobals { | 
					
						
							|  |  |  |   static GlobalKey<NavigatorState> rootNavKey = GlobalKey(); | 
					
						
							|  |  |  |   static NavigatorState get nav => rootNavKey.currentState!; | 
					
						
							| 
									
										
										
										
											2024-05-30 09:56:44 +08:00
										 |  |  |   static BuildContext get context => rootNavKey.currentContext!; | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-10-30 14:44:43 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | class ApplicationBlocObserver extends BlocObserver { | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   void onError(BlocBase bloc, Object error, StackTrace stackTrace) { | 
					
						
							|  |  |  |     Log.debug(error); | 
					
						
							|  |  |  |     super.onError(bloc, error, stackTrace); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-08-22 22:41:52 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | Future<AppTheme> appTheme(String themeName) async { | 
					
						
							|  |  |  |   if (themeName.isEmpty) { | 
					
						
							|  |  |  |     return AppTheme.fallback; | 
					
						
							|  |  |  |   } else { | 
					
						
							|  |  |  |     try { | 
					
						
							|  |  |  |       return await AppTheme.fromName(themeName); | 
					
						
							|  |  |  |     } catch (e) { | 
					
						
							|  |  |  |       return AppTheme.fallback; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |