فهرست منبع

[flutter]: merge welcome to user && refactor abstract class with class with freezed objects

appflowy 3 سال پیش
والد
کامیت
d46e5aa0b9
23فایلهای تغییر یافته به همراه51 افزوده شده و 59 حذف شده
  1. 1 1
      app_flowy/lib/main.dart
  2. 0 2
      app_flowy/lib/startup/deps_inject/prelude.dart
  3. 2 2
      app_flowy/lib/user/application/sign_up_bloc.dart
  4. 4 4
      app_flowy/lib/user/application/splash_bloc.dart
  5. 0 0
      app_flowy/lib/user/application/splash_bloc.freezed.dart
  6. 0 0
      app_flowy/lib/user/domain/auth_state.dart
  7. 0 0
      app_flowy/lib/user/domain/auth_state.freezed.dart
  8. 0 0
      app_flowy/lib/user/domain/i_splash.dart
  9. 20 0
      app_flowy/lib/user/infrastructure/deps_resolver.dart
  10. 1 1
      app_flowy/lib/user/infrastructure/i_auth_impl.dart
  11. 3 5
      app_flowy/lib/user/infrastructure/i_splash_impl.dart
  12. 3 3
      app_flowy/lib/user/presentation/splash_screen.dart
  13. 0 0
      app_flowy/lib/user/presentation/welcome_screen.dart
  14. 0 24
      app_flowy/lib/welcome/infrastructure/deps_resolver.dart
  15. 2 2
      app_flowy/lib/workspace/application/app/app_bloc.dart
  16. 2 2
      app_flowy/lib/workspace/application/app/app_watch_bloc.dart
  17. 2 2
      app_flowy/lib/workspace/application/doc/doc_edit_bloc.dart
  18. 2 2
      app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart
  19. 2 2
      app_flowy/lib/workspace/application/home/home_bloc.dart
  20. 2 2
      app_flowy/lib/workspace/application/menu/menu_watch.dart
  21. 2 2
      app_flowy/lib/workspace/application/view/view_bloc.dart
  22. 1 1
      app_flowy/lib/workspace/application/view/view_list_bloc.dart
  23. 2 2
      app_flowy/lib/workspace/application/workspace/welcome_bloc.dart

+ 1 - 1
app_flowy/lib/main.dart

@@ -1,5 +1,5 @@
 import 'package:app_flowy/startup/startup.dart';
