deps_resolver.dart 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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/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<HomeStackManager>(() => HomeStackManager());
  30. getIt.registerFactoryParam<WelcomeBloc, UserProfile, void>(
  31. (user, _) => WelcomeBloc(
  32. repo: UserRepo(user: user),
  33. listener: getIt<IUserListener>(param1: user),
  34. ),
  35. );
  36. //App
  37. getIt.registerFactoryParam<IApp, String, void>((appId, _) => IAppImpl(repo: AppRepository(appId: appId)));
  38. getIt.registerFactoryParam<IAppListenr, String, void>(
  39. (appId, _) => IAppListenerhImpl(repo: AppListenerRepository(appId: appId)));
  40. //workspace
  41. getIt.registerFactoryParam<IWorkspace, UserProfile, String>(
  42. (user, workspaceId) => IWorkspaceImpl(repo: WorkspaceRepo(user: user, workspaceId: workspaceId)));
  43. getIt.registerFactoryParam<IWorkspaceListener, UserProfile, String>((user, workspaceId) =>
  44. IWorkspaceListenerImpl(repo: WorkspaceListenerRepo(user: user, workspaceId: workspaceId)));
  45. // View
  46. getIt.registerFactoryParam<IView, View, void>((view, _) => IViewImpl(repo: ViewRepository(view: view)));
  47. getIt.registerFactoryParam<IViewListener, View, void>(
  48. (view, _) => IViewListenerImpl(repo: ViewListenerRepository(view: view)));
  49. getIt.registerFactoryParam<ViewBloc, View, void>(
  50. (view, _) => ViewBloc(
  51. viewManager: getIt<IView>(param1: view),
  52. listener: getIt<IViewListener>(param1: view),
  53. ),
  54. );
  55. // Doc
  56. getIt.registerFactoryParam<IDoc, String, void>((docId, _) => IDocImpl(repo: DocRepository(docId: docId)));
  57. // User
  58. getIt.registerFactoryParam<IUser, UserProfile, void>((user, _) => IUserImpl(repo: UserRepo(user: user)));
  59. getIt.registerFactoryParam<IUserListener, UserProfile, void>((user, _) => IUserListenerImpl(user: user));
  60. //Menu Bloc
  61. getIt.registerFactoryParam<MenuBloc, UserProfile, String>(
  62. (user, workspaceId) => MenuBloc(
  63. workspaceManager: getIt<IWorkspace>(param1: user, param2: workspaceId),
  64. listener: getIt<IWorkspaceListener>(param1: user, param2: workspaceId),
  65. ),
  66. );
  67. getIt.registerFactoryParam<MenuUserBloc, UserProfile, void>(
  68. (user, _) => MenuUserBloc(getIt<IUser>(param1: user), getIt<IUserListener>(param1: user)));
  69. // App
  70. getIt.registerFactoryParam<AppBloc, String, void>(
  71. (appId, _) => AppBloc(
  72. appManager: getIt<IApp>(param1: appId),
  73. listener: getIt<IAppListenr>(param1: appId),
  74. ),
  75. );
  76. // Doc
  77. getIt.registerFactoryParam<DocBloc, String, void>((docId, _) => DocBloc(docManager: getIt<IDoc>(param1: docId)));
  78. // trash
  79. getIt.registerLazySingleton<TrashRepo>(() => TrashRepo());
  80. getIt.registerLazySingleton<TrashListenerRepo>(() => TrashListenerRepo());
  81. getIt.registerFactory<ITrash>(() => ITrashImpl(repo: getIt<TrashRepo>()));
  82. getIt.registerFactory<ITrashListener>(() => ITrashListenerImpl(repo: getIt<TrashListenerRepo>()));
  83. getIt.registerFactory<TrashBloc>(() => TrashBloc(trasnManager: getIt<ITrash>(), listener: getIt<ITrashListener>()));
  84. }
  85. }