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

This commit is contained in:
appflowy 2021-10-09 10:09:31 +08:00
parent f62afcb436
commit d46e5aa0b9
23 changed files with 51 additions and 59 deletions

View File

@ -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 {

View File

@ -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);
}

View File

@ -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,

View File

@ -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;

View File

@ -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),
),
);
}
}

View File

@ -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';

View File

@ -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() {

View File

@ -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';

View File

@ -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),
),
);
}
}

View File

@ -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,

View File

@ -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(

View File

@ -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;

View File

@ -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,

View File

@ -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,

View File

@ -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(

View File

@ -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,

View File

@ -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,

View File

@ -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,