import 'package:appflowy/core/network_monitor.dart'; import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart'; import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart'; import 'package:appflowy/plugins/database_view/application/field/field_action_sheet_bloc.dart'; import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; import 'package:appflowy/plugins/database_view/application/field/field_service.dart'; import 'package:appflowy/plugins/database_view/application/setting/property_bloc.dart'; import 'package:appflowy/plugins/database_view/grid/application/cell/checkbox_cell_bloc.dart'; import 'package:appflowy/plugins/database_view/grid/application/cell/date_cell_bloc.dart'; import 'package:appflowy/plugins/database_view/grid/application/cell/number_cell_bloc.dart'; import 'package:appflowy/plugins/database_view/grid/application/cell/select_option_cell_bloc.dart'; import 'package:appflowy/plugins/database_view/grid/application/cell/text_cell_bloc.dart'; import 'package:appflowy/plugins/database_view/grid/application/grid_header_bloc.dart'; import 'package:appflowy/user/application/user_listener.dart'; import 'package:appflowy/user/application/user_service.dart'; import 'package:appflowy/util/file_picker/file_picker_impl.dart'; import 'package:appflowy/util/file_picker/file_picker_service.dart'; import 'package:appflowy/workspace/application/app/prelude.dart'; import 'package:appflowy/plugins/document/application/prelude.dart'; import 'package:appflowy/workspace/application/settings/settings_location_cubit.dart'; import 'package:appflowy/workspace/application/user/prelude.dart'; import 'package:appflowy/workspace/application/workspace/prelude.dart'; import 'package:appflowy/workspace/application/edit_panel/edit_panel_bloc.dart'; import 'package:appflowy/workspace/application/view/prelude.dart'; import 'package:appflowy/workspace/application/menu/prelude.dart'; import 'package:appflowy/workspace/application/settings/prelude.dart'; import 'package:appflowy/user/application/prelude.dart'; import 'package:appflowy/user/presentation/router.dart'; import 'package:appflowy/plugins/trash/application/prelude.dart'; import 'package:appflowy/workspace/presentation/home/home_stack.dart'; import 'package:appflowy/workspace/presentation/home/menu/menu.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/app.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart'; import 'package:fluttertoast/fluttertoast.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); _resolveCommonService(getIt); } } void _resolveCommonService(GetIt getIt) { getIt.registerFactory(() => FilePicker()); } 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: UserBackendService(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, ), ); getIt.registerFactoryParam( (user, _) => MenuUserBloc(user), ); //Settings getIt.registerFactoryParam( (user, _) => SettingsDialogBloc(user), ); // Location getIt.registerFactory( () => SettingsLocationCubit(), ); //User getIt.registerFactoryParam( (user, _) => SettingsUserViewBloc(user), ); // AppPB getIt.registerFactoryParam( (app, _) => AppBloc(app: app), ); // trash getIt.registerLazySingleton(() => TrashService()); getIt.registerLazySingleton(() => TrashListener()); getIt.registerFactory( () => TrashBloc(), ); } void _resolveDocDeps(GetIt getIt) { // Doc getIt.registerFactoryParam( (view, _) => DocumentBloc(view: view), ); } void _resolveGridDeps(GetIt getIt) { getIt.registerFactoryParam( (viewId, fieldController) => GridHeaderBloc( viewId: viewId, fieldController: fieldController, ), ); getIt.registerFactoryParam( (data, _) => FieldActionSheetBloc(fieldCellContext: data), ); 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: CellBackendService(), cellController: cellData, ), ); getIt.registerFactoryParam( (viewId, cache) => DatabasePropertyBloc(viewId: viewId, fieldController: cache), ); }