deps_resolver.dart 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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/doc/share_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/trash/trash_bloc.dart';
  7. import 'package:app_flowy/workspace/application/view/view_bloc.dart';
  8. import 'package:app_flowy/workspace/application/workspace/welcome_bloc.dart';
  9. import 'package:app_flowy/workspace/domain/i_doc.dart';
  10. import 'package:app_flowy/workspace/domain/i_share.dart';
  11. import 'package:app_flowy/workspace/domain/i_trash.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_trash_impl.dart';
  17. import 'package:app_flowy/workspace/infrastructure/i_workspace_impl.dart';
  18. import 'package:app_flowy/workspace/infrastructure/repos/app_repo.dart';
  19. import 'package:app_flowy/workspace/infrastructure/repos/doc_repo.dart';
  20. import 'package:app_flowy/workspace/infrastructure/repos/trash_repo.dart';
  21. import 'package:app_flowy/workspace/infrastructure/repos/view_repo.dart';
  22. import 'package:app_flowy/workspace/infrastructure/repos/workspace_repo.dart';
  23. import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
  24. import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
  25. import 'package:get_it/get_it.dart';
  26. import 'i_share_impl.dart';
  27. import 'i_user_impl.dart';
  28. import 'i_view_impl.dart';
  29. import 'repos/share_repo.dart';
  30. class HomeDepsResolver {
  31. static Future<void> resolve(GetIt getIt) async {
  32. //
  33. getIt.registerLazySingleton<HomeStackManager>(() => HomeStackManager());
  34. getIt.registerFactoryParam<WelcomeBloc, UserProfile, void>(
  35. (user, _) => WelcomeBloc(
  36. repo: UserRepo(user: user),
  37. listener: getIt<IUserListener>(param1: user),
  38. ),
  39. );
  40. //App
  41. getIt.registerFactoryParam<IApp, String, void>((appId, _) => IAppImpl(repo: AppRepository(appId: appId)));
  42. getIt.registerFactoryParam<IAppListenr, String, void>(
  43. (appId, _) => IAppListenerhImpl(repo: AppListenerRepository(appId: appId)));
  44. //workspace
  45. getIt.registerFactoryParam<IWorkspace, UserProfile, String>(
  46. (user, workspaceId) => IWorkspaceImpl(repo: WorkspaceRepo(user: user, workspaceId: workspaceId)));
  47. getIt.registerFactoryParam<IWorkspaceListener, UserProfile, String>((user, workspaceId) =>
  48. IWorkspaceListenerImpl(repo: WorkspaceListenerRepo(user: user, workspaceId: workspaceId)));
  49. // View
  50. getIt.registerFactoryParam<IView, View, void>((view, _) => IViewImpl(repo: ViewRepository(view: view)));
  51. getIt.registerFactoryParam<IViewListener, View, void>(
  52. (view, _) => IViewListenerImpl(repo: ViewListenerRepository(view: view)));
  53. getIt.registerFactoryParam<ViewBloc, View, void>(
  54. (view, _) => ViewBloc(
  55. viewManager: getIt<IView>(param1: view),
  56. listener: getIt<IViewListener>(param1: view),
  57. ),
  58. );
  59. // Doc
  60. getIt.registerFactoryParam<IDoc, String, void>((docId, _) => IDocImpl(repo: DocRepository(docId: docId)));
  61. // User
  62. getIt.registerFactoryParam<IUser, UserProfile, void>((user, _) => IUserImpl(repo: UserRepo(user: user)));
  63. getIt.registerFactoryParam<IUserListener, UserProfile, void>((user, _) => IUserListenerImpl(user: user));
  64. //Menu Bloc
  65. getIt.registerFactoryParam<MenuBloc, UserProfile, String>(
  66. (user, workspaceId) => MenuBloc(
  67. workspaceManager: getIt<IWorkspace>(param1: user, param2: workspaceId),
  68. listener: getIt<IWorkspaceListener>(param1: user, param2: workspaceId),
  69. ),
  70. );
  71. getIt.registerFactoryParam<MenuUserBloc, UserProfile, void>(
  72. (user, _) => MenuUserBloc(getIt<IUser>(param1: user), getIt<IUserListener>(param1: user)));
  73. // App
  74. getIt.registerFactoryParam<AppBloc, App, void>(
  75. (app, _) => AppBloc(
  76. app: app,
  77. appManager: getIt<IApp>(param1: app.id),
  78. listener: getIt<IAppListenr>(param1: app.id),
  79. ),
  80. );
  81. // Doc
  82. getIt.registerFactoryParam<DocBloc, View, void>(
  83. (view, _) => DocBloc(
  84. view: view,
  85. docManager: getIt<IDoc>(param1: view.id),
  86. listener: getIt<IViewListener>(param1: view),
  87. trasnManager: getIt<ITrash>(),
  88. ),
  89. );
  90. // trash
  91. getIt.registerLazySingleton<TrashRepo>(() => TrashRepo());
  92. getIt.registerLazySingleton<TrashListenerRepo>(() => TrashListenerRepo());
  93. getIt.registerFactory<ITrash>(() => ITrashImpl(repo: getIt<TrashRepo>()));
  94. getIt.registerFactory<ITrashListener>(() => ITrashListenerImpl(repo: getIt<TrashListenerRepo>()));
  95. getIt.registerFactory<TrashBloc>(() => TrashBloc(trasnManager: getIt<ITrash>(), listener: getIt<ITrashListener>()));
  96. // share
  97. getIt.registerLazySingleton<ShareRepo>(() => ShareRepo());
  98. getIt.registerFactory<IShare>(() => IShareImpl(repo: getIt<ShareRepo>()));
  99. getIt.registerFactoryParam<DocShareBloc, View, void>(
  100. (view, _) => DocShareBloc(view: view, shareManager: getIt<IShare>()));
  101. }
  102. }