deps_resolver.dart 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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/doc/doc_edit_bloc.dart';
  5. import 'package:app_flowy/workspace/application/menu/menu_bloc.dart';
  6. import 'package:app_flowy/workspace/application/menu/menu_user_bloc.dart';
  7. import 'package:app_flowy/workspace/application/menu/menu_watch.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_sdk/protobuf/flowy-user/user_profile.pb.dart';
  22. import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
  23. import 'package:get_it/get_it.dart';
  24. import 'i_user_impl.dart';
  25. import 'i_view_impl.dart';
  26. class HomeDepsResolver {
  27. static Future<void> resolve(GetIt getIt) async {
  28. //
  29. getIt.registerLazySingleton<HomeStack>(() => HomeStack());
  30. //App
  31. getIt.registerFactoryParam<IApp, String, void>((appId, _) => IAppImpl(repo: AppRepository(appId: appId)));
  32. getIt.registerFactoryParam<IAppWatch, String, void>(
  33. (appId, _) => IAppWatchImpl(repo: AppWatchRepository(appId: appId)));
  34. //workspace
  35. getIt.registerFactoryParam<IWorkspace, UserProfile, String>(
  36. (user, workspaceId) => IWorkspaceImpl(repo: WorkspaceRepo(user: user, workspaceId: workspaceId)));
  37. getIt.registerFactoryParam<IWorkspaceWatch, UserProfile, String>(
  38. (user, workspaceId) => IWorkspaceWatchImpl(repo: WorkspaceWatchRepo(user: user, workspaceId: workspaceId)));
  39. // View
  40. getIt.registerFactoryParam<IView, View, void>((view, _) => IViewImpl(repo: ViewRepository(view: view)));
  41. getIt.registerFactoryParam<IViewWatch, View, void>(
  42. (view, _) => IViewWatchImpl(repo: ViewWatchRepository(view: view)));
  43. // Doc
  44. getIt.registerFactoryParam<IDoc, String, void>((docId, _) => IDocImpl(repo: DocRepository(docId: docId)));
  45. // User
  46. getIt.registerFactoryParam<IUser, UserProfile, void>((user, _) => IUserImpl(repo: UserRepo(user: user)));
  47. getIt.registerFactoryParam<IUserWatch, UserProfile, void>((user, _) => IUserWatchImpl(user: user));
  48. //Menu Bloc
  49. getIt.registerFactoryParam<MenuBloc, UserProfile, String>(
  50. (user, workspaceId) => MenuBloc(getIt<IWorkspace>(param1: user, param2: workspaceId)));
  51. getIt.registerFactoryParam<MenuWatchBloc, UserProfile, String>(
  52. (user, workspaceId) => MenuWatchBloc(getIt<IWorkspaceWatch>(param1: user, param2: workspaceId)));
  53. getIt.registerFactoryParam<MenuUserBloc, UserProfile, void>(
  54. (user, _) => MenuUserBloc(getIt<IUser>(param1: user), getIt<IUserWatch>(param1: user)));
  55. //
  56. getIt.registerFactoryParam<AppBloc, String, void>((appId, _) => AppBloc(getIt<IApp>(param1: appId)));
  57. getIt.registerFactoryParam<AppWatchBloc, String, void>((appId, _) => AppWatchBloc(getIt<IAppWatch>(param1: appId)));
  58. getIt
  59. .registerFactoryParam<ViewBloc, String, void>((viewId, _) => ViewBloc(iViewImpl: getIt<IView>(param1: viewId)));
  60. getIt.registerFactoryParam<DocBloc, String, void>((docId, _) => DocBloc(iDocImpl: getIt<IDoc>(param1: docId)));
  61. getIt.registerFactoryParam<DocEditBloc, String, void>((docId, _) => DocEditBloc(getIt<IDoc>(param1: docId)));
  62. // editor
  63. getIt.registerFactoryParam<ViewListBloc, List<View>, void>((views, _) => ViewListBloc(views: views));
  64. getIt.registerFactoryParam<WelcomeBloc, UserProfile, void>(
  65. (user, _) => WelcomeBloc(
  66. repo: UserRepo(user: user),
  67. watch: getIt<IUserWatch>(param1: user),
  68. ),
  69. );
  70. // getIt.registerFactoryParam<ViewBloc, String, void>(
  71. // (viewId, _) => ViewBloc(iViewImpl: getIt<IView>(param1: viewId)));
  72. }
  73. }