i_auth_impl.dart 1.7 KB

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