mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
remove iAuth interface
This commit is contained in:
parent
4aa51a933d
commit
f709bb6a6d
@ -57,7 +57,7 @@ class ApplicationWidget extends StatelessWidget {
|
||||
value: settingModel,
|
||||
builder: (context, _) {
|
||||
const ratio = 1.73;
|
||||
const minWidth = 1000.0;
|
||||
const minWidth = 600.0;
|
||||
setWindowMinSize(const Size(minWidth, minWidth / ratio));
|
||||
AppTheme theme = context.select<AppearanceSettingModel, AppTheme>(
|
||||
(value) => value.theme,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import 'package:app_flowy/user/domain/i_auth.dart';
|
||||
import 'package:app_flowy/user/infrastructure/repos/auth_repo.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile, ErrorCode;
|
||||
@ -8,8 +8,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
part 'sign_in_bloc.freezed.dart';
|
||||
|
||||
class SignInBloc extends Bloc<SignInEvent, SignInState> {
|
||||
final IAuth authManager;
|
||||
SignInBloc(this.authManager) : super(SignInState.initial()) {
|
||||
final AuthRepository authRepo;
|
||||
SignInBloc(this.authRepo) : super(SignInState.initial()) {
|
||||
on<SignInEvent>((event, emit) async {
|
||||
await event.map(
|
||||
signedInWithUserEmailAndPassword: (e) async {
|
||||
@ -31,7 +31,10 @@ class SignInBloc extends Bloc<SignInEvent, SignInState> {
|
||||
Future<void> _performActionOnSignIn(SignInState state, Emitter<SignInState> emit) async {
|
||||
emit(state.copyWith(isSubmitting: true, emailError: none(), passwordError: none(), successOrFail: none()));
|
||||
|
||||
final result = await authManager.signIn(state.email, state.password);
|
||||
final result = await authRepo.signIn(
|
||||
email: state.email,
|
||||
password: state.password,
|
||||
);
|
||||
emit(result.fold(
|
||||
(userProfile) => state.copyWith(isSubmitting: false, successOrFail: some(left(userProfile))),
|
||||
(error) => stateFromCode(error),
|
||||
|
@ -1,4 +1,4 @@
|
||||
import 'package:app_flowy/user/domain/i_auth.dart';
|
||||
import 'package:app_flowy/user/infrastructure/repos/auth_repo.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile, ErrorCode;
|
||||
@ -10,8 +10,8 @@ import 'package:app_flowy/generated/locale_keys.g.dart';
|
||||
part 'sign_up_bloc.freezed.dart';
|
||||
|
||||
class SignUpBloc extends Bloc<SignUpEvent, SignUpState> {
|
||||
final IAuth authManager;
|
||||
SignUpBloc(this.authManager) : super(SignUpState.initial()) {
|
||||
final AuthRepository autoRepo;
|
||||
SignUpBloc(this.autoRepo) : super(SignUpState.initial()) {
|
||||
on<SignUpEvent>((event, emit) async {
|
||||
await event.map(signUpWithUserEmailAndPassword: (e) async {
|
||||
await _performActionOnSignUp(emit);
|
||||
@ -62,7 +62,11 @@ class SignUpBloc extends Bloc<SignUpEvent, SignUpState> {
|
||||
repeatPasswordError: none(),
|
||||
));
|
||||
|
||||
final result = await authManager.signUp(state.email, state.password, state.email);
|
||||
final result = await autoRepo.signUp(
|
||||
name: state.email,
|
||||
password: state.password,
|
||||
email: state.email,
|
||||
);
|
||||
emit(result.fold(
|
||||
(profile) => state.copyWith(
|
||||
isSubmitting: false,
|
||||
|
@ -1,8 +1,4 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/protobuf.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class NewUser {
|
||||
UserProfile profile;
|
||||
@ -12,16 +8,3 @@ class NewUser {
|
||||
required this.workspaceId,
|
||||
});
|
||||
}
|
||||
|
||||
abstract class IAuth {
|
||||
Future<Either<UserProfile, FlowyError>> signIn(String? email, String? password);
|
||||
Future<Either<UserProfile, FlowyError>> signUp(String? name, String? password, String? email);
|
||||
Future<Either<Unit, FlowyError>> signOut();
|
||||
}
|
||||
|
||||
abstract class IAuthRouter {
|
||||
void pushWelcomeScreen(BuildContext context, UserProfile userProfile);
|
||||
void pushSignUpScreen(BuildContext context);
|
||||
void pushForgetPasswordScreen(BuildContext context);
|
||||
void pushHomeScreen(BuildContext context, UserProfile profile, CurrentWorkspaceSetting workspaceSetting);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:app_flowy/user/application/sign_in_bloc.dart';
|
||||
import 'package:app_flowy/user/application/sign_up_bloc.dart';
|
||||
import 'package:app_flowy/user/application/splash_bloc.dart';
|
||||
import 'package:app_flowy/user/domain/i_auth.dart';
|
||||
import 'package:app_flowy/user/domain/i_splash.dart';
|
||||
import 'package:app_flowy/user/infrastructure/repos/auth_repo.dart';
|
||||
import 'package:app_flowy/user/infrastructure/i_auth_impl.dart';
|
||||
@ -20,12 +19,11 @@ class UserDepsResolver {
|
||||
getIt.registerFactory<AuthRepository>(() => AuthRepository());
|
||||
|
||||
//Interface implementation
|
||||
getIt.registerFactory<IAuth>(() => AuthImpl(repo: getIt<AuthRepository>()));
|
||||
getIt.registerFactory<IAuthRouter>(() => AuthRouterImpl());
|
||||
getIt.registerFactory<AuthRouter>(() => AuthRouter());
|
||||
|
||||
//Bloc
|
||||
getIt.registerFactory<SignInBloc>(() => SignInBloc(getIt<IAuth>()));
|
||||
getIt.registerFactory<SignUpBloc>(() => SignUpBloc(getIt<IAuth>()));
|
||||
getIt.registerFactory<SignInBloc>(() => SignInBloc(getIt<AuthRepository>()));
|
||||
getIt.registerFactory<SignUpBloc>(() => SignUpBloc(getIt<AuthRepository>()));
|
||||
|
||||
getIt.registerFactory<ISplashUser>(() => SplashUserImpl());
|
||||
getIt.registerFactory<ISplashRoute>(() => SplashRoute());
|
||||
|
@ -1,7 +1,8 @@
|
||||
import 'package:app_flowy/startup/startup.dart';
|
||||
import 'package:app_flowy/user/domain/auth_state.dart';
|
||||
import 'package:app_flowy/user/domain/i_auth.dart';
|
||||
import 'package:app_flowy/user/domain/i_splash.dart';
|
||||
import 'package:app_flowy/user/infrastructure/router.dart';
|
||||
import 'package:app_flowy/user/infrastructure/repos/auth_repo.dart';
|
||||
import 'package:app_flowy/user/presentation/sign_in_screen.dart';
|
||||
import 'package:app_flowy/user/presentation/skip_log_in_screen.dart';
|
||||
import 'package:app_flowy/user/presentation/welcome_screen.dart';
|
||||
@ -59,7 +60,7 @@ class SplashRoute implements ISplashRoute {
|
||||
void pushSignInScreen(BuildContext context) {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRoutes.fade(() => SignInScreen(router: getIt<IAuthRouter>()), RouteDurations.slow.inMilliseconds * .001),
|
||||
PageRoutes.fade(() => SignInScreen(router: getIt<AuthRouter>()), RouteDurations.slow.inMilliseconds * .001),
|
||||
);
|
||||
}
|
||||
|
||||
@ -69,8 +70,8 @@ class SplashRoute implements ISplashRoute {
|
||||
context,
|
||||
PageRoutes.fade(
|
||||
() => SkipLogInScreen(
|
||||
router: getIt<IAuthRouter>(),
|
||||
authManager: getIt<IAuth>(),
|
||||
router: getIt<AuthRouter>(),
|
||||
authRepo: getIt<AuthRepository>(),
|
||||
),
|
||||
RouteDurations.slow.inMilliseconds * .001),
|
||||
);
|
||||
|
@ -2,59 +2,30 @@ import 'package:app_flowy/startup/startup.dart';
|
||||
import 'package:app_flowy/user/domain/i_splash.dart';
|
||||
import 'package:app_flowy/user/presentation/sign_up_screen.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/home_screen.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_infra/time/duration.dart';
|
||||
import 'package:flowy_infra_ui/widget/route/animation.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile;
|
||||
import 'package:app_flowy/user/domain/i_auth.dart';
|
||||
import 'package:app_flowy/user/infrastructure/repos/auth_repo.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/protobuf.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AuthImpl extends IAuth {
|
||||
AuthRepository repo;
|
||||
AuthImpl({
|
||||
required this.repo,
|
||||
});
|
||||
|
||||
@override
|
||||
Future<Either<UserProfile, FlowyError>> signIn(String? email, String? password) {
|
||||
return repo.signIn(email: email, password: password);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Either<UserProfile, FlowyError>> signUp(String? name, String? password, String? email) {
|
||||
return repo.signUp(name: name, password: password, email: email);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Either<Unit, FlowyError>> signOut() {
|
||||
return repo.signOut();
|
||||
}
|
||||
}
|
||||
|
||||
class AuthRouterImpl extends IAuthRouter {
|
||||
class AuthRouter {
|
||||
@override
|
||||
void pushForgetPasswordScreen(BuildContext context) {
|
||||
// TODO: implement showForgetPasswordScreen
|
||||
}
|
||||
|
||||
@override
|
||||
void pushWelcomeScreen(BuildContext context, UserProfile userProfile) {
|
||||
getIt<ISplashRoute>().pushWelcomeScreen(context, userProfile);
|
||||
}
|
||||
|
||||
@override
|
||||
void pushSignUpScreen(BuildContext context) {
|
||||
Navigator.of(context).push(
|
||||
PageRoutes.fade(
|
||||
() => SignUpScreen(router: getIt<IAuthRouter>()),
|
||||
() => SignUpScreen(router: getIt<AuthRouter>()),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void pushHomeScreen(BuildContext context, UserProfile profile, CurrentWorkspaceSetting workspaceSetting) {
|
||||
Navigator.push(
|
||||
context,
|
@ -1,6 +1,6 @@
|
||||
import 'package:app_flowy/startup/startup.dart';
|
||||
import 'package:app_flowy/user/application/sign_in_bloc.dart';
|
||||
import 'package:app_flowy/user/domain/i_auth.dart';
|
||||
import 'package:app_flowy/user/infrastructure/router.dart';
|
||||
import 'package:app_flowy/user/presentation/widgets/background.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_infra/size.dart';
|
||||
@ -18,7 +18,7 @@ import 'package:flowy_infra/image.dart';
|
||||
import 'package:app_flowy/generated/locale_keys.g.dart';
|
||||
|
||||
class SignInScreen extends StatelessWidget {
|
||||
final IAuthRouter router;
|
||||
final AuthRouter router;
|
||||
const SignInScreen({Key? key, required this.router}) : super(key: key);
|
||||
|
||||
@override
|
||||
@ -48,7 +48,7 @@ class SignInScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
class SignInForm extends StatelessWidget {
|
||||
final IAuthRouter router;
|
||||
final AuthRouter router;
|
||||
const SignInForm({
|
||||
Key? key,
|
||||
required this.router,
|
||||
@ -88,7 +88,7 @@ class SignUpPrompt extends StatelessWidget {
|
||||
required this.router,
|
||||
}) : super(key: key);
|
||||
|
||||
final IAuthRouter router;
|
||||
final AuthRouter router;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -138,7 +138,7 @@ class ForgetPasswordButton extends StatelessWidget {
|
||||
required this.router,
|
||||
}) : super(key: key);
|
||||
|
||||
final IAuthRouter router;
|
||||
final AuthRouter router;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:app_flowy/user/domain/i_auth.dart';
|
||||
import 'package:app_flowy/user/infrastructure/i_auth_impl.dart';
|
||||
import 'package:app_flowy/user/infrastructure/repos/auth_repo.dart';
|
||||
import 'package:app_flowy/user/presentation/widgets/background.dart';
|
||||
import 'package:app_flowy/workspace/domain/i_user.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
@ -18,13 +19,13 @@ import 'package:dartz/dartz.dart' as dartz;
|
||||
import 'package:app_flowy/generated/locale_keys.g.dart';
|
||||
|
||||
class SkipLogInScreen extends StatefulWidget {
|
||||
final IAuthRouter router;
|
||||
final IAuth authManager;
|
||||
final AuthRouter router;
|
||||
final AuthRepository authRepo;
|
||||
|
||||
const SkipLogInScreen({
|
||||
Key? key,
|
||||
required this.router,
|
||||
required this.authManager,
|
||||
required this.authRepo,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@ -97,7 +98,11 @@ class _SkipLogInScreenState extends State<SkipLogInScreen> {
|
||||
const password = "AppFlowy123@";
|
||||
final uid = uuid();
|
||||
final userEmail = "$uid@appflowy.io";
|
||||
final result = await widget.authManager.signUp(LocaleKeys.defaultUsername.tr(), password, userEmail);
|
||||
final result = await widget.authRepo.signUp(
|
||||
name: LocaleKeys.defaultUsername.tr(),
|
||||
password: password,
|
||||
email: userEmail,
|
||||
);
|
||||
result.fold(
|
||||
(user) {
|
||||
FolderEventReadCurWorkspace().send().then((result) {
|
||||
|
@ -179,7 +179,7 @@ class DocumentShareButton extends StatelessWidget {
|
||||
child: Selector<AppearanceSettingModel, AppLanguage>(
|
||||
selector: (ctx, notifier) => notifier.language,
|
||||
builder: (ctx, _, child) => ConstrainedBox(
|
||||
constraints: BoxConstraints.expand(
|
||||
constraints: const BoxConstraints.expand(
|
||||
height: 30,
|
||||
// minWidth: buttonWidth,
|
||||
width: 100,
|
||||
|
@ -6,6 +6,7 @@ import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import connectivity_plus_macos
|
||||
import desktop_window
|
||||
import device_info_plus_macos
|
||||
import flowy_infra_ui
|
||||
import flowy_sdk
|
||||
@ -17,6 +18,7 @@ import window_size
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
|
||||
DesktopWindowPlugin.register(with: registry.registrar(forPlugin: "DesktopWindowPlugin"))
|
||||
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||
FlowyInfraUIPlugin.register(with: registry.registrar(forPlugin: "FlowyInfraUIPlugin"))
|
||||
FlowySdkPlugin.register(with: registry.registrar(forPlugin: "FlowySdkPlugin"))
|
||||
|
@ -260,6 +260,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.6.8"
|
||||
desktop_window:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: desktop_window
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.0"
|
||||
device_info_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -58,6 +58,7 @@ dependencies:
|
||||
url: git://github.com/google/flutter-desktop-embedding.git
|
||||
path: plugins/window_size
|
||||
ref: e48abe7c3e9ebfe0b81622167c5201d4e783bb81
|
||||
desktop_window: ^0.4.0
|
||||
sized_context: ^1.0.0+1
|
||||
styled_widget: "^0.3.1"
|
||||
expandable: ^5.0.1
|
||||
|
@ -40,7 +40,6 @@ pub extern "C" fn async_event(port: i64, input: *const u8, len: usize) {
|
||||
let dispatcher = match FLOWY_SDK.get() {
|
||||
None => {
|
||||
log::error!("sdk not init yet.");
|
||||
|
||||
return;
|
||||
}
|
||||
Some(e) => e.dispatcher.clone(),
|
||||
@ -59,7 +58,6 @@ pub extern "C" fn sync_event(input: *const u8, len: usize) -> *const u8 {
|
||||
let dispatcher = match FLOWY_SDK.get() {
|
||||
None => {
|
||||
log::error!("sdk not init yet.");
|
||||
|
||||
return forget_rust(Vec::default());
|
||||
}
|
||||
Some(e) => e.dispatcher.clone(),
|
||||
|
Loading…
Reference in New Issue
Block a user