deps_resolver.dart 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import 'package:app_flowy/user/application/sign_in_bloc.dart';
  2. import 'package:app_flowy/user/application/sign_up_bloc.dart';
  3. import 'package:app_flowy/user/application/splash_bloc.dart';
  4. import 'package:app_flowy/user/domain/i_auth.dart';
  5. import 'package:app_flowy/user/domain/i_splash.dart';
  6. import 'package:app_flowy/user/infrastructure/repos/auth_repo.dart';
  7. import 'package:app_flowy/user/infrastructure/i_auth_impl.dart';
  8. import 'package:app_flowy/user/infrastructure/i_splash_impl.dart';
  9. import 'package:app_flowy/workspace/application/edit_pannel/edit_pannel_bloc.dart';
  10. import 'package:app_flowy/workspace/application/home/home_bloc.dart';
  11. import 'package:app_flowy/workspace/application/home/home_auth_bloc.dart';
  12. import 'package:app_flowy/workspace/domain/i_user.dart';
  13. import 'package:app_flowy/workspace/infrastructure/i_user_impl.dart';
  14. import 'package:get_it/get_it.dart';
  15. class UserDepsResolver {
  16. static Future<void> resolve(GetIt getIt) async {
  17. getIt.registerFactory<AuthRepository>(() => AuthRepository());
  18. //Interface implementation
  19. getIt.registerFactory<IAuth>(() => AuthImpl(repo: getIt<AuthRepository>()));
  20. getIt.registerFactory<IAuthRouter>(() => AuthRouterImpl());
  21. //Bloc
  22. getIt.registerFactory<SignInBloc>(() => SignInBloc(getIt<IAuth>()));
  23. getIt.registerFactory<SignUpBloc>(() => SignUpBloc(getIt<IAuth>()));
  24. getIt.registerFactory<ISplashUser>(() => SplashUserImpl());
  25. getIt.registerFactory<ISplashRoute>(() => SplashRoute());
  26. getIt.registerFactory<HomeBloc>(() => HomeBloc());
  27. getIt.registerFactory<EditPannelBloc>(() => EditPannelBloc());
  28. getIt.registerFactory<SplashBloc>(() => SplashBloc(getIt<ISplashUser>()));
  29. getIt.registerFactoryParam<HomeAuthBloc, UserProfile, void>(
  30. (user, _) => HomeAuthBloc(
  31. getIt<IUserWatch>(param1: user),
  32. ),
  33. );
  34. }
  35. }