2021-07-25 18:04:16 +08:00
|
|
|
import 'package:app_flowy/workspace/presentation/home/home_screen.dart';
|
2021-07-13 13:14:49 +08:00
|
|
|
import 'package:dartz/dartz.dart';
|
2021-07-13 14:28:01 +08:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
|
2021-07-21 15:43:05 +08:00
|
|
|
import 'package:app_flowy/user/domain/i_auth.dart';
|
|
|
|
import 'package:app_flowy/user/infrastructure/repos/auth_repo.dart';
|
2021-07-25 18:04:16 +08:00
|
|
|
import 'package:flutter/material.dart';
|
2021-07-13 13:14:49 +08:00
|
|
|
|
|
|
|
class AuthImpl extends IAuth {
|
|
|
|
AuthRepository repo;
|
|
|
|
AuthImpl({
|
|
|
|
required this.repo,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<Either<UserDetail, UserError>> signIn(
|
|
|
|
String? email, String? password) {
|
|
|
|
return repo.signIn(email: email, password: password);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<Either<UserDetail, UserError>> signUp(
|
|
|
|
String? name, String? password, String? email) {
|
|
|
|
return repo.signUp(name: name, password: password, email: email);
|
|
|
|
}
|
2021-07-13 13:23:03 +08:00
|
|
|
|
|
|
|
@override
|
|
|
|
Future<Either<Unit, UserError>> signOut() {
|
|
|
|
return repo.signOut();
|
|
|
|
}
|
2021-07-13 13:14:49 +08:00
|
|
|
}
|
2021-07-25 18:04:16 +08:00
|
|
|
|
|
|
|
class AuthRouterImpl extends IAuthRouter {
|
|
|
|
@override
|
|
|
|
void showForgetPasswordScreen(BuildContext context) {
|
|
|
|
// TODO: implement showForgetPasswordScreen
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void showHomeScreen(BuildContext context, UserDetail user) {
|
|
|
|
Navigator.pushReplacement(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) {
|
|
|
|
return HomeScreen(user);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void showSignUpScreen(BuildContext context) {
|
|
|
|
// TODO: implement showSignUpScreen
|
|
|
|
}
|
|
|
|
}
|