deps_resolver.dart 3.0 KB

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