diff --git a/app_flowy/analysis_options.yaml b/app_flowy/analysis_options.yaml
index e9def11a1c..eb5b057c3c 100644
--- a/app_flowy/analysis_options.yaml
+++ b/app_flowy/analysis_options.yaml
@@ -15,6 +15,7 @@ analyzer:
- "**/*.g.dart"
- "**/*.freezed.dart"
- "packages/flowy_editor/**"
+ - "packages/flowy_infra_ui/**"
linter:
# The lint rules applied to this project can be customized in the
diff --git a/app_flowy/ios/Flutter/AppFrameworkInfo.plist b/app_flowy/ios/Flutter/AppFrameworkInfo.plist
index 9367d483e4..8d4492f977 100644
--- a/app_flowy/ios/Flutter/AppFrameworkInfo.plist
+++ b/app_flowy/ios/Flutter/AppFrameworkInfo.plist
@@ -21,6 +21,6 @@
CFBundleVersion
1.0
MinimumOSVersion
- 8.0
+ 9.0
diff --git a/app_flowy/lib/home/application/edit_pannel/edit_pannel_event.dart b/app_flowy/lib/home/application/edit_pannel/edit_pannel_event.dart
deleted file mode 100644
index 718e916e6d..0000000000
--- a/app_flowy/lib/home/application/edit_pannel/edit_pannel_event.dart
+++ /dev/null
@@ -1,9 +0,0 @@
-part of 'edit_pannel_bloc.dart';
-
-@freezed
-abstract class EditPannelEvent with _$EditPannelEvent {
- const factory EditPannelEvent.startEdit(EditPannelContext context) =
- _StartEdit;
-
- const factory EditPannelEvent.endEdit(EditPannelContext context) = _EndEdit;
-}
diff --git a/app_flowy/lib/home/application/edit_pannel/edit_pannel_state.dart b/app_flowy/lib/home/application/edit_pannel/edit_pannel_state.dart
deleted file mode 100644
index 3cca9a2b0a..0000000000
--- a/app_flowy/lib/home/application/edit_pannel/edit_pannel_state.dart
+++ /dev/null
@@ -1,14 +0,0 @@
-part of 'edit_pannel_bloc.dart';
-
-@freezed
-abstract class EditPannelState implements _$EditPannelState {
- const factory EditPannelState({
- required bool isEditing,
- required Option editContext,
- }) = _EditPannelState;
-
- factory EditPannelState.initial() => EditPannelState(
- isEditing: false,
- editContext: none(),
- );
-}
diff --git a/app_flowy/lib/home/application/home_bloc.dart b/app_flowy/lib/home/application/home_bloc.dart
deleted file mode 100644
index 259abc3bb6..0000000000
--- a/app_flowy/lib/home/application/home_bloc.dart
+++ /dev/null
@@ -1,42 +0,0 @@
-import 'package:app_flowy/home/domain/edit_context.dart';
-import 'package:app_flowy/home/domain/page_context.dart';
-import 'package:app_flowy/home/presentation/widgets/blank_page.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-import 'package:freezed_annotation/freezed_annotation.dart';
-import 'package:dartz/dartz.dart';
-
-part 'home_event.dart';
-part 'home_state.dart';
-part 'home_bloc.freezed.dart';
-
-class HomeBloc extends Bloc {
- HomeBloc() : super(HomeState.initial());
-
- @override
- Stream mapEventToState(
- HomeEvent event,
- ) async* {
- yield* event.map(
- setPage: (e) async* {
- yield state.copyWith(pageContext: e.context);
- },
- showLoading: (e) async* {
- yield state.copyWith(isLoading: e.isLoading);
- },
- setEditPannel: (e) async* {
- yield state.copyWith(editContext: some(e.editContext));
- },
- dismissEditPannel: (value) async* {
- yield state.copyWith(editContext: none());
- },
- showMenu: (e) async* {
- yield state.copyWith(showMenu: e.isShow);
- },
- );
- }
-
- @override
- Future close() {
- return super.close();
- }
-}
diff --git a/app_flowy/lib/home/application/home_event.dart b/app_flowy/lib/home/application/home_event.dart
deleted file mode 100644
index ec4d0a457b..0000000000
--- a/app_flowy/lib/home/application/home_event.dart
+++ /dev/null
@@ -1,15 +0,0 @@
-part of 'home_bloc.dart';
-
-@freezed
-abstract class HomeEvent with _$HomeEvent {
- const factory HomeEvent.showLoading(bool isLoading) = _ShowLoading;
- const factory HomeEvent.showMenu(bool isShow) = _ShowMenu;
-
- //page
- const factory HomeEvent.setPage(PageContext context) = SetCurrentPage;
-
- //edit pannel
- const factory HomeEvent.setEditPannel(EditPannelContext editContext) =
- _ShowEditPannel;
- const factory HomeEvent.dismissEditPannel() = _DismissEditPannel;
-}
diff --git a/app_flowy/lib/home/application/home_state.dart b/app_flowy/lib/home/application/home_state.dart
deleted file mode 100644
index ce0be0f38e..0000000000
--- a/app_flowy/lib/home/application/home_state.dart
+++ /dev/null
@@ -1,18 +0,0 @@
-part of 'home_bloc.dart';
-
-@freezed
-abstract class HomeState implements _$HomeState {
- const factory HomeState({
- required bool isLoading,
- required bool showMenu,
- required PageContext pageContext,
- required Option editContext,
- }) = _HomeState;
-
- factory HomeState.initial() => HomeState(
- isLoading: false,
- showMenu: true,
- pageContext: const BlankPageContext(),
- editContext: none(),
- );
-}
diff --git a/app_flowy/lib/home/application/menu/menu_bloc.dart b/app_flowy/lib/home/application/menu/menu_bloc.dart
deleted file mode 100644
index dd5790b458..0000000000
--- a/app_flowy/lib/home/application/menu/menu_bloc.dart
+++ /dev/null
@@ -1,44 +0,0 @@
-import 'dart:async';
-import 'package:app_flowy/home/domain/page_context.dart';
-import 'package:dartz/dartz.dart';
-import 'package:flutter/material.dart';
-import 'package:freezed_annotation/freezed_annotation.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-part 'menu_event.dart';
-part 'menu_state.dart';
-part 'menu_bloc.freezed.dart';
-
-class MenuBloc extends Bloc {
- MenuBloc() : super(MenuState.initial());
-
- @override
- Stream mapEventToState(
- MenuEvent event,
- ) async* {
- yield* event.map(
- collapse: (e) async* {
- final isCollapse = state.isCollapse;
- yield state.copyWith(isCollapse: !isCollapse);
- },
- openPage: (e) async* {
- yield* _performActionOnOpenPage(e);
- },
- createApp: (e) async* {
- yield* _performActionOnCreateApp(e);
- },
- );
- }
-
- Stream _performActionOnOpenPage(_OpenPage e) async* {
- yield state.copyWith(pageContext: some(e.context));
- }
-
- Stream _performActionOnCreateApp(_CreateApp e) async* {
- yield state;
- }
-
- @override
- Future close() {
- return super.close();
- }
-}
diff --git a/app_flowy/lib/home/application/menu/menu_bloc.freezed.dart b/app_flowy/lib/home/application/menu/menu_bloc.freezed.dart
deleted file mode 100644
index 38b4cb1fd0..0000000000
--- a/app_flowy/lib/home/application/menu/menu_bloc.freezed.dart
+++ /dev/null
@@ -1,525 +0,0 @@
-// GENERATED CODE - DO NOT MODIFY BY HAND
-// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides
-
-part of 'menu_bloc.dart';
-
-// **************************************************************************
-// FreezedGenerator
-// **************************************************************************
-
-T _$identity(T value) => value;
-
-final _privateConstructorUsedError = UnsupportedError(
- 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
-
-/// @nodoc
-class _$MenuEventTearOff {
- const _$MenuEventTearOff();
-
- Collapse collapse() {
- return const Collapse();
- }
-
- _OpenPage openPage(PageContext context) {
- return _OpenPage(
- context,
- );
- }
-
- _CreateApp createApp() {
- return const _CreateApp();
- }
-}
-
-/// @nodoc
-const $MenuEvent = _$MenuEventTearOff();
-
-/// @nodoc
-mixin _$MenuEvent {
- @optionalTypeArgs
- TResult when({
- required TResult Function() collapse,
- required TResult Function(PageContext context) openPage,
- required TResult Function() createApp,
- }) =>
- throw _privateConstructorUsedError;
- @optionalTypeArgs
- TResult maybeWhen({
- TResult Function()? collapse,
- TResult Function(PageContext context)? openPage,
- TResult Function()? createApp,
- required TResult orElse(),
- }) =>
- throw _privateConstructorUsedError;
- @optionalTypeArgs
- TResult map({
- required TResult Function(Collapse value) collapse,
- required TResult Function(_OpenPage value) openPage,
- required TResult Function(_CreateApp value) createApp,
- }) =>
- throw _privateConstructorUsedError;
- @optionalTypeArgs
- TResult maybeMap({
- TResult Function(Collapse value)? collapse,
- TResult Function(_OpenPage value)? openPage,
- TResult Function(_CreateApp value)? createApp,
- required TResult orElse(),
- }) =>
- throw _privateConstructorUsedError;
-}
-
-/// @nodoc
-abstract class $MenuEventCopyWith<$Res> {
- factory $MenuEventCopyWith(MenuEvent value, $Res Function(MenuEvent) then) =
- _$MenuEventCopyWithImpl<$Res>;
-}
-
-/// @nodoc
-class _$MenuEventCopyWithImpl<$Res> implements $MenuEventCopyWith<$Res> {
- _$MenuEventCopyWithImpl(this._value, this._then);
-
- final MenuEvent _value;
- // ignore: unused_field
- final $Res Function(MenuEvent) _then;
-}
-
-/// @nodoc
-abstract class $CollapseCopyWith<$Res> {
- factory $CollapseCopyWith(Collapse value, $Res Function(Collapse) then) =
- _$CollapseCopyWithImpl<$Res>;
-}
-
-/// @nodoc
-class _$CollapseCopyWithImpl<$Res> extends _$MenuEventCopyWithImpl<$Res>
- implements $CollapseCopyWith<$Res> {
- _$CollapseCopyWithImpl(Collapse _value, $Res Function(Collapse) _then)
- : super(_value, (v) => _then(v as Collapse));
-
- @override
- Collapse get _value => super._value as Collapse;
-}
-
-/// @nodoc
-
-class _$Collapse implements Collapse {
- const _$Collapse();
-
- @override
- String toString() {
- return 'MenuEvent.collapse()';
- }
-
- @override
- bool operator ==(dynamic other) {
- return identical(this, other) || (other is Collapse);
- }
-
- @override
- int get hashCode => runtimeType.hashCode;
-
- @override
- @optionalTypeArgs
- TResult when({
- required TResult Function() collapse,
- required TResult Function(PageContext context) openPage,
- required TResult Function() createApp,
- }) {
- return collapse();
- }
-
- @override
- @optionalTypeArgs
- TResult maybeWhen({
- TResult Function()? collapse,
- TResult Function(PageContext context)? openPage,
- TResult Function()? createApp,
- required TResult orElse(),
- }) {
- if (collapse != null) {
- return collapse();
- }
- return orElse();
- }
-
- @override
- @optionalTypeArgs
- TResult map({
- required TResult Function(Collapse value) collapse,
- required TResult Function(_OpenPage value) openPage,
- required TResult Function(_CreateApp value) createApp,
- }) {
- return collapse(this);
- }
-
- @override
- @optionalTypeArgs
- TResult maybeMap({
- TResult Function(Collapse value)? collapse,
- TResult Function(_OpenPage value)? openPage,
- TResult Function(_CreateApp value)? createApp,
- required TResult orElse(),
- }) {
- if (collapse != null) {
- return collapse(this);
- }
- return orElse();
- }
-}
-
-abstract class Collapse implements MenuEvent {
- const factory Collapse() = _$Collapse;
-}
-
-/// @nodoc
-abstract class _$OpenPageCopyWith<$Res> {
- factory _$OpenPageCopyWith(_OpenPage value, $Res Function(_OpenPage) then) =
- __$OpenPageCopyWithImpl<$Res>;
- $Res call({PageContext context});
-}
-
-/// @nodoc
-class __$OpenPageCopyWithImpl<$Res> extends _$MenuEventCopyWithImpl<$Res>
- implements _$OpenPageCopyWith<$Res> {
- __$OpenPageCopyWithImpl(_OpenPage _value, $Res Function(_OpenPage) _then)
- : super(_value, (v) => _then(v as _OpenPage));
-
- @override
- _OpenPage get _value => super._value as _OpenPage;
-
- @override
- $Res call({
- Object? context = freezed,
- }) {
- return _then(_OpenPage(
- context == freezed
- ? _value.context
- : context // ignore: cast_nullable_to_non_nullable
- as PageContext,
- ));
- }
-}
-
-/// @nodoc
-
-class _$_OpenPage implements _OpenPage {
- const _$_OpenPage(this.context);
-
- @override
- final PageContext context;
-
- @override
- String toString() {
- return 'MenuEvent.openPage(context: $context)';
- }
-
- @override
- bool operator ==(dynamic other) {
- return identical(this, other) ||
- (other is _OpenPage &&
- (identical(other.context, context) ||
- const DeepCollectionEquality().equals(other.context, context)));
- }
-
- @override
- int get hashCode =>
- runtimeType.hashCode ^ const DeepCollectionEquality().hash(context);
-
- @JsonKey(ignore: true)
- @override
- _$OpenPageCopyWith<_OpenPage> get copyWith =>
- __$OpenPageCopyWithImpl<_OpenPage>(this, _$identity);
-
- @override
- @optionalTypeArgs
- TResult when({
- required TResult Function() collapse,
- required TResult Function(PageContext context) openPage,
- required TResult Function() createApp,
- }) {
- return openPage(context);
- }
-
- @override
- @optionalTypeArgs
- TResult maybeWhen({
- TResult Function()? collapse,
- TResult Function(PageContext context)? openPage,
- TResult Function()? createApp,
- required TResult orElse(),
- }) {
- if (openPage != null) {
- return openPage(context);
- }
- return orElse();
- }
-
- @override
- @optionalTypeArgs
- TResult map({
- required TResult Function(Collapse value) collapse,
- required TResult Function(_OpenPage value) openPage,
- required TResult Function(_CreateApp value) createApp,
- }) {
- return openPage(this);
- }
-
- @override
- @optionalTypeArgs
- TResult maybeMap({
- TResult Function(Collapse value)? collapse,
- TResult Function(_OpenPage value)? openPage,
- TResult Function(_CreateApp value)? createApp,
- required TResult orElse(),
- }) {
- if (openPage != null) {
- return openPage(this);
- }
- return orElse();
- }
-}
-
-abstract class _OpenPage implements MenuEvent {
- const factory _OpenPage(PageContext context) = _$_OpenPage;
-
- PageContext get context => throw _privateConstructorUsedError;
- @JsonKey(ignore: true)
- _$OpenPageCopyWith<_OpenPage> get copyWith =>
- throw _privateConstructorUsedError;
-}
-
-/// @nodoc
-abstract class _$CreateAppCopyWith<$Res> {
- factory _$CreateAppCopyWith(
- _CreateApp value, $Res Function(_CreateApp) then) =
- __$CreateAppCopyWithImpl<$Res>;
-}
-
-/// @nodoc
-class __$CreateAppCopyWithImpl<$Res> extends _$MenuEventCopyWithImpl<$Res>
- implements _$CreateAppCopyWith<$Res> {
- __$CreateAppCopyWithImpl(_CreateApp _value, $Res Function(_CreateApp) _then)
- : super(_value, (v) => _then(v as _CreateApp));
-
- @override
- _CreateApp get _value => super._value as _CreateApp;
-}
-
-/// @nodoc
-
-class _$_CreateApp implements _CreateApp {
- const _$_CreateApp();
-
- @override
- String toString() {
- return 'MenuEvent.createApp()';
- }
-
- @override
- bool operator ==(dynamic other) {
- return identical(this, other) || (other is _CreateApp);
- }
-
- @override
- int get hashCode => runtimeType.hashCode;
-
- @override
- @optionalTypeArgs
- TResult when({
- required TResult Function() collapse,
- required TResult Function(PageContext context) openPage,
- required TResult Function() createApp,
- }) {
- return createApp();
- }
-
- @override
- @optionalTypeArgs
- TResult maybeWhen({
- TResult Function()? collapse,
- TResult Function(PageContext context)? openPage,
- TResult Function()? createApp,
- required TResult orElse(),
- }) {
- if (createApp != null) {
- return createApp();
- }
- return orElse();
- }
-
- @override
- @optionalTypeArgs
- TResult map({
- required TResult Function(Collapse value) collapse,
- required TResult Function(_OpenPage value) openPage,
- required TResult Function(_CreateApp value) createApp,
- }) {
- return createApp(this);
- }
-
- @override
- @optionalTypeArgs
- TResult maybeMap({
- TResult Function(Collapse value)? collapse,
- TResult Function(_OpenPage value)? openPage,
- TResult Function(_CreateApp value)? createApp,
- required TResult orElse(),
- }) {
- if (createApp != null) {
- return createApp(this);
- }
- return orElse();
- }
-}
-
-abstract class _CreateApp implements MenuEvent {
- const factory _CreateApp() = _$_CreateApp;
-}
-
-/// @nodoc
-class _$MenuStateTearOff {
- const _$MenuStateTearOff();
-
- _MenuState call(
- {required bool isCollapse, required Option pageContext}) {
- return _MenuState(
- isCollapse: isCollapse,
- pageContext: pageContext,
- );
- }
-}
-
-/// @nodoc
-const $MenuState = _$MenuStateTearOff();
-
-/// @nodoc
-mixin _$MenuState {
- bool get isCollapse => throw _privateConstructorUsedError;
- Option get pageContext => throw _privateConstructorUsedError;
-
- @JsonKey(ignore: true)
- $MenuStateCopyWith get copyWith =>
- throw _privateConstructorUsedError;
-}
-
-/// @nodoc
-abstract class $MenuStateCopyWith<$Res> {
- factory $MenuStateCopyWith(MenuState value, $Res Function(MenuState) then) =
- _$MenuStateCopyWithImpl<$Res>;
- $Res call({bool isCollapse, Option pageContext});
-}
-
-/// @nodoc
-class _$MenuStateCopyWithImpl<$Res> implements $MenuStateCopyWith<$Res> {
- _$MenuStateCopyWithImpl(this._value, this._then);
-
- final MenuState _value;
- // ignore: unused_field
- final $Res Function(MenuState) _then;
-
- @override
- $Res call({
- Object? isCollapse = freezed,
- Object? pageContext = freezed,
- }) {
- return _then(_value.copyWith(
- isCollapse: isCollapse == freezed
- ? _value.isCollapse
- : isCollapse // ignore: cast_nullable_to_non_nullable
- as bool,
- pageContext: pageContext == freezed
- ? _value.pageContext
- : pageContext // ignore: cast_nullable_to_non_nullable
- as Option,
- ));
- }
-}
-
-/// @nodoc
-abstract class _$MenuStateCopyWith<$Res> implements $MenuStateCopyWith<$Res> {
- factory _$MenuStateCopyWith(
- _MenuState value, $Res Function(_MenuState) then) =
- __$MenuStateCopyWithImpl<$Res>;
- @override
- $Res call({bool isCollapse, Option pageContext});
-}
-
-/// @nodoc
-class __$MenuStateCopyWithImpl<$Res> extends _$MenuStateCopyWithImpl<$Res>
- implements _$MenuStateCopyWith<$Res> {
- __$MenuStateCopyWithImpl(_MenuState _value, $Res Function(_MenuState) _then)
- : super(_value, (v) => _then(v as _MenuState));
-
- @override
- _MenuState get _value => super._value as _MenuState;
-
- @override
- $Res call({
- Object? isCollapse = freezed,
- Object? pageContext = freezed,
- }) {
- return _then(_MenuState(
- isCollapse: isCollapse == freezed
- ? _value.isCollapse
- : isCollapse // ignore: cast_nullable_to_non_nullable
- as bool,
- pageContext: pageContext == freezed
- ? _value.pageContext
- : pageContext // ignore: cast_nullable_to_non_nullable
- as Option,
- ));
- }
-}
-
-/// @nodoc
-
-class _$_MenuState implements _MenuState {
- const _$_MenuState({required this.isCollapse, required this.pageContext});
-
- @override
- final bool isCollapse;
- @override
- final Option pageContext;
-
- @override
- String toString() {
- return 'MenuState(isCollapse: $isCollapse, pageContext: $pageContext)';
- }
-
- @override
- bool operator ==(dynamic other) {
- return identical(this, other) ||
- (other is _MenuState &&
- (identical(other.isCollapse, isCollapse) ||
- const DeepCollectionEquality()
- .equals(other.isCollapse, isCollapse)) &&
- (identical(other.pageContext, pageContext) ||
- const DeepCollectionEquality()
- .equals(other.pageContext, pageContext)));
- }
-
- @override
- int get hashCode =>
- runtimeType.hashCode ^
- const DeepCollectionEquality().hash(isCollapse) ^
- const DeepCollectionEquality().hash(pageContext);
-
- @JsonKey(ignore: true)
- @override
- _$MenuStateCopyWith<_MenuState> get copyWith =>
- __$MenuStateCopyWithImpl<_MenuState>(this, _$identity);
-}
-
-abstract class _MenuState implements MenuState {
- const factory _MenuState(
- {required bool isCollapse,
- required Option pageContext}) = _$_MenuState;
-
- @override
- bool get isCollapse => throw _privateConstructorUsedError;
- @override
- Option get pageContext => throw _privateConstructorUsedError;
- @override
- @JsonKey(ignore: true)
- _$MenuStateCopyWith<_MenuState> get copyWith =>
- throw _privateConstructorUsedError;
-}
diff --git a/app_flowy/lib/home/application/menu/menu_event.dart b/app_flowy/lib/home/application/menu/menu_event.dart
deleted file mode 100644
index a187022b9a..0000000000
--- a/app_flowy/lib/home/application/menu/menu_event.dart
+++ /dev/null
@@ -1,8 +0,0 @@
-part of 'menu_bloc.dart';
-
-@freezed
-abstract class MenuEvent with _$MenuEvent {
- const factory MenuEvent.collapse() = Collapse;
- const factory MenuEvent.openPage(PageContext context) = _OpenPage;
- const factory MenuEvent.createApp() = _CreateApp;
-}
diff --git a/app_flowy/lib/home/application/menu/menu_state.dart b/app_flowy/lib/home/application/menu/menu_state.dart
deleted file mode 100644
index 548459be0d..0000000000
--- a/app_flowy/lib/home/application/menu/menu_state.dart
+++ /dev/null
@@ -1,14 +0,0 @@
-part of 'menu_bloc.dart';
-
-@freezed
-abstract class MenuState implements _$MenuState {
- const factory MenuState({
- required bool isCollapse,
- required Option pageContext,
- }) = _MenuState;
-
- factory MenuState.initial() => MenuState(
- isCollapse: false,
- pageContext: none(),
- );
-}
diff --git a/app_flowy/lib/home/application/watcher/home_watcher_event.dart b/app_flowy/lib/home/application/watcher/home_watcher_event.dart
deleted file mode 100644
index 0bae7a735c..0000000000
--- a/app_flowy/lib/home/application/watcher/home_watcher_event.dart
+++ /dev/null
@@ -1,7 +0,0 @@
-part of 'home_watcher_bloc.dart';
-
-@freezed
-abstract class HomeWatcherEvent with _$HomeWatcherEvent {
- const factory HomeWatcherEvent.started(String workspaceId) = _Started;
- const factory HomeWatcherEvent.stop(String workspaceId) = _Stop;
-}
diff --git a/app_flowy/lib/home/application/watcher/home_watcher_state.dart b/app_flowy/lib/home/application/watcher/home_watcher_state.dart
deleted file mode 100644
index 5081f94af0..0000000000
--- a/app_flowy/lib/home/application/watcher/home_watcher_state.dart
+++ /dev/null
@@ -1,7 +0,0 @@
-part of 'home_watcher_bloc.dart';
-
-@freezed
-abstract class HomeWatcherState with _$HomeWatcherState {
- const factory HomeWatcherState.initial() = _Initial;
- const factory HomeWatcherState.loading() = _Loading;
-}
diff --git a/app_flowy/lib/home/domain/page_context.dart b/app_flowy/lib/home/domain/page_context.dart
deleted file mode 100644
index a787bd927f..0000000000
--- a/app_flowy/lib/home/domain/page_context.dart
+++ /dev/null
@@ -1,19 +0,0 @@
-import 'package:equatable/equatable.dart';
-import 'package:flutter/material.dart';
-
-abstract class HomeStackPage extends StatefulWidget {
- final PageContext pageContext;
- const HomeStackPage({Key? key, required this.pageContext}) : super(key: key);
-}
-
-enum PageType {
- blank,
-}
-
-List pages = PageType.values.toList();
-
-abstract class PageContext extends Equatable {
- final PageType pageType;
- final String pageTitle;
- const PageContext(this.pageType, {required this.pageTitle});
-}
diff --git a/app_flowy/lib/home/presentation/widgets/menu/home_menu.dart b/app_flowy/lib/home/presentation/widgets/menu/home_menu.dart
deleted file mode 100644
index b233128131..0000000000
--- a/app_flowy/lib/home/presentation/widgets/menu/home_menu.dart
+++ /dev/null
@@ -1,121 +0,0 @@
-import 'package:app_flowy/home/application/menu/menu_bloc.dart';
-import 'package:app_flowy/home/domain/page_context.dart';
-import 'package:app_flowy/startup/startup.dart';
-import 'package:dartz/dartz.dart';
-import 'package:flowy_infra/size.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-import '../../home_sizes.dart';
-import 'package:styled_widget/styled_widget.dart';
-
-class HomeMenu extends StatelessWidget {
- final Function(Option) pageContextChanged;
- final Function(bool) isCollapseChanged;
-
- const HomeMenu(
- {Key? key,
- required this.pageContextChanged,
- required this.isCollapseChanged})
- : super(key: key);
-
- @override
- Widget build(BuildContext context) {
- return MultiBlocProvider(
- providers: [
- BlocProvider(create: (context) => getIt()),
- ],
- child: MultiBlocListener(
- listeners: bind(),
- child: Container(
- color: Theme.of(context).colorScheme.primaryVariant,
- child: Padding(
- padding: EdgeInsets.symmetric(horizontal: Insets.sm),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- const MenuTopBar(),
- Container(),
- const NewAppButton(),
- ],
- ),
- ),
- ),
- ));
- }
-
- // bind the function passed by ooutter with the bloc listener
- List> bind() {
- return [
- BlocListener(
- listenWhen: (p, c) => p.pageContext != c.pageContext,
- listener: (context, state) => pageContextChanged(state.pageContext),
- ),
- BlocListener(
- listenWhen: (p, c) => p.isCollapse != c.isCollapse,
- listener: (context, state) => isCollapseChanged(state.isCollapse),
- )
- ];
- }
-}
-
-class MenuTopBar extends StatelessWidget {
- const MenuTopBar({Key? key}) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return BlocBuilder(
- builder: (context, state) {
- return SizedBox(
- height: HomeSizes.menuTopBarHeight,
- child: Row(
- children: [
- const Text(
- 'AppFlowy',
- style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
- ).constrained(minWidth: 100),
- const Spacer(),
- IconButton(
- icon: const Icon(Icons.arrow_left),
- onPressed: () =>
- context.read().add(const MenuEvent.collapse()),
- ),
- ],
- ),
- );
- },
- );
- }
-}
-
-class NewAppButton extends StatelessWidget {
- const NewAppButton({Key? key}) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return SizedBox(
- height: HomeSizes.menuAddButtonHeight,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- const Icon(Icons.add),
- const SizedBox(
- width: 10,
- ),
- TextButton(
- onPressed: () async {
- // Dialogs.show(OkCancelDialog(
- // title: "No Connection",
- // message:
- // "It appears your device is offline. Please check your connection and try again.",
- // onOkPressed: () => AppGlobals.nav.pop(),
- // ));
- },
- child: const Text('New App',
- style: TextStyle(
- color: Colors.black,
- fontWeight: FontWeight.bold,
- fontSize: 20)),
- )
- ],
- ),
- );
- }
-}
diff --git a/app_flowy/lib/home/presentation/widgets/menu/prelude.dart b/app_flowy/lib/home/presentation/widgets/menu/prelude.dart
deleted file mode 100644
index d3156898d5..0000000000
--- a/app_flowy/lib/home/presentation/widgets/menu/prelude.dart
+++ /dev/null
@@ -1,2 +0,0 @@
-export 'home_menu.dart';
-export 'hom_menu_size.dart';
diff --git a/app_flowy/lib/main.dart b/app_flowy/lib/main.dart
index 76aa42d13f..6a7201968a 100644
--- a/app_flowy/lib/main.dart
+++ b/app_flowy/lib/main.dart
@@ -10,5 +10,5 @@ class FlowyAppFactory implements AppFactory {
}
void main() {
- App.run(FlowyAppFactory());
+ Application.run(FlowyAppFactory());
}
diff --git a/app_flowy/lib/startup/deps_inject/prelude.dart b/app_flowy/lib/startup/deps_inject/prelude.dart
index 3811e93bd0..8727cba4a2 100644
--- a/app_flowy/lib/startup/deps_inject/prelude.dart
+++ b/app_flowy/lib/startup/deps_inject/prelude.dart
@@ -1,7 +1,8 @@
+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/interface_impl.dart';
-import 'package:app_flowy/welcome/infrastructure/interface_impl.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,4 +17,5 @@ Future initGetIt(
await WelcomeDepsResolver.resolve(getIt);
await UserDepsResolver.resolve(getIt);
+ await HomeDepsResolver.resolve(getIt);
}
diff --git a/app_flowy/lib/startup/startup.dart b/app_flowy/lib/startup/startup.dart
index 31a75755a9..96588ff06c 100644
--- a/app_flowy/lib/startup/startup.dart
+++ b/app_flowy/lib/startup/startup.dart
@@ -14,7 +14,7 @@ abstract class AppFactory {
Widget create();
}
-class App {
+class Application {
static void run(AppFactory f) {
// Specify the evn
const env = IntegrationEnv.dev;
diff --git a/app_flowy/lib/startup/tasks/app_widget_task.dart b/app_flowy/lib/startup/tasks/application_task.dart
similarity index 90%
rename from app_flowy/lib/startup/tasks/app_widget_task.dart
rename to app_flowy/lib/startup/tasks/application_task.dart
index e18ef9a0a8..416310e470 100644
--- a/app_flowy/lib/startup/tasks/app_widget_task.dart
+++ b/app_flowy/lib/startup/tasks/application_task.dart
@@ -12,16 +12,16 @@ class AppWidgetTask extends LaunchTask {
@override
Future initialize(LaunchContext context) {
final widget = context.getIt().create();
- final app = AppWidget(child: widget);
+ final app = ApplicationWidget(child: widget);
runApp(app);
return Future(() => {});
}
}
-class AppWidget extends StatelessWidget {
+class ApplicationWidget extends StatelessWidget {
final Widget child;
- const AppWidget({
+ const ApplicationWidget({
Key? key,
required this.child,
}) : super(key: key);
diff --git a/app_flowy/lib/startup/tasks/prelude.dart b/app_flowy/lib/startup/tasks/prelude.dart
index d4474f0342..2e82179a7b 100644
--- a/app_flowy/lib/startup/tasks/prelude.dart
+++ b/app_flowy/lib/startup/tasks/prelude.dart
@@ -1,2 +1,2 @@
-export 'app_widget_task.dart';
+export 'application_task.dart';
export 'rust_sdk_init_task.dart';
diff --git a/app_flowy/lib/startup/tasks/rust_sdk_init_task.dart b/app_flowy/lib/startup/tasks/rust_sdk_init_task.dart
index 4f57190761..c5067b2cc9 100644
--- a/app_flowy/lib/startup/tasks/rust_sdk_init_task.dart
+++ b/app_flowy/lib/startup/tasks/rust_sdk_init_task.dart
@@ -38,8 +38,9 @@ class RustSDKInitTask extends LaunchTask {
class ApplicationBlocObserver extends BlocObserver {
@override
+ // ignore: unnecessary_overrides
void onTransition(Bloc bloc, Transition transition) {
- Log.debug(transition);
+ // Log.debug(transition);
super.onTransition(bloc, transition);
}
diff --git a/app_flowy/lib/user/application/sign_in/sign_in_bloc.dart b/app_flowy/lib/user/application/sign_in/sign_in_bloc.dart
index 08d8d71aac..8bb9a87ff8 100644
--- a/app_flowy/lib/user/application/sign_in/sign_in_bloc.dart
+++ b/app_flowy/lib/user/application/sign_in/sign_in_bloc.dart
@@ -1,12 +1,10 @@
-import 'package:app_flowy/user/domain/interface.dart';
+import 'package:app_flowy/user/domain/i_auth.dart';
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
// ignore: import_of_legacy_library_into_null_safe
import 'package:flutter_bloc/flutter_bloc.dart';
-part 'sign_in_event.dart';
-part 'sign_in_state.dart';
part 'sign_in_bloc.freezed.dart';
class SignInBloc extends Bloc {
@@ -43,3 +41,27 @@ class SignInBloc extends Bloc {
);
}
}
+
+@freezed
+abstract class SignInEvent with _$SignInEvent {
+ const factory SignInEvent.signedInWithUserEmailAndPassword() =
+ SignedInWithUserEmailAndPassword;
+
+ const factory SignInEvent.emailChanged(String email) = EmailChanged;
+ const factory SignInEvent.passwordChanged(String password) = PasswordChanged;
+}
+
+@freezed
+abstract class SignInState with _$SignInState {
+ const factory SignInState({
+ String? email,
+ String? password,
+ required bool isSubmitting,
+ required Option> signInFailure,
+ }) = _SignInState;
+
+ factory SignInState.initial() => SignInState(
+ isSubmitting: false,
+ signInFailure: none(),
+ );
+}
diff --git a/app_flowy/lib/user/application/sign_in/sign_in_event.dart b/app_flowy/lib/user/application/sign_in/sign_in_event.dart
deleted file mode 100644
index 702afea0bc..0000000000
--- a/app_flowy/lib/user/application/sign_in/sign_in_event.dart
+++ /dev/null
@@ -1,10 +0,0 @@
-part of 'sign_in_bloc.dart';
-
-@freezed
-abstract class SignInEvent with _$SignInEvent {
- const factory SignInEvent.signedInWithUserEmailAndPassword() =
- SignedInWithUserEmailAndPassword;
-
- const factory SignInEvent.emailChanged(String email) = EmailChanged;
- const factory SignInEvent.passwordChanged(String password) = PasswordChanged;
-}
diff --git a/app_flowy/lib/user/application/sign_in/sign_in_state.dart b/app_flowy/lib/user/application/sign_in/sign_in_state.dart
deleted file mode 100644
index 76555cb38b..0000000000
--- a/app_flowy/lib/user/application/sign_in/sign_in_state.dart
+++ /dev/null
@@ -1,16 +0,0 @@
-part of 'sign_in_bloc.dart';
-
-@freezed
-abstract class SignInState with _$SignInState {
- const factory SignInState({
- String? email,
- String? password,
- required bool isSubmitting,
- required Option> signInFailure,
- }) = _SignInState;
-
- factory SignInState.initial() => SignInState(
- isSubmitting: false,
- signInFailure: none(),
- );
-}
diff --git a/app_flowy/lib/user/domain/interface.dart b/app_flowy/lib/user/domain/i_auth.dart
similarity index 100%
rename from app_flowy/lib/user/domain/interface.dart
rename to app_flowy/lib/user/domain/i_auth.dart
diff --git a/app_flowy/lib/user/infrastructure/deps_resolver.dart b/app_flowy/lib/user/infrastructure/deps_resolver.dart
new file mode 100644
index 0000000000..92df6eef03
--- /dev/null
+++ b/app_flowy/lib/user/infrastructure/deps_resolver.dart
@@ -0,0 +1,17 @@
+import 'package:app_flowy/user/application/sign_in/sign_in_bloc.dart';
+import 'package:app_flowy/user/domain/i_auth.dart';
+import 'package:app_flowy/user/infrastructure/repos/auth_repo.dart';
+import 'package:app_flowy/user/infrastructure/i_auth_impl.dart';
+import 'package:get_it/get_it.dart';
+
+class UserDepsResolver {
+ static Future resolve(GetIt getIt) async {
+ getIt.registerLazySingleton(() => AuthRepository());
+
+ //Interface implementation
+ getIt.registerFactory(() => AuthImpl(repo: getIt()));
+
+ //Bloc
+ getIt.registerFactory(() => SignInBloc(getIt()));
+ }
+}
diff --git a/app_flowy/lib/user/infrastructure/interface_impl.dart b/app_flowy/lib/user/infrastructure/i_auth_impl.dart
similarity index 52%
rename from app_flowy/lib/user/infrastructure/interface_impl.dart
rename to app_flowy/lib/user/infrastructure/i_auth_impl.dart
index f7ddd74da4..580637cdcf 100644
--- a/app_flowy/lib/user/infrastructure/interface_impl.dart
+++ b/app_flowy/lib/user/infrastructure/i_auth_impl.dart
@@ -1,22 +1,7 @@
-import 'package:app_flowy/user/application/sign_in/sign_in_bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
-import 'package:get_it/get_it.dart';
-
-import 'package:app_flowy/user/domain/interface.dart';
-import 'package:app_flowy/user/infrastructure/auth_repo.dart';
-
-class UserDepsResolver {
- static Future resolve(GetIt getIt) async {
- getIt.registerLazySingleton(() => AuthRepository());
-
- //Interface implementation
- getIt.registerFactory(() => AuthImpl(repo: getIt()));
-
- //Bloc
- getIt.registerFactory(() => SignInBloc(getIt()));
- }
-}
+import 'package:app_flowy/user/domain/i_auth.dart';
+import 'package:app_flowy/user/infrastructure/repos/auth_repo.dart';
class AuthImpl extends IAuth {
AuthRepository repo;
diff --git a/app_flowy/lib/user/infrastructure/auth_repo.dart b/app_flowy/lib/user/infrastructure/repos/auth_repo.dart
similarity index 100%
rename from app_flowy/lib/user/infrastructure/auth_repo.dart
rename to app_flowy/lib/user/infrastructure/repos/auth_repo.dart
diff --git a/app_flowy/lib/user/presentation/sign_in/widgets/body.dart b/app_flowy/lib/user/presentation/sign_in/widgets/body.dart
index 7021dd740b..be49b3f7b9 100644
--- a/app_flowy/lib/user/presentation/sign_in/widgets/body.dart
+++ b/app_flowy/lib/user/presentation/sign_in/widgets/body.dart
@@ -1,7 +1,7 @@
-import 'package:app_flowy/home/presentation/home_screen.dart';
import 'package:app_flowy/startup/startup.dart';
import 'package:app_flowy/user/application/sign_in/sign_in_bloc.dart';
import 'package:app_flowy/user/presentation/sign_in/widgets/background.dart';
+import 'package:app_flowy/workspace/presentation/home/home_screen.dart';
import 'package:dartz/dartz.dart';
import 'package:flowy_infra_ui/widget/rounded_button.dart';
import 'package:flowy_infra_ui/widget/rounded_input_field.dart';
diff --git a/app_flowy/lib/welcome/application/welcome_bloc.dart b/app_flowy/lib/welcome/application/welcome_bloc.dart
index b8bfe9efb8..6595029a4a 100644
--- a/app_flowy/lib/welcome/application/welcome_bloc.dart
+++ b/app_flowy/lib/welcome/application/welcome_bloc.dart
@@ -1,10 +1,8 @@
import 'package:app_flowy/welcome/domain/auth_state.dart';
-import 'package:app_flowy/welcome/domain/interface.dart';
+import 'package:app_flowy/welcome/domain/i_welcome.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
-part 'welcome_event.dart';
-part 'welcome_state.dart';
part 'welcome_bloc.freezed.dart';
class WelcomeBloc extends Bloc {
@@ -21,3 +19,19 @@ class WelcomeBloc extends Bloc {
);
}
}
+
+@freezed
+abstract class WelcomeEvent with _$WelcomeEvent {
+ const factory WelcomeEvent.getUser() = _GetUser;
+}
+
+@freezed
+abstract class WelcomeState implements _$WelcomeState {
+ const factory WelcomeState({
+ required AuthState auth,
+ }) = _WelcomeState;
+
+ factory WelcomeState.initial() => const WelcomeState(
+ auth: AuthState.initial(),
+ );
+}
diff --git a/app_flowy/lib/welcome/application/welcome_event.dart b/app_flowy/lib/welcome/application/welcome_event.dart
deleted file mode 100644
index 0ade68c9df..0000000000
--- a/app_flowy/lib/welcome/application/welcome_event.dart
+++ /dev/null
@@ -1,6 +0,0 @@
-part of 'welcome_bloc.dart';
-
-@freezed
-abstract class WelcomeEvent with _$WelcomeEvent {
- const factory WelcomeEvent.getUser() = _GetUser;
-}
diff --git a/app_flowy/lib/welcome/application/welcome_state.dart b/app_flowy/lib/welcome/application/welcome_state.dart
deleted file mode 100644
index 04ba534244..0000000000
--- a/app_flowy/lib/welcome/application/welcome_state.dart
+++ /dev/null
@@ -1,12 +0,0 @@
-part of 'welcome_bloc.dart';
-
-@freezed
-abstract class WelcomeState implements _$WelcomeState {
- const factory WelcomeState({
- required AuthState auth,
- }) = _WelcomeState;
-
- factory WelcomeState.initial() => const WelcomeState(
- auth: AuthState.initial(),
- );
-}
diff --git a/app_flowy/lib/welcome/domain/interface.dart b/app_flowy/lib/welcome/domain/i_welcome.dart
similarity index 100%
rename from app_flowy/lib/welcome/domain/interface.dart
rename to app_flowy/lib/welcome/domain/i_welcome.dart
diff --git a/app_flowy/lib/welcome/infrastructure/deps_resolver.dart b/app_flowy/lib/welcome/infrastructure/deps_resolver.dart
new file mode 100644
index 0000000000..18024e9038
--- /dev/null
+++ b/app_flowy/lib/welcome/infrastructure/deps_resolver.dart
@@ -0,0 +1,19 @@
+import 'package:app_flowy/workspace/application/edit_pannel/edit_pannel_bloc.dart';
+import 'package:app_flowy/welcome/application/welcome_bloc.dart';
+import 'package:app_flowy/welcome/infrastructure/i_welcome_impl.dart';
+import 'package:app_flowy/workspace/application/home/home_bloc.dart';
+import 'package:app_flowy/workspace/application/home/home_watcher_bloc.dart';
+import 'package:get_it/get_it.dart';
+
+class WelcomeDepsResolver {
+ static Future resolve(GetIt getIt) async {
+ getIt.registerFactory(() => WelcomeAuthImpl());
+ getIt.registerFactory(() => WelcomeRoute());
+ getIt.registerFactory(() => HomeBloc());
+ getIt.registerFactory(() => HomeWatcherBloc());
+ getIt.registerFactory(() => EditPannelBloc());
+
+ getIt
+ .registerFactory(() => WelcomeBloc(getIt()));
+ }
+}
diff --git a/app_flowy/lib/welcome/infrastructure/i_welcome_impl.dart b/app_flowy/lib/welcome/infrastructure/i_welcome_impl.dart
new file mode 100644
index 0000000000..671c8427f6
--- /dev/null
+++ b/app_flowy/lib/welcome/infrastructure/i_welcome_impl.dart
@@ -0,0 +1,39 @@
+import 'package:app_flowy/user/presentation/sign_in/sign_in_screen.dart';
+import 'package:app_flowy/welcome/domain/auth_state.dart';
+import 'package:app_flowy/welcome/domain/i_welcome.dart';
+import 'package:app_flowy/workspace/presentation/home/home_screen.dart';
+import 'package:flowy_sdk/dispatch/dispatch.dart';
+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_welcome.dart';
+
+class WelcomeAuthImpl implements IWelcomeAuth {
+ @override
+ Future currentUserState() {
+ final result = UserEventGetStatus().send();
+ return result.then((result) {
+ return result.fold(
+ (userDetail) {
+ return AuthState.authenticated(userDetail);
+ },
+ (userError) {
+ return AuthState.unauthenticated(userError);
+ },
+ );
+ });
+ }
+}
+
+class WelcomeRoute implements IWelcomeRoute {
+ @override
+ Widget pushHomeScreen(UserDetail user) {
+ return HomeScreen(user);
+ }
+
+ @override
+ Widget pushSignInScreen() {
+ return const SignInScreen();
+ }
+}
diff --git a/app_flowy/lib/welcome/infrastructure/interface_impl.dart b/app_flowy/lib/welcome/infrastructure/interface_impl.dart
deleted file mode 100644
index d060aff1e1..0000000000
--- a/app_flowy/lib/welcome/infrastructure/interface_impl.dart
+++ /dev/null
@@ -1,58 +0,0 @@
-import 'package:app_flowy/home/application/edit_pannel/edit_pannel_bloc.dart';
-import 'package:app_flowy/home/application/home_bloc.dart';
-import 'package:app_flowy/home/application/menu/menu_bloc.dart';
-import 'package:app_flowy/home/application/watcher/home_watcher_bloc.dart';
-import 'package:app_flowy/home/presentation/home_screen.dart';
-import 'package:app_flowy/user/presentation/sign_in/sign_in_screen.dart';
-import 'package:app_flowy/welcome/application/welcome_bloc.dart';
-import 'package:app_flowy/welcome/domain/auth_state.dart';
-import 'package:app_flowy/welcome/domain/interface.dart';
-import 'package:flowy_sdk/dispatch/dispatch.dart';
-import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter/widgets.dart';
-import 'package:get_it/get_it.dart';
-
-class WelcomeDepsResolver {
- static Future resolve(GetIt getIt) async {
- getIt.registerFactory(() => WelcomeAuthImpl());
- getIt.registerFactory(() => WelcomeRoute());
- getIt.registerFactory(() => HomeBloc());
- getIt.registerFactory(() => HomeWatcherBloc());
- getIt.registerFactory(() => EditPannelBloc());
-
- getIt.registerFactory(() => MenuBloc());
-
- getIt
- .registerFactory(() => WelcomeBloc(getIt()));
- }
-}
-
-class WelcomeAuthImpl implements IWelcomeAuth {
- @override
- Future currentUserState() {
- final result = UserEventGetStatus().send();
- return result.then((result) {
- return result.fold(
- (userDetail) {
- return AuthState.authenticated(userDetail);
- },
- (userError) {
- return AuthState.unauthenticated(userError);
- },
- );
- });
- }
-}
-
-class WelcomeRoute implements IWelcomeRoute {
- @override
- Widget pushHomeScreen(UserDetail user) {
- return HomeScreen(user);
- }
-
- @override
- Widget pushSignInScreen() {
- return const SignInScreen();
- }
-}
diff --git a/app_flowy/lib/welcome/presentation/welcome_screen.dart b/app_flowy/lib/welcome/presentation/welcome_screen.dart
index b4ef56cf4d..82fc4cfcfa 100644
--- a/app_flowy/lib/welcome/presentation/welcome_screen.dart
+++ b/app_flowy/lib/welcome/presentation/welcome_screen.dart
@@ -1,4 +1,4 @@
-import 'package:app_flowy/welcome/domain/interface.dart';
+import 'package:app_flowy/welcome/domain/i_welcome.dart';
import 'package:app_flowy/welcome/domain/auth_state.dart';
import 'package:app_flowy/startup/startup.dart';
import 'package:app_flowy/welcome/application/welcome_bloc.dart';
diff --git a/app_flowy/lib/workspace/application/app/app_bloc.dart b/app_flowy/lib/workspace/application/app/app_bloc.dart
new file mode 100644
index 0000000000..45200aa8d3
--- /dev/null
+++ b/app_flowy/lib/workspace/application/app/app_bloc.dart
@@ -0,0 +1,58 @@
+import 'package:app_flowy/workspace/domain/i_app.dart';
+import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
+import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
+import 'package:freezed_annotation/freezed_annotation.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:dartz/dartz.dart';
+
+part 'app_bloc.freezed.dart';
+
+class AppBloc extends Bloc {
+ final IApp iAppImpl;
+ AppBloc(this.iAppImpl) : super(AppState.initial());
+
+ @override
+ Stream mapEventToState(
+ AppEvent event,
+ ) async* {
+ yield* event.map(
+ initial: (e) async* {
+ yield* _fetchViews();
+ },
+ createView: (CreateView value) async* {
+ iAppImpl.createView(
+ name: value.name, desc: value.desc, viewType: value.viewType);
+ },
+ );
+ }
+
+ Stream _fetchViews() async* {
+ final viewsOrFailed = await iAppImpl.getViews();
+ yield viewsOrFailed.fold(
+ (apps) => state.copyWith(views: some(apps)),
+ (error) => state.copyWith(successOrFailure: right(error)),
+ );
+ }
+}
+
+@freezed
+abstract 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 {
+ const factory AppState({
+ required bool isLoading,
+ required Option> views,
+ required Either successOrFailure,
+ }) = _AppState;
+
+ factory AppState.initial() => AppState(
+ isLoading: false,
+ views: none(),
+ successOrFailure: left(unit),
+ );
+}
diff --git a/app_flowy/lib/workspace/application/app/app_bloc.freezed.dart b/app_flowy/lib/workspace/application/app/app_bloc.freezed.dart
new file mode 100644
index 0000000000..eb75305a1b
--- /dev/null
+++ b/app_flowy/lib/workspace/application/app/app_bloc.freezed.dart
@@ -0,0 +1,484 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides
+
+part of 'app_bloc.dart';
+
+// **************************************************************************
+// FreezedGenerator
+// **************************************************************************
+
+T _$identity(T value) => value;
+
+final _privateConstructorUsedError = UnsupportedError(
+ 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
+
+/// @nodoc
+class _$AppEventTearOff {
+ const _$AppEventTearOff();
+
+ Initial initial() {
+ return const Initial();
+ }
+
+ CreateView createView(String name, String desc, ViewType viewType) {
+ return CreateView(
+ name,
+ desc,
+ viewType,
+ );
+ }
+}
+
+/// @nodoc
+const $AppEvent = _$AppEventTearOff();
+
+/// @nodoc
+mixin _$AppEvent {
+ @optionalTypeArgs
+ TResult when({
+ required TResult Function() initial,
+ required TResult Function(String name, String desc, ViewType viewType)
+ createView,
+ }) =>
+ throw _privateConstructorUsedError;
+ @optionalTypeArgs
+ TResult maybeWhen({
+ TResult Function()? initial,
+ TResult Function(String name, String desc, ViewType viewType)? createView,
+ required TResult orElse(),
+ }) =>
+ throw _privateConstructorUsedError;
+ @optionalTypeArgs
+ TResult map({
+ required TResult Function(Initial value) initial,
+ required TResult Function(CreateView value) createView,
+ }) =>
+ throw _privateConstructorUsedError;
+ @optionalTypeArgs
+ TResult maybeMap({
+ TResult Function(Initial value)? initial,
+ TResult Function(CreateView value)? createView,
+ required TResult orElse(),
+ }) =>
+ throw _privateConstructorUsedError;
+}
+
+/// @nodoc
+abstract class $AppEventCopyWith<$Res> {
+ factory $AppEventCopyWith(AppEvent value, $Res Function(AppEvent) then) =
+ _$AppEventCopyWithImpl<$Res>;
+}
+
+/// @nodoc
+class _$AppEventCopyWithImpl<$Res> implements $AppEventCopyWith<$Res> {
+ _$AppEventCopyWithImpl(this._value, this._then);
+
+ final AppEvent _value;
+ // ignore: unused_field
+ final $Res Function(AppEvent) _then;
+}
+
+/// @nodoc
+abstract class $InitialCopyWith<$Res> {
+ factory $InitialCopyWith(Initial value, $Res Function(Initial) then) =
+ _$InitialCopyWithImpl<$Res>;
+}
+
+/// @nodoc
+class _$InitialCopyWithImpl<$Res> extends _$AppEventCopyWithImpl<$Res>
+ implements $InitialCopyWith<$Res> {
+ _$InitialCopyWithImpl(Initial _value, $Res Function(Initial) _then)
+ : super(_value, (v) => _then(v as Initial));
+
+ @override
+ Initial get _value => super._value as Initial;
+}
+
+/// @nodoc
+
+class _$Initial implements Initial {
+ const _$Initial();
+
+ @override
+ String toString() {
+ return 'AppEvent.initial()';
+ }
+
+ @override
+ bool operator ==(dynamic other) {
+ return identical(this, other) || (other is Initial);
+ }
+
+ @override
+ int get hashCode => runtimeType.hashCode;
+
+ @override
+ @optionalTypeArgs
+ TResult when({
+ required TResult Function() initial,
+ required TResult Function(String name, String desc, ViewType viewType)
+ createView,
+ }) {
+ return initial();
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeWhen({
+ TResult Function()? initial,
+ TResult Function(String name, String desc, ViewType viewType)? createView,
+ required TResult orElse(),
+ }) {
+ if (initial != null) {
+ return initial();
+ }
+ return orElse();
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult map({
+ required TResult Function(Initial value) initial,
+ required TResult Function(CreateView value) createView,
+ }) {
+ return initial(this);
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeMap({
+ TResult Function(Initial value)? initial,
+ TResult Function(CreateView value)? createView,
+ required TResult orElse(),
+ }) {
+ if (initial != null) {
+ return initial(this);
+ }
+ return orElse();
+ }
+}
+
+abstract class Initial implements AppEvent {
+ const factory Initial() = _$Initial;
+}
+
+/// @nodoc
+abstract class $CreateViewCopyWith<$Res> {
+ factory $CreateViewCopyWith(
+ CreateView value, $Res Function(CreateView) then) =
+ _$CreateViewCopyWithImpl<$Res>;
+ $Res call({String name, String desc, ViewType viewType});
+}
+
+/// @nodoc
+class _$CreateViewCopyWithImpl<$Res> extends _$AppEventCopyWithImpl<$Res>
+ implements $CreateViewCopyWith<$Res> {
+ _$CreateViewCopyWithImpl(CreateView _value, $Res Function(CreateView) _then)
+ : super(_value, (v) => _then(v as CreateView));
+
+ @override
+ CreateView get _value => super._value as CreateView;
+
+ @override
+ $Res call({
+ Object? name = freezed,
+ Object? desc = freezed,
+ Object? viewType = freezed,
+ }) {
+ return _then(CreateView(
+ name == freezed
+ ? _value.name
+ : name // ignore: cast_nullable_to_non_nullable
+ as String,
+ desc == freezed
+ ? _value.desc
+ : desc // ignore: cast_nullable_to_non_nullable
+ as String,
+ viewType == freezed
+ ? _value.viewType
+ : viewType // ignore: cast_nullable_to_non_nullable
+ as ViewType,
+ ));
+ }
+}
+
+/// @nodoc
+
+class _$CreateView implements CreateView {
+ const _$CreateView(this.name, this.desc, this.viewType);
+
+ @override
+ final String name;
+ @override
+ final String desc;
+ @override
+ final ViewType viewType;
+
+ @override
+ String toString() {
+ return 'AppEvent.createView(name: $name, desc: $desc, viewType: $viewType)';
+ }
+
+ @override
+ bool operator ==(dynamic other) {
+ return identical(this, other) ||
+ (other is CreateView &&
+ (identical(other.name, name) ||
+ const DeepCollectionEquality().equals(other.name, name)) &&
+ (identical(other.desc, desc) ||
+ const DeepCollectionEquality().equals(other.desc, desc)) &&
+ (identical(other.viewType, viewType) ||
+ const DeepCollectionEquality()
+ .equals(other.viewType, viewType)));
+ }
+
+ @override
+ int get hashCode =>
+ runtimeType.hashCode ^
+ const DeepCollectionEquality().hash(name) ^
+ const DeepCollectionEquality().hash(desc) ^
+ const DeepCollectionEquality().hash(viewType);
+
+ @JsonKey(ignore: true)
+ @override
+ $CreateViewCopyWith get copyWith =>
+ _$CreateViewCopyWithImpl(this, _$identity);
+
+ @override
+ @optionalTypeArgs
+ TResult when({
+ required TResult Function() initial,
+ required TResult Function(String name, String desc, ViewType viewType)
+ createView,
+ }) {
+ return createView(name, desc, viewType);
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeWhen({
+ TResult Function()? initial,
+ TResult Function(String name, String desc, ViewType viewType)? createView,
+ required TResult orElse(),
+ }) {
+ if (createView != null) {
+ return createView(name, desc, viewType);
+ }
+ return orElse();
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult map({
+ required TResult Function(Initial value) initial,
+ required TResult Function(CreateView value) createView,
+ }) {
+ return createView(this);
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeMap({
+ TResult Function(Initial value)? initial,
+ TResult Function(CreateView value)? createView,
+ required TResult orElse(),
+ }) {
+ if (createView != null) {
+ return createView(this);
+ }
+ return orElse();
+ }
+}
+
+abstract class CreateView implements AppEvent {
+ const factory CreateView(String name, String desc, ViewType viewType) =
+ _$CreateView;
+
+ String get name => throw _privateConstructorUsedError;
+ String get desc => throw _privateConstructorUsedError;
+ ViewType get viewType => throw _privateConstructorUsedError;
+ @JsonKey(ignore: true)
+ $CreateViewCopyWith get copyWith =>
+ throw _privateConstructorUsedError;
+}
+
+/// @nodoc
+class _$AppStateTearOff {
+ const _$AppStateTearOff();
+
+ _AppState call(
+ {required bool isLoading,
+ required Option> views,
+ required Either successOrFailure}) {
+ return _AppState(
+ isLoading: isLoading,
+ views: views,
+ successOrFailure: successOrFailure,
+ );
+ }
+}
+
+/// @nodoc
+const $AppState = _$AppStateTearOff();
+
+/// @nodoc
+mixin _$AppState {
+ bool get isLoading => throw _privateConstructorUsedError;
+ Option> get views => throw _privateConstructorUsedError;
+ Either get successOrFailure =>
+ throw _privateConstructorUsedError;
+
+ @JsonKey(ignore: true)
+ $AppStateCopyWith get copyWith =>
+ throw _privateConstructorUsedError;
+}
+
+/// @nodoc
+abstract class $AppStateCopyWith<$Res> {
+ factory $AppStateCopyWith(AppState value, $Res Function(AppState) then) =
+ _$AppStateCopyWithImpl<$Res>;
+ $Res call(
+ {bool isLoading,
+ Option> views,
+ Either successOrFailure});
+}
+
+/// @nodoc
+class _$AppStateCopyWithImpl<$Res> implements $AppStateCopyWith<$Res> {
+ _$AppStateCopyWithImpl(this._value, this._then);
+
+ final AppState _value;
+ // ignore: unused_field
+ final $Res Function(AppState) _then;
+
+ @override
+ $Res call({
+ Object? isLoading = freezed,
+ Object? views = freezed,
+ Object? successOrFailure = freezed,
+ }) {
+ return _then(_value.copyWith(
+ isLoading: isLoading == freezed
+ ? _value.isLoading
+ : isLoading // ignore: cast_nullable_to_non_nullable
+ as bool,
+ views: views == freezed
+ ? _value.views
+ : views // ignore: cast_nullable_to_non_nullable
+ as Option>,
+ successOrFailure: successOrFailure == freezed
+ ? _value.successOrFailure
+ : successOrFailure // ignore: cast_nullable_to_non_nullable
+ as Either,
+ ));
+ }
+}
+
+/// @nodoc
+abstract class _$AppStateCopyWith<$Res> implements $AppStateCopyWith<$Res> {
+ factory _$AppStateCopyWith(_AppState value, $Res Function(_AppState) then) =
+ __$AppStateCopyWithImpl<$Res>;
+ @override
+ $Res call(
+ {bool isLoading,
+ Option> views,
+ Either successOrFailure});
+}
+
+/// @nodoc
+class __$AppStateCopyWithImpl<$Res> extends _$AppStateCopyWithImpl<$Res>
+ implements _$AppStateCopyWith<$Res> {
+ __$AppStateCopyWithImpl(_AppState _value, $Res Function(_AppState) _then)
+ : super(_value, (v) => _then(v as _AppState));
+
+ @override
+ _AppState get _value => super._value as _AppState;
+
+ @override
+ $Res call({
+ Object? isLoading = freezed,
+ Object? views = freezed,
+ Object? successOrFailure = freezed,
+ }) {
+ return _then(_AppState(
+ isLoading: isLoading == freezed
+ ? _value.isLoading
+ : isLoading // ignore: cast_nullable_to_non_nullable
+ as bool,
+ views: views == freezed
+ ? _value.views
+ : views // ignore: cast_nullable_to_non_nullable
+ as Option>,
+ successOrFailure: successOrFailure == freezed
+ ? _value.successOrFailure
+ : successOrFailure // ignore: cast_nullable_to_non_nullable
+ as Either,
+ ));
+ }
+}
+
+/// @nodoc
+
+class _$_AppState implements _AppState {
+ const _$_AppState(
+ {required this.isLoading,
+ required this.views,
+ required this.successOrFailure});
+
+ @override
+ final bool isLoading;
+ @override
+ final Option> views;
+ @override
+ final Either successOrFailure;
+
+ @override
+ String toString() {
+ return 'AppState(isLoading: $isLoading, views: $views, successOrFailure: $successOrFailure)';
+ }
+
+ @override
+ bool operator ==(dynamic other) {
+ return identical(this, other) ||
+ (other is _AppState &&
+ (identical(other.isLoading, isLoading) ||
+ const DeepCollectionEquality()
+ .equals(other.isLoading, isLoading)) &&
+ (identical(other.views, views) ||
+ const DeepCollectionEquality().equals(other.views, views)) &&
+ (identical(other.successOrFailure, successOrFailure) ||
+ const DeepCollectionEquality()
+ .equals(other.successOrFailure, successOrFailure)));
+ }
+
+ @override
+ int get hashCode =>
+ runtimeType.hashCode ^
+ const DeepCollectionEquality().hash(isLoading) ^
+ const DeepCollectionEquality().hash(views) ^
+ const DeepCollectionEquality().hash(successOrFailure);
+
+ @JsonKey(ignore: true)
+ @override
+ _$AppStateCopyWith<_AppState> get copyWith =>
+ __$AppStateCopyWithImpl<_AppState>(this, _$identity);
+}
+
+abstract class _AppState implements AppState {
+ const factory _AppState(
+ {required bool isLoading,
+ required Option> views,
+ required Either successOrFailure}) = _$_AppState;
+
+ @override
+ bool get isLoading => throw _privateConstructorUsedError;
+ @override
+ Option> get views => throw _privateConstructorUsedError;
+ @override
+ Either get successOrFailure =>
+ throw _privateConstructorUsedError;
+ @override
+ @JsonKey(ignore: true)
+ _$AppStateCopyWith<_AppState> get copyWith =>
+ throw _privateConstructorUsedError;
+}
diff --git a/app_flowy/lib/workspace/application/app/app_watch_bloc.dart b/app_flowy/lib/workspace/application/app/app_watch_bloc.dart
new file mode 100644
index 0000000000..4cabff5a96
--- /dev/null
+++ b/app_flowy/lib/workspace/application/app/app_watch_bloc.dart
@@ -0,0 +1,56 @@
+import 'package:app_flowy/workspace/domain/i_app.dart';
+import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
+import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
+import 'package:freezed_annotation/freezed_annotation.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:dartz/dartz.dart';
+
+part 'app_watch_bloc.freezed.dart';
+
+class AppWatchBloc extends Bloc {
+ final IAppWatch watcher;
+ AppWatchBloc(this.watcher) : super(const AppWatchState.initial());
+
+ @override
+ Stream mapEventToState(
+ AppWatchEvent event,
+ ) async* {
+ yield* event.map(started: (_) async* {
+ watcher.startWatching(
+ addViewCallback: (viewsOrFail) => _handleViewsOrFail(viewsOrFail),
+ );
+ }, viewsReceived: (ViewsReceived value) async* {
+ yield value.viewsOrFail.fold(
+ (views) => AppWatchState.loadViews(views),
+ (error) => AppWatchState.loadFail(error),
+ );
+ });
+ }
+
+ void _handleViewsOrFail(Either, WorkspaceError> viewsOrFail) {
+ viewsOrFail.fold(
+ (views) => add(AppWatchEvent.viewsReceived(left(views))),
+ (error) => add(AppWatchEvent.viewsReceived(right(error))),
+ );
+ }
+}
+
+@freezed
+abstract class AppWatchEvent with _$AppWatchEvent {
+ const factory AppWatchEvent.started() = _Started;
+ const factory AppWatchEvent.viewsReceived(
+ Either, WorkspaceError> viewsOrFail) = ViewsReceived;
+}
+
+@freezed
+abstract class AppWatchState implements _$AppWatchState {
+ const factory AppWatchState.initial() = _Initial;
+
+ const factory AppWatchState.loadViews(
+ List views,
+ ) = _LoadViews;
+
+ const factory AppWatchState.loadFail(
+ WorkspaceError error,
+ ) = _LoadFail;
+}
diff --git a/app_flowy/lib/workspace/application/app/app_watch_bloc.freezed.dart b/app_flowy/lib/workspace/application/app/app_watch_bloc.freezed.dart
new file mode 100644
index 0000000000..e3dc21be5c
--- /dev/null
+++ b/app_flowy/lib/workspace/application/app/app_watch_bloc.freezed.dart
@@ -0,0 +1,683 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides
+
+part of 'app_watch_bloc.dart';
+
+// **************************************************************************
+// FreezedGenerator
+// **************************************************************************
+
+T _$identity(T value) => value;
+
+final _privateConstructorUsedError = UnsupportedError(
+ 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
+
+/// @nodoc
+class _$AppWatchEventTearOff {
+ const _$AppWatchEventTearOff();
+
+ _Started started() {
+ return const _Started();
+ }
+
+ ViewsReceived viewsReceived(Either, WorkspaceError> viewsOrFail) {
+ return ViewsReceived(
+ viewsOrFail,
+ );
+ }
+}
+
+/// @nodoc
+const $AppWatchEvent = _$AppWatchEventTearOff();
+
+/// @nodoc
+mixin _$AppWatchEvent {
+ @optionalTypeArgs
+ TResult when({
+ required TResult Function() started,
+ required TResult Function(Either, WorkspaceError> viewsOrFail)
+ viewsReceived,
+ }) =>
+ throw _privateConstructorUsedError;
+ @optionalTypeArgs
+ TResult maybeWhen({
+ TResult Function()? started,
+ TResult Function(Either, WorkspaceError> viewsOrFail)?
+ viewsReceived,
+ required TResult orElse(),
+ }) =>
+ throw _privateConstructorUsedError;
+ @optionalTypeArgs
+ TResult map({
+ required TResult Function(_Started value) started,
+ required TResult Function(ViewsReceived value) viewsReceived,
+ }) =>
+ throw _privateConstructorUsedError;
+ @optionalTypeArgs
+ TResult maybeMap({
+ TResult Function(_Started value)? started,
+ TResult Function(ViewsReceived value)? viewsReceived,
+ required TResult orElse(),
+ }) =>
+ throw _privateConstructorUsedError;
+}
+
+/// @nodoc
+abstract class $AppWatchEventCopyWith<$Res> {
+ factory $AppWatchEventCopyWith(
+ AppWatchEvent value, $Res Function(AppWatchEvent) then) =
+ _$AppWatchEventCopyWithImpl<$Res>;
+}
+
+/// @nodoc
+class _$AppWatchEventCopyWithImpl<$Res>
+ implements $AppWatchEventCopyWith<$Res> {
+ _$AppWatchEventCopyWithImpl(this._value, this._then);
+
+ final AppWatchEvent _value;
+ // ignore: unused_field
+ final $Res Function(AppWatchEvent) _then;
+}
+
+/// @nodoc
+abstract class _$StartedCopyWith<$Res> {
+ factory _$StartedCopyWith(_Started value, $Res Function(_Started) then) =
+ __$StartedCopyWithImpl<$Res>;
+}
+
+/// @nodoc
+class __$StartedCopyWithImpl<$Res> extends _$AppWatchEventCopyWithImpl<$Res>
+ implements _$StartedCopyWith<$Res> {
+ __$StartedCopyWithImpl(_Started _value, $Res Function(_Started) _then)
+ : super(_value, (v) => _then(v as _Started));
+
+ @override
+ _Started get _value => super._value as _Started;
+}
+
+/// @nodoc
+
+class _$_Started implements _Started {
+ const _$_Started();
+
+ @override
+ String toString() {
+ return 'AppWatchEvent.started()';
+ }
+
+ @override
+ bool operator ==(dynamic other) {
+ return identical(this, other) || (other is _Started);
+ }
+
+ @override
+ int get hashCode => runtimeType.hashCode;
+
+ @override
+ @optionalTypeArgs
+ TResult when({
+ required TResult Function() started,
+ required TResult Function(Either, WorkspaceError> viewsOrFail)
+ viewsReceived,
+ }) {
+ return started();
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeWhen({
+ TResult Function()? started,
+ TResult Function(Either, WorkspaceError> viewsOrFail)?
+ viewsReceived,
+ required TResult orElse(),
+ }) {
+ if (started != null) {
+ return started();
+ }
+ return orElse();
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult map({
+ required TResult Function(_Started value) started,
+ required TResult Function(ViewsReceived value) viewsReceived,
+ }) {
+ return started(this);
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeMap({
+ TResult Function(_Started value)? started,
+ TResult Function(ViewsReceived value)? viewsReceived,
+ required TResult orElse(),
+ }) {
+ if (started != null) {
+ return started(this);
+ }
+ return orElse();
+ }
+}
+
+abstract class _Started implements AppWatchEvent {
+ const factory _Started() = _$_Started;
+}
+
+/// @nodoc
+abstract class $ViewsReceivedCopyWith<$Res> {
+ factory $ViewsReceivedCopyWith(
+ ViewsReceived value, $Res Function(ViewsReceived) then) =
+ _$ViewsReceivedCopyWithImpl<$Res>;
+ $Res call({Either, WorkspaceError> viewsOrFail});
+}
+
+/// @nodoc
+class _$ViewsReceivedCopyWithImpl<$Res>
+ extends _$AppWatchEventCopyWithImpl<$Res>
+ implements $ViewsReceivedCopyWith<$Res> {
+ _$ViewsReceivedCopyWithImpl(
+ ViewsReceived _value, $Res Function(ViewsReceived) _then)
+ : super(_value, (v) => _then(v as ViewsReceived));
+
+ @override
+ ViewsReceived get _value => super._value as ViewsReceived;
+
+ @override
+ $Res call({
+ Object? viewsOrFail = freezed,
+ }) {
+ return _then(ViewsReceived(
+ viewsOrFail == freezed
+ ? _value.viewsOrFail
+ : viewsOrFail // ignore: cast_nullable_to_non_nullable
+ as Either, WorkspaceError>,
+ ));
+ }
+}
+
+/// @nodoc
+
+class _$ViewsReceived implements ViewsReceived {
+ const _$ViewsReceived(this.viewsOrFail);
+
+ @override
+ final Either, WorkspaceError> viewsOrFail;
+
+ @override
+ String toString() {
+ return 'AppWatchEvent.viewsReceived(viewsOrFail: $viewsOrFail)';
+ }
+
+ @override
+ bool operator ==(dynamic other) {
+ return identical(this, other) ||
+ (other is ViewsReceived &&
+ (identical(other.viewsOrFail, viewsOrFail) ||
+ const DeepCollectionEquality()
+ .equals(other.viewsOrFail, viewsOrFail)));
+ }
+
+ @override
+ int get hashCode =>
+ runtimeType.hashCode ^ const DeepCollectionEquality().hash(viewsOrFail);
+
+ @JsonKey(ignore: true)
+ @override
+ $ViewsReceivedCopyWith get copyWith =>
+ _$ViewsReceivedCopyWithImpl(this, _$identity);
+
+ @override
+ @optionalTypeArgs
+ TResult when({
+ required TResult Function() started,
+ required TResult Function(Either, WorkspaceError> viewsOrFail)
+ viewsReceived,
+ }) {
+ return viewsReceived(viewsOrFail);
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeWhen({
+ TResult Function()? started,
+ TResult Function(Either, WorkspaceError> viewsOrFail)?
+ viewsReceived,
+ required TResult orElse(),
+ }) {
+ if (viewsReceived != null) {
+ return viewsReceived(viewsOrFail);
+ }
+ return orElse();
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult map({
+ required TResult Function(_Started value) started,
+ required TResult Function(ViewsReceived value) viewsReceived,
+ }) {
+ return viewsReceived(this);
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeMap({
+ TResult Function(_Started value)? started,
+ TResult Function(ViewsReceived value)? viewsReceived,
+ required TResult orElse(),
+ }) {
+ if (viewsReceived != null) {
+ return viewsReceived(this);
+ }
+ return orElse();
+ }
+}
+
+abstract class ViewsReceived implements AppWatchEvent {
+ const factory ViewsReceived(Either, WorkspaceError> viewsOrFail) =
+ _$ViewsReceived;
+
+ Either, WorkspaceError> get viewsOrFail =>
+ throw _privateConstructorUsedError;
+ @JsonKey(ignore: true)
+ $ViewsReceivedCopyWith get copyWith =>
+ throw _privateConstructorUsedError;
+}
+
+/// @nodoc
+class _$AppWatchStateTearOff {
+ const _$AppWatchStateTearOff();
+
+ _Initial initial() {
+ return const _Initial();
+ }
+
+ _LoadViews loadViews(List views) {
+ return _LoadViews(
+ views,
+ );
+ }
+
+ _LoadFail loadFail(WorkspaceError error) {
+ return _LoadFail(
+ error,
+ );
+ }
+}
+
+/// @nodoc
+const $AppWatchState = _$AppWatchStateTearOff();
+
+/// @nodoc
+mixin _$AppWatchState {
+ @optionalTypeArgs
+ TResult when({
+ required TResult Function() initial,
+ required TResult Function(List views) loadViews,
+ required TResult Function(WorkspaceError error) loadFail,
+ }) =>
+ throw _privateConstructorUsedError;
+ @optionalTypeArgs
+ TResult maybeWhen({
+ TResult Function()? initial,
+ TResult Function(List views)? loadViews,
+ TResult Function(WorkspaceError error)? loadFail,
+ required TResult orElse(),
+ }) =>
+ throw _privateConstructorUsedError;
+ @optionalTypeArgs
+ TResult map({
+ required TResult Function(_Initial value) initial,
+ required TResult Function(_LoadViews value) loadViews,
+ required TResult Function(_LoadFail value) loadFail,
+ }) =>
+ throw _privateConstructorUsedError;
+ @optionalTypeArgs
+ TResult maybeMap({
+ TResult Function(_Initial value)? initial,
+ TResult Function(_LoadViews value)? loadViews,
+ TResult Function(_LoadFail value)? loadFail,
+ required TResult orElse(),
+ }) =>
+ throw _privateConstructorUsedError;
+}
+
+/// @nodoc
+abstract class $AppWatchStateCopyWith<$Res> {
+ factory $AppWatchStateCopyWith(
+ AppWatchState value, $Res Function(AppWatchState) then) =
+ _$AppWatchStateCopyWithImpl<$Res>;
+}
+
+/// @nodoc
+class _$AppWatchStateCopyWithImpl<$Res>
+ implements $AppWatchStateCopyWith<$Res> {
+ _$AppWatchStateCopyWithImpl(this._value, this._then);
+
+ final AppWatchState _value;
+ // ignore: unused_field
+ final $Res Function(AppWatchState) _then;
+}
+
+/// @nodoc
+abstract class _$InitialCopyWith<$Res> {
+ factory _$InitialCopyWith(_Initial value, $Res Function(_Initial) then) =
+ __$InitialCopyWithImpl<$Res>;
+}
+
+/// @nodoc
+class __$InitialCopyWithImpl<$Res> extends _$AppWatchStateCopyWithImpl<$Res>
+ implements _$InitialCopyWith<$Res> {
+ __$InitialCopyWithImpl(_Initial _value, $Res Function(_Initial) _then)
+ : super(_value, (v) => _then(v as _Initial));
+
+ @override
+ _Initial get _value => super._value as _Initial;
+}
+
+/// @nodoc
+
+class _$_Initial implements _Initial {
+ const _$_Initial();
+
+ @override
+ String toString() {
+ return 'AppWatchState.initial()';
+ }
+
+ @override
+ bool operator ==(dynamic other) {
+ return identical(this, other) || (other is _Initial);
+ }
+
+ @override
+ int get hashCode => runtimeType.hashCode;
+
+ @override
+ @optionalTypeArgs
+ TResult when({
+ required TResult Function() initial,
+ required TResult Function(List views) loadViews,
+ required TResult Function(WorkspaceError error) loadFail,
+ }) {
+ return initial();
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeWhen({
+ TResult Function()? initial,
+ TResult Function(List views)? loadViews,
+ TResult Function(WorkspaceError error)? loadFail,
+ required TResult orElse(),
+ }) {
+ if (initial != null) {
+ return initial();
+ }
+ return orElse();
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult map({
+ required TResult Function(_Initial value) initial,
+ required TResult Function(_LoadViews value) loadViews,
+ required TResult Function(_LoadFail value) loadFail,
+ }) {
+ return initial(this);
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeMap({
+ TResult Function(_Initial value)? initial,
+ TResult Function(_LoadViews value)? loadViews,
+ TResult Function(_LoadFail value)? loadFail,
+ required TResult orElse(),
+ }) {
+ if (initial != null) {
+ return initial(this);
+ }
+ return orElse();
+ }
+}
+
+abstract class _Initial implements AppWatchState {
+ const factory _Initial() = _$_Initial;
+}
+
+/// @nodoc
+abstract class _$LoadViewsCopyWith<$Res> {
+ factory _$LoadViewsCopyWith(
+ _LoadViews value, $Res Function(_LoadViews) then) =
+ __$LoadViewsCopyWithImpl<$Res>;
+ $Res call({List views});
+}
+
+/// @nodoc
+class __$LoadViewsCopyWithImpl<$Res> extends _$AppWatchStateCopyWithImpl<$Res>
+ implements _$LoadViewsCopyWith<$Res> {
+ __$LoadViewsCopyWithImpl(_LoadViews _value, $Res Function(_LoadViews) _then)
+ : super(_value, (v) => _then(v as _LoadViews));
+
+ @override
+ _LoadViews get _value => super._value as _LoadViews;
+
+ @override
+ $Res call({
+ Object? views = freezed,
+ }) {
+ return _then(_LoadViews(
+ views == freezed
+ ? _value.views
+ : views // ignore: cast_nullable_to_non_nullable
+ as List,
+ ));
+ }
+}
+
+/// @nodoc
+
+class _$_LoadViews implements _LoadViews {
+ const _$_LoadViews(this.views);
+
+ @override
+ final List views;
+
+ @override
+ String toString() {
+ return 'AppWatchState.loadViews(views: $views)';
+ }
+
+ @override
+ bool operator ==(dynamic other) {
+ return identical(this, other) ||
+ (other is _LoadViews &&
+ (identical(other.views, views) ||
+ const DeepCollectionEquality().equals(other.views, views)));
+ }
+
+ @override
+ int get hashCode =>
+ runtimeType.hashCode ^ const DeepCollectionEquality().hash(views);
+
+ @JsonKey(ignore: true)
+ @override
+ _$LoadViewsCopyWith<_LoadViews> get copyWith =>
+ __$LoadViewsCopyWithImpl<_LoadViews>(this, _$identity);
+
+ @override
+ @optionalTypeArgs
+ TResult when({
+ required TResult Function() initial,
+ required TResult Function(List views) loadViews,
+ required TResult Function(WorkspaceError error) loadFail,
+ }) {
+ return loadViews(views);
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeWhen({
+ TResult Function()? initial,
+ TResult Function(List views)? loadViews,
+ TResult Function(WorkspaceError error)? loadFail,
+ required TResult orElse(),
+ }) {
+ if (loadViews != null) {
+ return loadViews(views);
+ }
+ return orElse();
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult map({
+ required TResult Function(_Initial value) initial,
+ required TResult Function(_LoadViews value) loadViews,
+ required TResult Function(_LoadFail value) loadFail,
+ }) {
+ return loadViews(this);
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeMap({
+ TResult Function(_Initial value)? initial,
+ TResult Function(_LoadViews value)? loadViews,
+ TResult Function(_LoadFail value)? loadFail,
+ required TResult orElse(),
+ }) {
+ if (loadViews != null) {
+ return loadViews(this);
+ }
+ return orElse();
+ }
+}
+
+abstract class _LoadViews implements AppWatchState {
+ const factory _LoadViews(List views) = _$_LoadViews;
+
+ List get views => throw _privateConstructorUsedError;
+ @JsonKey(ignore: true)
+ _$LoadViewsCopyWith<_LoadViews> get copyWith =>
+ throw _privateConstructorUsedError;
+}
+
+/// @nodoc
+abstract class _$LoadFailCopyWith<$Res> {
+ factory _$LoadFailCopyWith(_LoadFail value, $Res Function(_LoadFail) then) =
+ __$LoadFailCopyWithImpl<$Res>;
+ $Res call({WorkspaceError error});
+}
+
+/// @nodoc
+class __$LoadFailCopyWithImpl<$Res> extends _$AppWatchStateCopyWithImpl<$Res>
+ implements _$LoadFailCopyWith<$Res> {
+ __$LoadFailCopyWithImpl(_LoadFail _value, $Res Function(_LoadFail) _then)
+ : super(_value, (v) => _then(v as _LoadFail));
+
+ @override
+ _LoadFail get _value => super._value as _LoadFail;
+
+ @override
+ $Res call({
+ Object? error = freezed,
+ }) {
+ return _then(_LoadFail(
+ error == freezed
+ ? _value.error
+ : error // ignore: cast_nullable_to_non_nullable
+ as WorkspaceError,
+ ));
+ }
+}
+
+/// @nodoc
+
+class _$_LoadFail implements _LoadFail {
+ const _$_LoadFail(this.error);
+
+ @override
+ final WorkspaceError error;
+
+ @override
+ String toString() {
+ return 'AppWatchState.loadFail(error: $error)';
+ }
+
+ @override
+ bool operator ==(dynamic other) {
+ return identical(this, other) ||
+ (other is _LoadFail &&
+ (identical(other.error, error) ||
+ const DeepCollectionEquality().equals(other.error, error)));
+ }
+
+ @override
+ int get hashCode =>
+ runtimeType.hashCode ^ const DeepCollectionEquality().hash(error);
+
+ @JsonKey(ignore: true)
+ @override
+ _$LoadFailCopyWith<_LoadFail> get copyWith =>
+ __$LoadFailCopyWithImpl<_LoadFail>(this, _$identity);
+
+ @override
+ @optionalTypeArgs
+ TResult when({
+ required TResult Function() initial,
+ required TResult Function(List views) loadViews,
+ required TResult Function(WorkspaceError error) loadFail,
+ }) {
+ return loadFail(error);
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeWhen({
+ TResult Function()? initial,
+ TResult Function(List views)? loadViews,
+ TResult Function(WorkspaceError error)? loadFail,
+ required TResult orElse(),
+ }) {
+ if (loadFail != null) {
+ return loadFail(error);
+ }
+ return orElse();
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult map({
+ required TResult Function(_Initial value) initial,
+ required TResult Function(_LoadViews value) loadViews,
+ required TResult Function(_LoadFail value) loadFail,
+ }) {
+ return loadFail(this);
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeMap({
+ TResult Function(_Initial value)? initial,
+ TResult Function(_LoadViews value)? loadViews,
+ TResult Function(_LoadFail value)? loadFail,
+ required TResult orElse(),
+ }) {
+ if (loadFail != null) {
+ return loadFail(this);
+ }
+ return orElse();
+ }
+}
+
+abstract class _LoadFail implements AppWatchState {
+ const factory _LoadFail(WorkspaceError error) = _$_LoadFail;
+
+ WorkspaceError get error => throw _privateConstructorUsedError;
+ @JsonKey(ignore: true)
+ _$LoadFailCopyWith<_LoadFail> get copyWith =>
+ throw _privateConstructorUsedError;
+}
diff --git a/app_flowy/lib/workspace/application/doc/doc_bloc.dart b/app_flowy/lib/workspace/application/doc/doc_bloc.dart
new file mode 100644
index 0000000000..27f3b0f5a0
--- /dev/null
+++ b/app_flowy/lib/workspace/application/doc/doc_bloc.dart
@@ -0,0 +1,39 @@
+import 'package:app_flowy/workspace/domain/i_doc.dart';
+import 'package:freezed_annotation/freezed_annotation.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:dartz/dartz.dart';
+
+part 'doc_bloc.freezed.dart';
+
+class DocBloc extends Bloc {
+ final IDoc iDocImpl;
+
+ DocBloc(this.iDocImpl) : super(DocState.initial());
+
+ @override
+ Stream mapEventToState(DocEvent event) async* {
+ yield* event.map(
+ initial: (e) async* {},
+ save: (Save value) async* {},
+ close: (Close value) async* {},
+ );
+ }
+}
+
+@freezed
+abstract class DocEvent with _$DocEvent {
+ const factory DocEvent.initial() = Initial;
+ const factory DocEvent.save(String jsonStr) = Save;
+ const factory DocEvent.close() = Close;
+}
+
+@freezed
+abstract class DocState implements _$DocState {
+ const factory DocState({
+ required bool isSaving,
+ }) = _DocState;
+
+ factory DocState.initial() => const DocState(
+ isSaving: false,
+ );
+}
diff --git a/app_flowy/lib/workspace/application/doc/doc_bloc.freezed.dart b/app_flowy/lib/workspace/application/doc/doc_bloc.freezed.dart
new file mode 100644
index 0000000000..1e74f06c09
--- /dev/null
+++ b/app_flowy/lib/workspace/application/doc/doc_bloc.freezed.dart
@@ -0,0 +1,498 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides
+
+part of 'doc_bloc.dart';
+
+// **************************************************************************
+// FreezedGenerator
+// **************************************************************************
+
+T _$identity(T value) => value;
+
+final _privateConstructorUsedError = UnsupportedError(
+ 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
+
+/// @nodoc
+class _$DocEventTearOff {
+ const _$DocEventTearOff();
+
+ Initial initial() {
+ return const Initial();
+ }
+
+ Save save(String jsonStr) {
+ return Save(
+ jsonStr,
+ );
+ }
+
+ Close close() {
+ return const Close();
+ }
+}
+
+/// @nodoc
+const $DocEvent = _$DocEventTearOff();
+
+/// @nodoc
+mixin _$DocEvent {
+ @optionalTypeArgs
+ TResult when({
+ required TResult Function() initial,
+ required TResult Function(String jsonStr) save,
+ required TResult Function() close,
+ }) =>
+ throw _privateConstructorUsedError;
+ @optionalTypeArgs
+ TResult maybeWhen({
+ TResult Function()? initial,
+ TResult Function(String jsonStr)? save,
+ TResult Function()? close,
+ required TResult orElse(),
+ }) =>
+ throw _privateConstructorUsedError;
+ @optionalTypeArgs
+ TResult map({
+ required TResult Function(Initial value) initial,
+ required TResult Function(Save value) save,
+ required TResult Function(Close value) close,
+ }) =>
+ throw _privateConstructorUsedError;
+ @optionalTypeArgs
+ TResult maybeMap({
+ TResult Function(Initial value)? initial,
+ TResult Function(Save value)? save,
+ TResult Function(Close value)? close,
+ required TResult orElse(),
+ }) =>
+ throw _privateConstructorUsedError;
+}
+
+/// @nodoc
+abstract class $DocEventCopyWith<$Res> {
+ factory $DocEventCopyWith(DocEvent value, $Res Function(DocEvent) then) =
+ _$DocEventCopyWithImpl<$Res>;
+}
+
+/// @nodoc
+class _$DocEventCopyWithImpl<$Res> implements $DocEventCopyWith<$Res> {
+ _$DocEventCopyWithImpl(this._value, this._then);
+
+ final DocEvent _value;
+ // ignore: unused_field
+ final $Res Function(DocEvent) _then;
+}
+
+/// @nodoc
+abstract class $InitialCopyWith<$Res> {
+ factory $InitialCopyWith(Initial value, $Res Function(Initial) then) =
+ _$InitialCopyWithImpl<$Res>;
+}
+
+/// @nodoc
+class _$InitialCopyWithImpl<$Res> extends _$DocEventCopyWithImpl<$Res>
+ implements $InitialCopyWith<$Res> {
+ _$InitialCopyWithImpl(Initial _value, $Res Function(Initial) _then)
+ : super(_value, (v) => _then(v as Initial));
+
+ @override
+ Initial get _value => super._value as Initial;
+}
+
+/// @nodoc
+
+class _$Initial implements Initial {
+ const _$Initial();
+
+ @override
+ String toString() {
+ return 'DocEvent.initial()';
+ }
+
+ @override
+ bool operator ==(dynamic other) {
+ return identical(this, other) || (other is Initial);
+ }
+
+ @override
+ int get hashCode => runtimeType.hashCode;
+
+ @override
+ @optionalTypeArgs
+ TResult when({
+ required TResult Function() initial,
+ required TResult Function(String jsonStr) save,
+ required TResult Function() close,
+ }) {
+ return initial();
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeWhen({
+ TResult Function()? initial,
+ TResult Function(String jsonStr)? save,
+ TResult Function()? close,
+ required TResult orElse(),
+ }) {
+ if (initial != null) {
+ return initial();
+ }
+ return orElse();
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult map({
+ required TResult Function(Initial value) initial,
+ required TResult Function(Save value) save,
+ required TResult Function(Close value) close,
+ }) {
+ return initial(this);
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeMap({
+ TResult Function(Initial value)? initial,
+ TResult Function(Save value)? save,
+ TResult Function(Close value)? close,
+ required TResult orElse(),
+ }) {
+ if (initial != null) {
+ return initial(this);
+ }
+ return orElse();
+ }
+}
+
+abstract class Initial implements DocEvent {
+ const factory Initial() = _$Initial;
+}
+
+/// @nodoc
+abstract class $SaveCopyWith<$Res> {
+ factory $SaveCopyWith(Save value, $Res Function(Save) then) =
+ _$SaveCopyWithImpl<$Res>;
+ $Res call({String jsonStr});
+}
+
+/// @nodoc
+class _$SaveCopyWithImpl<$Res> extends _$DocEventCopyWithImpl<$Res>
+ implements $SaveCopyWith<$Res> {
+ _$SaveCopyWithImpl(Save _value, $Res Function(Save) _then)
+ : super(_value, (v) => _then(v as Save));
+
+ @override
+ Save get _value => super._value as Save;
+
+ @override
+ $Res call({
+ Object? jsonStr = freezed,
+ }) {
+ return _then(Save(
+ jsonStr == freezed
+ ? _value.jsonStr
+ : jsonStr // ignore: cast_nullable_to_non_nullable
+ as String,
+ ));
+ }
+}
+
+/// @nodoc
+
+class _$Save implements Save {
+ const _$Save(this.jsonStr);
+
+ @override
+ final String jsonStr;
+
+ @override
+ String toString() {
+ return 'DocEvent.save(jsonStr: $jsonStr)';
+ }
+
+ @override
+ bool operator ==(dynamic other) {
+ return identical(this, other) ||
+ (other is Save &&
+ (identical(other.jsonStr, jsonStr) ||
+ const DeepCollectionEquality().equals(other.jsonStr, jsonStr)));
+ }
+
+ @override
+ int get hashCode =>
+ runtimeType.hashCode ^ const DeepCollectionEquality().hash(jsonStr);
+
+ @JsonKey(ignore: true)
+ @override
+ $SaveCopyWith get copyWith =>
+ _$SaveCopyWithImpl(this, _$identity);
+
+ @override
+ @optionalTypeArgs
+ TResult when({
+ required TResult Function() initial,
+ required TResult Function(String jsonStr) save,
+ required TResult Function() close,
+ }) {
+ return save(jsonStr);
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeWhen({
+ TResult Function()? initial,
+ TResult Function(String jsonStr)? save,
+ TResult Function()? close,
+ required TResult orElse(),
+ }) {
+ if (save != null) {
+ return save(jsonStr);
+ }
+ return orElse();
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult map({
+ required TResult Function(Initial value) initial,
+ required TResult Function(Save value) save,
+ required TResult Function(Close value) close,
+ }) {
+ return save(this);
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeMap({
+ TResult Function(Initial value)? initial,
+ TResult Function(Save value)? save,
+ TResult Function(Close value)? close,
+ required TResult orElse(),
+ }) {
+ if (save != null) {
+ return save(this);
+ }
+ return orElse();
+ }
+}
+
+abstract class Save implements DocEvent {
+ const factory Save(String jsonStr) = _$Save;
+
+ String get jsonStr => throw _privateConstructorUsedError;
+ @JsonKey(ignore: true)
+ $SaveCopyWith get copyWith => throw _privateConstructorUsedError;
+}
+
+/// @nodoc
+abstract class $CloseCopyWith<$Res> {
+ factory $CloseCopyWith(Close value, $Res Function(Close) then) =
+ _$CloseCopyWithImpl<$Res>;
+}
+
+/// @nodoc
+class _$CloseCopyWithImpl<$Res> extends _$DocEventCopyWithImpl<$Res>
+ implements $CloseCopyWith<$Res> {
+ _$CloseCopyWithImpl(Close _value, $Res Function(Close) _then)
+ : super(_value, (v) => _then(v as Close));
+
+ @override
+ Close get _value => super._value as Close;
+}
+
+/// @nodoc
+
+class _$Close implements Close {
+ const _$Close();
+
+ @override
+ String toString() {
+ return 'DocEvent.close()';
+ }
+
+ @override
+ bool operator ==(dynamic other) {
+ return identical(this, other) || (other is Close);
+ }
+
+ @override
+ int get hashCode => runtimeType.hashCode;
+
+ @override
+ @optionalTypeArgs
+ TResult when({
+ required TResult Function() initial,
+ required TResult Function(String jsonStr) save,
+ required TResult Function() close,
+ }) {
+ return close();
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeWhen({
+ TResult Function()? initial,
+ TResult Function(String jsonStr)? save,
+ TResult Function()? close,
+ required TResult orElse(),
+ }) {
+ if (close != null) {
+ return close();
+ }
+ return orElse();
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult map({
+ required TResult Function(Initial value) initial,
+ required TResult Function(Save value) save,
+ required TResult Function(Close value) close,
+ }) {
+ return close(this);
+ }
+
+ @override
+ @optionalTypeArgs
+ TResult maybeMap({
+ TResult Function(Initial value)? initial,
+ TResult Function(Save value)? save,
+ TResult Function(Close value)? close,
+ required TResult orElse(),
+ }) {
+ if (close != null) {
+ return close(this);
+ }
+ return orElse();
+ }
+}
+
+abstract class Close implements DocEvent {
+ const factory Close() = _$Close;
+}
+
+/// @nodoc
+class _$DocStateTearOff {
+ const _$DocStateTearOff();
+
+ _DocState call({required bool isSaving}) {
+ return _DocState(
+ isSaving: isSaving,
+ );
+ }
+}
+
+/// @nodoc
+const $DocState = _$DocStateTearOff();
+
+/// @nodoc
+mixin _$DocState {
+ bool get isSaving => throw _privateConstructorUsedError;
+
+ @JsonKey(ignore: true)
+ $DocStateCopyWith get copyWith =>
+ throw _privateConstructorUsedError;
+}
+
+/// @nodoc
+abstract class $DocStateCopyWith<$Res> {
+ factory $DocStateCopyWith(DocState value, $Res Function(DocState) then) =
+ _$DocStateCopyWithImpl<$Res>;
+ $Res call({bool isSaving});
+}
+
+/// @nodoc
+class _$DocStateCopyWithImpl<$Res> implements $DocStateCopyWith<$Res> {
+ _$DocStateCopyWithImpl(this._value, this._then);
+
+ final DocState _value;
+ // ignore: unused_field
+ final $Res Function(DocState) _then;
+
+ @override
+ $Res call({
+ Object? isSaving = freezed,
+ }) {
+ return _then(_value.copyWith(
+ isSaving: isSaving == freezed
+ ? _value.isSaving
+ : isSaving // ignore: cast_nullable_to_non_nullable
+ as bool,
+ ));
+ }
+}
+
+/// @nodoc
+abstract class _$DocStateCopyWith<$Res> implements $DocStateCopyWith<$Res> {
+ factory _$DocStateCopyWith(_DocState value, $Res Function(_DocState) then) =
+ __$DocStateCopyWithImpl<$Res>;
+ @override
+ $Res call({bool isSaving});
+}
+
+/// @nodoc
+class __$DocStateCopyWithImpl<$Res> extends _$DocStateCopyWithImpl<$Res>
+ implements _$DocStateCopyWith<$Res> {
+ __$DocStateCopyWithImpl(_DocState _value, $Res Function(_DocState) _then)
+ : super(_value, (v) => _then(v as _DocState));
+
+ @override
+ _DocState get _value => super._value as _DocState;
+
+ @override
+ $Res call({
+ Object? isSaving = freezed,
+ }) {
+ return _then(_DocState(
+ isSaving: isSaving == freezed
+ ? _value.isSaving
+ : isSaving // ignore: cast_nullable_to_non_nullable
+ as bool,
+ ));
+ }
+}
+
+/// @nodoc
+
+class _$_DocState implements _DocState {
+ const _$_DocState({required this.isSaving});
+
+ @override
+ final bool isSaving;
+
+ @override
+ String toString() {
+ return 'DocState(isSaving: $isSaving)';
+ }
+
+ @override
+ bool operator ==(dynamic other) {
+ return identical(this, other) ||
+ (other is _DocState &&
+ (identical(other.isSaving, isSaving) ||
+ const DeepCollectionEquality()
+ .equals(other.isSaving, isSaving)));
+ }
+
+ @override
+ int get hashCode =>
+ runtimeType.hashCode ^ const DeepCollectionEquality().hash(isSaving);
+
+ @JsonKey(ignore: true)
+ @override
+ _$DocStateCopyWith<_DocState> get copyWith =>
+ __$DocStateCopyWithImpl<_DocState>(this, _$identity);
+}
+
+abstract class _DocState implements DocState {
+ const factory _DocState({required bool isSaving}) = _$_DocState;
+
+ @override
+ bool get isSaving => throw _privateConstructorUsedError;
+ @override
+ @JsonKey(ignore: true)
+ _$DocStateCopyWith<_DocState> get copyWith =>
+ throw _privateConstructorUsedError;
+}
diff --git a/app_flowy/lib/home/application/edit_pannel/edit_pannel_bloc.dart b/app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart
similarity index 54%
rename from app_flowy/lib/home/application/edit_pannel/edit_pannel_bloc.dart
rename to app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart
index addb06a3ad..ecaf26bc63 100644
--- a/app_flowy/lib/home/application/edit_pannel/edit_pannel_bloc.dart
+++ b/app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart
@@ -1,12 +1,10 @@
-import 'package:app_flowy/home/domain/edit_context.dart';
+import 'package:app_flowy/workspace/domain/edit_context.dart';
import 'package:dartz/dartz.dart';
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
// ignore: import_of_legacy_library_into_null_safe
import 'package:flutter_bloc/flutter_bloc.dart';
-part 'edit_pannel_event.dart';
-part 'edit_pannel_state.dart';
part 'edit_pannel_bloc.freezed.dart';
class EditPannelBloc extends Bloc {
@@ -26,3 +24,24 @@ class EditPannelBloc extends Bloc {
);
}
}
+
+@freezed
+abstract class EditPannelEvent with _$EditPannelEvent {
+ const factory EditPannelEvent.startEdit(EditPannelContext context) =
+ _StartEdit;
+
+ const factory EditPannelEvent.endEdit(EditPannelContext context) = _EndEdit;
+}
+
+@freezed
+abstract class EditPannelState implements _$EditPannelState {
+ const factory EditPannelState({
+ required bool isEditing,
+ required Option editContext,
+ }) = _EditPannelState;
+
+ factory EditPannelState.initial() => EditPannelState(
+ isEditing: false,
+ editContext: none(),
+ );
+}
diff --git a/app_flowy/lib/home/application/edit_pannel/edit_pannel_bloc.freezed.dart b/app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.freezed.dart
similarity index 100%
rename from app_flowy/lib/home/application/edit_pannel/edit_pannel_bloc.freezed.dart
rename to app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.freezed.dart
diff --git a/app_flowy/lib/workspace/application/home/home_bloc.dart b/app_flowy/lib/workspace/application/home/home_bloc.dart
new file mode 100644
index 0000000000..df985d9261
--- /dev/null
+++ b/app_flowy/lib/workspace/application/home/home_bloc.dart
@@ -0,0 +1,58 @@
+import 'package:app_flowy/workspace/domain/edit_context.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:freezed_annotation/freezed_annotation.dart';
+import 'package:dartz/dartz.dart';
+part 'home_bloc.freezed.dart';
+
+class HomeBloc extends Bloc {
+ HomeBloc() : super(HomeState.initial());
+
+ @override
+ Stream mapEventToState(
+ HomeEvent event,
+ ) async* {
+ yield* event.map(
+ showLoading: (e) async* {
+ yield state.copyWith(isLoading: e.isLoading);
+ },
+ setEditPannel: (e) async* {
+ yield state.copyWith(editContext: some(e.editContext));
+ },
+ dismissEditPannel: (value) async* {
+ yield state.copyWith(editContext: none());
+ },
+ forceCollapse: (e) async* {
+ yield state.copyWith(forceCollapse: e.forceCollapse);
+ },
+ );
+ }
+
+ @override
+ Future close() {
+ return super.close();
+ }
+}
+
+@freezed
+abstract class HomeEvent with _$HomeEvent {
+ const factory HomeEvent.showLoading(bool isLoading) = _ShowLoading;
+ const factory HomeEvent.forceCollapse(bool forceCollapse) = _ForceCollapse;
+ const factory HomeEvent.setEditPannel(EditPannelContext editContext) =
+ _ShowEditPannel;
+ const factory HomeEvent.dismissEditPannel() = _DismissEditPannel;
+}
+
+@freezed
+abstract class HomeState implements _$HomeState {
+ const factory HomeState({
+ required bool isLoading,
+ required bool forceCollapse,
+ required Option editContext,
+ }) = _HomeState;
+
+ factory HomeState.initial() => HomeState(
+ isLoading: false,
+ forceCollapse: false,
+ editContext: none(),
+ );
+}
diff --git a/app_flowy/lib/home/application/home_bloc.freezed.dart b/app_flowy/lib/workspace/application/home/home_bloc.freezed.dart
similarity index 66%
rename from app_flowy/lib/home/application/home_bloc.freezed.dart
rename to app_flowy/lib/workspace/application/home/home_bloc.freezed.dart
index 16ed6f5120..10787b8ac6 100644
--- a/app_flowy/lib/home/application/home_bloc.freezed.dart
+++ b/app_flowy/lib/workspace/application/home/home_bloc.freezed.dart
@@ -22,15 +22,9 @@ class _$HomeEventTearOff {
);
}
- _ShowMenu showMenu(bool isShow) {
- return _ShowMenu(
- isShow,
- );
- }
-
- SetCurrentPage setPage(PageContext context) {
- return SetCurrentPage(
- context,
+ _ForceCollapse forceCollapse(bool forceCollapse) {
+ return _ForceCollapse(
+ forceCollapse,
);
}
@@ -53,8 +47,7 @@ mixin _$HomeEvent {
@optionalTypeArgs
TResult when({
required TResult Function(bool isLoading) showLoading,
- required TResult Function(bool isShow) showMenu,
- required TResult Function(PageContext context) setPage,
+ required TResult Function(bool forceCollapse) forceCollapse,
required TResult Function(EditPannelContext editContext) setEditPannel,
required TResult Function() dismissEditPannel,
}) =>
@@ -62,8 +55,7 @@ mixin _$HomeEvent {
@optionalTypeArgs
TResult maybeWhen({
TResult Function(bool isLoading)? showLoading,
- TResult Function(bool isShow)? showMenu,
- TResult Function(PageContext context)? setPage,
+ TResult Function(bool forceCollapse)? forceCollapse,
TResult Function(EditPannelContext editContext)? setEditPannel,
TResult Function()? dismissEditPannel,
required TResult orElse(),
@@ -72,8 +64,7 @@ mixin _$HomeEvent {
@optionalTypeArgs
TResult map({
required TResult Function(_ShowLoading value) showLoading,
- required TResult Function(_ShowMenu value) showMenu,
- required TResult Function(SetCurrentPage value) setPage,
+ required TResult Function(_ForceCollapse value) forceCollapse,
required TResult Function(_ShowEditPannel value) setEditPannel,
required TResult Function(_DismissEditPannel value) dismissEditPannel,
}) =>
@@ -81,8 +72,7 @@ mixin _$HomeEvent {
@optionalTypeArgs
TResult maybeMap({
TResult Function(_ShowLoading value)? showLoading,
- TResult Function(_ShowMenu value)? showMenu,
- TResult Function(SetCurrentPage value)? setPage,
+ TResult Function(_ForceCollapse value)? forceCollapse,
TResult Function(_ShowEditPannel value)? setEditPannel,
TResult Function(_DismissEditPannel value)? dismissEditPannel,
required TResult orElse(),
@@ -171,8 +161,7 @@ class _$_ShowLoading implements _ShowLoading {
@optionalTypeArgs
TResult when({
required TResult Function(bool isLoading) showLoading,
- required TResult Function(bool isShow) showMenu,
- required TResult Function(PageContext context) setPage,
+ required TResult Function(bool forceCollapse) forceCollapse,
required TResult Function(EditPannelContext editContext) setEditPannel,
required TResult Function() dismissEditPannel,
}) {
@@ -183,8 +172,7 @@ class _$_ShowLoading implements _ShowLoading {
@optionalTypeArgs
TResult maybeWhen({
TResult Function(bool isLoading)? showLoading,
- TResult Function(bool isShow)? showMenu,
- TResult Function(PageContext context)? setPage,
+ TResult Function(bool forceCollapse)? forceCollapse,
TResult Function(EditPannelContext editContext)? setEditPannel,
TResult Function()? dismissEditPannel,
required TResult orElse(),
@@ -199,8 +187,7 @@ class _$_ShowLoading implements _ShowLoading {
@optionalTypeArgs
TResult map({
required TResult Function(_ShowLoading value) showLoading,
- required TResult Function(_ShowMenu value) showMenu,
- required TResult Function(SetCurrentPage value) setPage,
+ required TResult Function(_ForceCollapse value) forceCollapse,
required TResult Function(_ShowEditPannel value) setEditPannel,
required TResult Function(_DismissEditPannel value) dismissEditPannel,
}) {
@@ -211,8 +198,7 @@ class _$_ShowLoading implements _ShowLoading {
@optionalTypeArgs
TResult maybeMap({
TResult Function(_ShowLoading value)? showLoading,
- TResult Function(_ShowMenu value)? showMenu,
- TResult Function(SetCurrentPage value)? setPage,
+ TResult Function(_ForceCollapse value)? forceCollapse,
TResult Function(_ShowEditPannel value)? setEditPannel,
TResult Function(_DismissEditPannel value)? dismissEditPannel,
required TResult orElse(),
@@ -234,29 +220,31 @@ abstract class _ShowLoading implements HomeEvent {
}
/// @nodoc
-abstract class _$ShowMenuCopyWith<$Res> {
- factory _$ShowMenuCopyWith(_ShowMenu value, $Res Function(_ShowMenu) then) =
- __$ShowMenuCopyWithImpl<$Res>;
- $Res call({bool isShow});
+abstract class _$ForceCollapseCopyWith<$Res> {
+ factory _$ForceCollapseCopyWith(
+ _ForceCollapse value, $Res Function(_ForceCollapse) then) =
+ __$ForceCollapseCopyWithImpl<$Res>;
+ $Res call({bool forceCollapse});
}
/// @nodoc
-class __$ShowMenuCopyWithImpl<$Res> extends _$HomeEventCopyWithImpl<$Res>
- implements _$ShowMenuCopyWith<$Res> {
- __$ShowMenuCopyWithImpl(_ShowMenu _value, $Res Function(_ShowMenu) _then)
- : super(_value, (v) => _then(v as _ShowMenu));
+class __$ForceCollapseCopyWithImpl<$Res> extends _$HomeEventCopyWithImpl<$Res>
+ implements _$ForceCollapseCopyWith<$Res> {
+ __$ForceCollapseCopyWithImpl(
+ _ForceCollapse _value, $Res Function(_ForceCollapse) _then)
+ : super(_value, (v) => _then(v as _ForceCollapse));
@override
- _ShowMenu get _value => super._value as _ShowMenu;
+ _ForceCollapse get _value => super._value as _ForceCollapse;
@override
$Res call({
- Object? isShow = freezed,
+ Object? forceCollapse = freezed,
}) {
- return _then(_ShowMenu(
- isShow == freezed
- ? _value.isShow
- : isShow // ignore: cast_nullable_to_non_nullable
+ return _then(_ForceCollapse(
+ forceCollapse == freezed
+ ? _value.forceCollapse
+ : forceCollapse // ignore: cast_nullable_to_non_nullable
as bool,
));
}
@@ -264,58 +252,57 @@ class __$ShowMenuCopyWithImpl<$Res> extends _$HomeEventCopyWithImpl<$Res>
/// @nodoc
-class _$_ShowMenu implements _ShowMenu {
- const _$_ShowMenu(this.isShow);
+class _$_ForceCollapse implements _ForceCollapse {
+ const _$_ForceCollapse(this.forceCollapse);
@override
- final bool isShow;
+ final bool forceCollapse;
@override
String toString() {
- return 'HomeEvent.showMenu(isShow: $isShow)';
+ return 'HomeEvent.forceCollapse(forceCollapse: $forceCollapse)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
- (other is _ShowMenu &&
- (identical(other.isShow, isShow) ||
- const DeepCollectionEquality().equals(other.isShow, isShow)));
+ (other is _ForceCollapse &&
+ (identical(other.forceCollapse, forceCollapse) ||
+ const DeepCollectionEquality()
+ .equals(other.forceCollapse, forceCollapse)));
}
@override
int get hashCode =>
- runtimeType.hashCode ^ const DeepCollectionEquality().hash(isShow);
+ runtimeType.hashCode ^ const DeepCollectionEquality().hash(forceCollapse);
@JsonKey(ignore: true)
@override
- _$ShowMenuCopyWith<_ShowMenu> get copyWith =>
- __$ShowMenuCopyWithImpl<_ShowMenu>(this, _$identity);
+ _$ForceCollapseCopyWith<_ForceCollapse> get copyWith =>
+ __$ForceCollapseCopyWithImpl<_ForceCollapse>(this, _$identity);
@override
@optionalTypeArgs
TResult when({
required TResult Function(bool isLoading) showLoading,
- required TResult Function(bool isShow) showMenu,
- required TResult Function(PageContext context) setPage,
+ required TResult Function(bool forceCollapse) forceCollapse,
required TResult Function(EditPannelContext editContext) setEditPannel,
required TResult Function() dismissEditPannel,
}) {
- return showMenu(isShow);
+ return forceCollapse(this.forceCollapse);
}
@override
@optionalTypeArgs
TResult maybeWhen({
TResult Function(bool isLoading)? showLoading,
- TResult Function(bool isShow)? showMenu,
- TResult Function(PageContext context)? setPage,
+ TResult Function(bool forceCollapse)? forceCollapse,
TResult Function(EditPannelContext editContext)? setEditPannel,
TResult Function()? dismissEditPannel,
required TResult orElse(),
}) {
- if (showMenu != null) {
- return showMenu(isShow);
+ if (forceCollapse != null) {
+ return forceCollapse(this.forceCollapse);
}
return orElse();
}
@@ -324,164 +311,35 @@ class _$_ShowMenu implements _ShowMenu {
@optionalTypeArgs
TResult map({
required TResult Function(_ShowLoading value) showLoading,
- required TResult Function(_ShowMenu value) showMenu,
- required TResult Function(SetCurrentPage value) setPage,
+ required TResult Function(_ForceCollapse value) forceCollapse,
required TResult Function(_ShowEditPannel value) setEditPannel,
required TResult Function(_DismissEditPannel value) dismissEditPannel,
}) {
- return showMenu(this);
+ return forceCollapse(this);
}
@override
@optionalTypeArgs
TResult maybeMap({
TResult Function(_ShowLoading value)? showLoading,
- TResult Function(_ShowMenu value)? showMenu,
- TResult Function(SetCurrentPage value)? setPage,
+ TResult Function(_ForceCollapse value)? forceCollapse,
TResult Function(_ShowEditPannel value)? setEditPannel,
TResult Function(_DismissEditPannel value)? dismissEditPannel,
required TResult orElse(),
}) {
- if (showMenu != null) {
- return showMenu(this);
+ if (forceCollapse != null) {
+ return forceCollapse(this);
}
return orElse();
}
}
-abstract class _ShowMenu implements HomeEvent {
- const factory _ShowMenu(bool isShow) = _$_ShowMenu;
+abstract class _ForceCollapse implements HomeEvent {
+ const factory _ForceCollapse(bool forceCollapse) = _$_ForceCollapse;
- bool get isShow => throw _privateConstructorUsedError;
+ bool get forceCollapse => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
- _$ShowMenuCopyWith<_ShowMenu> get copyWith =>
- throw _privateConstructorUsedError;
-}
-
-/// @nodoc
-abstract class $SetCurrentPageCopyWith<$Res> {
- factory $SetCurrentPageCopyWith(
- SetCurrentPage value, $Res Function(SetCurrentPage) then) =
- _$SetCurrentPageCopyWithImpl<$Res>;
- $Res call({PageContext context});
-}
-
-/// @nodoc
-class _$SetCurrentPageCopyWithImpl<$Res> extends _$HomeEventCopyWithImpl<$Res>
- implements $SetCurrentPageCopyWith<$Res> {
- _$SetCurrentPageCopyWithImpl(
- SetCurrentPage _value, $Res Function(SetCurrentPage) _then)
- : super(_value, (v) => _then(v as SetCurrentPage));
-
- @override
- SetCurrentPage get _value => super._value as SetCurrentPage;
-
- @override
- $Res call({
- Object? context = freezed,
- }) {
- return _then(SetCurrentPage(
- context == freezed
- ? _value.context
- : context // ignore: cast_nullable_to_non_nullable
- as PageContext,
- ));
- }
-}
-
-/// @nodoc
-
-class _$SetCurrentPage implements SetCurrentPage {
- const _$SetCurrentPage(this.context);
-
- @override
- final PageContext context;
-
- @override
- String toString() {
- return 'HomeEvent.setPage(context: $context)';
- }
-
- @override
- bool operator ==(dynamic other) {
- return identical(this, other) ||
- (other is SetCurrentPage &&
- (identical(other.context, context) ||
- const DeepCollectionEquality().equals(other.context, context)));
- }
-
- @override
- int get hashCode =>
- runtimeType.hashCode ^ const DeepCollectionEquality().hash(context);
-
- @JsonKey(ignore: true)
- @override
- $SetCurrentPageCopyWith get copyWith =>
- _$SetCurrentPageCopyWithImpl(this, _$identity);
-
- @override
- @optionalTypeArgs
- TResult when({
- required TResult Function(bool isLoading) showLoading,
- required TResult Function(bool isShow) showMenu,
- required TResult Function(PageContext context) setPage,
- required TResult Function(EditPannelContext editContext) setEditPannel,
- required TResult Function() dismissEditPannel,
- }) {
- return setPage(context);
- }
-
- @override
- @optionalTypeArgs
- TResult maybeWhen({
- TResult Function(bool isLoading)? showLoading,
- TResult Function(bool isShow)? showMenu,
- TResult Function(PageContext context)? setPage,
- TResult Function(EditPannelContext editContext)? setEditPannel,
- TResult Function()? dismissEditPannel,
- required TResult orElse(),
- }) {
- if (setPage != null) {
- return setPage(context);
- }
- return orElse();
- }
-
- @override
- @optionalTypeArgs
- TResult map({
- required TResult Function(_ShowLoading value) showLoading,
- required TResult Function(_ShowMenu value) showMenu,
- required TResult Function(SetCurrentPage value) setPage,
- required TResult Function(_ShowEditPannel value) setEditPannel,
- required TResult Function(_DismissEditPannel value) dismissEditPannel,
- }) {
- return setPage(this);
- }
-
- @override
- @optionalTypeArgs
- TResult maybeMap({
- TResult Function(_ShowLoading value)? showLoading,
- TResult Function(_ShowMenu value)? showMenu,
- TResult Function(SetCurrentPage value)? setPage,
- TResult Function(_ShowEditPannel value)? setEditPannel,
- TResult Function(_DismissEditPannel value)? dismissEditPannel,
- required TResult orElse(),
- }) {
- if (setPage != null) {
- return setPage(this);
- }
- return orElse();
- }
-}
-
-abstract class SetCurrentPage implements HomeEvent {
- const factory SetCurrentPage(PageContext context) = _$SetCurrentPage;
-
- PageContext get context => throw _privateConstructorUsedError;
- @JsonKey(ignore: true)
- $SetCurrentPageCopyWith get copyWith =>
+ _$ForceCollapseCopyWith<_ForceCollapse> get copyWith =>
throw _privateConstructorUsedError;
}
@@ -551,8 +409,7 @@ class _$_ShowEditPannel implements _ShowEditPannel {
@optionalTypeArgs
TResult when({
required TResult Function(bool isLoading) showLoading,
- required TResult Function(bool isShow) showMenu,
- required TResult Function(PageContext context) setPage,
+ required TResult Function(bool forceCollapse) forceCollapse,
required TResult Function(EditPannelContext editContext) setEditPannel,
required TResult Function() dismissEditPannel,
}) {
@@ -563,8 +420,7 @@ class _$_ShowEditPannel implements _ShowEditPannel {
@optionalTypeArgs
TResult maybeWhen({
TResult Function(bool isLoading)? showLoading,
- TResult Function(bool isShow)? showMenu,
- TResult Function(PageContext context)? setPage,
+ TResult Function(bool forceCollapse)? forceCollapse,
TResult Function(EditPannelContext editContext)? setEditPannel,
TResult Function()? dismissEditPannel,
required TResult orElse(),
@@ -579,8 +435,7 @@ class _$_ShowEditPannel implements _ShowEditPannel {
@optionalTypeArgs
TResult map({
required TResult Function(_ShowLoading value) showLoading,
- required TResult Function(_ShowMenu value) showMenu,
- required TResult Function(SetCurrentPage value) setPage,
+ required TResult Function(_ForceCollapse value) forceCollapse,
required TResult Function(_ShowEditPannel value) setEditPannel,
required TResult Function(_DismissEditPannel value) dismissEditPannel,
}) {
@@ -591,8 +446,7 @@ class _$_ShowEditPannel implements _ShowEditPannel {
@optionalTypeArgs
TResult maybeMap({
TResult Function(_ShowLoading value)? showLoading,
- TResult Function(_ShowMenu value)? showMenu,
- TResult Function(SetCurrentPage value)? setPage,
+ TResult Function(_ForceCollapse value)? forceCollapse,
TResult Function(_ShowEditPannel value)? setEditPannel,
TResult Function(_DismissEditPannel value)? dismissEditPannel,
required TResult orElse(),
@@ -655,8 +509,7 @@ class _$_DismissEditPannel implements _DismissEditPannel {
@optionalTypeArgs
TResult when({
required TResult Function(bool isLoading) showLoading,
- required TResult Function(bool isShow) showMenu,
- required TResult Function(PageContext context) setPage,
+ required TResult Function(bool forceCollapse) forceCollapse,
required TResult Function(EditPannelContext editContext) setEditPannel,
required TResult Function() dismissEditPannel,
}) {
@@ -667,8 +520,7 @@ class _$_DismissEditPannel implements _DismissEditPannel {
@optionalTypeArgs
TResult maybeWhen({
TResult Function(bool isLoading)? showLoading,
- TResult Function(bool isShow)? showMenu,
- TResult Function(PageContext context)? setPage,
+ TResult Function(bool forceCollapse)? forceCollapse,
TResult Function(EditPannelContext editContext)? setEditPannel,
TResult Function()? dismissEditPannel,
required TResult orElse(),
@@ -683,8 +535,7 @@ class _$_DismissEditPannel implements _DismissEditPannel {
@optionalTypeArgs
TResult map({
required TResult Function(_ShowLoading value) showLoading,
- required TResult Function(_ShowMenu value) showMenu,
- required TResult Function(SetCurrentPage value) setPage,
+ required TResult Function(_ForceCollapse value) forceCollapse,
required TResult Function(_ShowEditPannel value) setEditPannel,
required TResult Function(_DismissEditPannel value) dismissEditPannel,
}) {
@@ -695,8 +546,7 @@ class _$_DismissEditPannel implements _DismissEditPannel {
@optionalTypeArgs
TResult maybeMap({
TResult Function(_ShowLoading value)? showLoading,
- TResult Function(_ShowMenu value)? showMenu,
- TResult Function(SetCurrentPage value)? setPage,
+ TResult Function(_ForceCollapse value)? forceCollapse,
TResult Function(_ShowEditPannel value)? setEditPannel,
TResult Function(_DismissEditPannel value)? dismissEditPannel,
required TResult orElse(),
@@ -718,13 +568,11 @@ class _$HomeStateTearOff {
_HomeState call(
{required bool isLoading,
- required bool showMenu,
- required PageContext pageContext,
+ required bool forceCollapse,
required Option editContext}) {
return _HomeState(
isLoading: isLoading,
- showMenu: showMenu,
- pageContext: pageContext,
+ forceCollapse: forceCollapse,
editContext: editContext,
);
}
@@ -736,8 +584,7 @@ const $HomeState = _$HomeStateTearOff();
/// @nodoc
mixin _$HomeState {
bool get isLoading => throw _privateConstructorUsedError;
- bool get showMenu => throw _privateConstructorUsedError;
- PageContext get pageContext => throw _privateConstructorUsedError;
+ bool get forceCollapse => throw _privateConstructorUsedError;
Option get editContext =>
throw _privateConstructorUsedError;
@@ -752,8 +599,7 @@ abstract class $HomeStateCopyWith<$Res> {
_$HomeStateCopyWithImpl<$Res>;
$Res call(
{bool isLoading,
- bool showMenu,
- PageContext pageContext,
+ bool forceCollapse,
Option editContext});
}
@@ -768,8 +614,7 @@ class _$HomeStateCopyWithImpl<$Res> implements $HomeStateCopyWith<$Res> {
@override
$Res call({
Object? isLoading = freezed,
- Object? showMenu = freezed,
- Object? pageContext = freezed,
+ Object? forceCollapse = freezed,
Object? editContext = freezed,
}) {
return _then(_value.copyWith(
@@ -777,14 +622,10 @@ class _$HomeStateCopyWithImpl<$Res> implements $HomeStateCopyWith<$Res> {
? _value.isLoading
: isLoading // ignore: cast_nullable_to_non_nullable
as bool,
- showMenu: showMenu == freezed
- ? _value.showMenu
- : showMenu // ignore: cast_nullable_to_non_nullable
+ forceCollapse: forceCollapse == freezed
+ ? _value.forceCollapse
+ : forceCollapse // ignore: cast_nullable_to_non_nullable
as bool,
- pageContext: pageContext == freezed
- ? _value.pageContext
- : pageContext // ignore: cast_nullable_to_non_nullable
- as PageContext,
editContext: editContext == freezed
? _value.editContext
: editContext // ignore: cast_nullable_to_non_nullable
@@ -801,8 +642,7 @@ abstract class _$HomeStateCopyWith<$Res> implements $HomeStateCopyWith<$Res> {
@override
$Res call(
{bool isLoading,
- bool showMenu,
- PageContext pageContext,
+ bool forceCollapse,
Option editContext});
}
@@ -818,8 +658,7 @@ class __$HomeStateCopyWithImpl<$Res> extends _$HomeStateCopyWithImpl<$Res>
@override
$Res call({
Object? isLoading = freezed,
- Object? showMenu = freezed,
- Object? pageContext = freezed,
+ Object? forceCollapse = freezed,
Object? editContext = freezed,
}) {
return _then(_HomeState(
@@ -827,14 +666,10 @@ class __$HomeStateCopyWithImpl<$Res> extends _$HomeStateCopyWithImpl<$Res>
? _value.isLoading
: isLoading // ignore: cast_nullable_to_non_nullable
as bool,
- showMenu: showMenu == freezed
- ? _value.showMenu
- : showMenu // ignore: cast_nullable_to_non_nullable
+ forceCollapse: forceCollapse == freezed
+ ? _value.forceCollapse
+ : forceCollapse // ignore: cast_nullable_to_non_nullable
as bool,
- pageContext: pageContext == freezed
- ? _value.pageContext
- : pageContext // ignore: cast_nullable_to_non_nullable
- as PageContext,
editContext: editContext == freezed
? _value.editContext
: editContext // ignore: cast_nullable_to_non_nullable
@@ -848,22 +683,19 @@ class __$HomeStateCopyWithImpl<$Res> extends _$HomeStateCopyWithImpl<$Res>
class _$_HomeState implements _HomeState {
const _$_HomeState(
{required this.isLoading,
- required this.showMenu,
- required this.pageContext,
+ required this.forceCollapse,
required this.editContext});
@override
final bool isLoading;
@override
- final bool showMenu;
- @override
- final PageContext pageContext;
+ final bool forceCollapse;
@override
final Option editContext;
@override
String toString() {
- return 'HomeState(isLoading: $isLoading, showMenu: $showMenu, pageContext: $pageContext, editContext: $editContext)';
+ return 'HomeState(isLoading: $isLoading, forceCollapse: $forceCollapse, editContext: $editContext)';
}
@override
@@ -873,12 +705,9 @@ class _$_HomeState implements _HomeState {
(identical(other.isLoading, isLoading) ||
const DeepCollectionEquality()
.equals(other.isLoading, isLoading)) &&
- (identical(other.showMenu, showMenu) ||
+ (identical(other.forceCollapse, forceCollapse) ||
const DeepCollectionEquality()
- .equals(other.showMenu, showMenu)) &&
- (identical(other.pageContext, pageContext) ||
- const DeepCollectionEquality()
- .equals(other.pageContext, pageContext)) &&
+ .equals(other.forceCollapse, forceCollapse)) &&
(identical(other.editContext, editContext) ||
const DeepCollectionEquality()
.equals(other.editContext, editContext)));
@@ -888,8 +717,7 @@ class _$_HomeState implements _HomeState {
int get hashCode =>
runtimeType.hashCode ^
const DeepCollectionEquality().hash(isLoading) ^
- const DeepCollectionEquality().hash(showMenu) ^
- const DeepCollectionEquality().hash(pageContext) ^
+ const DeepCollectionEquality().hash(forceCollapse) ^
const DeepCollectionEquality().hash(editContext);
@JsonKey(ignore: true)
@@ -901,16 +729,13 @@ class _$_HomeState implements _HomeState {
abstract class _HomeState implements HomeState {
const factory _HomeState(
{required bool isLoading,
- required bool showMenu,
- required PageContext pageContext,
+ required bool forceCollapse,
required Option editContext}) = _$_HomeState;
@override
bool get isLoading => throw _privateConstructorUsedError;
@override
- bool get showMenu => throw _privateConstructorUsedError;
- @override
- PageContext get pageContext => throw _privateConstructorUsedError;
+ bool get forceCollapse => throw _privateConstructorUsedError;
@override
Option get editContext =>
throw _privateConstructorUsedError;
diff --git a/app_flowy/lib/home/application/watcher/home_watcher_bloc.dart b/app_flowy/lib/workspace/application/home/home_watcher_bloc.dart
similarity index 53%
rename from app_flowy/lib/home/application/watcher/home_watcher_bloc.dart
rename to app_flowy/lib/workspace/application/home/home_watcher_bloc.dart
index afb787e980..d6d86c59de 100644
--- a/app_flowy/lib/home/application/watcher/home_watcher_bloc.dart
+++ b/app_flowy/lib/workspace/application/home/home_watcher_bloc.dart
@@ -1,10 +1,7 @@
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
-// ignore: import_of_legacy_library_into_null_safe
import 'package:flutter_bloc/flutter_bloc.dart';
-part 'home_watcher_event.dart';
-part 'home_watcher_state.dart';
part 'home_watcher_bloc.freezed.dart';
class HomeWatcherBloc extends Bloc