| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  | import 'package:app_flowy/core/network_monitor.dart'; | 
					
						
							|  |  |  | import 'package:app_flowy/user/application/user_listener.dart'; | 
					
						
							|  |  |  | import 'package:app_flowy/user/application/user_service.dart'; | 
					
						
							|  |  |  | import 'package:app_flowy/workspace/application/app/prelude.dart'; | 
					
						
							|  |  |  | import 'package:app_flowy/workspace/application/doc/prelude.dart'; | 
					
						
							|  |  |  | import 'package:app_flowy/workspace/application/grid/prelude.dart'; | 
					
						
							|  |  |  | import 'package:app_flowy/workspace/application/trash/prelude.dart'; | 
					
						
							|  |  |  | import 'package:app_flowy/workspace/application/workspace/prelude.dart'; | 
					
						
							|  |  |  | import 'package:app_flowy/workspace/application/edit_pannel/edit_pannel_bloc.dart'; | 
					
						
							|  |  |  | import 'package:app_flowy/workspace/application/home/home_bloc.dart'; | 
					
						
							|  |  |  | import 'package:app_flowy/workspace/application/view/prelude.dart'; | 
					
						
							|  |  |  | import 'package:app_flowy/workspace/application/home/prelude.dart'; | 
					
						
							|  |  |  | import 'package:app_flowy/workspace/application/menu/prelude.dart'; | 
					
						
							|  |  |  | import 'package:app_flowy/user/application/prelude.dart'; | 
					
						
							|  |  |  | import 'package:app_flowy/user/presentation/router.dart'; | 
					
						
							|  |  |  | import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; | 
					
						
							| 
									
										
										
										
											2022-04-26 14:43:42 +08:00
										 |  |  | import 'package:app_flowy/workspace/presentation/home/menu/menu.dart'; | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  | import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart'; | 
					
						
							|  |  |  | import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart'; | 
					
						
							| 
									
										
										
										
											2022-03-28 22:47:30 +08:00
										 |  |  | import 'package:flowy_sdk/protobuf/flowy-grid/date_type_option.pb.dart'; | 
					
						
							| 
									
										
										
										
											2022-03-27 22:38:50 +08:00
										 |  |  | import 'package:flowy_sdk/protobuf/flowy-grid/number_type_option.pb.dart'; | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  | import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart'; | 
					
						
							|  |  |  | import 'package:get_it/get_it.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DependencyResolver { | 
					
						
							|  |  |  |   static Future<void> resolve(GetIt getIt) async { | 
					
						
							|  |  |  |     _resolveUserDeps(getIt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     _resolveHomeDeps(getIt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     _resolveFolderDeps(getIt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     _resolveDocDeps(getIt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     _resolveGridDeps(getIt); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void _resolveUserDeps(GetIt getIt) { | 
					
						
							|  |  |  |   getIt.registerFactory<AuthService>(() => AuthService()); | 
					
						
							|  |  |  |   getIt.registerFactory<AuthRouter>(() => AuthRouter()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getIt.registerFactory<SignInBloc>(() => SignInBloc(getIt<AuthService>())); | 
					
						
							|  |  |  |   getIt.registerFactory<SignUpBloc>(() => SignUpBloc(getIt<AuthService>())); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getIt.registerFactory<SplashRoute>(() => SplashRoute()); | 
					
						
							|  |  |  |   getIt.registerFactory<HomeBloc>(() => HomeBloc()); | 
					
						
							|  |  |  |   getIt.registerFactory<EditPannelBloc>(() => EditPannelBloc()); | 
					
						
							|  |  |  |   getIt.registerFactory<SplashBloc>(() => SplashBloc()); | 
					
						
							|  |  |  |   getIt.registerLazySingleton<NetworkListener>(() => NetworkListener()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void _resolveHomeDeps(GetIt getIt) { | 
					
						
							| 
									
										
										
										
											2022-04-26 14:43:42 +08:00
										 |  |  |   getIt.registerSingleton(MenuSharedState()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  |   getIt.registerFactoryParam<UserListener, UserProfile, void>( | 
					
						
							|  |  |  |     (user, _) => UserListener(user: user), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getIt.registerFactoryParam<HomeListenBloc, UserProfile, void>( | 
					
						
							|  |  |  |     (user, _) => HomeListenBloc(getIt<UserListener>(param1: user)), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   //
 | 
					
						
							|  |  |  |   getIt.registerLazySingleton<HomeStackManager>(() => HomeStackManager()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getIt.registerFactoryParam<WelcomeBloc, UserProfile, void>( | 
					
						
							|  |  |  |     (user, _) => WelcomeBloc( | 
					
						
							|  |  |  |       userService: UserService(), | 
					
						
							|  |  |  |       userListener: getIt<UserListener>(param1: user), | 
					
						
							|  |  |  |     ), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // share
 | 
					
						
							|  |  |  |   getIt.registerLazySingleton<ShareService>(() => ShareService()); | 
					
						
							|  |  |  |   getIt.registerFactoryParam<DocShareBloc, View, void>( | 
					
						
							|  |  |  |       (view, _) => DocShareBloc(view: view, service: getIt<ShareService>())); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void _resolveFolderDeps(GetIt getIt) { | 
					
						
							|  |  |  |   //workspace
 | 
					
						
							|  |  |  |   getIt.registerFactoryParam<WorkspaceListener, UserProfile, String>((user, workspaceId) => | 
					
						
							|  |  |  |       WorkspaceListener(service: WorkspaceListenerService(user: user, workspaceId: workspaceId))); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // View
 | 
					
						
							|  |  |  |   getIt.registerFactoryParam<ViewListener, View, void>( | 
					
						
							|  |  |  |     (view, _) => ViewListener(view: view), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getIt.registerFactoryParam<ViewBloc, View, void>( | 
					
						
							|  |  |  |     (view, _) => ViewBloc( | 
					
						
							|  |  |  |       view: view, | 
					
						
							|  |  |  |       service: ViewService(), | 
					
						
							|  |  |  |       listener: getIt<ViewListener>(param1: view), | 
					
						
							|  |  |  |     ), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   //Menu
 | 
					
						
							|  |  |  |   getIt.registerFactoryParam<MenuBloc, UserProfile, String>( | 
					
						
							|  |  |  |     (user, workspaceId) => MenuBloc( | 
					
						
							|  |  |  |       workspaceId: workspaceId, | 
					
						
							|  |  |  |       listener: getIt<WorkspaceListener>(param1: user, param2: workspaceId), | 
					
						
							|  |  |  |     ), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getIt.registerFactoryParam<MenuUserBloc, UserProfile, void>( | 
					
						
							|  |  |  |     (user, _) => MenuUserBloc( | 
					
						
							|  |  |  |       user, | 
					
						
							|  |  |  |       UserService(), | 
					
						
							|  |  |  |       getIt<UserListener>(param1: user), | 
					
						
							|  |  |  |     ), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // App
 | 
					
						
							|  |  |  |   getIt.registerFactoryParam<AppBloc, App, void>( | 
					
						
							|  |  |  |     (app, _) => AppBloc( | 
					
						
							|  |  |  |       app: app, | 
					
						
							| 
									
										
										
										
											2022-04-26 20:35:41 +08:00
										 |  |  |       appService: AppService(appId: app.id), | 
					
						
							| 
									
										
										
										
											2022-04-26 14:43:42 +08:00
										 |  |  |       appListener: AppListener(appId: app.id), | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  |     ), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // trash
 | 
					
						
							|  |  |  |   getIt.registerLazySingleton<TrashService>(() => TrashService()); | 
					
						
							|  |  |  |   getIt.registerLazySingleton<TrashListener>(() => TrashListener()); | 
					
						
							|  |  |  |   getIt.registerFactory<TrashBloc>( | 
					
						
							|  |  |  |     () => TrashBloc( | 
					
						
							|  |  |  |       service: getIt<TrashService>(), | 
					
						
							|  |  |  |       listener: getIt<TrashListener>(), | 
					
						
							|  |  |  |     ), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void _resolveDocDeps(GetIt getIt) { | 
					
						
							|  |  |  | // Doc
 | 
					
						
							|  |  |  |   getIt.registerFactoryParam<DocumentBloc, View, void>( | 
					
						
							|  |  |  |     (view, _) => DocumentBloc( | 
					
						
							|  |  |  |       view: view, | 
					
						
							|  |  |  |       service: DocumentService(), | 
					
						
							|  |  |  |       listener: getIt<ViewListener>(param1: view), | 
					
						
							|  |  |  |       trashService: getIt<TrashService>(), | 
					
						
							|  |  |  |     ), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void _resolveGridDeps(GetIt getIt) { | 
					
						
							|  |  |  |   // Grid
 | 
					
						
							|  |  |  |   getIt.registerFactoryParam<GridBloc, View, void>( | 
					
						
							| 
									
										
										
										
											2022-04-10 08:25:01 +08:00
										 |  |  |     (view, _) => GridBloc(view: view), | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 18:11:28 +08:00
										 |  |  |   getIt.registerFactoryParam<GridHeaderBloc, String, GridFieldCache>( | 
					
						
							|  |  |  |     (gridId, fieldCache) => GridHeaderBloc( | 
					
						
							|  |  |  |       gridId: gridId, | 
					
						
							|  |  |  |       fieldCache: fieldCache, | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  |     ), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-03 17:05:28 +08:00
										 |  |  |   getIt.registerFactoryParam<FieldActionSheetBloc, GridFieldCellContext, void>( | 
					
						
							|  |  |  |     (data, _) => FieldActionSheetBloc( | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  |       field: data.field, | 
					
						
							|  |  |  |       service: FieldService(gridId: data.gridId), | 
					
						
							|  |  |  |     ), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-07 16:36:59 +08:00
										 |  |  |   getIt.registerFactoryParam<FieldEditorBloc, String, EditFieldContextLoader>( | 
					
						
							| 
									
										
										
										
											2022-03-31 22:51:46 +08:00
										 |  |  |     (gridId, fieldLoader) => FieldEditorBloc( | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  |       service: FieldService(gridId: gridId), | 
					
						
							| 
									
										
										
										
											2022-03-31 22:51:46 +08:00
										 |  |  |       fieldLoader: fieldLoader, | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  |     ), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-24 17:03:00 +08:00
										 |  |  |   getIt.registerFactoryParam<TextCellBloc, GridDefaultCellContext, void>( | 
					
						
							| 
									
										
										
										
											2022-04-22 22:13:51 +08:00
										 |  |  |     (context, _) => TextCellBloc( | 
					
						
							| 
									
										
										
										
											2022-04-22 23:36:39 +08:00
										 |  |  |       cellContext: context, | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  |     ), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-24 17:03:00 +08:00
										 |  |  |   getIt.registerFactoryParam<SelectionCellBloc, GridSelectOptionCellContext, void>( | 
					
						
							| 
									
										
										
										
											2022-04-22 22:13:51 +08:00
										 |  |  |     (context, _) => SelectionCellBloc( | 
					
						
							| 
									
										
										
										
											2022-04-22 23:36:39 +08:00
										 |  |  |       cellContext: context, | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  |     ), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-24 07:10:09 +08:00
										 |  |  |   getIt.registerFactoryParam<NumberCellBloc, GridDefaultCellContext, void>( | 
					
						
							| 
									
										
										
										
											2022-04-22 22:13:51 +08:00
										 |  |  |     (context, _) => NumberCellBloc( | 
					
						
							| 
									
										
										
										
											2022-04-22 23:36:39 +08:00
										 |  |  |       cellContext: context, | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  |     ), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-24 07:10:09 +08:00
										 |  |  |   getIt.registerFactoryParam<DateCellBloc, GridDefaultCellContext, void>( | 
					
						
							| 
									
										
										
										
											2022-04-22 22:13:51 +08:00
										 |  |  |     (context, _) => DateCellBloc( | 
					
						
							| 
									
										
										
										
											2022-04-22 23:36:39 +08:00
										 |  |  |       cellContext: context, | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  |     ), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-24 07:10:09 +08:00
										 |  |  |   getIt.registerFactoryParam<CheckboxCellBloc, GridDefaultCellContext, void>( | 
					
						
							| 
									
										
										
										
											2022-03-26 20:27:32 +08:00
										 |  |  |     (cellData, _) => CheckboxCellBloc( | 
					
						
							|  |  |  |       service: CellService(), | 
					
						
							| 
									
										
										
										
											2022-04-22 23:36:39 +08:00
										 |  |  |       cellContext: cellData, | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  |     ), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-03 17:05:28 +08:00
										 |  |  |   getIt.registerFactoryParam<FieldSwitcherBloc, SwitchFieldContext, void>( | 
					
						
							|  |  |  |     (context, _) => FieldSwitcherBloc(context), | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-28 22:47:30 +08:00
										 |  |  |   getIt.registerFactoryParam<DateTypeOptionBloc, DateTypeOption, void>( | 
					
						
							|  |  |  |     (typeOption, _) => DateTypeOptionBloc(typeOption: typeOption), | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-27 22:38:50 +08:00
										 |  |  |   getIt.registerFactoryParam<NumberTypeOptionBloc, NumberTypeOption, void>( | 
					
						
							|  |  |  |     (typeOption, _) => NumberTypeOptionBloc(typeOption: typeOption), | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  |   ); | 
					
						
							| 
									
										
										
										
											2022-04-03 17:05:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-17 15:15:34 +08:00
										 |  |  |   getIt.registerFactoryParam<GridPropertyBloc, String, GridFieldCache>( | 
					
						
							|  |  |  |     (gridId, cache) => GridPropertyBloc(gridId: gridId, fieldCache: cache), | 
					
						
							| 
									
										
										
										
											2022-04-03 17:05:28 +08:00
										 |  |  |   ); | 
					
						
							| 
									
										
										
										
											2022-03-25 15:02:43 +08:00
										 |  |  | } |