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/grid/row/row_listener.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'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid-data-model/grid.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart'; import 'package:get_it/get_it.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(() => HomeBloc()); getIt.registerFactory(() => EditPannelBloc()); getIt.registerFactory(() => SplashBloc()); getIt.registerLazySingleton(() => NetworkListener()); } void _resolveHomeDeps(GetIt getIt) { getIt.registerFactoryParam( (user, _) => UserListener(user: user), ); getIt.registerFactoryParam( (user, _) => HomeListenBloc(getIt(param1: user)), ); // getIt.registerLazySingleton(() => HomeStackManager()); getIt.registerFactoryParam( (user, _) => WelcomeBloc( userService: UserService(), userListener: getIt(param1: user), ), ); // share getIt.registerLazySingleton(() => ShareService()); getIt.registerFactoryParam( (view, _) => DocShareBloc(view: view, service: getIt())); } void _resolveFolderDeps(GetIt getIt) { //workspace getIt.registerFactoryParam((user, workspaceId) => WorkspaceListener(service: WorkspaceListenerService(user: user, workspaceId: workspaceId))); // View 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, service: WorkspaceService(), listener: getIt(param1: user, param2: workspaceId), ), ); getIt.registerFactoryParam( (user, _) => MenuUserBloc( user, UserService(), getIt(param1: user), ), ); // App getIt.registerFactoryParam( (app, _) => AppBloc( app: app, service: AppService(), listener: 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) { // Grid getIt.registerFactoryParam( (view, _) => GridBloc(view: view, service: GridService()), ); getIt.registerFactoryParam( (data, _) => RowBloc( rowData: data, rowlistener: RowListener(rowId: data.rowId), ), ); getIt.registerFactoryParam>( (gridId, fields) => GridHeaderBloc( data: GridHeaderData(gridId: gridId, fields: fields), service: FieldService(gridId: gridId), ), ); getIt.registerFactoryParam( (data, _) => EditFieldBloc( field: data.field, service: FieldService(gridId: data.gridId), ), ); getIt.registerFactoryParam( (gridId, _) => CreateFieldBloc( service: FieldService(gridId: gridId), ), ); getIt.registerFactoryParam( (cellData, _) => TextCellBloc( service: CellService(), cellData: cellData, ), ); getIt.registerFactoryParam( (cellData, _) => SelectionCellBloc( service: CellService(), cellData: cellData, ), ); getIt.registerFactoryParam( (cellData, _) => NumberCellBloc( service: CellService(), cellData: cellData, ), ); getIt.registerFactoryParam( (cellData, _) => DateCellBloc( service: CellService(), cellData: cellData, ), ); getIt.registerFactoryParam( (cellData, _) => CheckboxCellBloc( service: CellService(), cellData: cellData, ), ); getIt.registerFactoryParam( (context, _) => SwitchFieldTypeBloc(context), ); getIt.registerFactory( () => SelectionTypeOptionBloc(), ); getIt.registerFactory( () => DateTypeOptionBloc(), ); getIt.registerFactory( () => NumberTypeOptionBloc(), ); }