i_auth_impl.dart 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import 'package:app_flowy/startup/startup.dart';
  2. import 'package:app_flowy/user/presentation/sign_up_screen.dart';
  3. import 'package:app_flowy/welcome/domain/i_welcome.dart';
  4. import 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart';
  5. import 'package:app_flowy/workspace/presentation/workspace/workspace_select_screen.dart';
  6. import 'package:dartz/dartz.dart';
  7. import 'package:flowy_infra_ui/widget/route/animation.dart';
  8. import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
  9. import 'package:app_flowy/user/domain/i_auth.dart';
  10. import 'package:app_flowy/user/infrastructure/repos/auth_repo.dart';
  11. import 'package:flutter/material.dart';
  12. class AuthImpl extends IAuth {
  13. AuthRepository repo;
  14. AuthImpl({
  15. required this.repo,
  16. });
  17. @override
  18. Future<Either<UserProfile, UserError>> signIn(
  19. String? email, String? password) {
  20. return repo.signIn(email: email, password: password);
  21. }
  22. @override
  23. Future<Either<UserProfile, UserError>> signUp(
  24. String? name, String? password, String? email) {
  25. return repo.signUp(name: name, password: password, email: email);
  26. }
  27. @override
  28. Future<Either<Unit, UserError>> signOut() {
  29. return repo.signOut();
  30. }
  31. }
  32. class AuthRouterImpl extends IAuthRouter {
  33. @override
  34. void pushForgetPasswordScreen(BuildContext context) {
  35. // TODO: implement showForgetPasswordScreen
  36. }
  37. @override
  38. void pushWelcomeScreen(BuildContext context, UserProfile userProfile) {
  39. getIt<IWelcomeRoute>().pushWelcomeScreen(context, userProfile);
  40. }
  41. @override
  42. void pushSignUpScreen(BuildContext context) {
  43. Navigator.of(context).push(
  44. PageRoutes.fade(
  45. () => SignUpScreen(router: getIt<IAuthRouter>()),
  46. ),
  47. );
  48. }
  49. }