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/plugins/doc/application/prelude.dart'; import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:app_flowy/workspace/application/user/prelude.dart'; import 'package:app_flowy/workspace/application/workspace/prelude.dart'; import 'package:app_flowy/workspace/application/edit_panel/edit_panel_bloc.dart'; import 'package:app_flowy/workspace/application/view/prelude.dart'; import 'package:app_flowy/workspace/application/menu/prelude.dart'; import 'package:app_flowy/workspace/application/settings/prelude.dart'; import 'package:app_flowy/user/application/prelude.dart'; import 'package:app_flowy/user/presentation/router.dart'; import 'package:app_flowy/plugins/trash/application/prelude.dart'; import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; import 'package:app_flowy/workspace/presentation/home/menu/menu.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:get_it/get_it.dart'; import '../plugins/grid/application/field/field_controller.dart'; class DependencyResolver { static Future resolve(GetIt getIt) async { _resolveUserDeps(getIt); _resolveHomeDeps(getIt); _resolveFolderDeps(getIt); _resolveDocDeps(getIt); _resolveGridDeps(getIt); } } void _resolveUserDeps(GetIt getIt) { getIt.registerFactory(() => AuthService()); getIt.registerFactory(() => AuthRouter()); getIt.registerFactory(() => SignInBloc(getIt())); getIt.registerFactory(() => SignUpBloc(getIt())); getIt.registerFactory(() => SplashRoute()); getIt.registerFactory(() => EditPanelBloc()); getIt.registerFactory(() => SplashBloc()); getIt.registerLazySingleton(() => NetworkListener()); } void _resolveHomeDeps(GetIt getIt) { getIt.registerSingleton(FToast()); getIt.registerSingleton(MenuSharedState()); getIt.registerFactoryParam( (user, _) => UserListener(userProfile: user), ); // getIt.registerLazySingleton(() => HomeStackManager()); getIt.registerFactoryParam( (user, _) => WelcomeBloc( userService: UserService(userId: user.id), userWorkspaceListener: UserWorkspaceListener(userProfile: user), ), ); // share getIt.registerLazySingleton(() => ShareService()); getIt.registerFactoryParam( (view, _) => DocShareBloc(view: view, service: getIt())); } void _resolveFolderDeps(GetIt getIt) { //workspace getIt.registerFactoryParam( (user, workspaceId) => WorkspaceListener(user: user, workspaceId: workspaceId)); // ViewPB getIt.registerFactoryParam( (view, _) => ViewListener(view: view), ); getIt.registerFactoryParam( (view, _) => ViewBloc( view: view, service: ViewService(), listener: getIt(param1: view), ), ); //Menu getIt.registerFactoryParam( (user, workspaceId) => MenuBloc( workspaceId: workspaceId, listener: getIt(param1: user, param2: workspaceId), ), ); getIt.registerFactoryParam( (user, _) => MenuUserBloc(user), ); //Settings getIt.registerFactoryParam( (user, _) => SettingsDialogBloc(user), ); //User getIt.registerFactoryParam( (user, _) => SettingsUserViewBloc(user), ); // AppPB getIt.registerFactoryParam( (app, _) => AppBloc( app: app, appService: AppService(appId: app.id), appListener: AppListener(appId: app.id), ), ); // trash getIt.registerLazySingleton(() => TrashService()); getIt.registerLazySingleton(() => TrashListener()); getIt.registerFactory( () => TrashBloc( service: getIt(), listener: getIt(), ), ); } void _resolveDocDeps(GetIt getIt) { // Doc getIt.registerFactoryParam( (view, _) => DocumentBloc( view: view, service: DocumentService(), listener: getIt(param1: view), trashService: getIt(), ), ); } void _resolveGridDeps(GetIt getIt) { // GridPB getIt.registerFactoryParam( (view, _) => GridBloc(view: view), ); getIt.registerFactoryParam( (gridId, fieldController) => GridHeaderBloc( gridId: gridId, fieldController: fieldController, ), ); getIt.registerFactoryParam( (data, _) => FieldActionSheetBloc( field: data.field, fieldService: FieldService(gridId: data.gridId, fieldId: data.field.id), ), ); getIt.registerFactoryParam( (context, _) => TextCellBloc( cellController: context, ), ); getIt.registerFactoryParam( (context, _) => SelectOptionCellBloc( cellController: context, ), ); getIt.registerFactoryParam( (context, _) => NumberCellBloc( cellController: context, ), ); getIt.registerFactoryParam( (context, _) => DateCellBloc( cellController: context, ), ); getIt.registerFactoryParam( (cellData, _) => CheckboxCellBloc( service: CellService(), cellController: cellData, ), ); getIt.registerFactoryParam( (gridId, cache) => GridPropertyBloc(gridId: gridId, fieldController: cache), ); }