Przeglądaj źródła

remove splash interface

appflowy 3 lat temu
rodzic
commit
6e8c3c821a

+ 12 - 4
frontend/app_flowy/lib/user/application/splash_bloc.dart

@@ -1,17 +1,25 @@
 import 'package:app_flowy/user/domain/auth_state.dart';
-import 'package:app_flowy/user/domain/i_splash.dart';
+import 'package:flowy_sdk/dispatch/dispatch.dart';
 import 'package:flutter_bloc/flutter_bloc.dart';
 import 'package:freezed_annotation/freezed_annotation.dart';
 
 part 'splash_bloc.freezed.dart';
 
 class SplashBloc extends Bloc<SplashEvent, SplashState> {
-  final ISplashUser authImpl;
-  SplashBloc(this.authImpl) : super(SplashState.initial()) {
+  SplashBloc() : super(SplashState.initial()) {
     on<SplashEvent>((event, emit) async {
       await event.map(
         getUser: (val) async {
-          final authState = await authImpl.currentUserProfile();
+          final result = await UserEventCheckUser().send();
+          final authState = result.fold(
+            (userProfile) {
+              return AuthState.authenticated(userProfile);
+            },
+            (error) {
+              return AuthState.unauthenticated(error);
+            },
+          );
+
           emit(state.copyWith(auth: authState));
         },
       );

+ 0 - 10
frontend/app_flowy/lib/user/domain/i_auth.dart

@@ -1,10 +0,0 @@
-import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile;
-
-class NewUser {
-  UserProfile profile;
-  String workspaceId;
-  NewUser({
-    required this.profile,
-    required this.workspaceId,
-  });
-}

+ 0 - 25
frontend/app_flowy/lib/user/domain/i_splash.dart

@@ -1,25 +0,0 @@
-import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile;
-import 'package:flowy_sdk/protobuf/flowy-folder-data-model/protobuf.dart';
-import 'package:flutter/widgets.dart';
-
-import 'auth_state.dart';
-
-abstract class ISplashUser {
-  Future<AuthState> currentUserProfile();
-}
-
-abstract class ISplashUserWatch {
-  void startWatching({
-    void Function(AuthState)? authStateCallback,
-  });
-
-  Future<void> stopWatching();
-}
-
-abstract class ISplashRoute {
-  void pushSignInScreen(BuildContext context);
-  void pushSkipLoginScreen(BuildContext context);
-
-  Future<void> pushWelcomeScreen(BuildContext context, UserProfile profile);
-  void pushHomeScreen(BuildContext context, UserProfile profile, CurrentWorkspaceSetting workspaceSetting);
-}

+ 3 - 6
frontend/app_flowy/lib/user/infrastructure/deps_resolver.dart

@@ -1,10 +1,8 @@
 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_splash.dart';
 import 'package:app_flowy/user/infrastructure/repos/auth_repo.dart';
-import 'package:app_flowy/user/infrastructure/i_auth_impl.dart';
-import 'package:app_flowy/user/infrastructure/i_splash_impl.dart';
+import 'package:app_flowy/user/infrastructure/router.dart';
 import 'package:app_flowy/workspace/application/edit_pannel/edit_pannel_bloc.dart';
 import 'package:app_flowy/workspace/application/home/home_bloc.dart';
 import 'package:app_flowy/workspace/application/home/home_listen_bloc.dart';
@@ -25,11 +23,10 @@ class UserDepsResolver {
     getIt.registerFactory<SignInBloc>(() => SignInBloc(getIt<AuthRepository>()));
     getIt.registerFactory<SignUpBloc>(() => SignUpBloc(getIt<AuthRepository>()));
 
-    getIt.registerFactory<ISplashUser>(() => SplashUserImpl());
-    getIt.registerFactory<ISplashRoute>(() => SplashRoute());
+    getIt.registerFactory<SplashRoute>(() => SplashRoute());
     getIt.registerFactory<HomeBloc>(() => HomeBloc());
     getIt.registerFactory<EditPannelBloc>(() => EditPannelBloc());
-    getIt.registerFactory<SplashBloc>(() => SplashBloc(getIt<ISplashUser>()));
+    getIt.registerFactory<SplashBloc>(() => SplashBloc());
 
     getIt.registerFactoryParam<HomeListenBloc, UserProfile, void>((user, _) => HomeListenBloc(
           getIt<IUserListener>(param1: user),

+ 0 - 79
frontend/app_flowy/lib/user/infrastructure/i_splash_impl.dart

@@ -1,79 +0,0 @@
-import 'package:app_flowy/startup/startup.dart';
-import 'package:app_flowy/user/domain/auth_state.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';
-import 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart';
-import 'package:app_flowy/workspace/presentation/home/home_screen.dart';
-import 'package:flowy_infra/time/duration.dart';
-import 'package:flowy_infra_ui/widget/route/animation.dart';
-import 'package:flowy_sdk/dispatch/dispatch.dart';
-import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile;
-import 'package:flowy_sdk/protobuf/flowy-folder-data-model/protobuf.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter/widgets.dart';
-
-class SplashUserImpl implements ISplashUser {
-  @override
-  Future<AuthState> currentUserProfile() {
-    final result = UserEventCheckUser().send();
-    return result.then((result) {
-      return result.fold(
-        (userProfile) {
-          return AuthState.authenticated(userProfile);
-        },
-        (error) {
-          return AuthState.unauthenticated(error);
-        },
-      );
-    });
-  }
-}
-
-class SplashRoute implements ISplashRoute {
-  @override
-  Future<void> pushWelcomeScreen(BuildContext context, UserProfile user) async {
-    final repo = UserRepo(user: user);
-    final screen = WelcomeScreen(repo: repo);
-    final workspaceId = await Navigator.of(context).push(
-      PageRoutes.fade(
-        () => screen,
-        RouteDurations.slow.inMilliseconds * .001,
-      ),
-    );
-
-    pushHomeScreen(context, repo.user, workspaceId);
-  }
-
-  @override
-  void pushHomeScreen(BuildContext context, UserProfile userProfile, CurrentWorkspaceSetting workspaceSetting) {
-    Navigator.push(
-      context,
-      PageRoutes.fade(() => HomeScreen(userProfile, workspaceSetting), RouteDurations.slow.inMilliseconds * .001),
-    );
-  }
-
-  @override
-  void pushSignInScreen(BuildContext context) {
-    Navigator.push(
-      context,
-      PageRoutes.fade(() => SignInScreen(router: getIt<AuthRouter>()), RouteDurations.slow.inMilliseconds * .001),
-    );
-  }
-
-  @override
-  void pushSkipLoginScreen(BuildContext context) {
-    Navigator.push(
-      context,
-      PageRoutes.fade(
-          () => SkipLogInScreen(
-                router: getIt<AuthRouter>(),
-                authRepo: getIt<AuthRepository>(),
-              ),
-          RouteDurations.slow.inMilliseconds * .001),
-    );
-  }
-}

+ 47 - 3
frontend/app_flowy/lib/user/infrastructure/router.dart

@@ -1,6 +1,10 @@
 import 'package:app_flowy/startup/startup.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/presentation/sign_in_screen.dart';
 import 'package:app_flowy/user/presentation/sign_up_screen.dart';
+import 'package:app_flowy/user/presentation/skip_log_in_screen.dart';
+import 'package:app_flowy/user/presentation/welcome_screen.dart';
+import 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart';
 import 'package:app_flowy/workspace/presentation/home/home_screen.dart';
 import 'package:flowy_infra/time/duration.dart';
 import 'package:flowy_infra_ui/widget/route/animation.dart';
@@ -9,13 +13,12 @@ import 'package:flowy_sdk/protobuf/flowy-folder-data-model/protobuf.dart';
 import 'package:flutter/material.dart';
 
 class AuthRouter {
-  @override
   void pushForgetPasswordScreen(BuildContext context) {
     // TODO: implement showForgetPasswordScreen
   }
 
   void pushWelcomeScreen(BuildContext context, UserProfile userProfile) {
-    getIt<ISplashRoute>().pushWelcomeScreen(context, userProfile);
+    getIt<SplashRoute>().pushWelcomeScreen(context, userProfile);
   }
 
   void pushSignUpScreen(BuildContext context) {
@@ -33,3 +36,44 @@ class AuthRouter {
     );
   }
 }
+
+class SplashRoute {
+  Future<void> pushWelcomeScreen(BuildContext context, UserProfile user) async {
+    final repo = UserRepo(user: user);
+    final screen = WelcomeScreen(repo: repo);
+    final workspaceId = await Navigator.of(context).push(
+      PageRoutes.fade(
+        () => screen,
+        RouteDurations.slow.inMilliseconds * .001,
+      ),
+    );
+
+    pushHomeScreen(context, repo.user, workspaceId);
+  }
+
+  void pushHomeScreen(BuildContext context, UserProfile userProfile, CurrentWorkspaceSetting workspaceSetting) {
+    Navigator.push(
+      context,
+      PageRoutes.fade(() => HomeScreen(userProfile, workspaceSetting), RouteDurations.slow.inMilliseconds * .001),
+    );
+  }
+
+  void pushSignInScreen(BuildContext context) {
+    Navigator.push(
+      context,
+      PageRoutes.fade(() => SignInScreen(router: getIt<AuthRouter>()), RouteDurations.slow.inMilliseconds * .001),
+    );
+  }
+
+  void pushSkipLoginScreen(BuildContext context) {
+    Navigator.push(
+      context,
+      PageRoutes.fade(
+          () => SkipLogInScreen(
+                router: getIt<AuthRouter>(),
+                authRepo: getIt<AuthRepository>(),
+              ),
+          RouteDurations.slow.inMilliseconds * .001),
+    );
+  }
+}

+ 2 - 2
frontend/app_flowy/lib/user/presentation/sign_up_screen.dart

@@ -1,6 +1,6 @@
 import 'package:app_flowy/startup/startup.dart';
 import 'package:app_flowy/user/application/sign_up_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/theme.dart';
@@ -17,7 +17,7 @@ import 'package:flowy_infra/image.dart';
 import 'package:app_flowy/generated/locale_keys.g.dart';
 
 class SignUpScreen extends StatelessWidget {
-  final IAuthRouter router;
+  final AuthRouter router;
   const SignUpScreen({Key? key, required this.router}) : super(key: key);
 
   @override

+ 1 - 1
frontend/app_flowy/lib/user/presentation/skip_log_in_screen.dart

@@ -1,4 +1,4 @@
-import 'package:app_flowy/user/infrastructure/i_auth_impl.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/widgets/background.dart';
 import 'package:app_flowy/workspace/domain/i_user.dart';

+ 5 - 5
frontend/app_flowy/lib/user/presentation/splash_screen.dart

@@ -1,7 +1,7 @@
 import 'package:app_flowy/startup/startup.dart';
 import 'package:app_flowy/user/application/splash_bloc.dart';
 import 'package:app_flowy/user/domain/auth_state.dart';
-import 'package:app_flowy/user/domain/i_splash.dart';
+import 'package:app_flowy/user/infrastructure/router.dart';
 import 'package:flowy_log/flowy_log.dart';
 import 'package:flowy_sdk/dispatch/dispatch.dart';
 import 'package:flowy_sdk/protobuf/flowy-folder-data-model/errors.pb.dart';
@@ -47,11 +47,11 @@ class SplashScreen extends StatelessWidget {
     FolderEventReadCurWorkspace().send().then(
       (result) {
         return result.fold(
-          (workspaceSetting) => getIt<ISplashRoute>().pushHomeScreen(context, userProfile, workspaceSetting),
+          (workspaceSetting) => getIt<SplashRoute>().pushHomeScreen(context, userProfile, workspaceSetting),
           (error) async {
             Log.error(error);
             assert(error.code == ErrorCode.RecordNotFound.value);
-            getIt<ISplashRoute>().pushWelcomeScreen(context, userProfile);
+            getIt<SplashRoute>().pushWelcomeScreen(context, userProfile);
           },
         );
       },
@@ -59,8 +59,8 @@ class SplashScreen extends StatelessWidget {
   }
 
   void _handleUnauthenticated(BuildContext context, Unauthenticated result) {
-    // getIt<ISplashRoute>().pushSignInScreen(context);
-    getIt<ISplashRoute>().pushSkipLoginScreen(context);
+    // getIt<SplashRoute>().pushSignInScreen(context);
+    getIt<SplashRoute>().pushSkipLoginScreen(context);
   }
 }
 

+ 0 - 2
frontend/app_flowy/macos/Flutter/GeneratedPluginRegistrant.swift

@@ -6,7 +6,6 @@ import FlutterMacOS
 import Foundation
 
 import connectivity_plus_macos
-import desktop_window
 import device_info_plus_macos
 import flowy_infra_ui
 import flowy_sdk
@@ -18,7 +17,6 @@ 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"))

+ 0 - 7
frontend/app_flowy/pubspec.lock

@@ -260,13 +260,6 @@ 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:

+ 0 - 1
frontend/app_flowy/pubspec.yaml

@@ -58,7 +58,6 @@ 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