deps_resolver.dart 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import 'package:app_flowy/workspace/application/app/app_bloc.dart';
  2. import 'package:app_flowy/workspace/application/app/app_watch_bloc.dart';
  3. import 'package:app_flowy/workspace/application/doc/doc_bloc.dart';
  4. import 'package:app_flowy/workspace/application/menu/menu_bloc.dart';
  5. import 'package:app_flowy/workspace/application/menu/menu_watch.dart';
  6. import 'package:app_flowy/workspace/application/view/doc_watch_bloc.dart';
  7. import 'package:app_flowy/workspace/application/view/view_bloc.dart';
  8. import 'package:app_flowy/workspace/domain/i_doc.dart';
  9. import 'package:app_flowy/workspace/domain/i_view.dart';
  10. import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
  11. import 'package:app_flowy/workspace/infrastructure/i_app_impl.dart';
  12. import 'package:app_flowy/workspace/infrastructure/i_doc_impl.dart';
  13. import 'package:app_flowy/workspace/infrastructure/i_workspace_impl.dart';
  14. import 'package:app_flowy/workspace/infrastructure/repos/app_repo.dart';
  15. import 'package:app_flowy/workspace/infrastructure/repos/doc_repo.dart';
  16. import 'package:app_flowy/workspace/infrastructure/repos/view_repo.dart';
  17. import 'package:app_flowy/workspace/infrastructure/repos/workspace_repo.dart';
  18. import 'package:flowy_editor/flowy_editor.dart';
  19. import 'package:get_it/get_it.dart';
  20. import 'i_view_impl.dart';
  21. class HomeDepsResolver {
  22. static Future<void> resolve(GetIt getIt) async {
  23. //
  24. getIt.registerLazySingleton<HomePageStack>(() => HomePageStack());
  25. //App
  26. getIt.registerFactoryParam<IApp, String, void>(
  27. (appId, _) => IAppImpl(repo: AppRepository(appId: appId)));
  28. getIt.registerFactoryParam<IAppWatch, String, void>(
  29. (appId, _) => IAppWatchImpl(repo: AppWatchRepository(appId: appId)));
  30. //workspace
  31. getIt.registerFactoryParam<IWorkspace, String, void>((workspaceId, _) =>
  32. IWorkspaceImpl(repo: WorkspaceRepo(workspaceId: workspaceId)));
  33. getIt.registerFactoryParam<IWorkspaceWatch, String, void>((workspacId, _) =>
  34. IWorkspaceWatchImpl(repo: WorkspaceWatchRepo(workspaceId: workspacId)));
  35. // View
  36. getIt.registerFactoryParam<IView, String, void>(
  37. (viewId, _) => IViewImpl(repo: ViewRepository(viewId: viewId)));
  38. getIt.registerFactoryParam<IViewWatch, String, void>((viewId, _) =>
  39. IViewWatchImpl(repo: ViewWatchRepository(viewId: viewId)));
  40. // Doc
  41. getIt.registerFactoryParam<IDoc, String, void>(
  42. (docId, _) => IDocImpl(repo: DocRepository(docId: docId)));
  43. //Bloc
  44. getIt.registerFactoryParam<MenuBloc, String, void>(
  45. (workspaceId, _) => MenuBloc(getIt<IWorkspace>(param1: workspaceId)));
  46. getIt.registerFactoryParam<MenuWatchBloc, String, void>((workspaceId, _) =>
  47. MenuWatchBloc(getIt<IWorkspaceWatch>(param1: workspaceId)));
  48. getIt.registerFactoryParam<AppBloc, String, void>(
  49. (appId, _) => AppBloc(getIt<IApp>(param1: appId)));
  50. getIt.registerFactoryParam<AppWatchBloc, String, void>(
  51. (appId, _) => AppWatchBloc(getIt<IAppWatch>(param1: appId)));
  52. getIt.registerFactoryParam<ViewBloc, String, void>(
  53. (viewId, _) => ViewBloc(iViewImpl: getIt<IView>(param1: viewId)));
  54. getIt.registerFactoryParam<DocWatchBloc, String, void>(
  55. (docId, _) => DocWatchBloc(iDocImpl: getIt<IDoc>(param1: docId)));
  56. getIt.registerFactoryParam<DocBloc, String, void>(
  57. (docId, _) => DocBloc(getIt<IDoc>(param1: docId)));
  58. // editor
  59. getIt.registerFactoryParam<EditorPersistence, String, void>(
  60. (docId, _) => EditorPersistenceImpl(repo: DocRepository(docId: docId)));
  61. // getIt.registerFactoryParam<ViewBloc, String, void>(
  62. // (viewId, _) => ViewBloc(iViewImpl: getIt<IView>(param1: viewId)));
  63. }
  64. }