-import 'package:app_flowy/welcome/presentation/splash_screen.dart';
+import 'package:app_flowy/user/presentation/splash_screen.dart';
 import 'package:flutter/material.dart';
 
 class FlowyApp implements EntryPoint {

+ 0 - 2
app_flowy/lib/startup/deps_inject/prelude.dart

@@ -2,7 +2,6 @@ import 'package:app_flowy/workspace/infrastructure/deps_resolver.dart';
 import 'package:app_flowy/startup/launch.dart';
 import 'package:app_flowy/startup/startup.dart';
 import 'package:app_flowy/user/infrastructure/deps_resolver.dart';
-import 'package:app_flowy/welcome/infrastructure/deps_resolver.dart';
 import 'package:flowy_sdk/flowy_sdk.dart';
 import 'package:get_it/get_it.dart';
 
@@ -16,6 +15,5 @@ Future<void> initGetIt(
   getIt.registerLazySingleton<AppLauncher>(() => AppLauncher(env, getIt));
 
   await UserDepsResolver.resolve(getIt);
-  await WelcomeDepsResolver.resolve(getIt);
   await HomeDepsResolver.resolve(getIt);
 }

+ 2 - 2
app_flowy/lib/user/application/sign_up_bloc.dart

@@ -97,7 +97,7 @@ class SignUpBloc extends Bloc<SignUpEvent, SignUpState> {
 }
 
 @freezed
-abstract class SignUpEvent with _$SignUpEvent {
+class SignUpEvent with _$SignUpEvent {
   const factory SignUpEvent.signUpWithUserEmailAndPassword() =
       SignUpWithUserEmailAndPassword;
   const factory SignUpEvent.emailChanged(String email) = EmailChanged;
@@ -107,7 +107,7 @@ abstract class SignUpEvent with _$SignUpEvent {
 }
 
 @freezed
-abstract class SignUpState with _$SignUpState {
+class SignUpState with _$SignUpState {
   const factory SignUpState({
     String? email,
     String? password,

+ 4 - 4
app_flowy/lib/welcome/application/splash_bloc.dart → app_flowy/lib/user/application/splash_bloc.dart

@@ -1,5 +1,5 @@
-import 'package:app_flowy/welcome/domain/auth_state.dart';
-import 'package:app_flowy/welcome/domain/i_splash.dart';
+import 'package:app_flowy/user/domain/auth_state.dart';
+import 'package:app_flowy/user/domain/i_splash.dart';
 import 'package:flutter_bloc/flutter_bloc.dart';
 import 'package:freezed_annotation/freezed_annotation.dart';
 
@@ -21,12 +21,12 @@ class SplashBloc extends Bloc<SplashEvent, SplashState> {
 }
 
 @freezed
-abstract class SplashEvent with _$SplashEvent {
+class SplashEvent with _$SplashEvent {
   const factory SplashEvent.getUser() = _GetUser;
 }
 
 @freezed
-abstract class SplashState implements _$SplashState {
+class SplashState with _$SplashState {
   const factory SplashState({
     required AuthState auth,
   }) = _SplashState;

+ 0 - 0
app_flowy/lib/welcome/application/splash_bloc.freezed.dart → app_flowy/lib/user/application/splash_bloc.freezed.dart


+ 0 - 0
app_flowy/lib/welcome/domain/auth_state.dart → app_flowy/lib/user/domain/auth_state.dart


+ 0 - 0
app_flowy/lib/welcome/domain/auth_state.freezed.dart → app_flowy/lib/user/domain/auth_state.freezed.dart


+ 0 - 0
app_flowy/lib/welcome/domain/i_splash.dart → app_flowy/lib/user/domain/i_splash.dart


+ 20 - 0
app_flowy/lib/user/infrastructure/deps_resolver.dart

@@ -1,8 +1,16 @@
 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';
+import 'package:app_flowy/user/infrastructure/i_splash_impl.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_auth_bloc.dart';
+import 'package:app_flowy/workspace/domain/i_user.dart';
+import 'package:app_flowy/workspace/infrastructure/i_user_impl.dart';
 import 'package:get_it/get_it.dart';
 
 class UserDepsResolver {
@@ -16,5 +24,17 @@ class UserDepsResolver {
     //Bloc
     getIt.registerFactory<SignInBloc>(() => SignInBloc(getIt<IAuth>()));
     getIt.registerFactory<SignUpBloc>(() => SignUpBloc(getIt<IAuth>()));
+
+    getIt.registerFactory<ISplashUser>(() => SplashUserImpl());
+    getIt.registerFactory<ISplashRoute>(() => SplashRoute());
+    getIt.registerFactory<HomeBloc>(() => HomeBloc());
+    getIt.registerFactory<EditPannelBloc>(() => EditPannelBloc());
+    getIt.registerFactory<SplashBloc>(() => SplashBloc(getIt<ISplashUser>()));
+
+    getIt.registerFactoryParam<HomeAuthBloc, UserProfile, void>(
+      (user, _) => HomeAuthBloc(
+        getIt<IUserWatch>(param1: user),
+      ),
+    );
   }
 }

+ 1 - 1
app_flowy/lib/user/infrastructure/i_auth_impl.dart

@@ -1,6 +1,6 @@
 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/welcome/domain/i_splash.dart';
 import 'package:dartz/dartz.dart';
 import 'package:flowy_infra_ui/widget/route/animation.dart';
 import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';

+ 3 - 5
app_flowy/lib/welcome/infrastructure/i_splash_impl.dart → app_flowy/lib/user/infrastructure/i_splash_impl.dart

@@ -1,11 +1,11 @@
 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/presentation/sign_in_screen.dart';
-import 'package:app_flowy/welcome/domain/auth_state.dart';
-import 'package:app_flowy/welcome/domain/i_splash.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:app_flowy/welcome/presentation/welcome_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';
@@ -13,8 +13,6 @@ import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/widgets.dart';
 
-export 'package:app_flowy/welcome/domain/i_splash.dart';
-
 class SplashUserImpl implements ISplashUser {
   @override
   Future<AuthState> currentUserProfile() {

+ 3 - 3
app_flowy/lib/welcome/presentation/splash_screen.dart → app_flowy/lib/user/presentation/splash_screen.dart

@@ -1,7 +1,7 @@
-import 'package:app_flowy/welcome/domain/i_splash.dart';
-import 'package:app_flowy/welcome/domain/auth_state.dart';
 import 'package:app_flowy/startup/startup.dart';
-import 'package:app_flowy/welcome/application/splash_bloc.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:flowy_log/flowy_log.dart';
 import 'package:flowy_sdk/dispatch/dispatch.dart';
 import 'package:flutter/material.dart';

+ 0 - 0
app_flowy/lib/welcome/presentation/welcome_screen.dart → app_flowy/lib/user/presentation/welcome_screen.dart


+ 0 - 24
app_flowy/lib/welcome/infrastructure/deps_resolver.dart

@@ -1,24 +0,0 @@
-import 'package:app_flowy/workspace/application/edit_pannel/edit_pannel_bloc.dart';
-import 'package:app_flowy/welcome/application/splash_bloc.dart';
-import 'package:app_flowy/welcome/infrastructure/i_splash_impl.dart';
-import 'package:app_flowy/workspace/application/home/home_bloc.dart';
-import 'package:app_flowy/workspace/application/home/home_auth_bloc.dart';
-import 'package:app_flowy/workspace/domain/i_user.dart';
-import 'package:app_flowy/workspace/infrastructure/i_user_impl.dart';
-import 'package:get_it/get_it.dart';
-
-class WelcomeDepsResolver {
-  static Future<void> resolve(GetIt getIt) async {
-    getIt.registerFactory<ISplashUser>(() => SplashUserImpl());
-    getIt.registerFactory<ISplashRoute>(() => SplashRoute());
-    getIt.registerFactory<HomeBloc>(() => HomeBloc());
-    getIt.registerFactory<EditPannelBloc>(() => EditPannelBloc());
-    getIt.registerFactory<SplashBloc>(() => SplashBloc(getIt<ISplashUser>()));
-
-    getIt.registerFactoryParam<HomeAuthBloc, UserProfile, void>(
-      (user, _) => HomeAuthBloc(
-        getIt<IUserWatch>(param1: user),
-      ),
-    );
-  }
-}

+ 2 - 2
app_flowy/lib/workspace/application/app/app_bloc.dart

@@ -44,14 +44,14 @@ class AppBloc extends Bloc<AppEvent, AppState> {
 }
 
 @freezed
-abstract class AppEvent with _$AppEvent {
+class AppEvent with _$AppEvent {
   const factory AppEvent.initial() = Initial;
   const factory AppEvent.createView(
       String name, String desc, ViewType viewType) = CreateView;
 }
 
 @freezed
-abstract class AppState implements _$AppState {
+class AppState with _$AppState {
   const factory AppState({
     required bool isLoading,
     required List<View>? views,

+ 2 - 2
app_flowy/lib/workspace/application/app/app_watch_bloc.dart

@@ -36,14 +36,14 @@ class AppWatchBloc extends Bloc<AppWatchEvent, AppWatchState> {
 }
 
 @freezed
-abstract class AppWatchEvent with _$AppWatchEvent {
+class AppWatchEvent with _$AppWatchEvent {
   const factory AppWatchEvent.started() = _Started;
   const factory AppWatchEvent.viewsReceived(
       Either<List<View>, WorkspaceError> viewsOrFail) = ViewsReceived;
 }
 
 @freezed
-abstract class AppWatchState implements _$AppWatchState {
+class AppWatchState with _$AppWatchState {
   const factory AppWatchState.initial() = _Initial;
 
   const factory AppWatchState.loadViews(

+ 2 - 2
app_flowy/lib/workspace/application/doc/doc_edit_bloc.dart

@@ -21,13 +21,13 @@ class DocEditBloc extends Bloc<DocEditEvent, DocEditState> {
 }
 
 @freezed
-abstract class DocEditEvent with _$DocEditEvent {
+class DocEditEvent with _$DocEditEvent {
   const factory DocEditEvent.initial() = Initial;
   const factory DocEditEvent.close() = Close;
 }
 
 @freezed
-abstract class DocEditState implements _$DocEditState {
+class DocEditState with _$DocEditState {
   const factory DocEditState({
     required bool isSaving,
   }) = _DocEditState;

+ 2 - 2
app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart

@@ -26,7 +26,7 @@ class EditPannelBloc extends Bloc<EditPannelEvent, EditPannelState> {
 }
 
 @freezed
-abstract class EditPannelEvent with _$EditPannelEvent {
+class EditPannelEvent with _$EditPannelEvent {
   const factory EditPannelEvent.startEdit(EditPannelContext context) =
       _StartEdit;
 
@@ -34,7 +34,7 @@ abstract class EditPannelEvent with _$EditPannelEvent {
 }
 
 @freezed
-abstract class EditPannelState implements _$EditPannelState {
+class EditPannelState with _$EditPannelState {
   const factory EditPannelState({
     required bool isEditing,
     required Option<EditPannelContext> editContext,

+ 2 - 2
app_flowy/lib/workspace/application/home/home_bloc.dart

@@ -34,7 +34,7 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
 }
 
 @freezed
-abstract class HomeEvent with _$HomeEvent {
+class HomeEvent with _$HomeEvent {
   const factory HomeEvent.showLoading(bool isLoading) = _ShowLoading;
   const factory HomeEvent.forceCollapse(bool forceCollapse) = _ForceCollapse;
   const factory HomeEvent.setEditPannel(EditPannelContext editContext) =
@@ -43,7 +43,7 @@ abstract class HomeEvent with _$HomeEvent {
 }
 
 @freezed
-abstract class HomeState implements _$HomeState {
+class HomeState with _$HomeState {
   const factory HomeState({
     required bool isLoading,
     required bool forceCollapse,

+ 2 - 2
app_flowy/lib/workspace/application/menu/menu_watch.dart

@@ -48,14 +48,14 @@ class MenuWatchBloc extends Bloc<MenuWatchEvent, MenuWatchState> {
 }
 
 @freezed
-abstract class MenuWatchEvent with _$MenuWatchEvent {
+class MenuWatchEvent with _$MenuWatchEvent {
   const factory MenuWatchEvent.started() = _Started;
   const factory MenuWatchEvent.appsReceived(
       Either<List<App>, WorkspaceError> appsOrFail) = AppsReceived;
 }
 
 @freezed
-abstract class MenuWatchState with _$MenuWatchState {
+class MenuWatchState with _$MenuWatchState {
   const factory MenuWatchState.initial() = _Initial;
 
   const factory MenuWatchState.loadApps(

+ 2 - 2
app_flowy/lib/workspace/application/view/view_bloc.dart

@@ -23,12 +23,12 @@ class ViewBloc extends Bloc<ViewEvent, ViewState> {
 }
 
 @freezed
-abstract class ViewEvent with _$ViewEvent {
+class ViewEvent with _$ViewEvent {
   const factory ViewEvent.initial() = Initial;
 }
 
 @freezed
-abstract class ViewState implements _$ViewState {
+class ViewState with _$ViewState {
   const factory ViewState({
     required bool isLoading,
     required Option<View> view,

+ 1 - 1
app_flowy/lib/workspace/application/view/view_list_bloc.dart

@@ -29,7 +29,7 @@ class ViewListEvent with _$ViewListEvent {
 }
 
 @freezed
-abstract class ViewListState implements _$ViewListState {
+class ViewListState with _$ViewListState {
   const factory ViewListState({
     required bool isLoading,
     required Option<String> openedView,

+ 2 - 2
app_flowy/lib/workspace/application/workspace/welcome_bloc.dart

@@ -87,7 +87,7 @@ class WelcomeBloc extends Bloc<WelcomeEvent, WelcomeState> {
 }
 
 @freezed
-abstract class WelcomeEvent with _$WelcomeEvent {
+class WelcomeEvent with _$WelcomeEvent {
   const factory WelcomeEvent.initial() = Initial;
   // const factory WelcomeEvent.fetchWorkspaces() = FetchWorkspace;
   const factory WelcomeEvent.createWorkspace(String name, String desc) =
@@ -100,7 +100,7 @@ abstract class WelcomeEvent with _$WelcomeEvent {
 }
 
 @freezed
-abstract class WelcomeState implements _$WelcomeState {
+class WelcomeState with _$WelcomeState {
   const factory WelcomeState({
     required bool isLoading,
     required List<Workspace> workspaces,