diff --git a/frontend/app_flowy/lib/startup/tasks/application_widget.dart b/frontend/app_flowy/lib/startup/tasks/application_widget.dart index e99509afad..375d4a299a 100644 --- a/frontend/app_flowy/lib/startup/tasks/application_widget.dart +++ b/frontend/app_flowy/lib/startup/tasks/application_widget.dart @@ -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( (value) => value.theme, diff --git a/frontend/app_flowy/lib/user/application/sign_in_bloc.dart b/frontend/app_flowy/lib/user/application/sign_in_bloc.dart index e384a64a60..3bba8b3217 100644 --- a/frontend/app_flowy/lib/user/application/sign_in_bloc.dart +++ b/frontend/app_flowy/lib/user/application/sign_in_bloc.dart @@ -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 { - final IAuth authManager; - SignInBloc(this.authManager) : super(SignInState.initial()) { + final AuthRepository authRepo; + SignInBloc(this.authRepo) : super(SignInState.initial()) { on((event, emit) async { await event.map( signedInWithUserEmailAndPassword: (e) async { @@ -31,7 +31,10 @@ class SignInBloc extends Bloc { Future _performActionOnSignIn(SignInState state, Emitter 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), diff --git a/frontend/app_flowy/lib/user/application/sign_up_bloc.dart b/frontend/app_flowy/lib/user/application/sign_up_bloc.dart index dd8e599017..af1f028741 100644 --- a/frontend/app_flowy/lib/user/application/sign_up_bloc.dart +++ b/frontend/app_flowy/lib/user/application/sign_up_bloc.dart @@ -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 { - final IAuth authManager; - SignUpBloc(this.authManager) : super(SignUpState.initial()) { + final AuthRepository autoRepo; + SignUpBloc(this.autoRepo) : super(SignUpState.initial()) { on((event, emit) async { await event.map(signUpWithUserEmailAndPassword: (e) async { await _performActionOnSignUp(emit); @@ -62,7 +62,11 @@ class SignUpBloc extends Bloc { 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, diff --git a/frontend/app_flowy/lib/user/domain/i_auth.dart b/frontend/app_flowy/lib/user/domain/i_auth.dart index 5133c07e5c..cff6b5d05f 100644 --- a/frontend/app_flowy/lib/user/domain/i_auth.dart +++ b/frontend/app_flowy/lib/user/domain/i_auth.dart @@ -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> signIn(String? email, String? password); - Future> signUp(String? name, String? password, String? email); - Future> 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); -} diff --git a/frontend/app_flowy/lib/user/infrastructure/deps_resolver.dart b/frontend/app_flowy/lib/user/infrastructure/deps_resolver.dart index 113f100c7b..aaaa9f81b1 100644 --- a/frontend/app_flowy/lib/user/infrastructure/deps_resolver.dart +++ b/frontend/app_flowy/lib/user/infrastructure/deps_resolver.dart @@ -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()); //Interface implementation - getIt.registerFactory(() => AuthImpl(repo: getIt())); - getIt.registerFactory(() => AuthRouterImpl()); + getIt.registerFactory(() => AuthRouter()); //Bloc - getIt.registerFactory(() => SignInBloc(getIt())); - getIt.registerFactory(() => SignUpBloc(getIt())); + getIt.registerFactory(() => SignInBloc(getIt())); + getIt.registerFactory(() => SignUpBloc(getIt())); getIt.registerFactory(() => SplashUserImpl()); getIt.registerFactory(() => SplashRoute()); diff --git a/frontend/app_flowy/lib/user/infrastructure/i_splash_impl.dart b/frontend/app_flowy/lib/user/infrastructure/i_splash_impl.dart index ce3daf8461..6064c3a489 100644 --- a/frontend/app_flowy/lib/user/infrastructure/i_splash_impl.dart +++ b/frontend/app_flowy/lib/user/infrastructure/i_splash_impl.dart @@ -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()), RouteDurations.slow.inMilliseconds * .001), + PageRoutes.fade(() => SignInScreen(router: getIt()), RouteDurations.slow.inMilliseconds * .001), ); } @@ -69,8 +70,8 @@ class SplashRoute implements ISplashRoute { context, PageRoutes.fade( () => SkipLogInScreen( - router: getIt(), - authManager: getIt(), + router: getIt(), + authRepo: getIt(), ), RouteDurations.slow.inMilliseconds * .001), ); diff --git a/frontend/app_flowy/lib/user/infrastructure/i_auth_impl.dart b/frontend/app_flowy/lib/user/infrastructure/router.dart similarity index 57% rename from frontend/app_flowy/lib/user/infrastructure/i_auth_impl.dart rename to frontend/app_flowy/lib/user/infrastructure/router.dart index 6596fa7dc1..1bbb9e78d1 100644 --- a/frontend/app_flowy/lib/user/infrastructure/i_auth_impl.dart +++ b/frontend/app_flowy/lib/user/infrastructure/router.dart @@ -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> signIn(String? email, String? password) { - return repo.signIn(email: email, password: password); - } - - @override - Future> signUp(String? name, String? password, String? email) { - return repo.signUp(name: name, password: password, email: email); - } - - @override - Future> 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().pushWelcomeScreen(context, userProfile); } - @override void pushSignUpScreen(BuildContext context) { Navigator.of(context).push( PageRoutes.fade( - () => SignUpScreen(router: getIt()), + () => SignUpScreen(router: getIt()), ), ); } - @override void pushHomeScreen(BuildContext context, UserProfile profile, CurrentWorkspaceSetting workspaceSetting) { Navigator.push( context, diff --git a/frontend/app_flowy/lib/user/presentation/sign_in_screen.dart b/frontend/app_flowy/lib/user/presentation/sign_in_screen.dart index 8e5f817676..07ca83f64a 100644 --- a/frontend/app_flowy/lib/user/presentation/sign_in_screen.dart +++ b/frontend/app_flowy/lib/user/presentation/sign_in_screen.dart @@ -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) { diff --git a/frontend/app_flowy/lib/user/presentation/skip_log_in_screen.dart b/frontend/app_flowy/lib/user/presentation/skip_log_in_screen.dart index 6db6ce9d8b..2f3dd8127b 100644 --- a/frontend/app_flowy/lib/user/presentation/skip_log_in_screen.dart +++ b/frontend/app_flowy/lib/user/presentation/skip_log_in_screen.dart @@ -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 { 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) { diff --git a/frontend/app_flowy/lib/workspace/presentation/stack_page/doc/doc_stack_page.dart b/frontend/app_flowy/lib/workspace/presentation/stack_page/doc/doc_stack_page.dart index 5db2e12e4d..6127ab0fc8 100644 --- a/frontend/app_flowy/lib/workspace/presentation/stack_page/doc/doc_stack_page.dart +++ b/frontend/app_flowy/lib/workspace/presentation/stack_page/doc/doc_stack_page.dart @@ -179,7 +179,7 @@ class DocumentShareButton extends StatelessWidget { child: Selector( selector: (ctx, notifier) => notifier.language, builder: (ctx, _, child) => ConstrainedBox( - constraints: BoxConstraints.expand( + constraints: const BoxConstraints.expand( height: 30, // minWidth: buttonWidth, width: 100, diff --git a/frontend/app_flowy/macos/Flutter/GeneratedPluginRegistrant.swift b/frontend/app_flowy/macos/Flutter/GeneratedPluginRegistrant.swift index 8d97942332..da7d6b58e2 100644 --- a/frontend/app_flowy/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/frontend/app_flowy/macos/Flutter/GeneratedPluginRegistrant.swift @@ -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")) diff --git a/frontend/app_flowy/pubspec.lock b/frontend/app_flowy/pubspec.lock index e00e5ccb9f..394f0f66b1 100644 --- a/frontend/app_flowy/pubspec.lock +++ b/frontend/app_flowy/pubspec.lock @@ -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: diff --git a/frontend/app_flowy/pubspec.yaml b/frontend/app_flowy/pubspec.yaml index 206c60c5ba..64836b38d3 100644 --- a/frontend/app_flowy/pubspec.yaml +++ b/frontend/app_flowy/pubspec.yaml @@ -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 diff --git a/frontend/rust-lib/dart-ffi/src/lib.rs b/frontend/rust-lib/dart-ffi/src/lib.rs index 9a6d8574ca..027ddf5af2 100644 --- a/frontend/rust-lib/dart-ffi/src/lib.rs +++ b/frontend/rust-lib/dart-ffi/src/lib.rs @@ -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(),