Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

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

appflowyd46e5aa0b936
diff --git a/app_flowy/lib/main.dart b/app_flowy/lib/main.dart
index 6d037906f8..49a024173d 100644
--- a/app_flowy/lib/main.dart
+++ b/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 {
diff --git a/app_flowy/lib/startup/deps_inject/prelude.dart b/app_flowy/lib/startup/deps_inject/prelude.dart
index 84c5c13daa..f435b47eee 100644
--- a/app_flowy/lib/startup/deps_inject/prelude.dart
+++ b/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);
}
diff --git a/app_flowy/lib/user/application/sign_up_bloc.dart b/app_flowy/lib/user/application/sign_up_bloc.dart
index 33f1d59c7b..425007d1d4 100644
--- a/app_flowy/lib/user/application/sign_up_bloc.dart
+++ b/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,
diff --git a/app_flowy/lib/welcome/application/splash_bloc.dart b/app_flowy/lib/user/application/splash_bloc.dart
similarity index 78%
rename from app_flowy/lib/welcome/application/splash_bloc.dart
rename to app_flowy/lib/user/application/splash_bloc.dart
index 084d57046c..e93d3a7435 100644
--- a/app_flowy/lib/welcome/application/splash_bloc.dart
+++ b/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;
diff --git a/app_flowy/lib/welcome/application/splash_bloc.freezed.dart b/app_flowy/lib/user/application/splash_bloc.freezed.dart
similarity index 100%
rename from app_flowy/lib/welcome/application/splash_bloc.freezed.dart
rename to app_flowy/lib/user/application/splash_bloc.freezed.dart
diff --git a/app_flowy/lib/welcome/domain/auth_state.dart b/app_flowy/lib/user/domain/auth_state.dart
similarity index 100%
rename from app_flowy/lib/welcome/domain/auth_state.dart
rename to app_flowy/lib/user/domain/auth_state.dart
diff --git a/app_flowy/lib/welcome/domain/auth_state.freezed.dart b/app_flowy/lib/user/domain/auth_state.freezed.dart
similarity index 100%
rename from app_flowy/lib/welcome/domain/auth_state.freezed.dart
rename to app_flowy/lib/user/domain/auth_state.freezed.dart
diff --git a/app_flowy/lib/welcome/domain/i_splash.dart b/app_flowy/lib/user/domain/i_splash.dart
similarity index 100%
rename from app_flowy/lib/welcome/domain/i_splash.dart
rename to app_flowy/lib/user/domain/i_splash.dart
diff --git a/app_flowy/lib/user/infrastructure/deps_resolver.dart b/app_flowy/lib/user/infrastructure/deps_resolver.dart
index e6aeadf02e..7b7d77f64a 100644
--- a/app_flowy/lib/user/infrastructure/deps_resolver.dart
+++ b/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),
+ ),
+ );
}
}
diff --git a/app_flowy/lib/user/infrastructure/i_auth_impl.dart b/app_flowy/lib/user/infrastructure/i_auth_impl.dart
index 670087593b..4d82c3c88f 100644
--- a/app_flowy/lib/user/infrastructure/i_auth_impl.dart
+++ b/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';
diff --git a/app_flowy/lib/welcome/infrastructure/i_splash_impl.dart b/app_flowy/lib/user/infrastructure/i_splash_impl.dart
similarity index 89%
rename from app_flowy/lib/welcome/infrastructure/i_splash_impl.dart
rename to app_flowy/lib/user/infrastructure/i_splash_impl.dart
index f2e39aad33..358cec9dc7 100644
--- a/app_flowy/lib/welcome/infrastructure/i_splash_impl.dart
+++ b/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() {
diff --git a/app_flowy/lib/welcome/presentation/splash_screen.dart b/app_flowy/lib/user/presentation/splash_screen.dart
similarity index 92%
rename from app_flowy/lib/welcome/presentation/splash_screen.dart
rename to app_flowy/lib/user/presentation/splash_screen.dart
index ff443c92c9..d571755eb6 100644
--- a/app_flowy/lib/welcome/presentation/splash_screen.dart
+++ b/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';
diff --git a/app_flowy/lib/welcome/presentation/welcome_screen.dart b/app_flowy/lib/user/presentation/welcome_screen.dart
similarity index 100%
rename from app_flowy/lib/welcome/presentation/welcome_screen.dart
rename to app_flowy/lib/user/presentation/welcome_screen.dart
diff --git a/app_flowy/lib/welcome/infrastructure/deps_resolver.dart b/app_flowy/lib/welcome/infrastructure/deps_resolver.dart
deleted file mode 100644
index 50e5041628..0000000000
--- a/app_flowy/lib/welcome/infrastructure/deps_resolver.dart
+++ /dev/null
@@ -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),
- ),
- );
- }
-}
diff --git a/app_flowy/lib/workspace/application/app/app_bloc.dart b/app_flowy/lib/workspace/application/app/app_bloc.dart
index 52c5e7f150..d5978484b4 100644
--- a/app_flowy/lib/workspace/application/app/app_bloc.dart
+++ b/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,
diff --git a/app_flowy/lib/workspace/application/app/app_watch_bloc.dart b/app_flowy/lib/workspace/application/app/app_watch_bloc.dart
index 4cabff5a96..8f2a02d4f6 100644
--- a/app_flowy/lib/workspace/application/app/app_watch_bloc.dart
+++ b/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(
diff --git a/app_flowy/lib/workspace/application/doc/doc_edit_bloc.dart b/app_flowy/lib/workspace/application/doc/doc_edit_bloc.dart
index 1a279dff88..2242a322bf 100644
--- a/app_flowy/lib/workspace/application/doc/doc_edit_bloc.dart
+++ b/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;
diff --git a/app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart b/app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart
index ecaf26bc63..4b687e8eb8 100644
--- a/app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart
+++ b/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,
diff --git a/app_flowy/lib/workspace/application/home/home_bloc.dart b/app_flowy/lib/workspace/application/home/home_bloc.dart
index df985d9261..fef6b176a0 100644
--- a/app_flowy/lib/workspace/application/home/home_bloc.dart
+++ b/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,
diff --git a/app_flowy/lib/workspace/application/menu/menu_watch.dart b/app_flowy/lib/workspace/application/menu/menu_watch.dart
index d781616ec3..31c8fde0e3 100644
--- a/app_flowy/lib/workspace/application/menu/menu_watch.dart
+++ b/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(
diff --git a/app_flowy/lib/workspace/application/view/view_bloc.dart b/app_flowy/lib/workspace/application/view/view_bloc.dart
index 5dd7b4633a..b18a1866b6 100644
--- a/app_flowy/lib/workspace/application/view/view_bloc.dart
+++ b/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,
diff --git a/app_flowy/lib/workspace/application/view/view_list_bloc.dart b/app_flowy/lib/workspace/application/view/view_list_bloc.dart
index 315d49d560..2dc8a9ab19 100644
--- a/app_flowy/lib/workspace/application/view/view_list_bloc.dart
+++ b/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,
diff --git a/app_flowy/lib/workspace/application/workspace/welcome_bloc.dart b/app_flowy/lib/workspace/application/workspace/welcome_bloc.dart
index f63b74992c..a9f54db707 100644
--- a/app_flowy/lib/workspace/application/workspace/welcome_bloc.dart
+++ b/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,