deps_resolver.dart 4.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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/doc_edit_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_listen.dart';
  7. import 'package:app_flowy/workspace/application/trash/trash_bloc.dart';
  8. import 'package:app_flowy/workspace/application/view/view_bloc.dart';
  9. import 'package:app_flowy/workspace/application/workspace/welcome_bloc.dart';
  10. import 'package:app_flowy/workspace/domain/i_doc.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-user/user_profile.pb.dart';
  24. import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
  25. import 'package:get_it/get_it.dart';
  26. import 'i_user_impl.dart';
  27. import 'i_view_impl.dart';
  28. class HomeDepsResolver {
  29. static Future<void> resolve(GetIt getIt) async {
  30. //
  31. getIt.registerLazySingleton<HomeStackManager>(() => HomeStackManager());
  32. getIt.registerFactoryParam<WelcomeBloc, UserProfile, void>(
  33. (user, _) => WelcomeBloc(
  34. repo: UserRepo(user: user),
  35. watch: getIt<IUserListener>(param1: user),
  36. ),
  37. );
  38. //App
  39. getIt.registerFactoryParam<IApp, String, void>((appId, _) => IAppImpl(repo: AppRepository(appId: appId)));
  40. getIt.registerFactoryParam<IAppListenr, String, void>(
  41. (appId, _) => IAppListenerhImpl(repo: AppListenerRepository(appId: appId)));
  42. //workspace
  43. getIt.registerFactoryParam<IWorkspace, UserProfile, String>(
  44. (user, workspaceId) => IWorkspaceImpl(repo: WorkspaceRepo(user: user, workspaceId: workspaceId)));
  45. getIt.registerFactoryParam<IWorkspaceListener, UserProfile, String>((user, workspaceId) =>
  46. IWorkspaceListenerImpl(repo: WorkspaceListenerRepo(user: user, workspaceId: workspaceId)));
  47. // View
  48. getIt.registerFactoryParam<IView, View, void>((view, _) => IViewImpl(repo: ViewRepository(view: view)));
  49. getIt.registerFactoryParam<IViewListener, View, void>(
  50. (view, _) => IViewListenerImpl(repo: ViewListenerRepository(view: view)));
  51. getIt.registerFactoryParam<ViewBloc, View, void>(
  52. (view, _) => ViewBloc(
  53. viewManager: getIt<IView>(param1: view),
  54. listener: getIt<IViewListener>(param1: view),
  55. ),
  56. );
  57. // Doc
  58. getIt.registerFactoryParam<IDoc, String, void>((docId, _) => IDocImpl(repo: DocRepository(docId: docId)));
  59. // User
  60. getIt.registerFactoryParam<IUser, UserProfile, void>((user, _) => IUserImpl(repo: UserRepo(user: user)));
  61. getIt.registerFactoryParam<IUserListener, UserProfile, void>((user, _) => IUserListenerImpl(user: user));
  62. //Menu Bloc
  63. getIt.registerFactoryParam<MenuBloc, UserProfile, String>(
  64. (user, workspaceId) => MenuBloc(getIt<IWorkspace>(param1: user, param2: workspaceId)));
  65. getIt.registerFactoryParam<MenuListenBloc, UserProfile, String>(
  66. (user, workspaceId) => MenuListenBloc(getIt<IWorkspaceListener>(param1: user, param2: workspaceId)));
  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(iDocImpl: getIt<IDoc>(param1: docId)));
  78. getIt.registerFactoryParam<DocEditBloc, String, void>((docId, _) => DocEditBloc(getIt<IDoc>(param1: docId)));
  79. // trash
  80. getIt.registerLazySingleton<TrashRepo>(() => TrashRepo());
  81. getIt.registerLazySingleton<TrashListenerRepo>(() => TrashListenerRepo());
  82. getIt.registerFactory<ITrash>(() => ITrashImpl(repo: getIt<TrashRepo>()));
  83. getIt.registerFactory<ITrashListener>(() => ITrashListenerImpl(repo: getIt<TrashListenerRepo>()));
  84. getIt.registerFactory<TrashBloc>(() => TrashBloc(trasnManager: getIt<ITrash>(), listener: getIt<ITrashListener>()));
  85. }
  86. }