diff --git a/frontend/app_flowy/assets/images/editor/Icons 16/Yen.svg b/frontend/app_flowy/assets/images/editor/Icons 16/Yen.svg
deleted file mode 100644
index b7cf1d361d..0000000000
--- a/frontend/app_flowy/assets/images/editor/Icons 16/Yen.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/frontend/app_flowy/assets/images/grid/checkmark.svg b/frontend/app_flowy/assets/images/grid/checkmark.svg
new file mode 100644
index 0000000000..f9c848f713
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/checkmark.svg
@@ -0,0 +1,3 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/delete.svg b/frontend/app_flowy/assets/images/grid/delete.svg
new file mode 100644
index 0000000000..fcfbf2f6dd
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/delete.svg
@@ -0,0 +1,6 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/details.svg b/frontend/app_flowy/assets/images/grid/details.svg
new file mode 100644
index 0000000000..e4c9f58f27
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/details.svg
@@ -0,0 +1,4 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/duplicate.svg b/frontend/app_flowy/assets/images/grid/duplicate.svg
new file mode 100644
index 0000000000..f11048fd2f
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/duplicate.svg
@@ -0,0 +1,4 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/field/checkbox.svg b/frontend/app_flowy/assets/images/grid/field/checkbox.svg
new file mode 100644
index 0000000000..37f52c47ed
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/field/checkbox.svg
@@ -0,0 +1,4 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/field/checklist.svg b/frontend/app_flowy/assets/images/grid/field/checklist.svg
new file mode 100644
index 0000000000..3a88d236a1
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/field/checklist.svg
@@ -0,0 +1,4 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/field/date.svg b/frontend/app_flowy/assets/images/grid/field/date.svg
new file mode 100644
index 0000000000..78243f1e75
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/field/date.svg
@@ -0,0 +1,6 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/field/euro.svg b/frontend/app_flowy/assets/images/grid/field/euro.svg
new file mode 100644
index 0000000000..95f511f687
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/field/euro.svg
@@ -0,0 +1,3 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/field/multi_select.svg b/frontend/app_flowy/assets/images/grid/field/multi_select.svg
new file mode 100644
index 0000000000..97a2e9c434
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/field/multi_select.svg
@@ -0,0 +1,8 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/field/number.svg b/frontend/app_flowy/assets/images/grid/field/number.svg
new file mode 100644
index 0000000000..9d8b98d10d
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/field/number.svg
@@ -0,0 +1,3 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/field/numbers.svg b/frontend/app_flowy/assets/images/grid/field/numbers.svg
new file mode 100644
index 0000000000..9d8b98d10d
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/field/numbers.svg
@@ -0,0 +1,3 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/field/single_select.svg b/frontend/app_flowy/assets/images/grid/field/single_select.svg
new file mode 100644
index 0000000000..8ccbc9a2e3
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/field/single_select.svg
@@ -0,0 +1,4 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/field/text.svg b/frontend/app_flowy/assets/images/grid/field/text.svg
new file mode 100644
index 0000000000..7befa5080f
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/field/text.svg
@@ -0,0 +1,4 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/field/us_dollar.svg b/frontend/app_flowy/assets/images/grid/field/us_dollar.svg
new file mode 100644
index 0000000000..a8485cd6a1
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/field/us_dollar.svg
@@ -0,0 +1,3 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/field/yen.svg b/frontend/app_flowy/assets/images/grid/field/yen.svg
new file mode 100644
index 0000000000..8e9bf47c99
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/field/yen.svg
@@ -0,0 +1,3 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/hide.svg b/frontend/app_flowy/assets/images/grid/hide.svg
new file mode 100644
index 0000000000..dfb6dbb90c
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/hide.svg
@@ -0,0 +1,4 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/left.svg b/frontend/app_flowy/assets/images/grid/left.svg
new file mode 100644
index 0000000000..0f771a3858
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/left.svg
@@ -0,0 +1,5 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/more.svg b/frontend/app_flowy/assets/images/grid/more.svg
new file mode 100644
index 0000000000..b191e64a10
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/more.svg
@@ -0,0 +1,3 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/right.svg b/frontend/app_flowy/assets/images/grid/right.svg
new file mode 100644
index 0000000000..7d738f4e69
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/right.svg
@@ -0,0 +1,5 @@
+
diff --git a/frontend/app_flowy/assets/images/editor/Icons 16/Sort/Ascending.svg b/frontend/app_flowy/assets/images/grid/setting/ascending.svg
similarity index 100%
rename from frontend/app_flowy/assets/images/editor/Icons 16/Sort/Ascending.svg
rename to frontend/app_flowy/assets/images/grid/setting/ascending.svg
diff --git a/frontend/app_flowy/assets/images/editor/Icons 16/Sort/Descending.svg b/frontend/app_flowy/assets/images/grid/setting/descending.svg
similarity index 100%
rename from frontend/app_flowy/assets/images/editor/Icons 16/Sort/Descending.svg
rename to frontend/app_flowy/assets/images/grid/setting/descending.svg
diff --git a/frontend/app_flowy/assets/images/editor/Icons 16/Filter.svg b/frontend/app_flowy/assets/images/grid/setting/filter.svg
similarity index 100%
rename from frontend/app_flowy/assets/images/editor/Icons 16/Filter.svg
rename to frontend/app_flowy/assets/images/grid/setting/filter.svg
diff --git a/frontend/app_flowy/assets/images/editor/Icons 16/Properties.svg b/frontend/app_flowy/assets/images/grid/setting/properties.svg
similarity index 100%
rename from frontend/app_flowy/assets/images/editor/Icons 16/Properties.svg
rename to frontend/app_flowy/assets/images/grid/setting/properties.svg
diff --git a/frontend/app_flowy/assets/images/grid/setting/setting.svg b/frontend/app_flowy/assets/images/grid/setting/setting.svg
new file mode 100644
index 0000000000..3d632703ab
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/setting/setting.svg
@@ -0,0 +1,4 @@
+
diff --git a/frontend/app_flowy/assets/images/grid/setting/sort.svg b/frontend/app_flowy/assets/images/grid/setting/sort.svg
new file mode 100644
index 0000000000..06e17d62a9
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/setting/sort.svg
@@ -0,0 +1,4 @@
+
diff --git a/frontend/app_flowy/assets/translations/en.json b/frontend/app_flowy/assets/translations/en.json
index 7717e71229..7e20a947dc 100644
--- a/frontend/app_flowy/assets/translations/en.json
+++ b/frontend/app_flowy/assets/translations/en.json
@@ -141,5 +141,53 @@
"lightLabel": "Light Mode",
"darkLabel": "Dark Mode"
}
+ },
+ "grid": {
+ "settings": {
+ "filter": "Filter",
+ "sortBy": "Sort by",
+ "Properties": "Properties"
+ },
+ "field": {
+ "hide": "Hide",
+ "insertLeft": "Insert Left",
+ "insertRight": "Insert Right",
+ "duplicate": "Duplicate",
+ "delete": "Delete",
+ "textFieldName": "Text",
+ "checkboxFieldName": "Checkbox",
+ "dateFieldName": "Date",
+ "numberFieldName": "Numbers",
+ "singleSelectFieldName": "Select",
+ "multiSelectFieldName": "Multiselect",
+ "numberFormat": " Number format",
+ "dateFormat": " Date format",
+ "dateFormatFriendly": "Month Day,Year",
+ "dateFormatISO": "Year-Month-Day",
+ "dateFormatLocal": "Month/Month/Day",
+ "dateFormatUS": "Month/Month/Day",
+ "timeFormat": " Time format",
+ "timeFormatTwelveHour": "12 hour",
+ "timeFormatTwentyFourHour": "24 hour",
+ "addSelectOption": "Add an option",
+ "optionTitle": "Options",
+ "addOption": "Add option",
+ "editProperty": "Edit property"
+ },
+ "selectOption": {
+ "purpleColor": "Purple",
+ "pinkColor": "Pink",
+ "lightPinkColor": "Light Pink",
+ "orangeColor": "Orange",
+ "yellowColor": "Yellow",
+ "limeColor": "Lime",
+ "greenColor": "Green",
+ "aquaColor": "Aqua",
+ "blueColor": "Blue",
+ "deleteTag": "Delete tag",
+ "colorPannelTitle": "Colors",
+ "pannelTitle": "Select an option or create one",
+ "searchOption": "Search for an option"
+ }
}
}
diff --git a/frontend/app_flowy/lib/core/notification_helper.dart b/frontend/app_flowy/lib/core/notification_helper.dart
index d815bf92bb..650abc544c 100644
--- a/frontend/app_flowy/lib/core/notification_helper.dart
+++ b/frontend/app_flowy/lib/core/notification_helper.dart
@@ -1,3 +1,4 @@
+import 'dart:async';
import 'dart:typed_data';
import 'package:flowy_sdk/protobuf/dart-notify/protobuf.dart';
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
@@ -5,6 +6,7 @@ import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-folder/dart_notification.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-grid/dart_notification.pb.dart';
+import 'package:flowy_sdk/rust_stream.dart';
// User
typedef UserNotificationCallback = void Function(UserNotification, Either);
@@ -45,6 +47,23 @@ class GridNotificationParser extends NotificationParser result);
+
+class GridNotificationListener {
+ StreamSubscription? _subscription;
+ GridNotificationParser? _parser;
+
+ GridNotificationListener({required String objectId, required GridNotificationHandler handler})
+ : _parser = GridNotificationParser(id: objectId, callback: handler) {
+ _subscription = RustStreamReceiver.listen((observable) => _parser?.parse(observable));
+ }
+
+ Future stop() async {
+ _parser = null;
+ await _subscription?.cancel();
+ }
+}
+
class NotificationParser {
String? id;
void Function(T, Either) callback;
diff --git a/frontend/app_flowy/lib/plugin/plugin.dart b/frontend/app_flowy/lib/plugin/plugin.dart
index 607ebaab53..8d30b122ad 100644
--- a/frontend/app_flowy/lib/plugin/plugin.dart
+++ b/frontend/app_flowy/lib/plugin/plugin.dart
@@ -61,12 +61,6 @@ abstract class PluginConfig {
}
abstract class PluginDisplay with NavigationItem {
- @override
- Widget get leftBarItem;
-
- @override
- Widget? get rightBarItem;
-
List get navigationItems;
PublishNotifier? get notifier => null;
diff --git a/frontend/app_flowy/lib/startup/deps_resolver.dart b/frontend/app_flowy/lib/startup/deps_resolver.dart
new file mode 100644
index 0000000000..a0af57f580
--- /dev/null
+++ b/frontend/app_flowy/lib/startup/deps_resolver.dart
@@ -0,0 +1,238 @@
+import 'package:app_flowy/core/network_monitor.dart';
+import 'package:app_flowy/user/application/user_listener.dart';
+import 'package:app_flowy/user/application/user_service.dart';
+import 'package:app_flowy/workspace/application/app/prelude.dart';
+import 'package:app_flowy/workspace/application/doc/prelude.dart';
+import 'package:app_flowy/workspace/application/grid/field/type_option/multi_select_bloc.dart';
+import 'package:app_flowy/workspace/application/grid/prelude.dart';
+import 'package:app_flowy/workspace/application/grid/row/row_listener.dart';
+import 'package:app_flowy/workspace/application/trash/prelude.dart';
+import 'package:app_flowy/workspace/application/workspace/prelude.dart';
+import 'package:app_flowy/workspace/application/edit_pannel/edit_pannel_bloc.dart';
+import 'package:app_flowy/workspace/application/home/home_bloc.dart';
+import 'package:app_flowy/workspace/application/view/prelude.dart';
+import 'package:app_flowy/workspace/application/home/prelude.dart';
+import 'package:app_flowy/workspace/application/menu/prelude.dart';
+import 'package:app_flowy/user/application/prelude.dart';
+import 'package:app_flowy/user/presentation/router.dart';
+import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
+import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
+import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
+import 'package:flowy_sdk/protobuf/flowy-grid-data-model/grid.pb.dart';
+import 'package:flowy_sdk/protobuf/flowy-grid/date_type_option.pb.dart';
+import 'package:flowy_sdk/protobuf/flowy-grid/number_type_option.pb.dart';
+import 'package:flowy_sdk/protobuf/flowy-grid/selection_type_option.pb.dart';
+import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
+import 'package:get_it/get_it.dart';
+
+class DependencyResolver {
+ static Future resolve(GetIt getIt) async {
+ _resolveUserDeps(getIt);
+
+ _resolveHomeDeps(getIt);
+
+ _resolveFolderDeps(getIt);
+
+ _resolveDocDeps(getIt);
+
+ _resolveGridDeps(getIt);
+ }
+}
+
+void _resolveUserDeps(GetIt getIt) {
+ getIt.registerFactory(() => AuthService());
+ getIt.registerFactory(() => AuthRouter());
+
+ getIt.registerFactory(() => SignInBloc(getIt()));
+ getIt.registerFactory(() => SignUpBloc(getIt()));
+
+ getIt.registerFactory(() => SplashRoute());
+ getIt.registerFactory(() => HomeBloc());
+ getIt.registerFactory(() => EditPannelBloc());
+ getIt.registerFactory(() => SplashBloc());
+ getIt.registerLazySingleton(() => NetworkListener());
+}
+
+void _resolveHomeDeps(GetIt getIt) {
+ getIt.registerFactoryParam(
+ (user, _) => UserListener(user: user),
+ );
+
+ getIt.registerFactoryParam(
+ (user, _) => HomeListenBloc(getIt(param1: user)),
+ );
+
+ //
+ getIt.registerLazySingleton(() => HomeStackManager());
+
+ getIt.registerFactoryParam(
+ (user, _) => WelcomeBloc(
+ userService: UserService(),
+ userListener: getIt(param1: user),
+ ),
+ );
+
+ // share
+ getIt.registerLazySingleton(() => ShareService());
+ getIt.registerFactoryParam(
+ (view, _) => DocShareBloc(view: view, service: getIt()));
+}
+
+void _resolveFolderDeps(GetIt getIt) {
+ //workspace
+ getIt.registerFactoryParam((user, workspaceId) =>
+ WorkspaceListener(service: WorkspaceListenerService(user: user, workspaceId: workspaceId)));
+
+ // View
+ getIt.registerFactoryParam(
+ (view, _) => ViewListener(view: view),
+ );
+
+ getIt.registerFactoryParam(
+ (view, _) => ViewBloc(
+ view: view,
+ service: ViewService(),
+ listener: getIt(param1: view),
+ ),
+ );
+
+ //Menu
+ getIt.registerFactoryParam(
+ (user, workspaceId) => MenuBloc(
+ workspaceId: workspaceId,
+ service: WorkspaceService(),
+ listener: getIt(param1: user, param2: workspaceId),
+ ),
+ );
+
+ getIt.registerFactoryParam(
+ (user, _) => MenuUserBloc(
+ user,
+ UserService(),
+ getIt(param1: user),
+ ),
+ );
+
+ // App
+ getIt.registerFactoryParam(
+ (app, _) => AppBloc(
+ app: app,
+ service: AppService(),
+ listener: AppListener(appId: app.id),
+ ),
+ );
+
+ // trash
+ getIt.registerLazySingleton(() => TrashService());
+ getIt.registerLazySingleton(() => TrashListener());
+ getIt.registerFactory(
+ () => TrashBloc(
+ service: getIt(),
+ listener: getIt(),
+ ),
+ );
+}
+
+void _resolveDocDeps(GetIt getIt) {
+// Doc
+ getIt.registerFactoryParam(
+ (view, _) => DocumentBloc(
+ view: view,
+ service: DocumentService(),
+ listener: getIt(param1: view),
+ trashService: getIt(),
+ ),
+ );
+}
+
+void _resolveGridDeps(GetIt getIt) {
+ // Grid
+ getIt.registerFactoryParam(
+ (view, _) => GridBloc(view: view, service: GridService()),
+ );
+
+ getIt.registerFactoryParam(
+ (data, _) => RowBloc(
+ rowData: data,
+ rowlistener: RowListener(rowId: data.rowId),
+ ),
+ );
+
+ getIt.registerFactoryParam>(
+ (gridId, fields) => GridHeaderBloc(
+ data: GridHeaderData(gridId: gridId, fields: fields),
+ service: FieldService(gridId: gridId),
+ ),
+ );
+
+ getIt.registerFactoryParam(
+ (data, _) => FieldActionSheetBloc(
+ field: data.field,
+ service: FieldService(gridId: data.gridId),
+ ),
+ );
+
+ getIt.registerFactoryParam(
+ (gridId, fieldLoader) => FieldEditorBloc(
+ service: FieldService(gridId: gridId),
+ fieldLoader: fieldLoader,
+ ),
+ );
+
+ getIt.registerFactoryParam(
+ (cellData, _) => TextCellBloc(
+ service: CellService(),
+ cellData: cellData,
+ ),
+ );
+
+ getIt.registerFactoryParam(
+ (cellData, _) => SelectionCellBloc(
+ cellData: cellData,
+ ),
+ );
+
+ getIt.registerFactoryParam(
+ (cellData, _) => NumberCellBloc(
+ cellData: cellData,
+ ),
+ );
+
+ getIt.registerFactoryParam(
+ (cellData, _) => DateCellBloc(
+ service: CellService(),
+ cellData: cellData,
+ ),
+ );
+
+ getIt.registerFactoryParam(
+ (cellData, _) => CheckboxCellBloc(
+ service: CellService(),
+ cellData: cellData,
+ ),
+ );
+
+ getIt.registerFactoryParam(
+ (context, _) => FieldSwitcherBloc(context),
+ );
+
+ getIt.registerFactoryParam(
+ (typeOption, fieldId) => SingleSelectTypeOptionBloc(typeOption, fieldId),
+ );
+
+ getIt.registerFactoryParam(
+ (typeOption, fieldId) => MultiSelectTypeOptionBloc(typeOption, fieldId),
+ );
+
+ getIt.registerFactoryParam(
+ (typeOption, _) => DateTypeOptionBloc(typeOption: typeOption),
+ );
+
+ getIt.registerFactoryParam(
+ (typeOption, _) => NumberTypeOptionBloc(typeOption: typeOption),
+ );
+
+ getIt.registerFactoryParam>(
+ (gridId, fields) => GridPropertyBloc(gridId: gridId, fields: fields),
+ );
+}
diff --git a/frontend/app_flowy/lib/startup/home_deps_resolver.dart b/frontend/app_flowy/lib/startup/home_deps_resolver.dart
deleted file mode 100644
index 2dcf6ca077..0000000000
--- a/frontend/app_flowy/lib/startup/home_deps_resolver.dart
+++ /dev/null
@@ -1,156 +0,0 @@
-import 'package:app_flowy/user/application/user_listener.dart';
-import 'package:app_flowy/user/application/user_service.dart';
-import 'package:app_flowy/workspace/application/app/prelude.dart';
-import 'package:app_flowy/workspace/application/doc/prelude.dart';
-import 'package:app_flowy/workspace/application/grid/prelude.dart';
-import 'package:app_flowy/workspace/application/grid/row_listener.dart';
-import 'package:app_flowy/workspace/application/trash/prelude.dart';
-import 'package:app_flowy/workspace/application/workspace/prelude.dart';
-import 'package:app_flowy/workspace/application/view/prelude.dart';
-import 'package:app_flowy/workspace/application/home/prelude.dart';
-import 'package:app_flowy/workspace/application/menu/prelude.dart';
-
-import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
-import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
-import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
-import 'package:flowy_sdk/protobuf/flowy-grid-data-model/grid.pb.dart';
-import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
-import 'package:get_it/get_it.dart';
-
-class HomeDepsResolver {
- static Future resolve(GetIt getIt) async {
- getIt.registerFactoryParam(
- (user, _) => UserListener(user: user),
- );
-
- getIt.registerFactoryParam(
- (user, _) => HomeListenBloc(getIt(param1: user)),
- );
-
- //
- getIt.registerLazySingleton(() => HomeStackManager());
- getIt.registerFactoryParam(
- (user, _) => WelcomeBloc(
- userService: UserService(),
- userListener: getIt(param1: user),
- ),
- );
-
- //workspace
- getIt.registerFactoryParam((user, workspaceId) =>
- WorkspaceListener(service: WorkspaceListenerService(user: user, workspaceId: workspaceId)));
-
- // View
- getIt.registerFactoryParam(
- (view, _) => ViewListener(view: view),
- );
-
- getIt.registerFactoryParam(
- (view, _) => ViewBloc(
- view: view,
- service: ViewService(),
- listener: getIt(param1: view),
- ),
- );
-
- //Menu Bloc
- getIt.registerFactoryParam(
- (user, workspaceId) => MenuBloc(
- workspaceId: workspaceId,
- service: WorkspaceService(),
- listener: getIt(param1: user, param2: workspaceId),
- ),
- );
-
- getIt.registerFactoryParam(
- (user, _) => MenuUserBloc(
- user,
- UserService(),
- getIt(param1: user),
- ),
- );
-
- // App
- getIt.registerFactoryParam(
- (app, _) => AppBloc(
- app: app,
- service: AppService(),
- listener: AppListener(appId: app.id),
- ),
- );
-
- // Doc
- getIt.registerFactoryParam(
- (view, _) => DocumentBloc(
- view: view,
- service: DocumentService(),
- listener: getIt(param1: view),
- trashService: getIt(),
- ),
- );
-
- // Grid
- getIt.registerFactoryParam(
- (view, _) => GridBloc(view: view, service: GridService()),
- );
-
- getIt.registerFactoryParam(
- (data, _) => RowBloc(
- rowService: RowService(data),
- listener: RowListener(rowId: data.rowId),
- ),
- );
-
- getIt.registerFactoryParam, void>(
- (data, _) => ColumnBloc(
- data: GridColumnData(fields: data),
- service: ColumnService(),
- ),
- );
-
- getIt.registerFactoryParam(
- (context, _) => TextCellBloc(
- service: CellService(context),
- ),
- );
-
- getIt.registerFactoryParam(
- (context, _) => SelectionCellBloc(
- service: CellService(context),
- ),
- );
-
- getIt.registerFactoryParam(
- (context, _) => NumberCellBloc(
- service: CellService(context),
- ),
- );
-
- getIt.registerFactoryParam(
- (context, _) => DateCellBloc(
- service: CellService(context),
- ),
- );
-
- getIt.registerFactoryParam(
- (context, _) => CheckboxCellBloc(
- service: CellService(context),
- ),
- );
-
- // trash
- getIt.registerLazySingleton(() => TrashService());
- getIt.registerLazySingleton(() => TrashListener());
- getIt.registerFactory(
- () => TrashBloc(
- service: getIt(),
- listener: getIt(),
- ),
- );
-
- // share
- getIt.registerLazySingleton(() => ShareService());
- getIt.registerFactoryParam(
- (view, _) => DocShareBloc(view: view, service: getIt()));
- }
-}
diff --git a/frontend/app_flowy/lib/startup/startup.dart b/frontend/app_flowy/lib/startup/startup.dart
index 0335879f5a..38243afa56 100644
--- a/frontend/app_flowy/lib/startup/startup.dart
+++ b/frontend/app_flowy/lib/startup/startup.dart
@@ -2,8 +2,7 @@ import 'dart:io';
import 'package:app_flowy/plugin/plugin.dart';
import 'package:app_flowy/startup/tasks/prelude.dart';
-import 'package:app_flowy/startup/home_deps_resolver.dart';
-import 'package:app_flowy/startup/user_deps_resolver.dart';
+import 'package:app_flowy/startup/deps_resolver.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
@@ -62,8 +61,7 @@ Future initGetIt(
getIt.registerLazySingleton(() => AppLauncher(env, getIt));
getIt.registerSingleton(PluginSandbox());
- await UserDepsResolver.resolve(getIt);
- await HomeDepsResolver.resolve(getIt);
+ await DependencyResolver.resolve(getIt);
}
class LaunchContext {
diff --git a/frontend/app_flowy/lib/startup/tasks/app_widget.dart b/frontend/app_flowy/lib/startup/tasks/app_widget.dart
index 7368cc3b13..12e88949a0 100644
--- a/frontend/app_flowy/lib/startup/tasks/app_widget.dart
+++ b/frontend/app_flowy/lib/startup/tasks/app_widget.dart
@@ -113,7 +113,7 @@ class ApplicationBlocObserver extends BlocObserver {
// ignore: unnecessary_overrides
void onTransition(Bloc bloc, Transition transition) {
// Log.debug("[current]: ${transition.currentState} \n\n[next]: ${transition.nextState}");
- //Log.debug("${transition.nextState}");
+ // Log.debug("${transition.nextState}");
super.onTransition(bloc, transition);
}
diff --git a/frontend/app_flowy/lib/startup/user_deps_resolver.dart b/frontend/app_flowy/lib/startup/user_deps_resolver.dart
deleted file mode 100644
index daf67a071a..0000000000
--- a/frontend/app_flowy/lib/startup/user_deps_resolver.dart
+++ /dev/null
@@ -1,29 +0,0 @@
-import 'package:app_flowy/user/application/auth_service.dart';
-import 'package:app_flowy/user/application/sign_in_bloc.dart';
-import 'package:app_flowy/user/application/sign_up_bloc.dart';
-import 'package:app_flowy/user/application/splash_bloc.dart';
-import 'package:app_flowy/user/presentation/router.dart';
-import 'package:app_flowy/workspace/application/edit_pannel/edit_pannel_bloc.dart';
-import 'package:app_flowy/workspace/application/home/home_bloc.dart';
-import 'package:get_it/get_it.dart';
-
-import '../core/network_monitor.dart';
-
-class UserDepsResolver {
- static Future resolve(GetIt getIt) async {
- getIt.registerFactory(() => AuthService());
-
- //Interface implementation
- getIt.registerFactory(() => AuthRouter());
-
- //Bloc
- getIt.registerFactory(() => SignInBloc(getIt()));
- getIt.registerFactory(() => SignUpBloc(getIt()));
-
- getIt.registerFactory(() => SplashRoute());
- getIt.registerFactory(() => HomeBloc());
- getIt.registerFactory(() => EditPannelBloc());
- getIt.registerFactory(() => SplashBloc());
- getIt.registerLazySingleton(() => NetworkListener());
- }
-}
diff --git a/frontend/app_flowy/lib/user/application/prelude.dart b/frontend/app_flowy/lib/user/application/prelude.dart
new file mode 100644
index 0000000000..74b644808e
--- /dev/null
+++ b/frontend/app_flowy/lib/user/application/prelude.dart
@@ -0,0 +1,4 @@
+export './auth_service.dart';
+export './sign_in_bloc.dart';
+export './sign_up_bloc.dart';
+export './splash_bloc.dart';
diff --git a/frontend/app_flowy/lib/user/application/sign_in_bloc.dart b/frontend/app_flowy/lib/user/application/sign_in_bloc.dart
index 25aa66cc50..e0f5bed605 100644
--- a/frontend/app_flowy/lib/user/application/sign_in_bloc.dart
+++ b/frontend/app_flowy/lib/user/application/sign_in_bloc.dart
@@ -54,14 +54,14 @@ class SignInBloc extends Bloc {
}
@freezed
-abstract class SignInEvent with _$SignInEvent {
+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 {
+class SignInState with _$SignInState {
const factory SignInState({
String? email,
String? password,
diff --git a/frontend/app_flowy/lib/user/application/sign_up_bloc.dart b/frontend/app_flowy/lib/user/application/sign_up_bloc.dart
index 11acd1d385..2efc82d3c7 100644
--- a/frontend/app_flowy/lib/user/application/sign_up_bloc.dart
+++ b/frontend/app_flowy/lib/user/application/sign_up_bloc.dart
@@ -15,11 +15,11 @@ class SignUpBloc extends Bloc {
on((event, emit) async {
await event.map(signUpWithUserEmailAndPassword: (e) async {
await _performActionOnSignUp(emit);
- }, emailChanged: (EmailChanged value) async {
+ }, emailChanged: (_EmailChanged value) async {
emit(state.copyWith(email: value.email, emailError: none(), successOrFail: none()));
- }, passwordChanged: (PasswordChanged value) async {
+ }, passwordChanged: (_PasswordChanged value) async {
emit(state.copyWith(password: value.password, passwordError: none(), successOrFail: none()));
- }, repeatPasswordChanged: (RepeatPasswordChanged value) async {
+ }, repeatPasswordChanged: (_RepeatPasswordChanged value) async {
emit(state.copyWith(repeatedPassword: value.password, repeatPasswordError: none(), successOrFail: none()));
});
});
@@ -104,9 +104,9 @@ class SignUpBloc extends Bloc {
@freezed
class SignUpEvent with _$SignUpEvent {
const factory SignUpEvent.signUpWithUserEmailAndPassword() = SignUpWithUserEmailAndPassword;
- const factory SignUpEvent.emailChanged(String email) = EmailChanged;
- const factory SignUpEvent.passwordChanged(String password) = PasswordChanged;
- const factory SignUpEvent.repeatPasswordChanged(String password) = RepeatPasswordChanged;
+ const factory SignUpEvent.emailChanged(String email) = _EmailChanged;
+ const factory SignUpEvent.passwordChanged(String password) = _PasswordChanged;
+ const factory SignUpEvent.repeatPasswordChanged(String password) = _RepeatPasswordChanged;
}
@freezed
diff --git a/frontend/app_flowy/lib/user/application/user_listener.dart b/frontend/app_flowy/lib/user/application/user_listener.dart
index 993aee60e0..5b212cc2d0 100644
--- a/frontend/app_flowy/lib/user/application/user_listener.dart
+++ b/frontend/app_flowy/lib/user/application/user_listener.dart
@@ -12,7 +12,6 @@ import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-user/dart_notification.pb.dart' as user;
import 'package:flowy_sdk/rust_stream.dart';
-
typedef UserProfileUpdatedNotifierValue = Either;
typedef AuthNotifierValue = Either;
typedef WorkspaceUpdatedNotifierValue = Either, FlowyError>;
@@ -23,8 +22,8 @@ class UserListener {
final authDidChangedNotifier = PublishNotifier();
final workspaceUpdatedNotifier = PublishNotifier();
- late FolderNotificationParser _workspaceParser;
- late UserNotificationParser _userParser;
+ FolderNotificationParser? _workspaceParser;
+ UserNotificationParser? _userParser;
late UserProfile _user;
UserListener({
required UserProfile user,
@@ -36,12 +35,14 @@ class UserListener {
_workspaceParser = FolderNotificationParser(id: _user.token, callback: _notificationCallback);
_userParser = UserNotificationParser(id: _user.token, callback: _userNotificationCallback);
_subscription = RustStreamReceiver.listen((observable) {
- _workspaceParser.parse(observable);
- _userParser.parse(observable);
+ _workspaceParser?.parse(observable);
+ _userParser?.parse(observable);
});
}
Future stop() async {
+ _workspaceParser = null;
+ _userParser = null;
await _subscription?.cancel();
profileUpdatedNotifier.dispose();
authDidChangedNotifier.dispose();
diff --git a/frontend/app_flowy/lib/user/domain/auth_state.dart b/frontend/app_flowy/lib/user/domain/auth_state.dart
index b70383c0aa..96f2036e01 100644
--- a/frontend/app_flowy/lib/user/domain/auth_state.dart
+++ b/frontend/app_flowy/lib/user/domain/auth_state.dart
@@ -4,7 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
part 'auth_state.freezed.dart';
@freezed
-abstract class AuthState with _$AuthState {
+class AuthState with _$AuthState {
const factory AuthState.authenticated(UserProfile userProfile) = Authenticated;
const factory AuthState.unauthenticated(FlowyError error) = Unauthenticated;
const factory AuthState.initial() = _Initial;
diff --git a/frontend/app_flowy/lib/user/presentation/sign_in_screen.dart b/frontend/app_flowy/lib/user/presentation/sign_in_screen.dart
index f7afa0b4d3..9a02863345 100644
--- a/frontend/app_flowy/lib/user/presentation/sign_in_screen.dart
+++ b/frontend/app_flowy/lib/user/presentation/sign_in_screen.dart
@@ -170,11 +170,11 @@ class PasswordTextField extends StatelessWidget {
return RoundedInputField(
obscureText: true,
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
- obscureIcon: svg("home/hide"),
- obscureHideIcon: svg("home/show"),
+ obscureIcon: svgWidget("home/hide"),
+ obscureHideIcon: svgWidget("home/show"),
hintText: LocaleKeys.signIn_passwordHint.tr(),
normalBorderColor: theme.shader4,
- highlightBorderColor: theme.red,
+ errorBorderColor: theme.red,
cursorColor: theme.main1,
errorText: context.read().state.passwordError.fold(() => "", (error) => error),
onChanged: (value) => context.read().add(SignInEvent.passwordChanged(value)),
@@ -199,7 +199,7 @@ class EmailTextField extends StatelessWidget {
hintText: LocaleKeys.signIn_emailHint.tr(),
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
normalBorderColor: theme.shader4,
- highlightBorderColor: theme.red,
+ errorBorderColor: theme.red,
cursorColor: theme.main1,
errorText: context.read().state.emailError.fold(() => "", (error) => error),
onChanged: (value) => context.read().add(SignInEvent.emailChanged(value)),
diff --git a/frontend/app_flowy/lib/user/presentation/sign_up_screen.dart b/frontend/app_flowy/lib/user/presentation/sign_up_screen.dart
index 931ccff516..9f95a1db75 100644
--- a/frontend/app_flowy/lib/user/presentation/sign_up_screen.dart
+++ b/frontend/app_flowy/lib/user/presentation/sign_up_screen.dart
@@ -134,12 +134,12 @@ class PasswordTextField extends StatelessWidget {
builder: (context, state) {
return RoundedInputField(
obscureText: true,
- obscureIcon: svg("home/hide"),
- obscureHideIcon: svg("home/show"),
+ obscureIcon: svgWidget("home/hide"),
+ obscureHideIcon: svgWidget("home/show"),
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
hintText: LocaleKeys.signUp_passwordHint.tr(),
normalBorderColor: theme.shader4,
- highlightBorderColor: theme.red,
+ errorBorderColor: theme.red,
cursorColor: theme.main1,
errorText: context.read().state.passwordError.fold(() => "", (error) => error),
onChanged: (value) => context.read().add(SignUpEvent.passwordChanged(value)),
@@ -162,12 +162,12 @@ class RepeatPasswordTextField extends StatelessWidget {
builder: (context, state) {
return RoundedInputField(
obscureText: true,
- obscureIcon: svg("home/hide"),
- obscureHideIcon: svg("home/show"),
+ obscureIcon: svgWidget("home/hide"),
+ obscureHideIcon: svgWidget("home/show"),
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
hintText: LocaleKeys.signUp_repeatPasswordHint.tr(),
normalBorderColor: theme.shader4,
- highlightBorderColor: theme.red,
+ errorBorderColor: theme.red,
cursorColor: theme.main1,
errorText: context.read().state.repeatPasswordError.fold(() => "", (error) => error),
onChanged: (value) => context.read().add(SignUpEvent.repeatPasswordChanged(value)),
@@ -192,7 +192,7 @@ class EmailTextField extends StatelessWidget {
hintText: LocaleKeys.signUp_emailHint.tr(),
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
normalBorderColor: theme.shader4,
- highlightBorderColor: theme.red,
+ errorBorderColor: theme.red,
cursorColor: theme.main1,
errorText: context.read().state.emailError.fold(() => "", (error) => error),
onChanged: (value) => context.read().add(SignUpEvent.emailChanged(value)),
diff --git a/frontend/app_flowy/lib/user/presentation/splash_screen.dart b/frontend/app_flowy/lib/user/presentation/splash_screen.dart
index 5fe302abd0..dd8fdcd180 100644
--- a/frontend/app_flowy/lib/user/presentation/splash_screen.dart
+++ b/frontend/app_flowy/lib/user/presentation/splash_screen.dart
@@ -4,7 +4,7 @@ import 'package:app_flowy/user/domain/auth_state.dart';
import 'package:app_flowy/user/presentation/router.dart';
import 'package:flowy_sdk/log.dart';
import 'package:flowy_sdk/dispatch/dispatch.dart';
-import 'package:flowy_sdk/protobuf/flowy-folder-data-model/errors.pb.dart';
+import 'package:flowy_sdk/protobuf/error-code/error_code.pbenum.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
diff --git a/frontend/app_flowy/lib/user/presentation/widgets/background.dart b/frontend/app_flowy/lib/user/presentation/widgets/background.dart
index 86dfab7ffe..225f7f0080 100644
--- a/frontend/app_flowy/lib/user/presentation/widgets/background.dart
+++ b/frontend/app_flowy/lib/user/presentation/widgets/background.dart
@@ -44,7 +44,7 @@ class FlowyLogoTitle extends StatelessWidget {
children: [
SizedBox.fromSize(
size: logoSize,
- child: svg("flowy_logo"),
+ child: svgWidget("flowy_logo"),
),
const VSpace(30),
Text(
diff --git a/frontend/app_flowy/lib/workspace/application/app/app_bloc.dart b/frontend/app_flowy/lib/workspace/application/app/app_bloc.dart
index 5175fe2396..73192436bf 100644
--- a/frontend/app_flowy/lib/workspace/application/app/app_bloc.dart
+++ b/frontend/app_flowy/lib/workspace/application/app/app_bloc.dart
@@ -19,7 +19,7 @@ class AppBloc extends Bloc {
AppBloc({required this.app, required this.service, required this.listener}) : super(AppState.initial(app)) {
on((event, emit) async {
await event.map(initial: (e) async {
- listener.startListening(
+ listener.start(
viewsChanged: _handleViewsChanged,
appUpdated: (app) => add(AppEvent.appDidUpdate(app)),
);
diff --git a/frontend/app_flowy/lib/workspace/application/app/app_listener.dart b/frontend/app_flowy/lib/workspace/application/app/app_listener.dart
index 8f0ff7cb23..46b16bb080 100644
--- a/frontend/app_flowy/lib/workspace/application/app/app_listener.dart
+++ b/frontend/app_flowy/lib/workspace/application/app/app_listener.dart
@@ -17,18 +17,18 @@ class AppListener {
StreamSubscription? _subscription;
ViewsDidChangeCallback? _viewsChanged;
AppDidUpdateCallback? _updated;
- late FolderNotificationParser _parser;
+ FolderNotificationParser? _parser;
String appId;
AppListener({
required this.appId,
});
- void startListening({ViewsDidChangeCallback? viewsChanged, AppDidUpdateCallback? appUpdated}) {
+ void start({ViewsDidChangeCallback? viewsChanged, AppDidUpdateCallback? appUpdated}) {
_viewsChanged = viewsChanged;
_updated = appUpdated;
_parser = FolderNotificationParser(id: appId, callback: _bservableCallback);
- _subscription = RustStreamReceiver.listen((observable) => _parser.parse(observable));
+ _subscription = RustStreamReceiver.listen((observable) => _parser?.parse(observable));
}
void _bservableCallback(FolderNotification ty, Either result) {
@@ -61,6 +61,7 @@ class AppListener {
}
Future close() async {
+ _parser = null;
await _subscription?.cancel();
_viewsChanged = null;
_updated = null;
diff --git a/frontend/app_flowy/lib/workspace/application/appearance.dart b/frontend/app_flowy/lib/workspace/application/appearance.dart
index 87cd7e1af8..06473729a8 100644
--- a/frontend/app_flowy/lib/workspace/application/appearance.dart
+++ b/frontend/app_flowy/lib/workspace/application/appearance.dart
@@ -1,3 +1,5 @@
+import 'dart:async';
+
import 'package:app_flowy/user/application/user_settings_service.dart';
import 'package:equatable/equatable.dart';
import 'package:flowy_infra/theme.dart';
@@ -5,13 +7,12 @@ import 'package:flowy_sdk/log.dart';
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_setting.pb.dart';
import 'package:flutter/material.dart';
import 'package:easy_localization/easy_localization.dart';
-import 'package:async/async.dart';
class AppearanceSettingModel extends ChangeNotifier with EquatableMixin {
AppearanceSettings setting;
AppTheme _theme;
Locale _locale;
- CancelableOperation? _saveOperation;
+ Timer? _saveOperation;
AppearanceSettingModel(this.setting)
: _theme = AppTheme.fromName(name: setting.theme),
@@ -21,12 +22,10 @@ class AppearanceSettingModel extends ChangeNotifier with EquatableMixin {
Locale get locale => _locale;
Future save() async {
- _saveOperation?.cancel;
- _saveOperation = CancelableOperation.fromFuture(
- Future.delayed(const Duration(seconds: 1), () async {
- await UserSettingsService().setAppearanceSettings(setting);
- }),
- );
+ _saveOperation?.cancel();
+ _saveOperation = Timer(const Duration(seconds: 2), () async {
+ await UserSettingsService().setAppearanceSettings(setting);
+ });
}
@override
diff --git a/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_context.dart b/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_context.dart
index cd52bc7f11..571461b365 100644
--- a/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_context.dart
+++ b/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_context.dart
@@ -5,19 +5,8 @@ abstract class EditPannelContext extends Equatable {
final String identifier;
final String title;
final Widget child;
- const EditPannelContext(
- {required this.child, required this.identifier, required this.title});
+ const EditPannelContext({required this.child, required this.identifier, required this.title});
@override
List