deps_resolver.dart 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import 'package:app_flowy/workspace/application/app/app_bloc.dart';
  2. import 'package:app_flowy/workspace/application/doc/doc_bloc.dart';
  3. import 'package:app_flowy/workspace/application/menu/menu_bloc.dart';
  4. import 'package:app_flowy/workspace/application/menu/menu_user_bloc.dart';
  5. import 'package:app_flowy/workspace/application/trash/trash_bloc.dart';
  6. import 'package:app_flowy/workspace/application/view/view_bloc.dart';
  7. import 'package:app_flowy/workspace/application/workspace/welcome_bloc.dart';
  8. import 'package:app_flowy/workspace/domain/i_doc.dart';
  9. import 'package:app_flowy/workspace/domain/i_trash.dart';
  10. import 'package:app_flowy/workspace/domain/i_view.dart';
  11. import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
  12. import 'package:app_flowy/workspace/infrastructure/i_app_impl.dart';
  13. import 'package:app_flowy/workspace/infrastructure/i_doc_impl.dart';
  14. import 'package:app_flowy/workspace/infrastructure/i_trash_impl.dart';
  15. import 'package:app_flowy/workspace/infrastructure/i_workspace_impl.dart';
  16. import 'package:app_flowy/workspace/infrastructure/repos/app_repo.dart';
  17. import 'package:app_flowy/workspace/infrastructure/repos/doc_repo.dart';
  18. import 'package:app_flowy/workspace/infrastructure/repos/trash_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-infra/app_create.pb.dart';
  23. import 'package:flowy_sdk/protobuf/flowy-workspace-infra/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<HomeStackManager>(() => HomeStackManager());
  31. getIt.registerFactoryParam<WelcomeBloc, UserProfile, void>(
  32. (user, _) => WelcomeBloc(
  33. repo: UserRepo(user: user),
  34. listener: getIt<IUserListener>(param1: user),
  35. ),
  36. );
  37. //App
  38. getIt.registerFactoryParam<IApp, String, void>((appId, _) => IAppImpl(repo: AppRepository(appId: appId)));
  39. getIt.registerFactoryParam<IAppListenr, String, void>(
  40. (appId, _) => IAppListenerhImpl(repo: AppListenerRepository(appId: appId)));
  41. //workspace
  42. getIt.registerFactoryParam<IWorkspace, UserProfile, String>(
  43. (user, workspaceId) => IWorkspaceImpl(repo: WorkspaceRepo(user: user, workspaceId: workspaceId)));
  44. getIt.registerFactoryParam<IWorkspaceListener, UserProfile, String>((user, workspaceId) =>
  45. IWorkspaceListenerImpl(repo: WorkspaceListenerRepo(user: user, workspaceId: workspaceId)));
  46. // View
  47. getIt.registerFactoryParam<IView, View, void>((view, _) => IViewImpl(repo: ViewRepository(view: view)));
  48. getIt.registerFactoryParam<IViewListener, View, void>(
  49. (view, _) => IViewListenerImpl(repo: ViewListenerRepository(view: view)));
  50. getIt.registerFactoryParam<ViewBloc, View, void>(
  51. (view, _) => ViewBloc(
  52. viewManager: getIt<IView>(param1: view),
  53. listener: getIt<IViewListener>(param1: view),
  54. ),
  55. );
  56. // Doc
  57. getIt.registerFactoryParam<IDoc, String, void>((docId, _) => IDocImpl(repo: DocRepository(docId: docId)));
  58. // User
  59. getIt.registerFactoryParam<IUser, UserProfile, void>((user, _) => IUserImpl(repo: UserRepo(user: user)));
  60. getIt.registerFactoryParam<IUserListener, UserProfile, void>((user, _) => IUserListenerImpl(user: user));
  61. //Menu Bloc
  62. getIt.registerFactoryParam<MenuBloc, UserProfile, String>(
  63. (user, workspaceId) => MenuBloc(
  64. workspaceManager: getIt<IWorkspace>(param1: user, param2: workspaceId),
  65. listener: getIt<IWorkspaceListener>(param1: user, param2: workspaceId),
  66. ),
  67. );
  68. getIt.registerFactoryParam<MenuUserBloc, UserProfile, void>(
  69. (user, _) => MenuUserBloc(getIt<IUser>(param1: user), getIt<IUserListener>(param1: user)));
  70. // App
  71. getIt.registerFactoryParam<AppBloc, App, void>(
  72. (app, _) => AppBloc(
  73. app: app,
  74. appManager: getIt<IApp>(param1: app.id),
  75. listener: getIt<IAppListenr>(param1: app.id),
  76. ),
  77. );
  78. // Doc
  79. getIt.registerFactoryParam<DocBloc, View, void>(
  80. (view, _) => DocBloc(
  81. view: view,
  82. docManager: getIt<IDoc>(param1: view.id),
  83. listener: getIt<IViewListener>(param1: view),
  84. trasnManager: getIt<ITrash>(),
  85. ),
  86. );
  87. // trash
  88. getIt.registerLazySingleton<TrashRepo>(() => TrashRepo());
  89. getIt.registerLazySingleton<TrashListenerRepo>(() => TrashListenerRepo());
  90. getIt.registerFactory<ITrash>(() => ITrashImpl(repo: getIt<TrashRepo>()));
  91. getIt.registerFactory<ITrashListener>(() => ITrashListenerImpl(repo: getIt<TrashListenerRepo>()));
  92. getIt.registerFactory<TrashBloc>(() => TrashBloc(trasnManager: getIt<ITrash>(), listener: getIt<ITrashListener>()));
  93. }
  94. }