deps_resolver.dart 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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_user_bloc.dart';
  6. import 'package:app_flowy/workspace/application/menu/menu_watch.dart';
  7. import 'package:app_flowy/workspace/application/view/doc_watch_bloc.dart';
  8. import 'package:app_flowy/workspace/application/view/view_bloc.dart';
  9. import 'package:app_flowy/workspace/application/view/view_list_bloc.dart';
  10. import 'package:app_flowy/workspace/application/workspace/welcome_bloc.dart';
  11. import 'package:app_flowy/workspace/domain/i_doc.dart';
  12. import 'package:app_flowy/workspace/domain/i_view.dart';
  13. import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
  14. import 'package:app_flowy/workspace/infrastructure/i_app_impl.dart';
  15. import 'package:app_flowy/workspace/infrastructure/i_doc_impl.dart';
  16. import 'package:app_flowy/workspace/infrastructure/i_workspace_impl.dart';
  17. import 'package:app_flowy/workspace/infrastructure/repos/app_repo.dart';
  18. import 'package:app_flowy/workspace/infrastructure/repos/doc_repo.dart';
  19. import 'package:app_flowy/workspace/infrastructure/repos/view_repo.dart';
  20. import 'package:app_flowy/workspace/infrastructure/repos/workspace_repo.dart';
  21. import 'package:flowy_editor/flowy_editor.dart';
  22. import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
  23. import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
  24. import 'package:get_it/get_it.dart';
  25. import 'i_user_impl.dart';
  26. import 'i_view_impl.dart';
  27. class HomeDepsResolver {
  28. static Future<void> resolve(GetIt getIt) async {
  29. //
  30. getIt.registerLazySingleton<HomePageStack>(() => HomePageStack());
  31. //App
  32. getIt.registerFactoryParam<IApp, String, void>(
  33. (appId, _) => IAppImpl(repo: AppRepository(appId: appId)));
  34. getIt.registerFactoryParam<IAppWatch, String, void>(
  35. (appId, _) => IAppWatchImpl(repo: AppWatchRepository(appId: appId)));
  36. //workspace
  37. getIt.registerFactoryParam<IWorkspace, UserProfile, String>(
  38. (user, workspaceId) => IWorkspaceImpl(
  39. repo: WorkspaceRepo(user: user, workspaceId: workspaceId)));
  40. getIt.registerFactoryParam<IWorkspaceWatch, UserProfile, String>(
  41. (user, workspaceId) => IWorkspaceWatchImpl(
  42. repo: WorkspaceWatchRepo(user: user, workspaceId: workspaceId)));
  43. // View
  44. getIt.registerFactoryParam<IView, View, void>(
  45. (view, _) => IViewImpl(repo: ViewRepository(view: view)));
  46. getIt.registerFactoryParam<IViewWatch, View, void>(
  47. (view, _) => IViewWatchImpl(repo: ViewWatchRepository(view: view)));
  48. // Doc
  49. getIt.registerFactoryParam<IDoc, String, void>(
  50. (docId, _) => IDocImpl(repo: DocRepository(docId: docId)));
  51. // User
  52. getIt.registerFactoryParam<IUser, UserProfile, void>(
  53. (user, _) => IUserImpl(repo: UserRepo(user: user)));
  54. getIt.registerFactoryParam<IUserWatch, UserProfile, void>(
  55. (user, _) => IUserWatchImpl(user: user));
  56. //Menu Bloc
  57. getIt.registerFactoryParam<MenuBloc, UserProfile, String>(
  58. (user, workspaceId) =>
  59. MenuBloc(getIt<IWorkspace>(param1: user, param2: workspaceId)));
  60. getIt.registerFactoryParam<MenuWatchBloc, UserProfile, String>(
  61. (user, workspaceId) => MenuWatchBloc(
  62. getIt<IWorkspaceWatch>(param1: user, param2: workspaceId)));
  63. getIt.registerFactoryParam<MenuUserBloc, UserProfile, void>((user, _) =>
  64. MenuUserBloc(
  65. getIt<IUser>(param1: user), getIt<IUserWatch>(param1: user)));
  66. //
  67. getIt.registerFactoryParam<AppBloc, String, void>(
  68. (appId, _) => AppBloc(getIt<IApp>(param1: appId)));
  69. getIt.registerFactoryParam<AppWatchBloc, String, void>(
  70. (appId, _) => AppWatchBloc(getIt<IAppWatch>(param1: appId)));
  71. getIt.registerFactoryParam<ViewBloc, String, void>(
  72. (viewId, _) => ViewBloc(iViewImpl: getIt<IView>(param1: viewId)));
  73. getIt.registerFactoryParam<DocWatchBloc, String, void>(
  74. (docId, _) => DocWatchBloc(iDocImpl: getIt<IDoc>(param1: docId)));
  75. getIt.registerFactoryParam<DocBloc, String, void>(
  76. (docId, _) => DocBloc(getIt<IDoc>(param1: docId)));
  77. // editor
  78. getIt.registerFactoryParam<EditorPersistence, String, void>(
  79. (docId, _) => EditorPersistenceImpl(repo: DocRepository(docId: docId)));
  80. getIt.registerFactoryParam<ViewListBloc, List<View>, void>(
  81. (views, _) => ViewListBloc(views: views));
  82. getIt.registerFactoryParam<WelcomeBloc, UserProfile, void>(
  83. (user, _) => WelcomeBloc(
  84. repo: UserRepo(user: user),
  85. watch: getIt<IUserWatch>(param1: user),
  86. ),
  87. );
  88. // getIt.registerFactoryParam<ViewBloc, String, void>(
  89. // (viewId, _) => ViewBloc(iViewImpl: getIt<IView>(param1: viewId)));
  90. }
  91. }