From 61df3848e4db5c17621394b67a6a26dcf3f0011f Mon Sep 17 00:00:00 2001 From: appflowy Date: Tue, 9 Aug 2022 10:03:42 +0800 Subject: [PATCH 1/3] chore: update appflowy_board pub.dev config --- .../packages/appflowy_board/CHANGELOG.md | 3 ++ .../packages/appflowy_board/README.md | 2 +- .../example/lib/multi_board_list_example.dart | 35 ++++++++++--------- .../src/widgets/reorder_flex/drag_target.dart | 2 +- .../widgets/reorder_flex/reorder_flex.dart | 8 ++--- .../packages/appflowy_board/pubspec.yaml | 6 ++-- 6 files changed, 30 insertions(+), 26 deletions(-) diff --git a/frontend/app_flowy/packages/appflowy_board/CHANGELOG.md b/frontend/app_flowy/packages/appflowy_board/CHANGELOG.md index 7cf059202f..76f33711b1 100644 --- a/frontend/app_flowy/packages/appflowy_board/CHANGELOG.md +++ b/frontend/app_flowy/packages/appflowy_board/CHANGELOG.md @@ -1,3 +1,6 @@ +# 0.0.4 +* fix some bugs + # 0.0.3 * Support customize UI * Update example diff --git a/frontend/app_flowy/packages/appflowy_board/README.md b/frontend/app_flowy/packages/appflowy_board/README.md index 893bc3ed64..b33c4d7883 100644 --- a/frontend/app_flowy/packages/appflowy_board/README.md +++ b/frontend/app_flowy/packages/appflowy_board/README.md @@ -7,7 +7,7 @@ The **appflowy_board** is a package that is used in [AppFlowy](https://github.co ## Getting Started

- +

```dart diff --git a/frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart b/frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart index 3edb32c3bf..d692a6fe20 100644 --- a/frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart +++ b/frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart @@ -99,22 +99,25 @@ class _MultiBoardListExampleState extends State { } if (item is RichTextItem) { - return Padding( - padding: const EdgeInsets.all(20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - item.title, - style: const TextStyle(fontSize: 14), - textAlign: TextAlign.left, - ), - const SizedBox(height: 10), - Text( - item.subtitle, - style: const TextStyle(fontSize: 12, color: Colors.grey), - ) - ], + return Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + item.title, + style: const TextStyle(fontSize: 14), + textAlign: TextAlign.left, + ), + const SizedBox(height: 10), + Text( + item.subtitle, + style: const TextStyle(fontSize: 12, color: Colors.grey), + ) + ], + ), ), ); } diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target.dart index ea8cc91fab..a6a09a9770 100644 --- a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target.dart +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target.dart @@ -187,7 +187,7 @@ class _ReorderDragTargetState clipBehavior: Clip.hardEdge, child: ConstrainedBox( constraints: constraints, - child: Opacity(opacity: 0.6, child: child), + child: Opacity(opacity: 0.3, child: child), ), ), ); diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_flex.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_flex.dart index 6354b25c33..27af28d778 100644 --- a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_flex.dart +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_flex.dart @@ -33,7 +33,7 @@ abstract class ReoderFlexItem { class ReorderFlexConfig { /// The opacity of the dragging widget - final double draggingWidgetOpacity = 0.2; + final double draggingWidgetOpacity = 0.3; // How long an animation to reorder an element final Duration reorderAnimationDuration = const Duration(milliseconds: 250); @@ -499,16 +499,14 @@ class ReorderFlexState extends State switch (widget.direction) { case Axis.horizontal: return Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, + crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: widget.mainAxisAlignment, children: children, ); case Axis.vertical: default: return Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, + crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: widget.mainAxisAlignment, children: children, ); diff --git a/frontend/app_flowy/packages/appflowy_board/pubspec.yaml b/frontend/app_flowy/packages/appflowy_board/pubspec.yaml index 92b1782ea0..962fc8be80 100644 --- a/frontend/app_flowy/packages/appflowy_board/pubspec.yaml +++ b/frontend/app_flowy/packages/appflowy_board/pubspec.yaml @@ -1,8 +1,8 @@ name: appflowy_board -description: A new Flutter package project. -version: 0.0.3 +description: AppFlowy board implementation. +version: 0.0.4 homepage: https://github.com/AppFlowy-IO/AppFlowy -repository: https://github.com/AppFlowy-IO/AppFlowy +repository: https://github.com/AppFlowy-IO/AppFlowy/tree/main/frontend/app_flowy/packages/appflowy_board environment: sdk: ">=2.17.0 <3.0.0" From 6d385e811f6b4daeeed2e84382be0d74cb9028b3 Mon Sep 17 00:00:00 2001 From: appflowy Date: Tue, 9 Aug 2022 10:35:27 +0800 Subject: [PATCH 2/3] refactor: move plugin application and presentation together --- .../plugins/blank/blank.dart | 5 +- .../board/application}/board_bloc.dart | 0 .../plugins/board/board.dart | 6 +- .../board/presentation}/board_page.dart | 0 .../doc/application}/doc_bloc.dart | 22 ++++--- .../doc/application}/doc_service.dart | 0 .../doc/application}/prelude.dart | 0 .../doc/application}/share_bloc.dart | 11 ++-- .../doc/application}/share_service.dart | 0 .../plugins/doc/document.dart | 42 +++++++------ .../src => plugins/doc}/document_page.dart | 22 ++++--- .../doc/presentation}/banner.dart | 0 .../doc/presentation}/style_widgets.dart | 0 .../presentation}/toolbar/check_button.dart | 0 .../presentation}/toolbar/color_picker.dart | 0 .../presentation}/toolbar/header_button.dart | 0 .../presentation}/toolbar/history_button.dart | 0 .../presentation}/toolbar/image_button.dart | 0 .../presentation}/toolbar/link_button.dart | 0 .../presentation}/toolbar/toggle_button.dart | 0 .../doc/presentation}/toolbar/tool_bar.dart | 0 .../toolbar/toolbar_icon_button.dart | 0 .../doc/src => plugins/doc}/styles.dart | 19 +++--- .../grid/application}/block/block_cache.dart | 4 +- .../application}/block/block_listener.dart | 0 .../grid/application}/cell/cell_listener.dart | 0 .../cell/cell_service/cell_cache.dart | 0 .../cell/cell_service/cell_data_loader.dart | 0 .../cell_service/cell_data_persistence.dart | 0 .../cell_service/cell_field_notifier.dart | 0 .../cell/cell_service/cell_service.dart | 6 +- .../cell/cell_service/context_builder.dart | 0 .../application}/cell/checkbox_cell_bloc.dart | 0 .../grid/application}/cell/date_cal_bloc.dart | 40 +++++++++---- .../application}/cell/date_cell_bloc.dart | 0 .../application}/cell/number_cell_bloc.dart | 0 .../cell/select_option_cell_bloc.dart | 8 ++- .../cell/select_option_editor_bloc.dart | 41 ++++++++----- .../cell/select_option_service.dart | 6 +- .../application}/cell/text_cell_bloc.dart | 0 .../grid/application}/cell/url_cell_bloc.dart | 0 .../cell/url_cell_editor_bloc.dart | 0 .../field/field_action_sheet_bloc.dart | 0 .../application}/field/field_cell_bloc.dart | 16 +++-- .../application}/field/field_editor_bloc.dart | 0 .../application}/field/field_listener.dart | 0 .../application}/field/field_service.dart | 0 .../field/field_type_option_edit_bloc.dart | 0 .../field/grid_header_listener.dart | 0 .../grid/application}/field/grid_listenr.dart | 0 .../field/type_option/date_bloc.dart | 26 +++++--- .../type_option/edit_select_option_bloc.dart | 0 .../type_option/multi_select_type_option.dart | 14 +++-- .../field/type_option/number_bloc.dart | 14 +++-- .../field/type_option/number_format_bloc.dart | 0 .../select_option_type_option_bloc.dart | 0 .../single_select_type_option.dart | 14 +++-- .../type_option/type_option_service.dart | 6 +- .../grid/application}/grid_bloc.dart | 0 .../grid/application}/grid_header_bloc.dart | 14 +++-- .../grid/application}/grid_service.dart | 20 ++++--- .../grid/application}/prelude.dart | 0 .../row/row_action_sheet_bloc.dart | 8 ++- .../grid/application}/row/row_bloc.dart | 18 ++++-- .../application}/row/row_detail_bloc.dart | 8 ++- .../grid/application}/row/row_listener.dart | 0 .../grid/application}/row/row_service.dart | 31 ++++++---- .../application}/setting/property_bloc.dart | 25 +++++--- .../application}/setting/setting_bloc.dart | 0 .../presentation => }/plugins/grid/grid.dart | 6 +- .../controller/flowy_table_selection.dart | 0 .../presentation}/controller/grid_scroll.dart | 0 .../grid/presentation}/grid_page.dart | 43 ++++++++------ .../grid/presentation}/layout/layout.dart | 0 .../grid/presentation}/layout/sizes.dart | 0 .../widgets/cell/cell_accessory.dart | 0 .../widgets/cell/cell_builder.dart | 47 +++++++++++---- .../widgets/cell/cell_cotainer.dart | 31 ++++++---- .../widgets/cell/cell_decoration.dart | 0 .../widgets/cell/cell_shortcuts.dart | 0 .../widgets/cell/checkbox_cell.dart | 13 ++-- .../widgets/cell/date_cell/date_cell.dart | 12 ++-- .../widgets/cell/date_cell/date_editor.dart | 41 +++++++++---- .../widgets/cell/number_cell.dart | 14 +++-- .../presentation}/widgets/cell/prelude.dart | 1 + .../cell/select_option_cell/extension.dart | 0 .../select_option_cell.dart | 26 +++++--- .../select_option_editor.dart | 53 +++++++++++------ .../cell/select_option_cell/text_field.dart | 0 .../presentation}/widgets/cell/text_cell.dart | 5 +- .../widgets/cell/url_cell/cell_editor.dart | 11 ++-- .../widgets/cell/url_cell/url_cell.dart | 59 +++++++++++-------- .../widgets/common/text_field.dart | 0 .../widgets/footer/grid_footer.dart | 2 +- .../widgets/header/constants.dart | 0 .../widgets/header/field_cell.dart | 15 +++-- .../header/field_cell_action_sheet.dart | 36 +++++++---- .../widgets/header/field_editor.dart | 14 +++-- .../widgets/header/field_name_input.dart | 0 .../widgets/header/field_type_extension.dart | 0 .../widgets/header/field_type_list.dart | 5 +- .../header/field_type_option_editor.dart | 23 +++++--- .../widgets/header/grid_header.dart | 32 ++++++---- .../widgets/header/type_option/builder.dart | 6 +- .../widgets/header/type_option/checkbox.dart | 5 +- .../widgets/header/type_option/date.dart | 41 +++++++++---- .../header/type_option/multi_select.dart | 4 +- .../widgets/header/type_option/number.dart | 33 +++++++---- .../widgets/header/type_option/rich_text.dart | 5 +- .../header/type_option/select_option.dart | 48 ++++++++++----- .../type_option/select_option_editor.dart | 41 +++++++++---- .../header/type_option/single_select.dart | 4 +- .../widgets/header/type_option/url.dart | 5 +- .../presentation}/widgets/row/grid_row.dart | 20 ++++--- .../widgets/row/row_action_sheet.dart | 19 ++++-- .../presentation}/widgets/row/row_detail.dart | 32 +++++----- .../grid/presentation}/widgets/shortcuts.dart | 0 .../widgets/toolbar/grid_property.dart | 26 ++++---- .../widgets/toolbar/grid_setting.dart | 29 +++++---- .../widgets/toolbar/grid_toolbar.dart | 11 ++-- .../trash/application}/prelude.dart | 0 .../trash/application}/trash_bloc.dart | 17 ++++-- .../trash/application}/trash_listener.dart | 0 .../trash/application}/trash_service.dart | 0 .../presentation => }/plugins/trash/menu.dart | 14 +++-- .../plugins/trash/src/sizes.dart | 0 .../plugins/trash/src/trash_cell.dart | 0 .../plugins/trash/src/trash_header.dart | 0 .../plugins/trash/trash.dart | 22 ++++--- .../app_flowy/lib/startup/deps_resolver.dart | 12 ++-- .../lib/{ => startup}/plugin/plugin.dart | 5 +- .../lib/{ => startup}/plugin/src/runner.dart | 0 .../lib/{ => startup}/plugin/src/sandbox.dart | 0 frontend/app_flowy/lib/startup/startup.dart | 2 +- .../lib/startup/tasks/load_plugin.dart | 12 ++-- .../workspace/application/app/app_bloc.dart | 30 ++++++---- .../application/app/app_service.dart | 5 +- .../workspace/application/menu/menu_bloc.dart | 16 +++-- .../workspace/application/view/view_ext.dart | 2 +- .../presentation/home/home_screen.dart | 55 ++++++++++++----- .../presentation/home/home_stack.dart | 17 ++++-- .../home/menu/app/header/add_button.dart | 5 +- .../presentation/home/menu/menu.dart | 29 ++++++--- .../emoji_picker/src/emoji_button.dart | 18 ++++-- .../{plugins => }/widgets/left_bar_item.dart | 0 frontend/app_flowy/pubspec.lock | 7 +++ 146 files changed, 992 insertions(+), 540 deletions(-) rename frontend/app_flowy/lib/{workspace/presentation => }/plugins/blank/blank.dart (91%) rename frontend/app_flowy/lib/{workspace/application/board => plugins/board/application}/board_bloc.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation => }/plugins/board/board.dart (89%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/board/src => plugins/board/presentation}/board_page.dart (100%) rename frontend/app_flowy/lib/{workspace/application/doc => plugins/doc/application}/doc_bloc.dart (85%) rename frontend/app_flowy/lib/{workspace/application/doc => plugins/doc/application}/doc_service.dart (100%) rename frontend/app_flowy/lib/{workspace/application/doc => plugins/doc/application}/prelude.dart (100%) rename frontend/app_flowy/lib/{workspace/application/doc => plugins/doc/application}/share_bloc.dart (84%) rename frontend/app_flowy/lib/{workspace/application/doc => plugins/doc/application}/share_service.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation => }/plugins/doc/document.dart (85%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/doc/src => plugins/doc}/document_page.dart (85%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/doc/src/widget => plugins/doc/presentation}/banner.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/doc/src/widget => plugins/doc/presentation}/style_widgets.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/doc/src/widget => plugins/doc/presentation}/toolbar/check_button.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/doc/src/widget => plugins/doc/presentation}/toolbar/color_picker.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/doc/src/widget => plugins/doc/presentation}/toolbar/header_button.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/doc/src/widget => plugins/doc/presentation}/toolbar/history_button.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/doc/src/widget => plugins/doc/presentation}/toolbar/image_button.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/doc/src/widget => plugins/doc/presentation}/toolbar/link_button.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/doc/src/widget => plugins/doc/presentation}/toolbar/toggle_button.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/doc/src/widget => plugins/doc/presentation}/toolbar/tool_bar.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/doc/src/widget => plugins/doc/presentation}/toolbar/toolbar_icon_button.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/doc/src => plugins/doc}/styles.dart (86%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/block/block_cache.dart (90%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/block/block_listener.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/cell/cell_listener.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/cell/cell_service/cell_cache.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/cell/cell_service/cell_data_loader.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/cell/cell_service/cell_data_persistence.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/cell/cell_service/cell_field_notifier.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/cell/cell_service/cell_service.dart (90%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/cell/cell_service/context_builder.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/cell/checkbox_cell_bloc.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/cell/date_cal_bloc.dart (86%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/cell/date_cell_bloc.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/cell/number_cell_bloc.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/cell/select_option_cell_bloc.dart (87%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/cell/select_option_editor_bloc.dart (84%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/cell/select_option_service.dart (92%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/cell/text_cell_bloc.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/cell/url_cell_bloc.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/cell/url_cell_editor_bloc.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/field/field_action_sheet_bloc.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/field/field_cell_bloc.dart (86%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/field/field_editor_bloc.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/field/field_listener.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/field/field_service.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/field/field_type_option_edit_bloc.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/field/grid_header_listener.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/field/grid_listenr.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/field/type_option/date_bloc.dart (76%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/field/type_option/edit_select_option_bloc.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/field/type_option/multi_select_type_option.dart (81%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/field/type_option/number_bloc.dart (82%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/field/type_option/number_format_bloc.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/field/type_option/select_option_type_option_bloc.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/field/type_option/single_select_type_option.dart (81%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/field/type_option/type_option_service.dart (93%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/grid_bloc.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/grid_header_bloc.dart (83%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/grid_service.dart (89%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/prelude.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/row/row_action_sheet_bloc.dart (86%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/row/row_bloc.dart (81%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/row/row_detail_bloc.dart (84%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/row/row_listener.dart (100%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/row/row_service.dart (90%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/setting/property_bloc.dart (73%) rename frontend/app_flowy/lib/{workspace/application/grid => plugins/grid/application}/setting/setting_bloc.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation => }/plugins/grid/grid.dart (90%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/controller/flowy_table_selection.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/controller/grid_scroll.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/grid_page.dart (87%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/layout/layout.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/layout/sizes.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/cell/cell_accessory.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/cell/cell_builder.dart (77%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/cell/cell_cotainer.dart (80%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/cell/cell_decoration.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/cell/cell_shortcuts.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/cell/checkbox_cell.dart (77%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/cell/date_cell/date_cell.dart (85%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/cell/date_cell/date_editor.dart (90%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/cell/number_cell.dart (82%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/cell/prelude.dart (85%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/cell/select_option_cell/extension.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/cell/select_option_cell/select_option_cell.dart (86%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/cell/select_option_cell/select_option_editor.dart (82%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/cell/select_option_cell/text_field.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/cell/text_cell.dart (94%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/cell/url_cell/cell_editor.dart (87%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/cell/url_cell/url_cell.dart (73%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/common/text_field.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/footer/grid_footer.dart (91%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/constants.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/field_cell.dart (90%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/field_cell_action_sheet.dart (83%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/field_editor.dart (88%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/field_name_input.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/field_type_extension.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/field_type_list.dart (93%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/field_type_option_editor.dart (82%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/grid_header.dart (84%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/type_option/builder.dart (92%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/type_option/checkbox.dart (74%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/type_option/date.dart (88%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/type_option/multi_select.dart (85%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/type_option/number.dart (83%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/type_option/rich_text.dart (74%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/type_option/select_option.dart (79%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/type_option/select_option_editor.dart (81%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/type_option/single_select.dart (85%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/header/type_option/url.dart (74%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/row/grid_row.dart (89%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/row/row_action_sheet.dart (87%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/row/row_detail.dart (83%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/shortcuts.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/toolbar/grid_property.dart (81%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/toolbar/grid_setting.dart (82%) rename frontend/app_flowy/lib/{workspace/presentation/plugins/grid/src => plugins/grid/presentation}/widgets/toolbar/grid_toolbar.dart (85%) rename frontend/app_flowy/lib/{workspace/application/trash => plugins/trash/application}/prelude.dart (100%) rename frontend/app_flowy/lib/{workspace/application/trash => plugins/trash/application}/trash_bloc.dart (82%) rename frontend/app_flowy/lib/{workspace/application/trash => plugins/trash/application}/trash_listener.dart (100%) rename frontend/app_flowy/lib/{workspace/application/trash => plugins/trash/application}/trash_service.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation => }/plugins/trash/menu.dart (77%) rename frontend/app_flowy/lib/{workspace/presentation => }/plugins/trash/src/sizes.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation => }/plugins/trash/src/trash_cell.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation => }/plugins/trash/src/trash_header.dart (100%) rename frontend/app_flowy/lib/{workspace/presentation => }/plugins/trash/trash.dart (90%) rename frontend/app_flowy/lib/{ => startup}/plugin/plugin.dart (93%) rename frontend/app_flowy/lib/{ => startup}/plugin/src/runner.dart (100%) rename frontend/app_flowy/lib/{ => startup}/plugin/src/sandbox.dart (100%) rename frontend/app_flowy/lib/workspace/presentation/{plugins => }/widgets/left_bar_item.dart (100%) diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/blank/blank.dart b/frontend/app_flowy/lib/plugins/blank/blank.dart similarity index 91% rename from frontend/app_flowy/lib/workspace/presentation/plugins/blank/blank.dart rename to frontend/app_flowy/lib/plugins/blank/blank.dart index 05456f20f4..11f779eeb0 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/blank/blank.dart +++ b/frontend/app_flowy/lib/plugins/blank/blank.dart @@ -4,7 +4,7 @@ import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flutter/material.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; class BlankPluginBuilder extends PluginBuilder { @override @@ -42,7 +42,8 @@ class BlankPagePlugin extends Plugin { class BlankPagePluginDisplay extends PluginDisplay with NavigationItem { @override - Widget get leftBarItem => FlowyText.medium(LocaleKeys.blankPageTitle.tr(), fontSize: 12); + Widget get leftBarItem => + FlowyText.medium(LocaleKeys.blankPageTitle.tr(), fontSize: 12); @override Widget buildWidget() => const BlankPage(); diff --git a/frontend/app_flowy/lib/workspace/application/board/board_bloc.dart b/frontend/app_flowy/lib/plugins/board/application/board_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/board/board_bloc.dart rename to frontend/app_flowy/lib/plugins/board/application/board_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/board/board.dart b/frontend/app_flowy/lib/plugins/board/board.dart similarity index 89% rename from frontend/app_flowy/lib/workspace/presentation/plugins/board/board.dart rename to frontend/app_flowy/lib/plugins/board/board.dart index 30e8d2743c..11a6d415eb 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/board/board.dart +++ b/frontend/app_flowy/lib/plugins/board/board.dart @@ -1,10 +1,10 @@ import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; -import 'package:app_flowy/workspace/presentation/plugins/widgets/left_bar_item.dart'; +import 'package:app_flowy/workspace/presentation/widgets/left_bar_item.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:flutter/material.dart'; -import 'src/board_page.dart'; +import 'presentation/board_page.dart'; class BoardPluginBuilder implements PluginBuilder { @override diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/board/src/board_page.dart b/frontend/app_flowy/lib/plugins/board/presentation/board_page.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/board/src/board_page.dart rename to frontend/app_flowy/lib/plugins/board/presentation/board_page.dart diff --git a/frontend/app_flowy/lib/workspace/application/doc/doc_bloc.dart b/frontend/app_flowy/lib/plugins/doc/application/doc_bloc.dart similarity index 85% rename from frontend/app_flowy/lib/workspace/application/doc/doc_bloc.dart rename to frontend/app_flowy/lib/plugins/doc/application/doc_bloc.dart index 8be4c40d85..ed12227af0 100644 --- a/frontend/app_flowy/lib/workspace/application/doc/doc_bloc.dart +++ b/frontend/app_flowy/lib/plugins/doc/application/doc_bloc.dart @@ -1,7 +1,7 @@ import 'dart:convert'; -import 'package:app_flowy/workspace/application/doc/doc_service.dart'; -import 'package:app_flowy/workspace/application/trash/trash_service.dart'; +import 'package:app_flowy/plugins/trash/application/trash_service.dart'; import 'package:app_flowy/workspace/application/view/view_listener.dart'; +import 'package:app_flowy/plugins/doc/application/doc_service.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/trash.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; @@ -43,14 +43,17 @@ class DocumentBloc extends Bloc { emit(state.copyWith(isDeleted: false)); }, deletePermanently: (DeletePermanently value) async { - final result = await trashService.deleteViews([Tuple2(view.id, TrashType.TrashView)]); + final result = await trashService + .deleteViews([Tuple2(view.id, TrashType.TrashView)]); - final newState = result.fold((l) => state.copyWith(forceClose: true), (r) => state); + final newState = result.fold( + (l) => state.copyWith(forceClose: true), (r) => state); emit(newState); }, restorePage: (RestorePage value) async { final result = await trashService.putback(view.id); - final newState = result.fold((l) => state.copyWith(isDeleted: false), (r) => state); + final newState = result.fold( + (l) => state.copyWith(isDeleted: false), (r) => state); emit(newState); }, ); @@ -93,10 +96,12 @@ class DocumentBloc extends Bloc { final documentDelta = document.toDelta(); _composeDelta(delta, documentDelta); }); - emit(state.copyWith(loadingState: DocumentLoadingState.finish(left(unit)))); + emit(state.copyWith( + loadingState: DocumentLoadingState.finish(left(unit)))); }, (err) { - emit(state.copyWith(loadingState: DocumentLoadingState.finish(right(err)))); + emit(state.copyWith( + loadingState: DocumentLoadingState.finish(right(err)))); }, ); } @@ -156,5 +161,6 @@ class DocumentState with _$DocumentState { @freezed class DocumentLoadingState with _$DocumentLoadingState { const factory DocumentLoadingState.loading() = _Loading; - const factory DocumentLoadingState.finish(Either successOrFail) = _Finish; + const factory DocumentLoadingState.finish( + Either successOrFail) = _Finish; } diff --git a/frontend/app_flowy/lib/workspace/application/doc/doc_service.dart b/frontend/app_flowy/lib/plugins/doc/application/doc_service.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/doc/doc_service.dart rename to frontend/app_flowy/lib/plugins/doc/application/doc_service.dart diff --git a/frontend/app_flowy/lib/workspace/application/doc/prelude.dart b/frontend/app_flowy/lib/plugins/doc/application/prelude.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/doc/prelude.dart rename to frontend/app_flowy/lib/plugins/doc/application/prelude.dart diff --git a/frontend/app_flowy/lib/workspace/application/doc/share_bloc.dart b/frontend/app_flowy/lib/plugins/doc/application/share_bloc.dart similarity index 84% rename from frontend/app_flowy/lib/workspace/application/doc/share_bloc.dart rename to frontend/app_flowy/lib/plugins/doc/application/share_bloc.dart index ba3c7676c6..98904c035a 100644 --- a/frontend/app_flowy/lib/workspace/application/doc/share_bloc.dart +++ b/frontend/app_flowy/lib/plugins/doc/application/share_bloc.dart @@ -1,8 +1,8 @@ import 'dart:async'; import 'dart:io'; import 'package:app_flowy/startup/tasks/rust_sdk.dart'; -import 'package:app_flowy/workspace/application/doc/share_service.dart'; import 'package:app_flowy/workspace/application/markdown/delta_markdown.dart'; +import 'package:app_flowy/plugins/doc/application/share_service.dart'; import 'package:flowy_sdk/protobuf/flowy-text-block/entities.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; @@ -14,13 +14,15 @@ part 'share_bloc.freezed.dart'; class DocShareBloc extends Bloc { ShareService service; ViewPB view; - DocShareBloc({required this.view, required this.service}) : super(const DocShareState.initial()) { + DocShareBloc({required this.view, required this.service}) + : super(const DocShareState.initial()) { on((event, emit) async { await event.map( shareMarkdown: (ShareMarkdown value) async { await service.exportMarkdown(view.id).then((result) { result.fold( - (value) => emit(DocShareState.finish(left(_convertDeltaToMarkdown(value)))), + (value) => emit( + DocShareState.finish(left(_convertDeltaToMarkdown(value)))), (error) => emit(DocShareState.finish(right(error))), ); }); @@ -73,5 +75,6 @@ class DocShareEvent with _$DocShareEvent { class DocShareState with _$DocShareState { const factory DocShareState.initial() = _Initial; const factory DocShareState.loading() = _Loading; - const factory DocShareState.finish(Either successOrFail) = _Finish; + const factory DocShareState.finish( + Either successOrFail) = _Finish; } diff --git a/frontend/app_flowy/lib/workspace/application/doc/share_service.dart b/frontend/app_flowy/lib/plugins/doc/application/share_service.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/doc/share_service.dart rename to frontend/app_flowy/lib/plugins/doc/application/share_service.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/document.dart b/frontend/app_flowy/lib/plugins/doc/document.dart similarity index 85% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/document.dart rename to frontend/app_flowy/lib/plugins/doc/document.dart index c09843873d..91bae222c1 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/document.dart +++ b/frontend/app_flowy/lib/plugins/doc/document.dart @@ -1,14 +1,14 @@ library docuemnt_plugin; import 'package:app_flowy/generated/locale_keys.g.dart'; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/application/appearance.dart'; -import 'package:app_flowy/workspace/application/doc/share_bloc.dart'; import 'package:app_flowy/workspace/application/view/view_listener.dart'; +import 'package:app_flowy/plugins/doc/application/share_bloc.dart'; import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; import 'package:app_flowy/workspace/presentation/home/toast.dart'; -import 'package:app_flowy/workspace/presentation/plugins/widgets/left_bar_item.dart'; +import 'package:app_flowy/workspace/presentation/widgets/left_bar_item.dart'; import 'package:app_flowy/workspace/presentation/widgets/dialogs.dart'; import 'package:app_flowy/workspace/presentation/widgets/pop_up_action.dart'; import 'package:clipboard/clipboard.dart'; @@ -26,12 +26,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:provider/provider.dart'; -import 'src/document_page.dart'; - -export './src/document_page.dart'; -export './src/widget/toolbar/history_button.dart'; -export './src/widget/toolbar/tool_bar.dart'; -export './src/widget/toolbar/toolbar_icon_button.dart'; +import 'document_page.dart'; class DocumentPluginBuilder extends PluginBuilder { @override @@ -58,7 +53,9 @@ class DocumentPlugin implements Plugin { ViewListener? _listener; late PluginType _pluginType; - DocumentPlugin({required PluginType pluginType, required ViewPB view, Key? key}) : _view = view { + DocumentPlugin( + {required PluginType pluginType, required ViewPB view, Key? key}) + : _view = view { _pluginType = pluginType; _listener = getIt(param1: view); _listener?.start(onViewUpdated: (result) { @@ -112,7 +109,8 @@ class DocumentPluginDisplay extends PluginDisplay with NavigationItem { class DocumentShareButton extends StatelessWidget { final ViewPB view; - DocumentShareButton({Key? key, required this.view}) : super(key: ValueKey(view.hashCode)); + DocumentShareButton({Key? key, required this.view}) + : super(key: ValueKey(view.hashCode)); @override Widget build(BuildContext context) { @@ -149,7 +147,8 @@ class DocumentShareButton extends StatelessWidget { fontSize: 12, borderRadius: Corners.s6Border, color: Colors.lightBlue, - onPressed: () => _showActionList(context, Offset(-(buttonWidth / 2), 10)), + onPressed: () => _showActionList( + context, Offset(-(buttonWidth / 2), 10)), ), ), ), @@ -165,7 +164,8 @@ class DocumentShareButton extends StatelessWidget { case ExportType.Link: break; case ExportType.Markdown: - FlutterClipboard.copy(exportData.data).then((value) => Log.info('copied to clipboard')); + FlutterClipboard.copy(exportData.data) + .then((value) => Log.info('copied to clipboard')); break; case ExportType.Text: break; @@ -179,11 +179,15 @@ class DocumentShareButton extends StatelessWidget { result.fold(() {}, (action) { switch (action) { case ShareAction.markdown: - context.read().add(const DocShareEvent.shareMarkdown()); - showMessageToast('Exported to: ${LocaleKeys.notifications_export_path.tr()}'); + context + .read() + .add(const DocShareEvent.shareMarkdown()); + showMessageToast( + 'Exported to: ${LocaleKeys.notifications_export_path.tr()}'); break; case ShareAction.copyLink: - FlowyAlertDialog(title: LocaleKeys.shareAction_workInProgress.tr()).show(context); + FlowyAlertDialog(title: LocaleKeys.shareAction_workInProgress.tr()) + .show(context); break; } }); @@ -198,7 +202,8 @@ class DocumentShareButton extends StatelessWidget { class ShareActions with ActionList, FlowyOverlayDelegate { final Function(dartz.Option) onSelected; - final _items = ShareAction.values.map((action) => ShareActionWrapper(action)).toList(); + final _items = + ShareAction.values.map((action) => ShareActionWrapper(action)).toList(); ShareActions({required this.onSelected}); @@ -212,7 +217,8 @@ class ShareActions with ActionList, FlowyOverlayDelegate { List get items => _items; @override - void Function(dartz.Option p1) get selectCallback => (result) { + void Function(dartz.Option p1) get selectCallback => + (result) { result.fold( () => onSelected(dartz.none()), (wrapper) => onSelected( diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/document_page.dart b/frontend/app_flowy/lib/plugins/doc/document_page.dart similarity index 85% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/document_page.dart rename to frontend/app_flowy/lib/plugins/doc/document_page.dart index 3598c5a5ac..7a7550ed2c 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/document_page.dart +++ b/frontend/app_flowy/lib/plugins/doc/document_page.dart @@ -1,7 +1,7 @@ import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/application/appearance.dart'; -import 'package:app_flowy/workspace/application/doc/doc_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/doc/document.dart'; +import 'package:app_flowy/plugins/doc/presentation/banner.dart'; +import 'package:app_flowy/plugins/doc/presentation/toolbar/tool_bar.dart'; import 'package:flowy_infra_ui/style_widget/scrolling/styled_scroll_bar.dart'; import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flutter_quill/flutter_quill.dart' as quill; @@ -10,8 +10,8 @@ import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:provider/provider.dart'; +import 'application/doc_bloc.dart'; import 'styles.dart'; -import 'widget/banner.dart'; class DocumentPage extends StatefulWidget { final ViewPB view; @@ -29,7 +29,8 @@ class _DocumentPageState extends State { @override void initState() { - documentBloc = getIt(param1: super.widget.view)..add(const DocumentEvent.initial()); + documentBloc = getIt(param1: super.widget.view) + ..add(const DocumentEvent.initial()); super.initState(); } @@ -39,10 +40,12 @@ class _DocumentPageState extends State { providers: [ BlocProvider.value(value: documentBloc), ], - child: BlocBuilder(builder: (context, state) { + child: + BlocBuilder(builder: (context, state) { return state.loadingState.map( // loading: (_) => const FlowyProgressIndicator(), - loading: (_) => SizedBox.expand(child: Container(color: Colors.transparent)), + loading: (_) => + SizedBox.expand(child: Container(color: Colors.transparent)), finish: (result) => result.successOrFail.fold( (_) { if (state.forceClose) { @@ -90,8 +93,11 @@ class _DocumentPageState extends State { Widget _renderBanner(BuildContext context) { return DocumentBanner( - onRestore: () => context.read().add(const DocumentEvent.restorePage()), - onDelete: () => context.read().add(const DocumentEvent.deletePermanently()), + onRestore: () => + context.read().add(const DocumentEvent.restorePage()), + onDelete: () => context + .read() + .add(const DocumentEvent.deletePermanently()), ); } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/banner.dart b/frontend/app_flowy/lib/plugins/doc/presentation/banner.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/banner.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/banner.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/style_widgets.dart b/frontend/app_flowy/lib/plugins/doc/presentation/style_widgets.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/style_widgets.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/style_widgets.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/check_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/check_button.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/check_button.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/check_button.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/color_picker.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/color_picker.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/color_picker.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/color_picker.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/header_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/header_button.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/header_button.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/header_button.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/history_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/history_button.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/history_button.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/history_button.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/image_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/image_button.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/image_button.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/image_button.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/link_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/link_button.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/link_button.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/link_button.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/toggle_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/toggle_button.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/toggle_button.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/toggle_button.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/tool_bar.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/tool_bar.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/tool_bar.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/tool_bar.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/toolbar_icon_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/toolbar_icon_button.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/toolbar_icon_button.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/toolbar_icon_button.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/styles.dart b/frontend/app_flowy/lib/plugins/doc/styles.dart similarity index 86% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/styles.dart rename to frontend/app_flowy/lib/plugins/doc/styles.dart index c6eb292c49..d3dee3f97a 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/styles.dart +++ b/frontend/app_flowy/lib/plugins/doc/styles.dart @@ -1,11 +1,10 @@ +import 'package:app_flowy/plugins/doc/presentation/style_widgets.dart'; import 'package:flutter/material.dart'; import 'package:flutter_quill/flutter_quill.dart'; import 'package:provider/provider.dart'; import 'package:tuple/tuple.dart'; import 'package:flowy_infra/theme.dart'; -import 'widget/style_widgets.dart'; - DefaultStyles customStyles(BuildContext context) { const baseSpacing = Tuple2(6, 0); @@ -53,7 +52,8 @@ DefaultStyles customStyles(BuildContext context) { const Tuple2(8, 0), const Tuple2(0, 0), null), - paragraph: DefaultTextBlockStyle(baseStyle, const Tuple2(10, 0), const Tuple2(0, 0), null), + paragraph: DefaultTextBlockStyle( + baseStyle, const Tuple2(10, 0), const Tuple2(0, 0), null), bold: const TextStyle(fontWeight: FontWeight.bold), italic: const TextStyle(fontStyle: FontStyle.italic), small: const TextStyle(fontSize: 12, color: Colors.black45), @@ -78,8 +78,8 @@ DefaultStyles customStyles(BuildContext context) { const Tuple2(0, 0), const Tuple2(0, 0), null), - lists: - DefaultListBlockStyle(baseStyle, baseSpacing, const Tuple2(0, 6), null, StyleWidgetBuilder.checkbox(theme)), + lists: DefaultListBlockStyle(baseStyle, baseSpacing, const Tuple2(0, 6), + null, StyleWidgetBuilder.checkbox(theme)), quote: DefaultTextBlockStyle( TextStyle(color: baseStyle.color!.withOpacity(0.6)), baseSpacing, @@ -102,9 +102,12 @@ DefaultStyles customStyles(BuildContext context) { color: Colors.grey.shade50, borderRadius: BorderRadius.circular(2), )), - indent: DefaultTextBlockStyle(baseStyle, baseSpacing, const Tuple2(0, 6), null), - align: DefaultTextBlockStyle(baseStyle, const Tuple2(0, 0), const Tuple2(0, 0), null), - leading: DefaultTextBlockStyle(baseStyle, const Tuple2(0, 0), const Tuple2(0, 0), null), + indent: DefaultTextBlockStyle( + baseStyle, baseSpacing, const Tuple2(0, 6), null), + align: DefaultTextBlockStyle( + baseStyle, const Tuple2(0, 0), const Tuple2(0, 0), null), + leading: DefaultTextBlockStyle( + baseStyle, const Tuple2(0, 0), const Tuple2(0, 0), null), sizeSmall: const TextStyle(fontSize: 10), sizeLarge: const TextStyle(fontSize: 18), sizeHuge: const TextStyle(fontSize: 22)); diff --git a/frontend/app_flowy/lib/workspace/application/grid/block/block_cache.dart b/frontend/app_flowy/lib/plugins/grid/application/block/block_cache.dart similarity index 90% rename from frontend/app_flowy/lib/workspace/application/grid/block/block_cache.dart rename to frontend/app_flowy/lib/plugins/grid/application/block/block_cache.dart index 3c99c0e0e1..5ccff7c838 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/block/block_cache.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/block/block_cache.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:app_flowy/workspace/application/grid/grid_service.dart'; -import 'package:app_flowy/workspace/application/grid/row/row_service.dart'; +import 'package:app_flowy/plugins/grid/application/grid_service.dart'; +import 'package:app_flowy/plugins/grid/application/row/row_service.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/block_entities.pb.dart'; diff --git a/frontend/app_flowy/lib/workspace/application/grid/block/block_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/block/block_listener.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/block/block_listener.dart rename to frontend/app_flowy/lib/plugins/grid/application/block/block_listener.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_listener.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/cell_listener.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/cell_listener.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_cache.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_cache.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_cache.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_cache.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_data_loader.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_data_loader.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_data_loader.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_data_loader.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_data_persistence.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_data_persistence.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_data_persistence.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_data_persistence.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_field_notifier.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_field_notifier.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_field_notifier.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_field_notifier.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_service.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_service.dart similarity index 90% rename from frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_service.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_service.dart index 47cd67a55f..2bef94c16a 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_service.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_service.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'dart:collection'; -import 'package:app_flowy/workspace/application/grid/grid_service.dart'; +import 'package:app_flowy/plugins/grid/application/grid_service.dart'; import 'package:dartz/dartz.dart'; import 'package:equatable/equatable.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart'; @@ -14,8 +14,8 @@ import 'package:flowy_sdk/protobuf/flowy-grid/select_option.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/url_type_option_entities.pb.dart'; import 'package:flutter/foundation.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:app_flowy/workspace/application/grid/cell/cell_listener.dart'; -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_listener.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; import 'dart:convert' show utf8; import '../../field/type_option/type_option_service.dart'; diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/context_builder.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/context_builder.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/context_builder.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/context_builder.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/checkbox_cell_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/checkbox_cell_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/checkbox_cell_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/checkbox_cell_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/date_cal_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/date_cal_bloc.dart similarity index 86% rename from frontend/app_flowy/lib/workspace/application/grid/cell/date_cal_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/date_cal_bloc.dart index d99bdbf817..85dbbb40be 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/cell/date_cal_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/date_cal_bloc.dart @@ -1,6 +1,7 @@ import 'package:app_flowy/generated/locale_keys.g.dart'; -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; -import 'package:easy_localization/easy_localization.dart' show StringTranslateExtension; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; +import 'package:easy_localization/easy_localization.dart' + show StringTranslateExtension; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-error-code/code.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; @@ -40,7 +41,8 @@ class DateCalBloc extends Bloc { }, didReceiveCellUpdate: (DateCellDataPB? cellData) { final calData = calDataFromCellData(cellData); - final time = calData.foldRight("", (dateData, previous) => dateData.time); + final time = + calData.foldRight("", (dateData, previous) => dateData.time); emit(state.copyWith(calData: calData, time: time)); }, setIncludeTime: (includeTime) async { @@ -57,15 +59,18 @@ class DateCalBloc extends Bloc { await _updateDateData(emit, time: time); } }, - didUpdateCalData: (Option data, Option timeFormatError) { - emit(state.copyWith(calData: data, timeFormatError: timeFormatError)); + didUpdateCalData: + (Option data, Option timeFormatError) { + emit(state.copyWith( + calData: data, timeFormatError: timeFormatError)); }, ); }, ); } - Future _updateDateData(Emitter emit, {DateTime? date, String? time}) { + Future _updateDateData(Emitter emit, + {DateTime? date, String? time}) { final CalendarData newDateData = state.calData.fold( () => CalendarData(date: date ?? DateTime.now(), time: time), (dateData) { @@ -84,13 +89,17 @@ class DateCalBloc extends Bloc { return _saveDateData(emit, newDateData); } - Future _saveDateData(Emitter emit, CalendarData newCalData) async { + Future _saveDateData( + Emitter emit, CalendarData newCalData) async { if (state.calData == Some(newCalData)) { return; } - updateCalData(Option calData, Option timeFormatError) { - if (!isClosed) add(DateCalEvent.didUpdateCalData(calData, timeFormatError)); + updateCalData( + Option calData, Option timeFormatError) { + if (!isClosed) { + add(DateCalEvent.didUpdateCalData(calData, timeFormatError)); + } } cellContext.saveCellData(newCalData, resultCallback: (result) { @@ -172,7 +181,9 @@ class DateCalBloc extends Bloc { ); result.fold( - (l) => emit(state.copyWith(dateTypeOption: newDateTypeOption, timeHintText: _timeHintText(newDateTypeOption))), + (l) => emit(state.copyWith( + dateTypeOption: newDateTypeOption, + timeHintText: _timeHintText(newDateTypeOption))), (err) => Log.error(err), ); } @@ -182,14 +193,17 @@ class DateCalBloc extends Bloc { class DateCalEvent with _$DateCalEvent { const factory DateCalEvent.initial() = _Initial; const factory DateCalEvent.selectDay(DateTime day) = _SelectDay; - const factory DateCalEvent.setCalFormat(CalendarFormat format) = _CalendarFormat; + const factory DateCalEvent.setCalFormat(CalendarFormat format) = + _CalendarFormat; const factory DateCalEvent.setFocusedDay(DateTime day) = _FocusedDay; const factory DateCalEvent.setTimeFormat(TimeFormat timeFormat) = _TimeFormat; const factory DateCalEvent.setDateFormat(DateFormat dateFormat) = _DateFormat; const factory DateCalEvent.setIncludeTime(bool includeTime) = _IncludeTime; const factory DateCalEvent.setTime(String time) = _Time; - const factory DateCalEvent.didReceiveCellUpdate(DateCellDataPB? data) = _DidReceiveCellUpdate; - const factory DateCalEvent.didUpdateCalData(Option data, Option timeFormatError) = + const factory DateCalEvent.didReceiveCellUpdate(DateCellDataPB? data) = + _DidReceiveCellUpdate; + const factory DateCalEvent.didUpdateCalData( + Option data, Option timeFormatError) = _DidUpdateCalData; } diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/date_cell_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/date_cell_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/date_cell_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/date_cell_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/number_cell_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/number_cell_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/number_cell_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/number_cell_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/select_option_cell_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_cell_bloc.dart similarity index 87% rename from frontend/app_flowy/lib/workspace/application/grid/cell/select_option_cell_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/select_option_cell_bloc.dart index d0db8669fa..d823568e17 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/cell/select_option_cell_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_cell_bloc.dart @@ -2,11 +2,12 @@ import 'dart:async'; import 'package:flowy_sdk/protobuf/flowy-grid/select_option.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; part 'select_option_cell_bloc.freezed.dart'; -class SelectOptionCellBloc extends Bloc { +class SelectOptionCellBloc + extends Bloc { final GridSelectOptionCellController cellContext; void Function()? _onCellChangedFn; @@ -66,7 +67,8 @@ class SelectOptionCellState with _$SelectOptionCellState { required List selectedOptions, }) = _SelectOptionCellState; - factory SelectOptionCellState.initial(GridSelectOptionCellController context) { + factory SelectOptionCellState.initial( + GridSelectOptionCellController context) { final data = context.getCellData(); return SelectOptionCellState( diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/select_option_editor_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_editor_bloc.dart similarity index 84% rename from frontend/app_flowy/lib/workspace/application/grid/cell/select_option_editor_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/select_option_editor_bloc.dart index 0990dca28a..6ee7fe9f32 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/cell/select_option_editor_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_editor_bloc.dart @@ -4,20 +4,22 @@ import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/select_option.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; import 'select_option_service.dart'; import 'package:collection/collection.dart'; part 'select_option_editor_bloc.freezed.dart'; -class SelectOptionCellEditorBloc extends Bloc { +class SelectOptionCellEditorBloc + extends Bloc { final SelectOptionService _selectOptionService; final GridSelectOptionCellController cellController; Timer? _delayOperation; SelectOptionCellEditorBloc({ required this.cellController, - }) : _selectOptionService = SelectOptionService(cellId: cellController.cellId), + }) : _selectOptionService = + SelectOptionService(cellId: cellController.cellId), super(SelectOptionEditorState.initial(cellController)) { on( (event, emit) async { @@ -87,7 +89,8 @@ class SelectOptionCellEditorBloc extends Bloc option.id == optionId); + final hasSelected = state.selectedOptions + .firstWhereOrNull((option) => option.id == optionId); if (hasSelected != null) { _selectOptionService.unSelect(optionId: optionId); } else { @@ -96,7 +99,8 @@ class SelectOptionCellEditorBloc extends Bloc emit) { - final _MakeOptionResult result = _makeOptions(Some(optionName), state.allOptions); + final _MakeOptionResult result = + _makeOptions(Some(optionName), state.allOptions); emit(state.copyWith( filter: Some(optionName), options: result.options, @@ -112,7 +116,8 @@ class SelectOptionCellEditorBloc extends Bloc add(SelectOptionEditorEvent.didReceiveOptions(data.options, data.selectOptions)), + (data) => add(SelectOptionEditorEvent.didReceiveOptions( + data.options, data.selectOptions)), (err) { Log.error(err); return null; @@ -122,7 +127,8 @@ class SelectOptionCellEditorBloc extends Bloc filter, List allOptions) { + _MakeOptionResult _makeOptions( + Option filter, List allOptions) { final List options = List.from(allOptions); Option createOption = filter; @@ -165,12 +171,18 @@ class SelectOptionCellEditorBloc extends Bloc options, List selectedOptions) = _DidReceiveOptions; - const factory SelectOptionEditorEvent.newOption(String optionName) = _NewOption; - const factory SelectOptionEditorEvent.selectOption(String optionId) = _SelectOption; - const factory SelectOptionEditorEvent.updateOption(SelectOptionPB option) = _UpdateOption; - const factory SelectOptionEditorEvent.deleteOption(SelectOptionPB option) = _DeleteOption; - const factory SelectOptionEditorEvent.filterOption(String optionName) = _SelectOptionFilter; + List options, List selectedOptions) = + _DidReceiveOptions; + const factory SelectOptionEditorEvent.newOption(String optionName) = + _NewOption; + const factory SelectOptionEditorEvent.selectOption(String optionId) = + _SelectOption; + const factory SelectOptionEditorEvent.updateOption(SelectOptionPB option) = + _UpdateOption; + const factory SelectOptionEditorEvent.deleteOption(SelectOptionPB option) = + _DeleteOption; + const factory SelectOptionEditorEvent.filterOption(String optionName) = + _SelectOptionFilter; } @freezed @@ -183,7 +195,8 @@ class SelectOptionEditorState with _$SelectOptionEditorState { required Option filter, }) = _SelectOptionEditorState; - factory SelectOptionEditorState.initial(GridSelectOptionCellController context) { + factory SelectOptionEditorState.initial( + GridSelectOptionCellController context) { final data = context.getCellData(loadIfNotExist: false); return SelectOptionEditorState( options: data?.options ?? [], diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/select_option_service.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_service.dart similarity index 92% rename from frontend/app_flowy/lib/workspace/application/grid/cell/select_option_service.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/select_option_service.dart index b6966a3e4e..9172450ef0 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/cell/select_option_service.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_service.dart @@ -2,7 +2,7 @@ import 'package:dartz/dartz.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/cell_entities.pb.dart'; -import 'package:app_flowy/workspace/application/grid/field/type_option/type_option_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_service.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/select_option.pb.dart'; import 'cell_service/cell_service.dart'; @@ -15,7 +15,9 @@ class SelectOptionService { String get rowId => cellId.rowId; Future> create({required String name}) { - return TypeOptionService(gridId: gridId, fieldId: fieldId).newOption(name: name).then( + return TypeOptionService(gridId: gridId, fieldId: fieldId) + .newOption(name: name) + .then( (result) { return result.fold( (option) { diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/text_cell_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/text_cell_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/text_cell_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/text_cell_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/url_cell_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/url_cell_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/url_cell_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/url_cell_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/url_cell_editor_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/url_cell_editor_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/url_cell_editor_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/url_cell_editor_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/field_action_sheet_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/field_action_sheet_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/field_action_sheet_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/field_action_sheet_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/field_cell_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/field_cell_bloc.dart similarity index 86% rename from frontend/app_flowy/lib/workspace/application/grid/field/field_cell_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/field_cell_bloc.dart index 8a2a0e2d06..ce09ba20bf 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/field/field_cell_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/field/field_cell_bloc.dart @@ -1,5 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/field/field_listener.dart'; -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_listener.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -15,7 +15,8 @@ class FieldCellBloc extends Bloc { FieldCellBloc({ required GridFieldCellContext cellContext, }) : _fieldListener = SingleFieldListener(fieldId: cellContext.field.id), - _fieldService = FieldService(gridId: cellContext.gridId, fieldId: cellContext.field.id), + _fieldService = FieldService( + gridId: cellContext.gridId, fieldId: cellContext.field.id), super(FieldCellState.initial(cellContext)) { on( (event, emit) async { @@ -62,8 +63,10 @@ class FieldCellBloc extends Bloc { @freezed class FieldCellEvent with _$FieldCellEvent { const factory FieldCellEvent.initial() = _InitialCell; - const factory FieldCellEvent.didReceiveFieldUpdate(GridFieldPB field) = _DidReceiveFieldUpdate; - const factory FieldCellEvent.startUpdateWidth(double offset) = _StartUpdateWidth; + const factory FieldCellEvent.didReceiveFieldUpdate(GridFieldPB field) = + _DidReceiveFieldUpdate; + const factory FieldCellEvent.startUpdateWidth(double offset) = + _StartUpdateWidth; const factory FieldCellEvent.endUpdateWidth() = _EndUpdateWidth; } @@ -75,7 +78,8 @@ class FieldCellState with _$FieldCellState { required double width, }) = _FieldCellState; - factory FieldCellState.initial(GridFieldCellContext cellContext) => FieldCellState( + factory FieldCellState.initial(GridFieldCellContext cellContext) => + FieldCellState( gridId: cellContext.gridId, field: cellContext.field, width: cellContext.field.width.toDouble(), diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/field_editor_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/field_editor_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/field_editor_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/field_editor_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/field_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/field/field_listener.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/field_listener.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/field_listener.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/field_service.dart b/frontend/app_flowy/lib/plugins/grid/application/field/field_service.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/field_service.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/field_service.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/field_type_option_edit_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/field_type_option_edit_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/field_type_option_edit_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/field_type_option_edit_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/grid_header_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/field/grid_header_listener.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/grid_header_listener.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/grid_header_listener.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/grid_listenr.dart b/frontend/app_flowy/lib/plugins/grid/application/field/grid_listenr.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/grid_listenr.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/grid_listenr.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/date_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/date_bloc.dart similarity index 76% rename from frontend/app_flowy/lib/workspace/application/grid/field/type_option/date_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/type_option/date_bloc.dart index 00deff56e7..f995a0bad0 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/date_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/date_bloc.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/type_option_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_service.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/date_type_option.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/date_type_option_entities.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -16,20 +16,24 @@ class DateTypeOptionDataParser extends TypeOptionDataParser { } } -class DateTypeOptionBloc extends Bloc { +class DateTypeOptionBloc + extends Bloc { DateTypeOptionBloc({required DateTypeOptionContext typeOptionContext}) : super(DateTypeOptionState.initial(typeOptionContext.typeOption)) { on( (event, emit) async { event.map( didSelectDateFormat: (_DidSelectDateFormat value) { - emit(state.copyWith(typeOption: _updateTypeOption(dateFormat: value.format))); + emit(state.copyWith( + typeOption: _updateTypeOption(dateFormat: value.format))); }, didSelectTimeFormat: (_DidSelectTimeFormat value) { - emit(state.copyWith(typeOption: _updateTypeOption(timeFormat: value.format))); + emit(state.copyWith( + typeOption: _updateTypeOption(timeFormat: value.format))); }, includeTime: (_IncludeTime value) { - emit(state.copyWith(typeOption: _updateTypeOption(includeTime: value.includeTime))); + emit(state.copyWith( + typeOption: _updateTypeOption(includeTime: value.includeTime))); }, ); }, @@ -65,9 +69,12 @@ class DateTypeOptionBloc extends Bloc @freezed class DateTypeOptionEvent with _$DateTypeOptionEvent { - const factory DateTypeOptionEvent.didSelectDateFormat(DateFormat format) = _DidSelectDateFormat; - const factory DateTypeOptionEvent.didSelectTimeFormat(TimeFormat format) = _DidSelectTimeFormat; - const factory DateTypeOptionEvent.includeTime(bool includeTime) = _IncludeTime; + const factory DateTypeOptionEvent.didSelectDateFormat(DateFormat format) = + _DidSelectDateFormat; + const factory DateTypeOptionEvent.didSelectTimeFormat(TimeFormat format) = + _DidSelectTimeFormat; + const factory DateTypeOptionEvent.includeTime(bool includeTime) = + _IncludeTime; } @freezed @@ -76,5 +83,6 @@ class DateTypeOptionState with _$DateTypeOptionState { required DateTypeOption typeOption, }) = _DateTypeOptionState; - factory DateTypeOptionState.initial(DateTypeOption typeOption) => DateTypeOptionState(typeOption: typeOption); + factory DateTypeOptionState.initial(DateTypeOption typeOption) => + DateTypeOptionState(typeOption: typeOption); } diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/edit_select_option_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/edit_select_option_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/type_option/edit_select_option_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/type_option/edit_select_option_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/multi_select_type_option.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/multi_select_type_option.dart similarity index 81% rename from frontend/app_flowy/lib/workspace/application/grid/field/type_option/multi_select_type_option.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/type_option/multi_select_type_option.dart index e0e242305b..ebc88aaf95 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/multi_select_type_option.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/multi_select_type_option.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/multi_select_type_option.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/select_option.pb.dart'; @@ -7,7 +7,8 @@ import 'package:protobuf/protobuf.dart'; import 'select_option_type_option_bloc.dart'; import 'type_option_service.dart'; -class MultiSelectTypeOptionContext extends TypeOptionWidgetContext +class MultiSelectTypeOptionContext + extends TypeOptionWidgetContext with SelectOptionTypeOptionAction { final TypeOptionService service; @@ -25,7 +26,8 @@ class MultiSelectTypeOptionContext extends TypeOptionWidgetContext element.id == option.id); + final index = + typeOption.options.indexWhere((element) => element.id == option.id); if (index != -1) { typeOption.options.removeAt(index); } @@ -61,7 +63,8 @@ class MultiSelectTypeOptionContext extends TypeOptionWidgetContext element.id == option.id); + final index = + typeOption.options.indexWhere((element) => element.id == option.id); if (index != -1) { typeOption.options[index] = option; } @@ -71,7 +74,8 @@ class MultiSelectTypeOptionContext extends TypeOptionWidgetContext { +class MultiSelectTypeOptionWidgetDataParser + extends TypeOptionDataParser { @override MultiSelectTypeOption fromBuffer(List buffer) { return MultiSelectTypeOption.fromBuffer(buffer); diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/number_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/number_bloc.dart similarity index 82% rename from frontend/app_flowy/lib/workspace/application/grid/field/type_option/number_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/type_option/number_bloc.dart index 804ce3ee11..7228adf90e 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/number_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/number_bloc.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/type_option_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_service.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/format.pbenum.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/number_type_option.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -10,14 +10,16 @@ part 'number_bloc.freezed.dart'; typedef NumberTypeOptionContext = TypeOptionWidgetContext; -class NumberTypeOptionWidgetDataParser extends TypeOptionDataParser { +class NumberTypeOptionWidgetDataParser + extends TypeOptionDataParser { @override NumberTypeOption fromBuffer(List buffer) { return NumberTypeOption.fromBuffer(buffer); } } -class NumberTypeOptionBloc extends Bloc { +class NumberTypeOptionBloc + extends Bloc { NumberTypeOptionBloc({required NumberTypeOptionContext typeOptionContext}) : super(NumberTypeOptionState.initial(typeOptionContext.typeOption)) { on( @@ -46,7 +48,8 @@ class NumberTypeOptionBloc extends Bloc NumberTypeOptionState( + factory NumberTypeOptionState.initial(NumberTypeOption typeOption) => + NumberTypeOptionState( typeOption: typeOption, ); } diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/number_format_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/number_format_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/type_option/number_format_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/type_option/number_format_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/select_option_type_option_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/select_option_type_option_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/type_option/select_option_type_option_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/type_option/select_option_type_option_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/single_select_type_option.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/single_select_type_option.dart similarity index 81% rename from frontend/app_flowy/lib/workspace/application/grid/field/type_option/single_select_type_option.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/type_option/single_select_type_option.dart index 857838de38..bdf89b5b78 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/single_select_type_option.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/single_select_type_option.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/select_option.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/single_select_type_option.pb.dart'; @@ -7,7 +7,8 @@ import 'package:protobuf/protobuf.dart'; import 'select_option_type_option_bloc.dart'; import 'type_option_service.dart'; -class SingleSelectTypeOptionContext extends TypeOptionWidgetContext +class SingleSelectTypeOptionContext + extends TypeOptionWidgetContext with SelectOptionTypeOptionAction { final TypeOptionService service; @@ -25,7 +26,8 @@ class SingleSelectTypeOptionContext extends TypeOptionWidgetContext element.id == option.id); + final index = + typeOption.options.indexWhere((element) => element.id == option.id); if (index != -1) { typeOption.options.removeAt(index); } @@ -61,7 +63,8 @@ class SingleSelectTypeOptionContext extends TypeOptionWidgetContext element.id == option.id); + final index = + typeOption.options.indexWhere((element) => element.id == option.id); if (index != -1) { typeOption.options[index] = option; } @@ -71,7 +74,8 @@ class SingleSelectTypeOptionContext extends TypeOptionWidgetContext { +class SingleSelectTypeOptionWidgetDataParser + extends TypeOptionDataParser { @override SingleSelectTypeOptionPB fromBuffer(List buffer) { return SingleSelectTypeOptionPB.fromBuffer(buffer); diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/type_option_service.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/type_option_service.dart similarity index 93% rename from frontend/app_flowy/lib/workspace/application/grid/field/type_option/type_option_service.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/type_option/type_option_service.dart index fca6995b3f..d7873e0c86 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/type_option_service.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/type_option_service.dart @@ -1,6 +1,6 @@ import 'dart:typed_data'; -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; import 'package:dartz/dartz.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; @@ -92,7 +92,9 @@ class TypeOptionContext2 { return Future(() => left(_data!)); } - return _fieldService.getFieldTypeOptionData(fieldType: field.fieldType).then((result) { + return _fieldService + .getFieldTypeOptionData(fieldType: field.fieldType) + .then((result) { return result.fold( (data) { _data = dataBuilder.fromBuffer(data.typeOptionData); diff --git a/frontend/app_flowy/lib/workspace/application/grid/grid_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/grid_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/grid_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/grid_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/grid_header_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/grid_header_bloc.dart similarity index 83% rename from frontend/app_flowy/lib/workspace/application/grid/grid_header_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/grid_header_bloc.dart index b34064da13..06a6b791d8 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/grid_header_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/grid_header_bloc.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -33,7 +33,8 @@ class GridHeaderBloc extends Bloc { ); } - Future _moveField(_MoveField value, Emitter emit) async { + Future _moveField( + _MoveField value, Emitter emit) async { final fields = List.from(state.fields); fields.insert(value.toIndex, fields.removeAt(value.fromIndex)); emit(state.copyWith(fields: fields)); @@ -62,13 +63,16 @@ class GridHeaderBloc extends Bloc { @freezed class GridHeaderEvent with _$GridHeaderEvent { const factory GridHeaderEvent.initial() = _InitialHeader; - const factory GridHeaderEvent.didReceiveFieldUpdate(List fields) = _DidReceiveFieldUpdate; - const factory GridHeaderEvent.moveField(GridFieldPB field, int fromIndex, int toIndex) = _MoveField; + const factory GridHeaderEvent.didReceiveFieldUpdate( + List fields) = _DidReceiveFieldUpdate; + const factory GridHeaderEvent.moveField( + GridFieldPB field, int fromIndex, int toIndex) = _MoveField; } @freezed class GridHeaderState with _$GridHeaderState { - const factory GridHeaderState({required List fields}) = _GridHeaderState; + const factory GridHeaderState({required List fields}) = + _GridHeaderState; factory GridHeaderState.initial(List fields) { // final List newFields = List.from(fields); diff --git a/frontend/app_flowy/lib/workspace/application/grid/grid_service.dart b/frontend/app_flowy/lib/plugins/grid/application/grid_service.dart similarity index 89% rename from frontend/app_flowy/lib/workspace/application/grid/grid_service.dart rename to frontend/app_flowy/lib/plugins/grid/application/grid_service.dart index 1f8b4336fc..14fbf2bf62 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/grid_service.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/grid_service.dart @@ -1,6 +1,6 @@ import 'dart:collection'; -import 'package:app_flowy/workspace/application/grid/field/grid_listenr.dart'; +import 'package:app_flowy/plugins/grid/application/field/grid_listenr.dart'; import 'package:dartz/dartz.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart'; import 'package:flowy_sdk/log.dart'; @@ -26,13 +26,15 @@ class GridService { return GridEventGetGrid(payload).send(); } - Future> createRow({Option? startRowId}) { + Future> createRow( + {Option? startRowId}) { CreateRowPayloadPB payload = CreateRowPayloadPB.create()..gridId = gridId; startRowId?.fold(() => null, (id) => payload.startRowId = id); return GridEventCreateRow(payload).send(); } - Future> getFields({required List fieldIds}) { + Future> getFields( + {required List fieldIds}) { final payload = QueryFieldPayloadPB.create() ..gridId = gridId ..fieldIds = RepeatedGridFieldIdPB(items: fieldIds); @@ -64,9 +66,11 @@ class GridFieldCache { final GridFieldsListener _fieldListener; FieldsNotifier? _fieldNotifier = FieldsNotifier(); final Map _fieldsCallbackMap = {}; - final Map _changesetCallbackMap = {}; + final Map + _changesetCallbackMap = {}; - GridFieldCache({required this.gridId}) : _fieldListener = GridFieldsListener(gridId: gridId) { + GridFieldCache({required this.gridId}) + : _fieldListener = GridFieldsListener(gridId: gridId) { _fieldListener.start(onFieldsChanged: (result) { result.fold( (changeset) { @@ -88,7 +92,8 @@ class GridFieldCache { _fieldNotifier = null; } - UnmodifiableListView get unmodifiableFields => UnmodifiableListView(_fieldNotifier?.fields ?? []); + UnmodifiableListView get unmodifiableFields => + UnmodifiableListView(_fieldNotifier?.fields ?? []); List get fields => [..._fieldNotifier?.fields ?? []]; @@ -175,7 +180,8 @@ class GridFieldCache { } final List newFields = fields; for (final updatedField in updatedFields) { - final index = newFields.indexWhere((field) => field.id == updatedField.id); + final index = + newFields.indexWhere((field) => field.id == updatedField.id); if (index != -1) { newFields.removeAt(index); newFields.insert(index, updatedField); diff --git a/frontend/app_flowy/lib/workspace/application/grid/prelude.dart b/frontend/app_flowy/lib/plugins/grid/application/prelude.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/prelude.dart rename to frontend/app_flowy/lib/plugins/grid/application/prelude.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/row/row_action_sheet_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/row/row_action_sheet_bloc.dart similarity index 86% rename from frontend/app_flowy/lib/workspace/application/grid/row/row_action_sheet_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/row/row_action_sheet_bloc.dart index 9fe12f3ff5..7881e485cb 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/row/row_action_sheet_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/row/row_action_sheet_bloc.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/row/row_service.dart'; +import 'package:app_flowy/plugins/grid/application/row/row_service.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -8,7 +8,8 @@ import 'package:dartz/dartz.dart'; part 'row_action_sheet_bloc.freezed.dart'; -class RowActionSheetBloc extends Bloc { +class RowActionSheetBloc + extends Bloc { final RowService _rowService; RowActionSheetBloc({required GridRowInfo rowData}) @@ -56,7 +57,8 @@ class RowActionSheetState with _$RowActionSheetState { required GridRowInfo rowData, }) = _RowActionSheetState; - factory RowActionSheetState.initial(GridRowInfo rowData) => RowActionSheetState( + factory RowActionSheetState.initial(GridRowInfo rowData) => + RowActionSheetState( rowData: rowData, ); } diff --git a/frontend/app_flowy/lib/workspace/application/grid/row/row_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/row/row_bloc.dart similarity index 81% rename from frontend/app_flowy/lib/workspace/application/grid/row/row_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/row/row_bloc.dart index 1d7224383d..3b755d1524 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/row/row_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/row/row_bloc.dart @@ -1,5 +1,5 @@ import 'dart:collection'; -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; import 'package:equatable/equatable.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -34,7 +34,9 @@ class RowBloc extends Bloc { _rowService.createRow(); }, didReceiveCellDatas: (_DidReceiveCellDatas value) async { - final fields = value.gridCellMap.values.map((e) => GridCellEquatable(e.field)).toList(); + final fields = value.gridCellMap.values + .map((e) => GridCellEquatable(e.field)) + .toList(); final snapshots = UnmodifiableListView(fields); emit(state.copyWith( gridCellMap: value.gridCellMap, @@ -59,7 +61,8 @@ class RowBloc extends Bloc { Future _startListening() async { _rowListenFn = _rowCache.addListener( rowId: state.rowInfo.id, - onCellUpdated: (cellDatas, reason) => add(RowEvent.didReceiveCellDatas(cellDatas, reason)), + onCellUpdated: (cellDatas, reason) => + add(RowEvent.didReceiveCellDatas(cellDatas, reason)), listenWhen: () => !isClosed, ); } @@ -69,7 +72,8 @@ class RowBloc extends Bloc { class RowEvent with _$RowEvent { const factory RowEvent.initial() = _InitialRow; const factory RowEvent.createRow() = _CreateRow; - const factory RowEvent.didReceiveCellDatas(GridCellMap gridCellMap, GridRowChangeReason reason) = + const factory RowEvent.didReceiveCellDatas( + GridCellMap gridCellMap, GridRowChangeReason reason) = _DidReceiveCellDatas; } @@ -82,10 +86,12 @@ class RowState with _$RowState { GridRowChangeReason? changeReason, }) = _RowState; - factory RowState.initial(GridRowInfo rowInfo, GridCellMap cellDataMap) => RowState( + factory RowState.initial(GridRowInfo rowInfo, GridCellMap cellDataMap) => + RowState( rowInfo: rowInfo, gridCellMap: cellDataMap, - snapshots: UnmodifiableListView(cellDataMap.values.map((e) => GridCellEquatable(e.field)).toList()), + snapshots: UnmodifiableListView( + cellDataMap.values.map((e) => GridCellEquatable(e.field)).toList()), ); } diff --git a/frontend/app_flowy/lib/workspace/application/grid/row/row_detail_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/row/row_detail_bloc.dart similarity index 84% rename from frontend/app_flowy/lib/workspace/application/grid/row/row_detail_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/row/row_detail_bloc.dart index 966310fe8c..900b56f9a5 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/row/row_detail_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/row/row_detail_bloc.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'dart:async'; @@ -42,7 +42,8 @@ class RowDetailBloc extends Bloc { Future _startListening() async { _rowListenFn = _rowCache.addListener( rowId: rowInfo.id, - onCellUpdated: (cellDatas, reason) => add(RowDetailEvent.didReceiveCellDatas(cellDatas.values.toList())), + onCellUpdated: (cellDatas, reason) => + add(RowDetailEvent.didReceiveCellDatas(cellDatas.values.toList())), listenWhen: () => !isClosed, ); } @@ -58,7 +59,8 @@ class RowDetailBloc extends Bloc { @freezed class RowDetailEvent with _$RowDetailEvent { const factory RowDetailEvent.initial() = _Initial; - const factory RowDetailEvent.didReceiveCellDatas(List gridCells) = _DidReceiveCellDatas; + const factory RowDetailEvent.didReceiveCellDatas( + List gridCells) = _DidReceiveCellDatas; } @freezed diff --git a/frontend/app_flowy/lib/workspace/application/grid/row/row_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/row/row_listener.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/row/row_listener.dart rename to frontend/app_flowy/lib/plugins/grid/application/row/row_listener.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/row/row_service.dart b/frontend/app_flowy/lib/plugins/grid/application/row/row_service.dart similarity index 90% rename from frontend/app_flowy/lib/workspace/application/grid/row/row_service.dart rename to frontend/app_flowy/lib/plugins/grid/application/row/row_service.dart index 893ebb719b..4fd18a1fdd 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/row/row_service.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/row/row_service.dart @@ -1,5 +1,5 @@ import 'dart:collection'; -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; import 'package:dartz/dartz.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart'; import 'package:flowy_sdk/log.dart'; @@ -53,9 +53,12 @@ class GridRowCache { _rowChangeReasonNotifier = _GridRowChangesetNotifier(), _fieldNotifier = notifier { // - notifier.onFieldsChanged(() => _rowChangeReasonNotifier.receive(const GridRowChangeReason.fieldDidChange())); + notifier.onFieldsChanged(() => _rowChangeReasonNotifier + .receive(const GridRowChangeReason.fieldDidChange())); notifier.onFieldChanged((field) => _cellCache.remove(field.id)); - _rowInfos = block.rows.map((rowInfo) => buildGridRow(rowInfo.id, rowInfo.height.toDouble())).toList(); + _rowInfos = block.rows + .map((rowInfo) => buildGridRow(rowInfo.id, rowInfo.height.toDouble())) + .toList(); } Future dispose() async { @@ -81,7 +84,9 @@ class GridRowCache { final List newRows = []; final DeletedIndexs deletedIndex = []; - final Map deletedRowByRowId = {for (var rowId in deletedRows) rowId: rowId}; + final Map deletedRowByRowId = { + for (var rowId in deletedRows) rowId: rowId + }; _rowInfos.asMap().forEach((index, row) { if (deletedRowByRowId[row.id] == null) { @@ -107,7 +112,8 @@ class GridRowCache { rowId: insertRow.rowId, ); insertIndexs.add(insertIndex); - _rowInfos.insert(insertRow.index, (buildGridRow(insertRow.rowId, insertRow.height.toDouble()))); + _rowInfos.insert(insertRow.index, + (buildGridRow(insertRow.rowId, insertRow.height.toDouble()))); } _rowChangeReasonNotifier.receive(GridRowChangeReason.insert(insertIndexs)); @@ -126,7 +132,8 @@ class GridRowCache { _rowByRowId[rowId] = updatedRow.row; _rowInfos.removeAt(index); - _rowInfos.insert(index, buildGridRow(rowId, updatedRow.row.height.toDouble())); + _rowInfos.insert( + index, buildGridRow(rowId, updatedRow.row.height.toDouble())); updatedIndexs[rowId] = UpdatedIndex(index: index, rowId: rowId); } } @@ -225,7 +232,8 @@ class GridRowCache { updatedRow.freeze(); _rowByRowId[updatedRow.id] = updatedRow; - final index = _rowInfos.indexWhere((gridRow) => gridRow.id == updatedRow.id); + final index = + _rowInfos.indexWhere((gridRow) => gridRow.id == updatedRow.id); if (index != -1) { // update the corresponding row in _rows if they are not the same if (_rowInfos[index].rawRow != updatedRow) { @@ -237,7 +245,8 @@ class GridRowCache { updatedIndexs[row.id] = UpdatedIndex(index: index, rowId: row.id); // - _rowChangeReasonNotifier.receive(GridRowChangeReason.update(updatedIndexs)); + _rowChangeReasonNotifier + .receive(GridRowChangeReason.update(updatedIndexs)); } } } @@ -275,7 +284,8 @@ class RowService { final String blockId; final String rowId; - RowService({required this.gridId, required this.blockId, required this.rowId}); + RowService( + {required this.gridId, required this.blockId, required this.rowId}); Future> createRow() { CreateRowPayloadPB payload = CreateRowPayloadPB.create() @@ -285,7 +295,8 @@ class RowService { return GridEventCreateRow(payload).send(); } - Future> moveRow(String rowId, int fromIndex, int toIndex) { + Future> moveRow( + String rowId, int fromIndex, int toIndex) { final payload = MoveItemPayloadPB.create() ..gridId = gridId ..itemId = rowId diff --git a/frontend/app_flowy/lib/workspace/application/grid/setting/property_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/setting/property_bloc.dart similarity index 73% rename from frontend/app_flowy/lib/workspace/application/grid/setting/property_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/setting/property_bloc.dart index ee16eb0455..7c185279ae 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/setting/property_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/setting/property_bloc.dart @@ -1,5 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; -import 'package:app_flowy/workspace/application/grid/grid_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/grid_service.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -22,8 +22,10 @@ class GridPropertyBloc extends Bloc { _startListening(); }, setFieldVisibility: (_SetFieldVisibility value) async { - final fieldService = FieldService(gridId: gridId, fieldId: value.fieldId); - final result = await fieldService.updateField(visibility: value.visibility); + final fieldService = + FieldService(gridId: gridId, fieldId: value.fieldId); + final result = + await fieldService.updateField(visibility: value.visibility); result.fold( (l) => null, (err) => Log.error(err), @@ -50,7 +52,8 @@ class GridPropertyBloc extends Bloc { } void _startListening() { - _onFieldsFn = (fields) => add(GridPropertyEvent.didReceiveFieldUpdate(fields)); + _onFieldsFn = + (fields) => add(GridPropertyEvent.didReceiveFieldUpdate(fields)); _fieldCache.addListener( onFields: _onFieldsFn, listenWhen: () => !isClosed, @@ -61,9 +64,12 @@ class GridPropertyBloc extends Bloc { @freezed class GridPropertyEvent with _$GridPropertyEvent { const factory GridPropertyEvent.initial() = _Initial; - const factory GridPropertyEvent.setFieldVisibility(String fieldId, bool visibility) = _SetFieldVisibility; - const factory GridPropertyEvent.didReceiveFieldUpdate(List fields) = _DidReceiveFieldUpdate; - const factory GridPropertyEvent.moveField(int fromIndex, int toIndex) = _MoveField; + const factory GridPropertyEvent.setFieldVisibility( + String fieldId, bool visibility) = _SetFieldVisibility; + const factory GridPropertyEvent.didReceiveFieldUpdate( + List fields) = _DidReceiveFieldUpdate; + const factory GridPropertyEvent.moveField(int fromIndex, int toIndex) = + _MoveField; } @freezed @@ -73,7 +79,8 @@ class GridPropertyState with _$GridPropertyState { required List fields, }) = _GridPropertyState; - factory GridPropertyState.initial(String gridId, List fields) => GridPropertyState( + factory GridPropertyState.initial(String gridId, List fields) => + GridPropertyState( gridId: gridId, fields: fields, ); diff --git a/frontend/app_flowy/lib/workspace/application/grid/setting/setting_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/setting/setting_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/setting/setting_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/setting/setting_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/grid.dart b/frontend/app_flowy/lib/plugins/grid/grid.dart similarity index 90% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/grid.dart rename to frontend/app_flowy/lib/plugins/grid/grid.dart index 776dd833ea..c0c6d78642 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/grid.dart +++ b/frontend/app_flowy/lib/plugins/grid/grid.dart @@ -1,12 +1,12 @@ import 'package:app_flowy/generated/locale_keys.g.dart'; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; -import 'package:app_flowy/workspace/presentation/plugins/widgets/left_bar_item.dart'; +import 'package:app_flowy/workspace/presentation/widgets/left_bar_item.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter/material.dart'; -import 'src/grid_page.dart'; +import 'presentation/grid_page.dart'; class GridPluginBuilder implements PluginBuilder { @override diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/controller/flowy_table_selection.dart b/frontend/app_flowy/lib/plugins/grid/presentation/controller/flowy_table_selection.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/controller/flowy_table_selection.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/controller/flowy_table_selection.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/controller/grid_scroll.dart b/frontend/app_flowy/lib/plugins/grid/presentation/controller/grid_scroll.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/controller/grid_scroll.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/controller/grid_scroll.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/grid_page.dart b/frontend/app_flowy/lib/plugins/grid/presentation/grid_page.dart similarity index 87% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/grid_page.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/grid_page.dart index 4aae99acbe..ed6306a972 100755 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/grid_page.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/grid_page.dart @@ -1,6 +1,6 @@ import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/grid_bloc.dart'; -import 'package:app_flowy/workspace/application/grid/row/row_service.dart'; +import 'package:app_flowy/plugins/grid/application/grid_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/row/row_service.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart'; import 'package:flowy_infra_ui/style_widget/scrolling/styled_scroll_bar.dart'; @@ -35,13 +35,15 @@ class _GridPageState extends State { return MultiBlocProvider( providers: [ BlocProvider( - create: (context) => getIt(param1: widget.view)..add(const GridEvent.initial()), + create: (context) => getIt(param1: widget.view) + ..add(const GridEvent.initial()), ), ], child: BlocBuilder( builder: (context, state) { return state.loadingState.map( - loading: (_) => const Center(child: CircularProgressIndicator.adaptive()), + loading: (_) => + const Center(child: CircularProgressIndicator.adaptive()), finish: (result) => result.successOrFail.fold( (_) => const GridShortcuts(child: FlowyGrid()), (err) => FlowyErrorPage(err.toString()), @@ -76,7 +78,8 @@ class FlowyGrid extends StatefulWidget { } class _FlowyGridState extends State { - final _scrollController = GridScrollController(scrollGroupContorller: LinkedScrollControllerGroup()); + final _scrollController = GridScrollController( + scrollGroupContorller: LinkedScrollControllerGroup()); late ScrollController headerScrollController; @override @@ -204,7 +207,8 @@ class _GridRowsState extends State<_GridRows> { for (final item in value.items) { _key.currentState?.removeItem( item.index, - (context, animation) => _renderRow(context, item.row, animation), + (context, animation) => + _renderRow(context, item.row, animation), ); } }, @@ -215,8 +219,10 @@ class _GridRowsState extends State<_GridRows> { return SliverAnimatedList( key: _key, initialItemCount: context.read().state.rowInfos.length, - itemBuilder: (BuildContext context, int index, Animation animation) { - final GridRowInfo rowInfo = context.read().state.rowInfos[index]; + itemBuilder: + (BuildContext context, int index, Animation animation) { + final GridRowInfo rowInfo = + context.read().state.rowInfos[index]; return _renderRow(context, rowInfo, animation); }, ); @@ -229,7 +235,8 @@ class _GridRowsState extends State<_GridRows> { GridRowInfo rowInfo, Animation animation, ) { - final rowCache = context.read().getRowCache(rowInfo.blockId, rowInfo.id); + final rowCache = + context.read().getRowCache(rowInfo.blockId, rowInfo.id); final fieldCache = context.read().fieldCache; if (rowCache != null) { return SizeTransition( @@ -266,10 +273,10 @@ class _GridFooter extends StatelessWidget { SizedBox(width: GridSize.leadingHeaderPadding), Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ const SizedBox(width: 120, child: GridAddRowButton()), const SizedBox(height: 30), - _rowCountTextWidget(theme: theme,count: rowCount) + _rowCountTextWidget(theme: theme, count: rowCount) ], ), ], @@ -280,16 +287,18 @@ class _GridFooter extends StatelessWidget { ); } - Widget _rowCountTextWidget({required AppTheme theme, required int count}){ + Widget _rowCountTextWidget({required AppTheme theme, required int count}) { return Row( mainAxisAlignment: MainAxisAlignment.start, children: [ - FlowyText.regular('Count : ', - fontSize: 13, - color: theme.shader3, + FlowyText.regular( + 'Count : ', + fontSize: 13, + color: theme.shader3, ), - FlowyText.regular(count.toString(), - fontSize: 13, + FlowyText.regular( + count.toString(), + fontSize: 13, ), ], ); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/layout/layout.dart b/frontend/app_flowy/lib/plugins/grid/presentation/layout/layout.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/layout/layout.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/layout/layout.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/layout/sizes.dart b/frontend/app_flowy/lib/plugins/grid/presentation/layout/sizes.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/layout/sizes.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/layout/sizes.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_accessory.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_accessory.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_accessory.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_accessory.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_builder.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_builder.dart similarity index 77% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_builder.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_builder.dart index f785672f71..1913aac786 100755 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_builder.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_builder.dart @@ -1,5 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; -import 'package:app_flowy/workspace/application/grid/grid_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/grid_service.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; @@ -30,19 +30,36 @@ class GridCellBuilder { final key = cell.key(); switch (cell.fieldType) { case FieldType.Checkbox: - return GridCheckboxCell(cellControllerBuilder: cellControllerBuilder, key: key); + return GridCheckboxCell( + cellControllerBuilder: cellControllerBuilder, key: key); case FieldType.DateTime: - return GridDateCell(cellControllerBuilder: cellControllerBuilder, key: key, style: style); + return GridDateCell( + cellControllerBuilder: cellControllerBuilder, + key: key, + style: style); case FieldType.SingleSelect: - return GridSingleSelectCell(cellContorllerBuilder: cellControllerBuilder, style: style, key: key); + return GridSingleSelectCell( + cellContorllerBuilder: cellControllerBuilder, + style: style, + key: key); case FieldType.MultiSelect: - return GridMultiSelectCell(cellContorllerBuilder: cellControllerBuilder, style: style, key: key); + return GridMultiSelectCell( + cellContorllerBuilder: cellControllerBuilder, + style: style, + key: key); case FieldType.Number: - return GridNumberCell(cellContorllerBuilder: cellControllerBuilder, key: key); + return GridNumberCell( + cellContorllerBuilder: cellControllerBuilder, key: key); case FieldType.RichText: - return GridTextCell(cellContorllerBuilder: cellControllerBuilder, style: style, key: key); + return GridTextCell( + cellContorllerBuilder: cellControllerBuilder, + style: style, + key: key); case FieldType.URL: - return GridURLCell(cellContorllerBuilder: cellControllerBuilder, style: style, key: key); + return GridURLCell( + cellContorllerBuilder: cellControllerBuilder, + style: style, + key: key); } throw UnimplementedError; } @@ -65,7 +82,8 @@ abstract class CellEditable { ValueNotifier get onCellEditing; } -abstract class GridCellWidget extends StatefulWidget implements CellAccessory, CellEditable, CellShortcuts { +abstract class GridCellWidget extends StatefulWidget + implements CellAccessory, CellEditable, CellShortcuts { GridCellWidget({Key? key}) : super(key: key) { onCellEditing.addListener(() { onCellFocus.value = onCellEditing.value; @@ -83,7 +101,8 @@ abstract class GridCellWidget extends StatefulWidget implements CellAccessory, C final ValueNotifier onCellEditing = ValueNotifier(false); @override - List Function(GridCellAccessoryBuildContext buildContext)? get accessoryBuilder => null; + List Function(GridCellAccessoryBuildContext buildContext)? + get accessoryBuilder => null; @override final GridCellFocusListener beginFocus = GridCellFocusListener(); @@ -129,12 +148,14 @@ abstract class GridCellState extends State { void onInsert(String value) {} } -abstract class GridFocusNodeCellState extends GridCellState { +abstract class GridFocusNodeCellState + extends GridCellState { SingleListenrFocusNode focusNode = SingleListenrFocusNode(); @override void initState() { - widget.shortcutHandlers[CellKeyboardKey.onEnter] = () => focusNode.unfocus(); + widget.shortcutHandlers[CellKeyboardKey.onEnter] = + () => focusNode.unfocus(); _listenOnFocusNodeChanged(); super.initState(); } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_cotainer.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_cotainer.dart similarity index 80% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_cotainer.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_cotainer.dart index fbb343dd6c..b88508837c 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_cotainer.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_cotainer.dart @@ -1,10 +1,10 @@ -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/row/grid_row.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flutter/widgets.dart'; import 'package:provider/provider.dart'; import 'package:styled_widget/styled_widget.dart'; +import '../../layout/sizes.dart'; +import '../row/grid_row.dart'; import 'cell_accessory.dart'; import 'cell_builder.dart'; import 'cell_shortcuts.dart'; @@ -24,9 +24,11 @@ class CellContainer extends StatelessWidget { @override Widget build(BuildContext context) { - return ChangeNotifierProxyProvider( + return ChangeNotifierProxyProvider( create: (_) => CellContainerNotifier(child), - update: (_, rowStateNotifier, cellStateNotifier) => cellStateNotifier!..onEnter = rowStateNotifier.onEnter, + update: (_, rowStateNotifier, cellStateNotifier) => + cellStateNotifier!..onEnter = rowStateNotifier.onEnter, child: Selector( selector: (context, notifier) => notifier.isFocus, builder: (context, isFocus, _) { @@ -39,7 +41,8 @@ class CellContainer extends StatelessWidget { )); if (accessories.isNotEmpty) { - container = CellEnterRegion(child: container, accessories: accessories); + container = + CellEnterRegion(child: container, accessories: accessories); } } @@ -65,7 +68,8 @@ class CellContainer extends StatelessWidget { return BoxDecoration(border: Border.fromBorderSide(borderSide)); } else { final borderSide = BorderSide(color: theme.shader5, width: 1.0); - return BoxDecoration(border: Border(right: borderSide, bottom: borderSide)); + return BoxDecoration( + border: Border(right: borderSide, bottom: borderSide)); } } } @@ -73,7 +77,9 @@ class CellContainer extends StatelessWidget { class CellEnterRegion extends StatelessWidget { final Widget child; final List accessories; - const CellEnterRegion({required this.child, required this.accessories, Key? key}) : super(key: key); + const CellEnterRegion( + {required this.child, required this.accessories, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -82,13 +88,18 @@ class CellEnterRegion extends StatelessWidget { builder: (context, onEnter, _) { List children = [child]; if (onEnter) { - children.add(CellAccessoryContainer(accessories: accessories).positioned(right: 0)); + children.add(CellAccessoryContainer(accessories: accessories) + .positioned(right: 0)); } return MouseRegion( cursor: SystemMouseCursors.click, - onEnter: (p) => Provider.of(context, listen: false).onEnter = true, - onExit: (p) => Provider.of(context, listen: false).onEnter = false, + onEnter: (p) => + Provider.of(context, listen: false) + .onEnter = true, + onExit: (p) => + Provider.of(context, listen: false) + .onEnter = false, child: Stack( alignment: AlignmentDirectional.center, fit: StackFit.expand, diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_decoration.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_decoration.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_decoration.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_decoration.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_shortcuts.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_shortcuts.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_shortcuts.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_shortcuts.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/checkbox_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/checkbox_cell.dart similarity index 77% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/checkbox_cell.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/checkbox_cell.dart index 9fcbaf751f..d334cc38af 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/checkbox_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/checkbox_cell.dart @@ -1,5 +1,5 @@ import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra_ui/style_widget/icon_button.dart'; import 'package:flutter/widgets.dart'; @@ -23,7 +23,8 @@ class _CheckboxCellState extends GridCellState { @override void initState() { final cellContext = widget.cellControllerBuilder.build(); - _cellBloc = getIt(param1: cellContext)..add(const CheckboxCellEvent.initial()); + _cellBloc = getIt(param1: cellContext) + ..add(const CheckboxCellEvent.initial()); super.initState(); } @@ -33,11 +34,15 @@ class _CheckboxCellState extends GridCellState { value: _cellBloc, child: BlocBuilder( builder: (context, state) { - final icon = state.isSelected ? svgWidget('editor/editor_check') : svgWidget('editor/editor_uncheck'); + final icon = state.isSelected + ? svgWidget('editor/editor_check') + : svgWidget('editor/editor_uncheck'); return Align( alignment: Alignment.centerLeft, child: FlowyIconButton( - onPressed: () => context.read().add(const CheckboxCellEvent.select()), + onPressed: () => context + .read() + .add(const CheckboxCellEvent.select()), iconPadding: EdgeInsets.zero, icon: icon, width: 20, diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell/date_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_cell.dart similarity index 85% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell/date_cell.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_cell.dart index 78d18a50e8..3254f58e6c 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell/date_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_cell.dart @@ -2,7 +2,7 @@ import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import '../cell_builder.dart'; import 'date_editor.dart'; @@ -44,13 +44,16 @@ class _DateCellState extends GridCellState { @override void initState() { final cellContext = widget.cellControllerBuilder.build(); - _cellBloc = getIt(param1: cellContext)..add(const DateCellEvent.initial()); + _cellBloc = getIt(param1: cellContext) + ..add(const DateCellEvent.initial()); super.initState(); } @override Widget build(BuildContext context) { - final alignment = widget.cellStyle != null ? widget.cellStyle!.alignment : Alignment.center; + final alignment = widget.cellStyle != null + ? widget.cellStyle!.alignment + : Alignment.center; return BlocProvider.value( value: _cellBloc, child: BlocBuilder( @@ -77,7 +80,8 @@ class _DateCellState extends GridCellState { void _showCalendar(BuildContext context) { final bloc = context.read(); widget.onCellEditing.value = true; - final calendar = DateCellEditor(onDismissed: () => widget.onCellEditing.value = false); + final calendar = + DateCellEditor(onDismissed: () => widget.onCellEditing.value = false); calendar.show( context, cellController: bloc.cellContext.clone(), diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell/date_editor.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_editor.dart similarity index 90% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell/date_editor.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_editor.dart index 36ad22ec53..a439506815 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell/date_editor.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_editor.dart @@ -1,7 +1,5 @@ import 'package:app_flowy/generated/locale_keys.g.dart'; -import 'package:app_flowy/workspace/application/grid/cell/date_cal_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/type_option/date.dart'; +import 'package:app_flowy/plugins/grid/application/cell/date_cal_bloc.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; @@ -15,7 +13,10 @@ import 'package:flowy_sdk/protobuf/flowy-grid/date_type_option.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:table_calendar/table_calendar.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; + +import '../../../layout/sizes.dart'; +import '../../header/type_option/date.dart'; final kToday = DateTime.now(); final kFirstDay = DateTime(kToday.year, kToday.month - 3, kToday.day); @@ -35,7 +36,8 @@ class DateCellEditor with FlowyOverlayDelegate { }) async { DateCellEditor.remove(context); - final result = await cellController.getFieldTypeOption(DateTypeOptionDataParser()); + final result = + await cellController.getFieldTypeOption(DateTypeOptionDataParser()); result.fold( (dateTypeOption) { final calendar = _CellCalendarWidget( @@ -167,7 +169,9 @@ class _CellCalendarWidget extends StatelessWidget { }, onDaySelected: (selectedDay, focusedDay) { _CalDateTimeSetting.hide(context); - context.read().add(DateCalEvent.selectDay(selectedDay)); + context + .read() + .add(DateCalEvent.selectDay(selectedDay)); }, onFormatChanged: (format) { _CalDateTimeSetting.hide(context); @@ -175,7 +179,9 @@ class _CellCalendarWidget extends StatelessWidget { }, onPageChanged: (focusedDay) { _CalDateTimeSetting.hide(context); - context.read().add(DateCalEvent.setFocusedDay(focusedDay)); + context + .read() + .add(DateCalEvent.setFocusedDay(focusedDay)); }, ); }, @@ -200,11 +206,14 @@ class _IncludeTimeButton extends StatelessWidget { children: [ svgWidget("grid/clock", color: theme.iconColor), const HSpace(4), - FlowyText.medium(LocaleKeys.grid_field_includeTime.tr(), fontSize: 14), + FlowyText.medium(LocaleKeys.grid_field_includeTime.tr(), + fontSize: 14), const Spacer(), Switch( value: includeTime, - onChanged: (newValue) => context.read().add(DateCalEvent.setIncludeTime(newValue)), + onChanged: (newValue) => context + .read() + .add(DateCalEvent.setIncludeTime(newValue)), ), ], ), @@ -294,7 +303,9 @@ class _DateTypeOptionButton extends StatelessWidget { @override Widget build(BuildContext context) { final theme = context.watch(); - final title = LocaleKeys.grid_field_dateFormat.tr() + " &" + LocaleKeys.grid_field_timeFormat.tr(); + final title = LocaleKeys.grid_field_dateFormat.tr() + + " &" + + LocaleKeys.grid_field_timeFormat.tr(); return BlocSelector( selector: (state) => state.dateTypeOption, builder: (context, dateTypeOption) { @@ -321,7 +332,9 @@ class _DateTypeOptionButton extends StatelessWidget { class _CalDateTimeSetting extends StatefulWidget { final DateTypeOption dateTypeOption; final Function(DateCalEvent) onEvent; - const _CalDateTimeSetting({required this.dateTypeOption, required this.onEvent, Key? key}) : super(key: key); + const _CalDateTimeSetting( + {required this.dateTypeOption, required this.onEvent, Key? key}) + : super(key: key); @override State<_CalDateTimeSetting> createState() => _CalDateTimeSettingState(); @@ -358,7 +371,8 @@ class _CalDateTimeSettingState extends State<_CalDateTimeSetting> { DateFormatButton(onTap: () { final list = DateFormatList( selectedFormat: widget.dateTypeOption.dateFormat, - onSelected: (format) => widget.onEvent(DateCalEvent.setDateFormat(format)), + onSelected: (format) => + widget.onEvent(DateCalEvent.setDateFormat(format)), ); _showOverlay(context, list); }), @@ -367,7 +381,8 @@ class _CalDateTimeSettingState extends State<_CalDateTimeSetting> { onTap: () { final list = TimeFormatList( selectedFormat: widget.dateTypeOption.timeFormat, - onSelected: (format) => widget.onEvent(DateCalEvent.setTimeFormat(format)), + onSelected: (format) => + widget.onEvent(DateCalEvent.setTimeFormat(format)), ); _showOverlay(context, list); }, diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/number_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/number_cell.dart similarity index 82% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/number_cell.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/number_cell.dart index 573a4168c9..8c6db0afe9 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/number_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/number_cell.dart @@ -1,6 +1,6 @@ import 'dart:async'; import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -26,8 +26,10 @@ class _NumberCellState extends GridFocusNodeCellState { @override void initState() { final cellContext = widget.cellContorllerBuilder.build(); - _cellBloc = getIt(param1: cellContext)..add(const NumberCellEvent.initial()); - _controller = TextEditingController(text: contentFromState(_cellBloc.state)); + _cellBloc = getIt(param1: cellContext) + ..add(const NumberCellEvent.initial()); + _controller = + TextEditingController(text: contentFromState(_cellBloc.state)); super.initState(); } @@ -39,7 +41,8 @@ class _NumberCellState extends GridFocusNodeCellState { listeners: [ BlocListener( listenWhen: (p, c) => p.content != c.content, - listener: (context, state) => _controller.text = contentFromState(state), + listener: (context, state) => + _controller.text = contentFromState(state), ), ], child: TextField( @@ -70,7 +73,8 @@ class _NumberCellState extends GridFocusNodeCellState { if (mounted) { _delayOperation?.cancel(); _delayOperation = Timer(const Duration(milliseconds: 300), () { - if (_cellBloc.isClosed == false && _controller.text != contentFromState(_cellBloc.state)) { + if (_cellBloc.isClosed == false && + _controller.text != contentFromState(_cellBloc.state)) { _cellBloc.add(NumberCellEvent.updateCell(_controller.text)); } }); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/prelude.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/prelude.dart similarity index 85% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/prelude.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/prelude.dart index 792e58810f..7b34d8fcdf 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/prelude.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/prelude.dart @@ -4,3 +4,4 @@ export 'number_cell.dart'; export 'date_cell/date_cell.dart'; export 'checkbox_cell.dart'; export 'select_option_cell/select_option_cell.dart'; +export 'url_cell/url_cell.dart'; diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/extension.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/extension.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/extension.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/extension.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/select_option_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_cell.dart similarity index 86% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/select_option_cell.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_cell.dart index f822e503d2..53c77c6016 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/select_option_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_cell.dart @@ -1,6 +1,6 @@ import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/cell_builder.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; + import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/text.dart'; // ignore: unused_import @@ -9,6 +9,7 @@ import 'package:flowy_sdk/protobuf/flowy-grid/select_option.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import '../cell_builder.dart'; import 'extension.dart'; import 'select_option_editor.dart'; @@ -45,8 +46,10 @@ class _SingleSelectCellState extends State { @override void initState() { - final cellContext = widget.cellContorllerBuilder.build() as GridSelectOptionCellController; - _cellBloc = getIt(param1: cellContext)..add(const SelectOptionCellEvent.initial()); + final cellContext = + widget.cellContorllerBuilder.build() as GridSelectOptionCellController; + _cellBloc = getIt(param1: cellContext) + ..add(const SelectOptionCellEvent.initial()); super.initState(); } @@ -99,8 +102,10 @@ class _MultiSelectCellState extends State { @override void initState() { - final cellContext = widget.cellContorllerBuilder.build() as GridSelectOptionCellController; - _cellBloc = getIt(param1: cellContext)..add(const SelectOptionCellEvent.initial()); + final cellContext = + widget.cellContorllerBuilder.build() as GridSelectOptionCellController; + _cellBloc = getIt(param1: cellContext) + ..add(const SelectOptionCellEvent.initial()); super.initState(); } @@ -147,7 +152,8 @@ class _SelectOptionCell extends StatelessWidget { if (selectOptions.isEmpty && cellStyle != null) { child = Align( alignment: Alignment.centerLeft, - child: FlowyText.medium(cellStyle!.placeholder, fontSize: 14, color: theme.shader3), + child: FlowyText.medium(cellStyle!.placeholder, + fontSize: 14, color: theme.shader3), ); } else { final tags = selectOptions @@ -172,8 +178,10 @@ class _SelectOptionCell extends StatelessWidget { InkWell( onTap: () { onFocus(true); - final cellContext = cellContorllerBuilder.build() as GridSelectOptionCellController; - SelectOptionCellEditor.show(context, cellContext, () => onFocus(false)); + final cellContext = + cellContorllerBuilder.build() as GridSelectOptionCellController; + SelectOptionCellEditor.show( + context, cellContext, () => onFocus(false)); }, ), ], diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/select_option_editor.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_editor.dart similarity index 82% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/select_option_editor.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_editor.dart index 95f2bf1e03..c07eef5617 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/select_option_editor.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_editor.dart @@ -1,9 +1,7 @@ import 'dart:collection'; -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; -import 'package:app_flowy/workspace/application/grid/cell/select_option_editor_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/type_option/select_option_editor.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/common/text_field.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/select_option_editor_bloc.dart'; + import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; @@ -18,6 +16,9 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; import 'package:textfield_tags/textfield_tags.dart'; +import '../../../layout/sizes.dart'; +import '../../common/text_field.dart'; +import '../../header/type_option/select_option_editor.dart'; import 'extension.dart'; import 'text_field.dart'; @@ -105,7 +106,8 @@ class _OptionList extends StatelessWidget { builder: (context, state) { List cells = []; cells.addAll(state.options.map((option) { - return _SelectOptionCell(option, state.selectedOptions.contains(option)); + return _SelectOptionCell( + option, state.selectedOptions.contains(option)); }).toList()); state.createOption.fold( @@ -146,8 +148,10 @@ class _TextField extends StatelessWidget { Widget build(BuildContext context) { return BlocBuilder( builder: (context, state) { - final optionMap = LinkedHashMap.fromIterable(state.selectedOptions, - key: (option) => option.name, value: (option) => option); + final optionMap = LinkedHashMap.fromIterable( + state.selectedOptions, + key: (option) => option.name, + value: (option) => option); return SizedBox( height: 42, @@ -156,12 +160,17 @@ class _TextField extends StatelessWidget { selectedOptionMap: optionMap, distanceToText: _editorPannelWidth * 0.7, tagController: _tagController, - onClick: () => FlowyOverlay.of(context).remove(SelectOptionTypeOptionEditor.identifier), + onClick: () => FlowyOverlay.of(context) + .remove(SelectOptionTypeOptionEditor.identifier), newText: (text) { - context.read().add(SelectOptionEditorEvent.filterOption(text)); + context + .read() + .add(SelectOptionEditorEvent.filterOption(text)); }, onNewTag: (tagName) { - context.read().add(SelectOptionEditorEvent.newOption(tagName)); + context + .read() + .add(SelectOptionEditorEvent.newOption(tagName)); }, ), ); @@ -208,7 +217,9 @@ class _CreateOptionCell extends StatelessWidget { SelectOptionTag( name: name, color: theme.shader6, - onSelected: () => context.read().add(SelectOptionEditorEvent.newOption(name)), + onSelected: () => context + .read() + .add(SelectOptionEditorEvent.newOption(name)), ), ], ); @@ -218,7 +229,8 @@ class _CreateOptionCell extends StatelessWidget { class _SelectOptionCell extends StatelessWidget { final SelectOptionPB option; final bool isSelected; - const _SelectOptionCell(this.option, this.isSelected, {Key? key}) : super(key: key); + const _SelectOptionCell(this.option, this.isSelected, {Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -232,7 +244,9 @@ class _SelectOptionCell extends StatelessWidget { child: SelectOptionTagCell( option: option, onSelected: (option) { - context.read().add(SelectOptionEditorEvent.selectOption(option.id)); + context + .read() + .add(SelectOptionEditorEvent.selectOption(option.id)); }, children: [ if (isSelected) @@ -258,12 +272,17 @@ class _SelectOptionCell extends StatelessWidget { final pannel = SelectOptionTypeOptionEditor( option: option, onDeleted: () { - context.read().add(SelectOptionEditorEvent.deleteOption(option)); + context + .read() + .add(SelectOptionEditorEvent.deleteOption(option)); }, onUpdated: (updatedOption) { - context.read().add(SelectOptionEditorEvent.updateOption(updatedOption)); + context + .read() + .add(SelectOptionEditorEvent.updateOption(updatedOption)); }, - key: ValueKey(option.id), // Use ValueKey to refresh the UI, otherwise, it will remain the old value. + key: ValueKey(option + .id), // Use ValueKey to refresh the UI, otherwise, it will remain the old value. ); final overlayIdentifier = (SelectOptionTypeOptionEditor).toString(); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/text_field.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/text_field.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/text_field.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/text_field.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/text_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/text_cell.dart similarity index 94% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/text_cell.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/text_cell.dart index 55bf757ba4..29471c13b6 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/text_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/text_cell.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'cell_builder.dart'; class GridTextCellStyle extends GridCellStyle { @@ -86,7 +86,8 @@ class _GridTextCellState extends GridFocusNodeCellState { if (mounted) { _delayOperation?.cancel(); _delayOperation = Timer(const Duration(milliseconds: 300), () { - if (_cellBloc.isClosed == false && _controller.text != _cellBloc.state.content) { + if (_cellBloc.isClosed == false && + _controller.text != _cellBloc.state.content) { _cellBloc.add(TextCellEvent.updateText(_controller.text)); } }); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/url_cell/cell_editor.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/cell_editor.dart similarity index 87% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/url_cell/cell_editor.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/cell_editor.dart index b6bc8daa21..9095d73fa6 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/url_cell/cell_editor.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/cell_editor.dart @@ -1,5 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; -import 'package:app_flowy/workspace/application/grid/cell/url_cell_editor_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/url_cell_editor_bloc.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flutter/material.dart'; import 'dart:async'; @@ -9,7 +9,9 @@ import 'package:flutter_bloc/flutter_bloc.dart'; class URLCellEditor extends StatefulWidget with FlowyOverlayDelegate { final GridURLCellController cellController; final VoidCallback completed; - const URLCellEditor({required this.cellController, required this.completed, Key? key}) : super(key: key); + const URLCellEditor( + {required this.cellController, required this.completed, Key? key}) + : super(key: key); @override State createState() => _URLCellEditorState(); @@ -105,7 +107,8 @@ class _URLCellEditorState extends State { Future focusChanged() async { if (mounted) { - if (_cellBloc.isClosed == false && _controller.text != _cellBloc.state.content) { + if (_cellBloc.isClosed == false && + _controller.text != _cellBloc.state.content) { _cellBloc.add(URLCellEditorEvent.updateText(_controller.text)); } } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/url_cell/url_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/url_cell.dart similarity index 73% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/url_cell/url_cell.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/url_cell.dart index 9cc14fbbda..bb39b8f276 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/url_cell/url_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/url_cell.dart @@ -1,16 +1,16 @@ import 'dart:async'; import 'package:app_flowy/generated/locale_keys.g.dart'; -import 'package:app_flowy/workspace/application/grid/cell/url_cell_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/cell/url_cell_bloc.dart'; import 'package:app_flowy/workspace/presentation/home/toast.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/cell_accessory.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:url_launcher/url_launcher.dart'; +import '../cell_accessory.dart'; import '../cell_builder.dart'; import 'cell_editor.dart'; @@ -48,34 +48,41 @@ class GridURLCell extends GridCellWidget { @override GridCellState createState() => _GridURLCellState(); - GridCellAccessory accessoryFromType(GridURLCellAccessoryType ty, GridCellAccessoryBuildContext buildContext) { + GridCellAccessory accessoryFromType( + GridURLCellAccessoryType ty, GridCellAccessoryBuildContext buildContext) { switch (ty) { case GridURLCellAccessoryType.edit: - final cellContext = cellContorllerBuilder.build() as GridURLCellController; - return _EditURLAccessory(cellContext: cellContext, anchorContext: buildContext.anchorContext); + final cellContext = + cellContorllerBuilder.build() as GridURLCellController; + return _EditURLAccessory( + cellContext: cellContext, + anchorContext: buildContext.anchorContext); case GridURLCellAccessoryType.copyURL: - final cellContext = cellContorllerBuilder.build() as GridURLCellController; + final cellContext = + cellContorllerBuilder.build() as GridURLCellController; return _CopyURLAccessory(cellContext: cellContext); } } @override - List Function(GridCellAccessoryBuildContext buildContext) get accessoryBuilder => (buildContext) { - final List accessories = []; - if (cellStyle != null) { - accessories.addAll(cellStyle!.accessoryTypes.map((ty) { - return accessoryFromType(ty, buildContext); - })); - } + List Function(GridCellAccessoryBuildContext buildContext) + get accessoryBuilder => (buildContext) { + final List accessories = []; + if (cellStyle != null) { + accessories.addAll(cellStyle!.accessoryTypes.map((ty) { + return accessoryFromType(ty, buildContext); + })); + } - // If the accessories is empty then the default accessory will be GridURLCellAccessoryType.edit - if (accessories.isEmpty) { - accessories.add(accessoryFromType(GridURLCellAccessoryType.edit, buildContext)); - } + // If the accessories is empty then the default accessory will be GridURLCellAccessoryType.edit + if (accessories.isEmpty) { + accessories.add(accessoryFromType( + GridURLCellAccessoryType.edit, buildContext)); + } - return accessories; - }; + return accessories; + }; } class _GridURLCellState extends GridCellState { @@ -83,7 +90,8 @@ class _GridURLCellState extends GridCellState { @override void initState() { - final cellContext = widget.cellContorllerBuilder.build() as GridURLCellController; + final cellContext = + widget.cellContorllerBuilder.build() as GridURLCellController; _cellBloc = URLCellBloc(cellContext: cellContext); _cellBloc.add(const URLCellEvent.initial()); super.initState(); @@ -132,7 +140,8 @@ class _GridURLCellState extends GridCellState { if (url.isNotEmpty && await canLaunchUrl(uri)) { await launchUrl(uri); } else { - final cellContext = widget.cellContorllerBuilder.build() as GridURLCellController; + final cellContext = + widget.cellContorllerBuilder.build() as GridURLCellController; widget.onCellEditing.value = true; URLCellEditor.show(context, cellContext, () { widget.onCellEditing.value = false; @@ -177,7 +186,8 @@ class _EditURLAccessory extends StatelessWidget with GridCellAccessory { class _CopyURLAccessory extends StatelessWidget with GridCellAccessory { final GridURLCellController cellContext; - const _CopyURLAccessory({required this.cellContext, Key? key}) : super(key: key); + const _CopyURLAccessory({required this.cellContext, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -187,7 +197,8 @@ class _CopyURLAccessory extends StatelessWidget with GridCellAccessory { @override void onTap() { - final content = cellContext.getCellData(loadIfNotExist: false)?.content ?? ""; + final content = + cellContext.getCellData(loadIfNotExist: false)?.content ?? ""; Clipboard.setData(ClipboardData(text: content)); showMessageToast(LocaleKeys.grid_row_copyProperty.tr()); } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/common/text_field.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/common/text_field.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/common/text_field.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/common/text_field.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/footer/grid_footer.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/footer/grid_footer.dart similarity index 91% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/footer/grid_footer.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/footer/grid_footer.dart index 6ed8700cfc..f7b5ab350a 100755 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/footer/grid_footer.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/footer/grid_footer.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/grid_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/grid_bloc.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/button.dart'; diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/constants.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/constants.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/constants.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/constants.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell.dart similarity index 90% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_cell.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell.dart index 1d13870bbf..aec88f5eaf 100755 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell.dart @@ -1,6 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/field/field_cell_bloc.dart'; -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_cell_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/button.dart'; @@ -9,6 +8,7 @@ import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import '../../layout/sizes.dart'; import 'field_type_extension.dart'; import 'field_cell_action_sheet.dart'; @@ -21,7 +21,8 @@ class GridFieldCell extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => FieldCellBloc(cellContext: cellContext)..add(const FieldCellEvent.initial()), + create: (context) => FieldCellBloc(cellContext: cellContext) + ..add(const FieldCellEvent.initial()), child: BlocBuilder( // buildWhen: (p, c) => p.field != c.field, builder: (context, state) { @@ -53,7 +54,8 @@ class GridFieldCell extends StatelessWidget { void _showActionSheet(BuildContext context) { final state = context.read().state; GridFieldCellActionSheet( - cellContext: GridFieldCellContext(gridId: state.gridId, field: state.field), + cellContext: + GridFieldCellContext(gridId: state.gridId, field: state.field), onEdited: () => _showFieldEditor(context), ).show(context); } @@ -96,7 +98,8 @@ class _GridHeaderCellContainer extends StatelessWidget { return Container( width: width, decoration: decoration, - child: ConstrainedBox(constraints: const BoxConstraints.expand(), child: child), + child: ConstrainedBox( + constraints: const BoxConstraints.expand(), child: child), ); } } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_cell_action_sheet.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dart similarity index 83% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_cell_action_sheet.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dart index 3e7f0c9271..cd884cd557 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_cell_action_sheet.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dart @@ -1,6 +1,5 @@ import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; @@ -12,10 +11,15 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; -class GridFieldCellActionSheet extends StatelessWidget with FlowyOverlayDelegate { +import '../../layout/sizes.dart'; + +class GridFieldCellActionSheet extends StatelessWidget + with FlowyOverlayDelegate { final GridFieldCellContext cellContext; final VoidCallback onEdited; - const GridFieldCellActionSheet({required this.cellContext, required this.onEdited, Key? key}) : super(key: key); + const GridFieldCellActionSheet( + {required this.cellContext, required this.onEdited, Key? key}) + : super(key: key); void show(BuildContext overlayContext) { FlowyOverlay.of(overlayContext).insertWithAnchor( @@ -44,7 +48,8 @@ class GridFieldCellActionSheet extends StatelessWidget with FlowyOverlayDelegate }, ), const VSpace(6), - _FieldOperationList(cellContext, () => FlowyOverlay.of(context).remove(identifier())), + _FieldOperationList(cellContext, + () => FlowyOverlay.of(context).remove(identifier())), ], ), ), @@ -73,7 +78,8 @@ class _EditFieldButton extends StatelessWidget { return SizedBox( height: GridSize.typeOptionItemHeight, child: FlowyButton( - text: FlowyText.medium(LocaleKeys.grid_field_editProperty.tr(), fontSize: 12), + text: FlowyText.medium(LocaleKeys.grid_field_editProperty.tr(), + fontSize: 12), hoverColor: theme.hover, onTap: onEdited, ), @@ -86,7 +92,8 @@ class _EditFieldButton extends StatelessWidget { class _FieldOperationList extends StatelessWidget { final GridFieldCellContext fieldData; final VoidCallback onDismissed; - const _FieldOperationList(this.fieldData, this.onDismissed, {Key? key}) : super(key: key); + const _FieldOperationList(this.fieldData, this.onDismissed, {Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -143,7 +150,8 @@ class FieldActionCell extends StatelessWidget { Widget build(BuildContext context) { final theme = context.watch(); return FlowyButton( - text: FlowyText.medium(action.title(), fontSize: 12, color: enable ? null : theme.shader4), + text: FlowyText.medium(action.title(), + fontSize: 12, color: enable ? null : theme.shader4), hoverColor: theme.hover, onTap: () { if (enable) { @@ -188,13 +196,19 @@ extension _FieldActionExtension on FieldAction { void run(BuildContext context) { switch (this) { case FieldAction.hide: - context.read().add(const FieldActionSheetEvent.hideField()); + context + .read() + .add(const FieldActionSheetEvent.hideField()); break; case FieldAction.duplicate: - context.read().add(const FieldActionSheetEvent.duplicateField()); + context + .read() + .add(const FieldActionSheetEvent.duplicateField()); break; case FieldAction.delete: - context.read().add(const FieldActionSheetEvent.deleteField()); + context + .read() + .add(const FieldActionSheetEvent.deleteField()); break; } } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_editor.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_editor.dart similarity index 88% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_editor.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_editor.dart index 3a857a9fb4..30a76a34bb 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_editor.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_editor.dart @@ -1,5 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/field/field_editor_bloc.dart'; -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_editor_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flowy_infra_ui/style_widget/text.dart'; @@ -36,7 +36,8 @@ class FieldEditor extends StatelessWidget with FlowyOverlayDelegate { return ListView( shrinkWrap: true, children: [ - FlowyText.medium(LocaleKeys.grid_field_editProperty.tr(), fontSize: 12), + FlowyText.medium(LocaleKeys.grid_field_editProperty.tr(), + fontSize: 12), const VSpace(10), const _FieldNameCell(), const VSpace(10), @@ -85,7 +86,8 @@ class _FieldTypeOptionCell extends StatelessWidget { return state.field.fold( () => const SizedBox(), (fieldContext) { - final dataController = context.read().dataController; + final dataController = + context.read().dataController; return FieldTypeOptionEditor(dataController: dataController); }, ); @@ -105,7 +107,9 @@ class _FieldNameCell extends StatelessWidget { name: state.name, errorText: context.read().state.errorText, onNameChanged: (newName) { - context.read().add(FieldEditorEvent.updateName(newName)); + context + .read() + .add(FieldEditorEvent.updateName(newName)); }, ); }, diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_name_input.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_name_input.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_name_input.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_name_input.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_type_extension.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_extension.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_type_extension.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_extension.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_type_list.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_list.dart similarity index 93% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_type_list.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_list.dart index 0ea53fb547..de9b3a809f 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_type_list.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_list.dart @@ -1,4 +1,3 @@ -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; @@ -8,6 +7,7 @@ import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter/material.dart'; +import '../../layout/sizes.dart'; import 'field_type_extension.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -15,7 +15,8 @@ typedef SelectFieldCallback = void Function(FieldType); class FieldTypeList extends StatelessWidget with FlowyOverlayDelegate { final SelectFieldCallback onSelectField; - const FieldTypeList({required this.onSelectField, Key? key}) : super(key: key); + const FieldTypeList({required this.onSelectField, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_type_option_editor.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_option_editor.dart similarity index 82% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_type_option_editor.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_option_editor.dart index 95dd39bae9..c2a12bb7ad 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_type_option_editor.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_option_editor.dart @@ -9,14 +9,15 @@ import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_type_list.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; +import '../../layout/sizes.dart'; import 'field_type_extension.dart'; +import 'field_type_list.dart'; import 'type_option/builder.dart'; typedef UpdateFieldCallback = void Function(GridFieldPB, Uint8List); -typedef SwitchToFieldCallback = Future> Function( +typedef SwitchToFieldCallback + = Future> Function( String fieldId, FieldType fieldType, ); @@ -39,12 +40,15 @@ class _FieldTypeOptionEditorState extends State { @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => - FieldTypeOptionEditBloc(widget.dataController)..add(const FieldTypeOptionEditEvent.initial()), + create: (context) => FieldTypeOptionEditBloc(widget.dataController) + ..add(const FieldTypeOptionEditEvent.initial()), child: BlocBuilder( builder: (context, state) { - List children = [_switchFieldTypeButton(context, widget.dataController.field)]; - final typeOptionWidget = _typeOptionWidget(context: context, state: state); + List children = [ + _switchFieldTypeButton(context, widget.dataController.field) + ]; + final typeOptionWidget = + _typeOptionWidget(context: context, state: state); if (typeOptionWidget != null) { children.add(typeOptionWidget); @@ -95,7 +99,8 @@ class _FieldTypeOptionEditorState extends State { ); } - void _showOverlay(BuildContext context, Widget child, {VoidCallback? onRemoved}) { + void _showOverlay(BuildContext context, Widget child, + {VoidCallback? onRemoved}) { final identifier = child.toString(); if (currentOverlayIdentifier != null) { FlowyOverlay.of(context).remove(currentOverlayIdentifier!); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/grid_header.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/grid_header.dart similarity index 84% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/grid_header.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/grid_header.dart index 5a888129b5..df7be4ee2b 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/grid_header.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/grid_header.dart @@ -1,6 +1,5 @@ import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/button.dart'; @@ -9,6 +8,7 @@ import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:reorderables/reorderables.dart'; +import '../../layout/sizes.dart'; import 'field_editor.dart'; import 'field_cell.dart'; @@ -24,7 +24,8 @@ class GridHeaderSliverAdaptor extends StatefulWidget { }) : super(key: key); @override - State createState() => _GridHeaderSliverAdaptorState(); + State createState() => + _GridHeaderSliverAdaptorState(); } class _GridHeaderSliverAdaptorState extends State { @@ -32,12 +33,14 @@ class _GridHeaderSliverAdaptorState extends State { Widget build(BuildContext context) { return BlocProvider( create: (context) { - final bloc = getIt(param1: widget.gridId, param2: widget.fieldCache); + final bloc = getIt( + param1: widget.gridId, param2: widget.fieldCache); bloc.add(const GridHeaderEvent.initial()); return bloc; }, child: BlocBuilder( - buildWhen: (previous, current) => previous.fields.length != current.fields.length, + buildWhen: (previous, current) => + previous.fields.length != current.fields.length, builder: (context, state) { return SingleChildScrollView( scrollDirection: Axis.horizontal, @@ -76,7 +79,8 @@ class _GridHeaderState extends State<_GridHeader> { builder: (context, state) { final cells = state.fields .where((field) => field.visibility) - .map((field) => GridFieldCellContext(gridId: widget.gridId, field: field)) + .map((field) => + GridFieldCellContext(gridId: widget.gridId, field: field)) .map((ctx) => GridFieldCell(ctx, key: ValueKey(ctx.field.id))) .toList(); @@ -99,10 +103,13 @@ class _GridHeaderState extends State<_GridHeader> { ); } - void _onReorder(List cells, int oldIndex, BuildContext context, int newIndex) { + void _onReorder(List cells, int oldIndex, BuildContext context, + int newIndex) { if (cells.length > oldIndex) { final field = cells[oldIndex].cellContext.field; - context.read().add(GridHeaderEvent.moveField(field, oldIndex, newIndex)); + context + .read() + .add(GridHeaderEvent.moveField(field, oldIndex, newIndex)); } } } @@ -158,14 +165,17 @@ class CreateFieldButton extends StatelessWidget { } } -class SliverHeaderDelegateImplementation extends SliverPersistentHeaderDelegate { +class SliverHeaderDelegateImplementation + extends SliverPersistentHeaderDelegate { final String gridId; final List fields; - SliverHeaderDelegateImplementation({required this.gridId, required this.fields}); + SliverHeaderDelegateImplementation( + {required this.gridId, required this.fields}); @override - Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) { + Widget build( + BuildContext context, double shrinkOffset, bool overlapsContent) { return _GridHeader(gridId: gridId); } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/builder.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/builder.dart similarity index 92% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/builder.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/builder.dart index 63fa761d98..4471e672a3 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/builder.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/builder.dart @@ -1,10 +1,10 @@ import 'dart:typed_data'; -import 'package:app_flowy/workspace/application/grid/field/type_option/multi_select_type_option.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/type_option/checkbox.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/multi_select_type_option.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter/material.dart'; +import 'checkbox.dart'; import 'date.dart'; import 'multi_select.dart'; import 'number.dart'; diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/checkbox.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/checkbox.dart similarity index 74% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/checkbox.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/checkbox.dart index beca8acd09..fdc5719181 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/checkbox.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/checkbox.dart @@ -1,11 +1,12 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/type_option_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_service.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/checkbox_type_option.pb.dart'; import 'package:flutter/material.dart'; import 'builder.dart'; typedef CheckboxTypeOptionContext = TypeOptionWidgetContext; -class CheckboxTypeOptionWidgetDataParser extends TypeOptionDataParser { +class CheckboxTypeOptionWidgetDataParser + extends TypeOptionDataParser { @override CheckboxTypeOption fromBuffer(List buffer) { return CheckboxTypeOption.fromBuffer(buffer); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/date.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/date.dart similarity index 88% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/date.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/date.dart index 39408c9ee3..c162595b88 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/date.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/date.dart @@ -1,6 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/date_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_type_option_editor.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/date_bloc.dart'; import 'package:easy_localization/easy_localization.dart' hide DateFormat; import 'package:app_flowy/generated/locale_keys.g.dart'; import 'package:flowy_infra/image.dart'; @@ -12,6 +10,8 @@ import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/date_type_option_entities.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import '../../../layout/sizes.dart'; +import '../field_type_option_editor.dart'; import 'builder.dart'; class DateTypeOptionWidgetBuilder extends TypeOptionWidgetBuilder { @@ -44,9 +44,11 @@ class DateTypeOptionWidget extends TypeOptionWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => DateTypeOptionBloc(typeOptionContext: typeOptionContext), + create: (context) => + DateTypeOptionBloc(typeOptionContext: typeOptionContext), child: BlocConsumer( - listener: (context, state) => typeOptionContext.typeOption = state.typeOption, + listener: (context, state) => + typeOptionContext.typeOption = state.typeOption, builder: (context, state) { return Column(children: [ _renderDateFormatButton(context, state.typeOption.dateFormat), @@ -63,7 +65,9 @@ class DateTypeOptionWidget extends TypeOptionWidget { final list = DateFormatList( selectedFormat: dataFormat, onSelected: (format) { - context.read().add(DateTypeOptionEvent.didSelectDateFormat(format)); + context + .read() + .add(DateTypeOptionEvent.didSelectDateFormat(format)); }, ); overlayDelegate.showOverlay(context, list); @@ -77,7 +81,9 @@ class DateTypeOptionWidget extends TypeOptionWidget { final list = TimeFormatList( selectedFormat: timeFormat, onSelected: (format) { - context.read().add(DateTypeOptionEvent.didSelectTimeFormat(format)); + context + .read() + .add(DateTypeOptionEvent.didSelectTimeFormat(format)); }); overlayDelegate.showOverlay(context, list); }, @@ -95,7 +101,8 @@ class DateFormatButton extends StatelessWidget { return SizedBox( height: GridSize.typeOptionItemHeight, child: FlowyButton( - text: FlowyText.medium(LocaleKeys.grid_field_dateFormat.tr(), fontSize: 12), + text: FlowyText.medium(LocaleKeys.grid_field_dateFormat.tr(), + fontSize: 12), margin: GridSize.typeOptionContentInsets, hoverColor: theme.hover, onTap: onTap, @@ -108,7 +115,9 @@ class DateFormatButton extends StatelessWidget { class TimeFormatButton extends StatelessWidget { final TimeFormat timeFormat; final VoidCallback onTap; - const TimeFormatButton({required this.timeFormat, required this.onTap, Key? key}) : super(key: key); + const TimeFormatButton( + {required this.timeFormat, required this.onTap, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -116,7 +125,8 @@ class TimeFormatButton extends StatelessWidget { return SizedBox( height: GridSize.typeOptionItemHeight, child: FlowyButton( - text: FlowyText.medium(LocaleKeys.grid_field_timeFormat.tr(), fontSize: 12), + text: FlowyText.medium(LocaleKeys.grid_field_timeFormat.tr(), + fontSize: 12), margin: GridSize.typeOptionContentInsets, hoverColor: theme.hover, onTap: onTap, @@ -140,12 +150,15 @@ class _IncludeTimeButton extends StatelessWidget { padding: GridSize.typeOptionContentInsets, child: Row( children: [ - FlowyText.medium(LocaleKeys.grid_field_includeTime.tr(), fontSize: 12), + FlowyText.medium(LocaleKeys.grid_field_includeTime.tr(), + fontSize: 12), const Spacer(), Switch( value: includeTime, onChanged: (newValue) { - context.read().add(DateTypeOptionEvent.includeTime(newValue)); + context + .read() + .add(DateTypeOptionEvent.includeTime(newValue)); }, ), ], @@ -160,7 +173,9 @@ class _IncludeTimeButton extends StatelessWidget { class DateFormatList extends StatelessWidget { final DateFormat selectedFormat; final Function(DateFormat format) onSelected; - const DateFormatList({required this.selectedFormat, required this.onSelected, Key? key}) : super(key: key); + const DateFormatList( + {required this.selectedFormat, required this.onSelected, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/multi_select.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart similarity index 85% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/multi_select.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart index 8c7ab40a6f..e1b97fe087 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/multi_select.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart @@ -1,7 +1,7 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/multi_select_type_option.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_type_option_editor.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/multi_select_type_option.dart'; import 'package:flutter/material.dart'; +import '../field_type_option_editor.dart'; import 'builder.dart'; import 'select_option.dart'; diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/number.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart similarity index 83% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/number.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart index e15abb1728..8e4e53b40c 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/number.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart @@ -1,8 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/number_bloc.dart'; -import 'package:app_flowy/workspace/application/grid/field/type_option/number_format_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/common/text_field.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_type_option_editor.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/number_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/number_format_bloc.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; @@ -15,6 +12,9 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:easy_localization/easy_localization.dart' hide NumberFormat; import 'package:app_flowy/generated/locale_keys.g.dart'; +import '../../../layout/sizes.dart'; +import '../../common/text_field.dart'; +import '../field_type_option_editor.dart'; import 'builder.dart'; class NumberTypeOptionWidgetBuilder extends TypeOptionWidgetBuilder { @@ -45,19 +45,23 @@ class NumberTypeOptionWidget extends TypeOptionWidget { Widget build(BuildContext context) { final theme = context.watch(); return BlocProvider( - create: (context) => NumberTypeOptionBloc(typeOptionContext: typeOptionContext), + create: (context) => + NumberTypeOptionBloc(typeOptionContext: typeOptionContext), child: SizedBox( height: GridSize.typeOptionItemHeight, child: BlocConsumer( - listener: (context, state) => typeOptionContext.typeOption = state.typeOption, + listener: (context, state) => + typeOptionContext.typeOption = state.typeOption, builder: (context, state) { return FlowyButton( text: Row( children: [ - FlowyText.medium(LocaleKeys.grid_field_numberFormat.tr(), fontSize: 12), + FlowyText.medium(LocaleKeys.grid_field_numberFormat.tr(), + fontSize: 12), // const HSpace(6), const Spacer(), - FlowyText.regular(state.typeOption.format.title(), fontSize: 12), + FlowyText.regular(state.typeOption.format.title(), + fontSize: 12), ], ), margin: GridSize.typeOptionContentInsets, @@ -65,7 +69,9 @@ class NumberTypeOptionWidget extends TypeOptionWidget { onTap: () { final list = NumberFormatList( onSelected: (format) { - context.read().add(NumberTypeOptionEvent.didSelectFormat(format)); + context + .read() + .add(NumberTypeOptionEvent.didSelectFormat(format)); }, selectedFormat: state.typeOption.format, ); @@ -88,7 +94,9 @@ typedef _SelectNumberFormatCallback = Function(NumberFormat format); class NumberFormatList extends StatelessWidget { final _SelectNumberFormatCallback onSelected; final NumberFormat selectedFormat; - const NumberFormatList({required this.selectedFormat, required this.onSelected, Key? key}) : super(key: key); + const NumberFormatList( + {required this.selectedFormat, required this.onSelected, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -108,7 +116,8 @@ class NumberFormatList extends StatelessWidget { format: format, onSelected: (format) { onSelected(format); - FlowyOverlay.of(context).remove(NumberFormatList.identifier()); + FlowyOverlay.of(context) + .remove(NumberFormatList.identifier()); }); }).toList(); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/rich_text.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/rich_text.dart similarity index 74% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/rich_text.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/rich_text.dart index 2375918f11..a4291f91ce 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/rich_text.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/rich_text.dart @@ -1,11 +1,12 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/type_option_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_service.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/text_type_option.pb.dart'; import 'package:flutter/material.dart'; import 'builder.dart'; typedef RichTextTypeOptionContext = TypeOptionWidgetContext; -class RichTextTypeOptionWidgetDataParser extends TypeOptionDataParser { +class RichTextTypeOptionWidgetDataParser + extends TypeOptionDataParser { @override RichTextTypeOption fromBuffer(List buffer) { return RichTextTypeOption.fromBuffer(buffer); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/select_option.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option.dart similarity index 79% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/select_option.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option.dart index c0d54159e8..5d6304ea7a 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/select_option.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option.dart @@ -1,7 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/select_option_type_option_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/extension.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/common/text_field.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/select_option_type_option_bloc.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/button.dart'; @@ -13,6 +10,9 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; +import '../../../layout/sizes.dart'; +import '../../cell/select_option_cell/extension.dart'; +import '../../common/text_field.dart'; import 'builder.dart'; import 'select_option_editor.dart'; @@ -33,8 +33,10 @@ class SelectOptionTypeOptionWidget extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => SelectOptionTypeOptionBloc(options: options, typeOptionAction: typeOptionAction), - child: BlocBuilder( + create: (context) => SelectOptionTypeOptionBloc( + options: options, typeOptionAction: typeOptionAction), + child: + BlocBuilder( builder: (context, state) { List children = [ const TypeOptionSeparator(), @@ -44,7 +46,8 @@ class SelectOptionTypeOptionWidget extends StatelessWidget { padding: EdgeInsets.only(bottom: 10), child: _CreateOptionTextField(), ), - if (state.options.isEmpty && !state.isEditingOption) const _AddOptionButton(), + if (state.options.isEmpty && !state.isEditingOption) + const _AddOptionButton(), _OptionList(overlayDelegate) ]; @@ -62,7 +65,9 @@ class OptionTitle extends StatelessWidget { Widget build(BuildContext context) { return BlocBuilder( builder: (context, state) { - List children = [FlowyText.medium(LocaleKeys.grid_field_optionTitle.tr(), fontSize: 12)]; + List children = [ + FlowyText.medium(LocaleKeys.grid_field_optionTitle.tr(), fontSize: 12) + ]; if (state.options.isNotEmpty) { children.add(const Spacer()); children.add(const _OptionTitleButton()); @@ -94,7 +99,9 @@ class _OptionTitleButton extends StatelessWidget { ), hoverColor: theme.hover, onTap: () { - context.read().add(const SelectOptionTypeOptionEvent.addingOption()); + context + .read() + .add(const SelectOptionTypeOptionEvent.addingOption()); }, ), ); @@ -139,11 +146,15 @@ class _OptionList extends StatelessWidget { option: option, onDeleted: () { delegate.hideOverlay(context); - context.read().add(SelectOptionTypeOptionEvent.deleteOption(option)); + context + .read() + .add(SelectOptionTypeOptionEvent.deleteOption(option)); }, onUpdated: (updatedOption) { delegate.hideOverlay(context); - context.read().add(SelectOptionTypeOptionEvent.updateOption(updatedOption)); + context + .read() + .add(SelectOptionTypeOptionEvent.updateOption(updatedOption)); }, key: ValueKey(option.id), ); @@ -191,10 +202,13 @@ class _AddOptionButton extends StatelessWidget { return SizedBox( height: GridSize.typeOptionItemHeight, child: FlowyButton( - text: FlowyText.medium(LocaleKeys.grid_field_addSelectOption.tr(), fontSize: 12), + text: FlowyText.medium(LocaleKeys.grid_field_addSelectOption.tr(), + fontSize: 12), hoverColor: theme.hover, onTap: () { - context.read().add(const SelectOptionTypeOptionEvent.addingOption()); + context + .read() + .add(const SelectOptionTypeOptionEvent.addingOption()); }, leftIcon: svgWidget("home/add", color: theme.iconColor), ), @@ -214,10 +228,14 @@ class _CreateOptionTextField extends StatelessWidget { autoClearWhenDone: true, text: text, onCanceled: () { - context.read().add(const SelectOptionTypeOptionEvent.endAddingOption()); + context + .read() + .add(const SelectOptionTypeOptionEvent.endAddingOption()); }, onDone: (optionName) { - context.read().add(SelectOptionTypeOptionEvent.createOption(optionName)); + context + .read() + .add(SelectOptionTypeOptionEvent.createOption(optionName)); }, ); }, diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/select_option_editor.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option_editor.dart similarity index 81% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/select_option_editor.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option_editor.dart index 5381342d20..fbb42b5784 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/select_option_editor.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option_editor.dart @@ -1,7 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/edit_select_option_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/extension.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/common/text_field.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/edit_select_option_bloc.dart'; +import 'package:app_flowy/plugins/grid/presentation/widgets/cell/select_option_cell/extension.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/button.dart'; @@ -14,6 +12,9 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; +import '../../../layout/sizes.dart'; +import '../../common/text_field.dart'; + class SelectOptionTypeOptionEditor extends StatelessWidget { final SelectOptionPB option; final VoidCallback onDeleted; @@ -49,11 +50,14 @@ class SelectOptionTypeOptionEditor extends StatelessWidget { child: BlocBuilder( builder: (context, state) { List slivers = [ - SliverToBoxAdapter(child: _OptionNameTextField(state.option.name)), + SliverToBoxAdapter( + child: _OptionNameTextField(state.option.name)), const SliverToBoxAdapter(child: VSpace(10)), const SliverToBoxAdapter(child: _DeleteTag()), const SliverToBoxAdapter(child: TypeOptionSeparator()), - SliverToBoxAdapter(child: SelectOptionColorList(selectedColor: state.option.color)), + SliverToBoxAdapter( + child: + SelectOptionColorList(selectedColor: state.option.color)), ]; return SizedBox( @@ -80,11 +84,14 @@ class _DeleteTag extends StatelessWidget { return SizedBox( height: GridSize.typeOptionItemHeight, child: FlowyButton( - text: FlowyText.medium(LocaleKeys.grid_selectOption_deleteTag.tr(), fontSize: 12), + text: FlowyText.medium(LocaleKeys.grid_selectOption_deleteTag.tr(), + fontSize: 12), hoverColor: theme.hover, leftIcon: svgWidget("grid/delete", color: theme.iconColor), onTap: () { - context.read().add(const EditSelectOptionEvent.delete()); + context + .read() + .add(const EditSelectOptionEvent.delete()); }, ), ); @@ -102,7 +109,9 @@ class _OptionNameTextField extends StatelessWidget { onCanceled: () {}, onDone: (optionName) { if (name != optionName) { - context.read().add(EditSelectOptionEvent.updateName(optionName)); + context + .read() + .add(EditSelectOptionEvent.updateName(optionName)); } }, ); @@ -111,12 +120,14 @@ class _OptionNameTextField extends StatelessWidget { class SelectOptionColorList extends StatelessWidget { final SelectOptionColorPB selectedColor; - const SelectOptionColorList({required this.selectedColor, Key? key}) : super(key: key); + const SelectOptionColorList({required this.selectedColor, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { final cells = SelectOptionColorPB.values.map((color) { - return _SelectOptionColorCell(color: color, isSelected: selectedColor == color); + return _SelectOptionColorCell( + color: color, isSelected: selectedColor == color); }).toList(); return Column( @@ -154,7 +165,9 @@ class SelectOptionColorList extends StatelessWidget { class _SelectOptionColorCell extends StatelessWidget { final SelectOptionColorPB color; final bool isSelected; - const _SelectOptionColorCell({required this.color, required this.isSelected, Key? key}) : super(key: key); + const _SelectOptionColorCell( + {required this.color, required this.isSelected, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -182,7 +195,9 @@ class _SelectOptionColorCell extends StatelessWidget { leftIcon: colorIcon, rightIcon: checkmark, onTap: () { - context.read().add(EditSelectOptionEvent.updateColor(color)); + context + .read() + .add(EditSelectOptionEvent.updateColor(color)); }, ), ); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/single_select.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/single_select.dart similarity index 85% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/single_select.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/single_select.dart index a1ed4e857a..57940ecbee 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/single_select.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/single_select.dart @@ -1,6 +1,6 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/single_select_type_option.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_type_option_editor.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/single_select_type_option.dart'; import 'package:flutter/material.dart'; +import '../field_type_option_editor.dart'; import 'builder.dart'; import 'select_option.dart'; diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/url.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/url.dart similarity index 74% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/url.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/url.dart index 97c0db0814..894a1b1e5c 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/url.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/url.dart @@ -1,11 +1,12 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/type_option_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_service.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/url_type_option.pb.dart'; import 'package:flutter/material.dart'; import 'builder.dart'; typedef URLTypeOptionContext = TypeOptionWidgetContext; -class URLTypeOptionWidgetDataParser extends TypeOptionDataParser { +class URLTypeOptionWidgetDataParser + extends TypeOptionDataParser { @override URLTypeOption fromBuffer(List buffer) { return URLTypeOption.fromBuffer(buffer); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/grid_row.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/grid_row.dart similarity index 89% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/grid_row.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/grid_row.dart index c3e2e17b7e..effc1b188c 100755 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/grid_row.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/grid_row.dart @@ -1,8 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/prelude.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/cell_accessory.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/cell_cotainer.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/icon_button.dart'; @@ -11,6 +7,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:provider/provider.dart'; +import '../../layout/sizes.dart'; +import '../cell/cell_accessory.dart'; +import '../cell/cell_cotainer.dart'; +import '../cell/prelude.dart'; import 'row_action_sheet.dart'; import 'row_detail.dart'; @@ -95,7 +95,9 @@ class _RowLeading extends StatelessWidget { Widget build(BuildContext context) { return Consumer( builder: (context, state, _) { - return SizedBox(width: GridSize.leadingHeaderPadding, child: state.onEnter ? _activeWidget() : null); + return SizedBox( + width: GridSize.leadingHeaderPadding, + child: state.onEnter ? _activeWidget() : null); }, ); } @@ -168,7 +170,8 @@ class _RowCells extends StatelessWidget { @override Widget build(BuildContext context) { return BlocBuilder( - buildWhen: (previous, current) => !listEquals(previous.snapshots, current.snapshots), + buildWhen: (previous, current) => + !listEquals(previous.snapshots, current.snapshots), builder: (context, state) { return IntrinsicHeight( child: Row( @@ -204,7 +207,8 @@ class _RowCells extends StatelessWidget { return CellContainer( width: cellId.field.width.toDouble(), child: child, - rowStateNotifier: Provider.of(context, listen: false), + rowStateNotifier: + Provider.of(context, listen: false), accessoryBuilder: accessoryBuilder, ); }, diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_action_sheet.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_action_sheet.dart similarity index 87% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_action_sheet.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_action_sheet.dart index 06e9c68d19..67c7b4893b 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_action_sheet.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_action_sheet.dart @@ -1,6 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/row/row_action_sheet_bloc.dart'; -import 'package:app_flowy/workspace/application/grid/row/row_service.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; +import 'package:app_flowy/plugins/grid/application/row/row_action_sheet_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/row/row_service.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; import 'package:flowy_infra/image.dart'; @@ -13,6 +12,8 @@ import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import '../../layout/sizes.dart'; + class GridRowActionSheet extends StatelessWidget { final GridRowInfo rowData; const GridRowActionSheet({required this.rowData, Key? key}) : super(key: key); @@ -76,7 +77,9 @@ class GridRowActionSheet extends StatelessWidget { class _RowActionCell extends StatelessWidget { final _RowAction action; final VoidCallback onDismissed; - const _RowActionCell({required this.action, required this.onDismissed, Key? key}) : super(key: key); + const _RowActionCell( + {required this.action, required this.onDismissed, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -139,10 +142,14 @@ extension _RowActionExtension on _RowAction { void performAction(BuildContext context) { switch (this) { case _RowAction.duplicate: - context.read().add(const RowActionSheetEvent.duplicateRow()); + context + .read() + .add(const RowActionSheetEvent.duplicateRow()); break; case _RowAction.delete: - context.read().add(const RowActionSheetEvent.deleteRow()); + context + .read() + .add(const RowActionSheetEvent.deleteRow()); break; } } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_detail.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_detail.dart similarity index 83% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_detail.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_detail.dart index a01f97b847..e7e00ead68 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_detail.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_detail.dart @@ -1,13 +1,7 @@ -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; -import 'package:app_flowy/workspace/application/grid/row/row_detail_bloc.dart'; -import 'package:app_flowy/workspace/application/grid/row/row_service.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/cell_accessory.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/prelude.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/url_cell/url_cell.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_cell.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_editor.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/row/row_detail_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/row/row_service.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; @@ -20,6 +14,12 @@ import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import '../../layout/sizes.dart'; +import '../cell/cell_accessory.dart'; +import '../cell/prelude.dart'; +import '../header/field_cell.dart'; +import '../header/field_editor.dart'; + class RowDetailPage extends StatefulWidget with FlowyOverlayDelegate { final GridRowInfo rowInfo; final GridRowCache rowCache; @@ -62,7 +62,8 @@ class _RowDetailPageState extends State { Widget build(BuildContext context) { return BlocProvider( create: (context) { - final bloc = RowDetailBloc(rowInfo: widget.rowInfo, rowCache: widget.rowCache); + final bloc = + RowDetailBloc(rowInfo: widget.rowInfo, rowCache: widget.rowCache); bloc.add(const RowDetailEvent.initial()); return bloc; }, @@ -92,7 +93,8 @@ class _CloseButton extends StatelessWidget { final theme = context.watch(); return FlowyIconButton( width: 24, - onPressed: () => FlowyOverlay.of(context).remove(RowDetailPage.identifier()), + onPressed: () => + FlowyOverlay.of(context).remove(RowDetailPage.identifier()), iconPadding: const EdgeInsets.fromLTRB(2, 2, 2, 2), icon: svgWidget("home/close", color: theme.iconColor), ); @@ -156,7 +158,8 @@ class _RowDetailCell extends StatelessWidget { onTap: () => cell.beginFocus.notify(), child: AccessoryHover( child: cell, - contentPadding: const EdgeInsets.symmetric(horizontal: 10, vertical: 12), + contentPadding: + const EdgeInsets.symmetric(horizontal: 10, vertical: 12), ), ); @@ -169,7 +172,8 @@ class _RowDetailCell extends StatelessWidget { children: [ SizedBox( width: 150, - child: FieldCellButton(field: cellId.field, onTap: () => _showFieldEditor(context)), + child: FieldCellButton( + field: cellId.field, onTap: () => _showFieldEditor(context)), ), const HSpace(10), Expanded(child: gesture), diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/shortcuts.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/shortcuts.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/shortcuts.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/shortcuts.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_property.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_property.dart similarity index 81% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_property.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_property.dart index b34007493b..df4eb2115c 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_property.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_property.dart @@ -1,10 +1,8 @@ import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; -import 'package:app_flowy/workspace/application/grid/grid_service.dart'; -import 'package:app_flowy/workspace/application/grid/setting/property_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_editor.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_type_extension.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/grid_service.dart'; +import 'package:app_flowy/plugins/grid/application/setting/property_bloc.dart'; +import 'package:app_flowy/plugins/grid/presentation/widgets/header/field_type_extension.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; @@ -17,6 +15,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:styled_widget/styled_widget.dart'; +import '../../layout/sizes.dart'; +import '../header/field_editor.dart'; + class GridPropertyList extends StatelessWidget with FlowyOverlayDelegate { final String gridId; final GridFieldCache fieldCache; @@ -44,11 +45,13 @@ class GridPropertyList extends StatelessWidget with FlowyOverlayDelegate { Widget build(BuildContext context) { return BlocProvider( create: (context) => - getIt(param1: gridId, param2: fieldCache)..add(const GridPropertyEvent.initial()), + getIt(param1: gridId, param2: fieldCache) + ..add(const GridPropertyEvent.initial()), child: BlocBuilder( builder: (context, state) { final cells = state.fields.map((field) { - return _GridPropertyCell(gridId: gridId, field: field, key: ValueKey(field.id)); + return _GridPropertyCell( + gridId: gridId, field: field, key: ValueKey(field.id)); }).toList(); return ListView.separated( @@ -77,7 +80,8 @@ class GridPropertyList extends StatelessWidget with FlowyOverlayDelegate { class _GridPropertyCell extends StatelessWidget { final GridFieldPB field; final String gridId; - const _GridPropertyCell({required this.gridId, required this.field, Key? key}) : super(key: key); + const _GridPropertyCell({required this.gridId, required this.field, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -99,7 +103,9 @@ class _GridPropertyCell extends StatelessWidget { hoverColor: theme.hover, width: GridSize.typeOptionItemHeight, onPressed: () { - context.read().add(GridPropertyEvent.setFieldVisibility(field.id, !field.visibility)); + context.read().add( + GridPropertyEvent.setFieldVisibility( + field.id, !field.visibility)); }, icon: checkmark.padding(all: 6), ) diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_setting.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_setting.dart similarity index 82% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_setting.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_setting.dart index 7e3c14e021..d7c084fe2d 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_setting.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_setting.dart @@ -1,5 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/grid_service.dart'; -import 'package:app_flowy/workspace/application/grid/setting/setting_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/grid_service.dart'; +import 'package:app_flowy/plugins/grid/application/setting/setting_bloc.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; @@ -12,8 +12,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; - +import '../../layout/sizes.dart'; import 'grid_property.dart'; class GridSettingContext { @@ -29,7 +28,9 @@ class GridSettingContext { class GridSettingList extends StatelessWidget { final GridSettingContext settingContext; final Function(GridSettingAction, GridSettingContext) onAction; - const GridSettingList({required this.settingContext, required this.onAction, Key? key}) : super(key: key); + const GridSettingList( + {required this.settingContext, required this.onAction, Key? key}) + : super(key: key); static void show(BuildContext context, GridSettingContext settingContext) { final list = GridSettingList( @@ -41,7 +42,10 @@ class GridSettingList extends StatelessWidget { case GridSettingAction.sortBy: break; case GridSettingAction.properties: - GridPropertyList(gridId: settingContext.gridId, fieldCache: settingContext.fieldCache).show(context); + GridPropertyList( + gridId: settingContext.gridId, + fieldCache: settingContext.fieldCache) + .show(context); break; } }, @@ -64,7 +68,8 @@ class GridSettingList extends StatelessWidget { return BlocProvider( create: (context) => GridSettingBloc(gridId: settingContext.gridId), child: BlocListener( - listenWhen: (previous, current) => previous.selectedAction != current.selectedAction, + listenWhen: (previous, current) => + previous.selectedAction != current.selectedAction, listener: (context, state) { state.selectedAction.foldLeft(null, (_, action) { FlowyOverlay.of(context).remove(identifier()); @@ -85,7 +90,8 @@ class GridSettingList extends StatelessWidget { } Widget _renderList() { - final cells = GridSettingAction.values.where((value) => value.enable()).map((action) { + final cells = + GridSettingAction.values.where((value) => value.enable()).map((action) { return _SettingItem(action: action); }).toList(); @@ -128,10 +134,13 @@ class _SettingItem extends StatelessWidget { height: GridSize.typeOptionItemHeight, child: FlowyButton( isSelected: isSelected, - text: FlowyText.medium(action.title(), fontSize: 12, color: action.enable() ? null : theme.shader4), + text: FlowyText.medium(action.title(), + fontSize: 12, color: action.enable() ? null : theme.shader4), hoverColor: theme.hover, onTap: () { - context.read().add(GridSettingEvent.performAction(action)); + context + .read() + .add(GridSettingEvent.performAction(action)); }, leftIcon: svgWidget(action.iconName(), color: theme.iconColor), ), diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_toolbar.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_toolbar.dart similarity index 85% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_toolbar.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_toolbar.dart index 8d25189163..2f332ffe2f 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_toolbar.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_toolbar.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/grid_service.dart'; +import 'package:app_flowy/plugins/grid/application/grid_service.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/extension.dart'; @@ -6,8 +6,7 @@ import 'package:flowy_infra_ui/style_widget/icon_button.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; - +import '../../layout/sizes.dart'; import 'grid_setting.dart'; class GridToolbarContext { @@ -44,7 +43,8 @@ class GridToolbar extends StatelessWidget { class _SettingButton extends StatelessWidget { final GridSettingContext settingContext; - const _SettingButton({required this.settingContext, Key? key}) : super(key: key); + const _SettingButton({required this.settingContext, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -53,7 +53,8 @@ class _SettingButton extends StatelessWidget { hoverColor: theme.hover, width: 22, onPressed: () => GridSettingList.show(context, settingContext), - icon: svgWidget("grid/setting/setting").padding(horizontal: 3, vertical: 3), + icon: + svgWidget("grid/setting/setting").padding(horizontal: 3, vertical: 3), ); } } diff --git a/frontend/app_flowy/lib/workspace/application/trash/prelude.dart b/frontend/app_flowy/lib/plugins/trash/application/prelude.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/trash/prelude.dart rename to frontend/app_flowy/lib/plugins/trash/application/prelude.dart diff --git a/frontend/app_flowy/lib/workspace/application/trash/trash_bloc.dart b/frontend/app_flowy/lib/plugins/trash/application/trash_bloc.dart similarity index 82% rename from frontend/app_flowy/lib/workspace/application/trash/trash_bloc.dart rename to frontend/app_flowy/lib/plugins/trash/application/trash_bloc.dart index a7bcf0588c..0286747fd5 100644 --- a/frontend/app_flowy/lib/workspace/application/trash/trash_bloc.dart +++ b/frontend/app_flowy/lib/plugins/trash/application/trash_bloc.dart @@ -4,20 +4,23 @@ import 'package:flowy_sdk/protobuf/flowy-folder/trash.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:app_flowy/workspace/application/trash/trash_service.dart'; -import 'package:app_flowy/workspace/application/trash/trash_listener.dart'; +import 'package:app_flowy/plugins/trash/application/trash_service.dart'; +import 'package:app_flowy/plugins/trash/application/trash_listener.dart'; + part 'trash_bloc.freezed.dart'; class TrashBloc extends Bloc { final TrashService service; final TrashListener listener; - TrashBloc({required this.service, required this.listener}) : super(TrashState.init()) { + TrashBloc({required this.service, required this.listener}) + : super(TrashState.init()) { on((event, emit) async { await event.map(initial: (e) async { listener.start(trashUpdated: _listenTrashUpdated); final result = await service.readTrash(); emit(result.fold( - (object) => state.copyWith(objects: object.items, successOrFailure: left(unit)), + (object) => state.copyWith( + objects: object.items, successOrFailure: left(unit)), (error) => state.copyWith(successOrFailure: right(error)), )); }, didReceiveTrash: (e) async { @@ -26,7 +29,8 @@ class TrashBloc extends Bloc { final result = await service.putback(e.trashId); await _handleResult(result, emit); }, delete: (e) async { - final result = await service.deleteViews([Tuple2(e.trash.id, e.trash.ty)]); + final result = + await service.deleteViews([Tuple2(e.trash.id, e.trash.ty)]); await _handleResult(result, emit); }, deleteAll: (e) async { final result = await service.deleteAll(); @@ -38,7 +42,8 @@ class TrashBloc extends Bloc { }); } - Future _handleResult(Either result, Emitter emit) async { + Future _handleResult( + Either result, Emitter emit) async { emit(result.fold( (l) => state.copyWith(successOrFailure: left(unit)), (error) => state.copyWith(successOrFailure: right(error)), diff --git a/frontend/app_flowy/lib/workspace/application/trash/trash_listener.dart b/frontend/app_flowy/lib/plugins/trash/application/trash_listener.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/trash/trash_listener.dart rename to frontend/app_flowy/lib/plugins/trash/application/trash_listener.dart diff --git a/frontend/app_flowy/lib/workspace/application/trash/trash_service.dart b/frontend/app_flowy/lib/plugins/trash/application/trash_service.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/trash/trash_service.dart rename to frontend/app_flowy/lib/plugins/trash/application/trash_service.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/menu.dart b/frontend/app_flowy/lib/plugins/trash/menu.dart similarity index 77% rename from frontend/app_flowy/lib/workspace/presentation/plugins/trash/menu.dart rename to frontend/app_flowy/lib/plugins/trash/menu.dart index ec782db205..e0a6c5ce49 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/menu.dart +++ b/frontend/app_flowy/lib/plugins/trash/menu.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/application/appearance.dart'; import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; @@ -22,7 +22,8 @@ class MenuTrash extends StatelessWidget { child: InkWell( onTap: () { getIt().latestOpenView = null; - getIt().setPlugin(makePlugin(pluginType: DefaultPlugin.trash.type())); + getIt() + .setPlugin(makePlugin(pluginType: DefaultPlugin.trash.type())); }, child: _render(context), ), @@ -35,8 +36,10 @@ class MenuTrash extends StatelessWidget { value: Provider.of(context, listen: true), child: Selector( selector: (ctx, notifier) => notifier.theme, - builder: (ctx, theme, child) => - SizedBox(width: 16, height: 16, child: svgWidget("home/trash", color: theme.iconColor)), + builder: (ctx, theme, child) => SizedBox( + width: 16, + height: 16, + child: svgWidget("home/trash", color: theme.iconColor)), ), ), const HSpace(6), @@ -44,7 +47,8 @@ class MenuTrash extends StatelessWidget { value: Provider.of(context, listen: true), child: Selector( selector: (ctx, notifier) => notifier.locale, - builder: (ctx, _, child) => FlowyText.medium(LocaleKeys.trash_text.tr(), fontSize: 12), + builder: (ctx, _, child) => + FlowyText.medium(LocaleKeys.trash_text.tr(), fontSize: 12), ), ), ]); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/src/sizes.dart b/frontend/app_flowy/lib/plugins/trash/src/sizes.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/trash/src/sizes.dart rename to frontend/app_flowy/lib/plugins/trash/src/sizes.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/src/trash_cell.dart b/frontend/app_flowy/lib/plugins/trash/src/trash_cell.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/trash/src/trash_cell.dart rename to frontend/app_flowy/lib/plugins/trash/src/trash_cell.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/src/trash_header.dart b/frontend/app_flowy/lib/plugins/trash/src/trash_header.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/trash/src/trash_header.dart rename to frontend/app_flowy/lib/plugins/trash/src/trash_header.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/trash.dart b/frontend/app_flowy/lib/plugins/trash/trash.dart similarity index 90% rename from frontend/app_flowy/lib/workspace/presentation/plugins/trash/trash.dart rename to frontend/app_flowy/lib/plugins/trash/trash.dart index e098eddf96..18a2c4aa8e 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/trash.dart +++ b/frontend/app_flowy/lib/plugins/trash/trash.dart @@ -2,9 +2,9 @@ export "./src/sizes.dart"; export "./src/trash_cell.dart"; export "./src/trash_header.dart"; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/trash/trash_bloc.dart'; +import 'package:app_flowy/plugins/trash/application/trash_bloc.dart'; import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra/image.dart'; @@ -59,7 +59,8 @@ class TrashPlugin extends Plugin { class TrashPluginDisplay extends PluginDisplay { @override - Widget get leftBarItem => FlowyText.medium(LocaleKeys.trash_text.tr(), fontSize: 12); + Widget get leftBarItem => + FlowyText.medium(LocaleKeys.trash_text.tr(), fontSize: 12); @override Widget? get rightBarItem => null; @@ -145,20 +146,24 @@ class _TrashPageState extends State { SizedBox.fromSize( size: const Size(102, 30), child: FlowyButton( - text: FlowyText.medium(LocaleKeys.trash_restoreAll.tr(), fontSize: 12), + text: FlowyText.medium(LocaleKeys.trash_restoreAll.tr(), + fontSize: 12), leftIcon: svgWidget('editor/restore', color: theme.iconColor), hoverColor: theme.hover, - onTap: () => context.read().add(const TrashEvent.restoreAll()), + onTap: () => + context.read().add(const TrashEvent.restoreAll()), ), ), const HSpace(6), SizedBox.fromSize( size: const Size(102, 30), child: FlowyButton( - text: FlowyText.medium(LocaleKeys.trash_deleteAll.tr(), fontSize: 12), + text: FlowyText.medium(LocaleKeys.trash_deleteAll.tr(), + fontSize: 12), leftIcon: svgWidget('editor/delete', color: theme.iconColor), hoverColor: theme.hover, - onTap: () => context.read().add(const TrashEvent.deleteAll()), + onTap: () => + context.read().add(const TrashEvent.deleteAll()), ), ) ], @@ -186,7 +191,8 @@ class _TrashPageState extends State { onRestore: () { context.read().add(TrashEvent.putback(object.id)); }, - onDelete: () => context.read().add(TrashEvent.delete(object)), + onDelete: () => + context.read().add(TrashEvent.delete(object)), ), ); }, diff --git a/frontend/app_flowy/lib/startup/deps_resolver.dart b/frontend/app_flowy/lib/startup/deps_resolver.dart index e0ab40eea7..6627546c72 100644 --- a/frontend/app_flowy/lib/startup/deps_resolver.dart +++ b/frontend/app_flowy/lib/startup/deps_resolver.dart @@ -2,9 +2,8 @@ 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/prelude.dart'; -import 'package:app_flowy/workspace/application/trash/prelude.dart'; +import 'package:app_flowy/plugins/doc/application/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:app_flowy/workspace/application/user/prelude.dart'; import 'package:app_flowy/workspace/application/workspace/prelude.dart'; import 'package:app_flowy/workspace/application/edit_pannel/edit_pannel_bloc.dart'; @@ -13,6 +12,7 @@ import 'package:app_flowy/workspace/application/menu/prelude.dart'; import 'package:app_flowy/workspace/application/settings/prelude.dart'; import 'package:app_flowy/user/application/prelude.dart'; import 'package:app_flowy/user/presentation/router.dart'; +import 'package:app_flowy/plugins/trash/application/prelude.dart'; import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; import 'package:app_flowy/workspace/presentation/home/menu/menu.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart'; @@ -76,7 +76,8 @@ void _resolveHomeDeps(GetIt getIt) { void _resolveFolderDeps(GetIt getIt) { //workspace getIt.registerFactoryParam( - (user, workspaceId) => WorkspaceListener(user: user, workspaceId: workspaceId)); + (user, workspaceId) => + WorkspaceListener(user: user, workspaceId: workspaceId)); // ViewPB getIt.registerFactoryParam( @@ -171,7 +172,8 @@ void _resolveGridDeps(GetIt getIt) { ), ); - getIt.registerFactoryParam( + getIt.registerFactoryParam( (context, _) => SelectOptionCellBloc( cellContext: context, ), diff --git a/frontend/app_flowy/lib/plugin/plugin.dart b/frontend/app_flowy/lib/startup/plugin/plugin.dart similarity index 93% rename from frontend/app_flowy/lib/plugin/plugin.dart rename to frontend/app_flowy/lib/startup/plugin/plugin.dart index e05a3ad862..a02a8cfb83 100644 --- a/frontend/app_flowy/lib/plugin/plugin.dart +++ b/frontend/app_flowy/lib/startup/plugin/plugin.dart @@ -1,6 +1,6 @@ library flowy_plugin; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; import 'package:flowy_infra/notifier.dart'; @@ -72,7 +72,8 @@ abstract class PluginDisplay with NavigationItem { } void registerPlugin({required PluginBuilder builder, PluginConfig? config}) { - getIt().registerPlugin(builder.pluginType, builder, config: config); + getIt() + .registerPlugin(builder.pluginType, builder, config: config); } Plugin makePlugin({required PluginType pluginType, dynamic data}) { diff --git a/frontend/app_flowy/lib/plugin/src/runner.dart b/frontend/app_flowy/lib/startup/plugin/src/runner.dart similarity index 100% rename from frontend/app_flowy/lib/plugin/src/runner.dart rename to frontend/app_flowy/lib/startup/plugin/src/runner.dart diff --git a/frontend/app_flowy/lib/plugin/src/sandbox.dart b/frontend/app_flowy/lib/startup/plugin/src/sandbox.dart similarity index 100% rename from frontend/app_flowy/lib/plugin/src/sandbox.dart rename to frontend/app_flowy/lib/startup/plugin/src/sandbox.dart diff --git a/frontend/app_flowy/lib/startup/startup.dart b/frontend/app_flowy/lib/startup/startup.dart index 38243afa56..f71df96f23 100644 --- a/frontend/app_flowy/lib/startup/startup.dart +++ b/frontend/app_flowy/lib/startup/startup.dart @@ -1,6 +1,6 @@ import 'dart:io'; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/startup/tasks/prelude.dart'; import 'package:app_flowy/startup/deps_resolver.dart'; import 'package:flutter/foundation.dart'; diff --git a/frontend/app_flowy/lib/startup/tasks/load_plugin.dart b/frontend/app_flowy/lib/startup/tasks/load_plugin.dart index d89bc83b37..5eabc18064 100644 --- a/frontend/app_flowy/lib/startup/tasks/load_plugin.dart +++ b/frontend/app_flowy/lib/startup/tasks/load_plugin.dart @@ -1,10 +1,10 @@ -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/presentation/plugins/blank/blank.dart'; -import 'package:app_flowy/workspace/presentation/plugins/board/board.dart'; -import 'package:app_flowy/workspace/presentation/plugins/doc/document.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/grid.dart'; -import 'package:app_flowy/workspace/presentation/plugins/trash/trash.dart'; +import 'package:app_flowy/plugins/blank/blank.dart'; +import 'package:app_flowy/plugins/board/board.dart'; +import 'package:app_flowy/plugins/doc/document.dart'; +import 'package:app_flowy/plugins/grid/grid.dart'; +import 'package:app_flowy/plugins/trash/trash.dart'; class PluginLoadTask extends LaunchTask { @override 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 e8d2335168..f86bb5855b 100644 --- a/frontend/app_flowy/lib/workspace/application/app/app_bloc.dart +++ b/frontend/app_flowy/lib/workspace/application/app/app_bloc.dart @@ -1,6 +1,6 @@ import 'dart:collection'; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/application/app/app_listener.dart'; import 'package:app_flowy/workspace/application/app/app_service.dart'; @@ -22,7 +22,9 @@ class AppBloc extends Bloc { final AppService appService; final AppListener appListener; - AppBloc({required this.app, required this.appService, required this.appListener}) : super(AppState.initial(app)) { + AppBloc( + {required this.app, required this.appService, required this.appListener}) + : super(AppState.initial(app)) { on((event, emit) async { await event.map(initial: (e) async { _startListening(); @@ -103,11 +105,13 @@ class AppBloc extends Bloc { return super.close(); } - Future _didReceiveViewUpdated(List views, Emitter emit) async { + Future _didReceiveViewUpdated( + List views, Emitter emit) async { final latestCreatedView = state.latestCreatedView; AppState newState = state.copyWith(views: views); if (latestCreatedView != null) { - final index = views.indexWhere((element) => element.id == latestCreatedView.id); + final index = + views.indexWhere((element) => element.id == latestCreatedView.id); if (index == -1) { newState = newState.copyWith(latestCreatedView: null); } @@ -139,7 +143,8 @@ class AppEvent with _$AppEvent { ) = CreateView; const factory AppEvent.delete() = Delete; const factory AppEvent.rename(String newName) = Rename; - const factory AppEvent.didReceiveViewUpdated(List views) = ReceiveViews; + const factory AppEvent.didReceiveViewUpdated(List views) = + ReceiveViews; const factory AppEvent.appDidUpdate(AppPB app) = AppDidUpdate; } @@ -164,11 +169,13 @@ class AppViewDataContext extends ChangeNotifier { final ValueNotifier> _viewsNotifier = ValueNotifier([]); final ValueNotifier _selectedViewNotifier = ValueNotifier(null); VoidCallback? _menuSharedStateListener; - ExpandableController expandController = ExpandableController(initialExpanded: false); + ExpandableController expandController = + ExpandableController(initialExpanded: false); AppViewDataContext({required this.appId}) { _setLatestView(getIt().latestOpenView); - _menuSharedStateListener = getIt().addLatestViewListener((view) { + _menuSharedStateListener = + getIt().addLatestViewListener((view) { _setLatestView(view); }); } @@ -206,9 +213,11 @@ class AppViewDataContext extends ChangeNotifier { } } - UnmodifiableListView get views => UnmodifiableListView(_viewsNotifier.value); + UnmodifiableListView get views => + UnmodifiableListView(_viewsNotifier.value); - VoidCallback addViewsChangeListener(void Function(UnmodifiableListView) callback) { + VoidCallback addViewsChangeListener( + void Function(UnmodifiableListView) callback) { listener() { callback(views); } @@ -241,7 +250,8 @@ class AppViewDataContext extends ChangeNotifier { @override void dispose() { if (_menuSharedStateListener != null) { - getIt().removeLatestViewListener(_menuSharedStateListener!); + getIt() + .removeLatestViewListener(_menuSharedStateListener!); } super.dispose(); } diff --git a/frontend/app_flowy/lib/workspace/application/app/app_service.dart b/frontend/app_flowy/lib/workspace/application/app/app_service.dart index cc75751e49..695f2f4b6b 100644 --- a/frontend/app_flowy/lib/workspace/application/app/app_service.dart +++ b/frontend/app_flowy/lib/workspace/application/app/app_service.dart @@ -6,7 +6,7 @@ import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; class AppService { final String appId; @@ -53,7 +53,8 @@ class AppService { return FolderEventDeleteApp(request).send(); } - Future> updateApp({required String appId, String? name}) { + Future> updateApp( + {required String appId, String? name}) { UpdateAppPayloadPB payload = UpdateAppPayloadPB.create()..appId = appId; if (name != null) { diff --git a/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart b/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart index 21d51f5a93..4b699570e6 100644 --- a/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart +++ b/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart @@ -1,5 +1,5 @@ import 'dart:async'; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/workspace/application/workspace/workspace_listener.dart'; import 'package:app_flowy/workspace/application/workspace/workspace_service.dart'; import 'package:dartz/dartz.dart'; @@ -40,7 +40,10 @@ class MenuBloc extends Bloc { moveApp: (_MoveApp value) { if (state.apps.length > value.fromIndex) { final app = state.apps[value.fromIndex]; - _workspaceService.moveApp(appId: app.id, fromIndex: value.fromIndex, toIndex: value.toIndex); + _workspaceService.moveApp( + appId: app.id, + fromIndex: value.fromIndex, + toIndex: value.toIndex); final apps = List.from(state.apps); apps.insert(value.toIndex, apps.removeAt(value.fromIndex)); emit(state.copyWith(apps: apps)); @@ -56,8 +59,10 @@ class MenuBloc extends Bloc { return super.close(); } - Future _performActionOnCreateApp(_CreateApp event, Emitter emit) async { - final result = await _workspaceService.createApp(name: event.name, desc: event.desc ?? ""); + Future _performActionOnCreateApp( + _CreateApp event, Emitter emit) async { + final result = await _workspaceService.createApp( + name: event.name, desc: event.desc ?? ""); result.fold( (app) => {}, (error) { @@ -93,7 +98,8 @@ class MenuEvent with _$MenuEvent { const factory MenuEvent.openPage(Plugin plugin) = _OpenPage; const factory MenuEvent.createApp(String name, {String? desc}) = _CreateApp; const factory MenuEvent.moveApp(int fromIndex, int toIndex) = _MoveApp; - const factory MenuEvent.didReceiveApps(Either, FlowyError> appsOrFail) = _ReceiveApps; + const factory MenuEvent.didReceiveApps( + Either, FlowyError> appsOrFail) = _ReceiveApps; } @freezed diff --git a/frontend/app_flowy/lib/workspace/application/view/view_ext.dart b/frontend/app_flowy/lib/workspace/application/view/view_ext.dart index a54d5ecf40..79a27b64ce 100644 --- a/frontend/app_flowy/lib/workspace/application/view/view_ext.dart +++ b/frontend/app_flowy/lib/workspace/application/view/view_ext.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter/material.dart'; diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart index abe89c14cb..3aca4dd9ff 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/workspace/application/home/home_bloc.dart'; import 'package:app_flowy/workspace/presentation/widgets/edit_pannel/pannel_animation.dart'; import 'package:app_flowy/workspace/presentation/widgets/float_bubble/question_bubble.dart'; @@ -21,7 +21,8 @@ import 'menu/menu.dart'; class HomeScreen extends StatefulWidget { final UserProfilePB user; final CurrentWorkspaceSettingPB workspaceSetting; - const HomeScreen(this.user, this.workspaceSetting, {Key? key}) : super(key: key); + const HomeScreen(this.user, this.workspaceSetting, {Key? key}) + : super(key: key); @override State createState() => _HomeScreenState(); @@ -47,7 +48,8 @@ class _HomeScreenState extends State { providers: [ BlocProvider( create: (context) { - return HomeBloc(widget.user, widget.workspaceSetting)..add(const HomeEvent.initial()); + return HomeBloc(widget.user, widget.workspaceSetting) + ..add(const HomeEvent.initial()); }, ), ], @@ -62,9 +64,12 @@ class _HomeScreenState extends State { child: BlocBuilder( buildWhen: (previous, current) => previous != current, builder: (context, state) { - final collapasedNotifier = getIt().collapsedNotifier; + final collapasedNotifier = + getIt().collapsedNotifier; collapasedNotifier.addPublishListener((isCollapsed) { - context.read().add(HomeEvent.forceCollapse(isCollapsed)); + context + .read() + .add(HomeEvent.forceCollapse(isCollapsed)); }); return FlowyContainer( Theme.of(context).colorScheme.surface, @@ -107,7 +112,10 @@ class _HomeScreenState extends State { ); } - Widget _buildHomeMenu({required HomeLayout layout, required BuildContext context, required HomeState state}) { + Widget _buildHomeMenu( + {required HomeLayout layout, + required BuildContext context, + required HomeState state}) { final workspaceSetting = state.workspaceSetting; if (initialView == null && workspaceSetting.hasLatestView()) { initialView = workspaceSetting.latestView; @@ -124,7 +132,8 @@ class _HomeScreenState extends State { collapsedNotifier: getIt().collapsedNotifier, ); - final latestView = workspaceSetting.hasLatestView() ? workspaceSetting.latestView : null; + final latestView = + workspaceSetting.hasLatestView() ? workspaceSetting.latestView : null; if (getIt().latestOpenView == null) { /// AppFlowy will open the view that the last time the user opened it. The _buildHomeMenu will get called when AppFlowy's screen resizes. So we only set the latestOpenView when it's null. getIt().latestOpenView = latestView; @@ -133,10 +142,14 @@ class _HomeScreenState extends State { return FocusTraversalGroup(child: RepaintBoundary(child: homeMenu)); } - Widget _buildEditPannel({required HomeState homeState, required BuildContext context, required HomeLayout layout}) { + Widget _buildEditPannel( + {required HomeState homeState, + required BuildContext context, + required HomeLayout layout}) { final homeBloc = context.read(); return BlocBuilder( - buildWhen: (previous, current) => previous.pannelContext != current.pannelContext, + buildWhen: (previous, current) => + previous.pannelContext != current.pannelContext, builder: (context, state) { return state.pannelContext.fold( () => const SizedBox(), @@ -144,7 +157,8 @@ class _HomeScreenState extends State { child: RepaintBoundary( child: EditPannel( pannelContext: pannelContext, - onEndEdit: () => homeBloc.add(const HomeEvent.dismissEditPannel()), + onEndEdit: () => + homeBloc.add(const HomeEvent.dismissEditPannel()), ), ), ), @@ -161,7 +175,9 @@ class _HomeScreenState extends State { child: GestureDetector( dragStartBehavior: DragStartBehavior.down, onPanUpdate: ((details) { - context.read().add(HomeEvent.editPannelResized(details.delta.dx)); + context + .read() + .add(HomeEvent.editPannelResized(details.delta.dx)); }), behavior: HitTestBehavior.translucent, child: SizedBox( @@ -186,11 +202,21 @@ class _HomeScreenState extends State { closeX: -layout.menuWidth, isClosed: !layout.showMenu, ) - .positioned(left: 0, top: 0, width: layout.menuWidth, bottom: 0, animate: true) + .positioned( + left: 0, + top: 0, + width: layout.menuWidth, + bottom: 0, + animate: true) .animate(layout.animDuration, Curves.easeOut), homeStack .constrained(minWidth: 500) - .positioned(left: layout.homePageLOffset, right: layout.homePageROffset, bottom: 0, top: 0, animate: true) + .positioned( + left: layout.homePageLOffset, + right: layout.homePageROffset, + bottom: 0, + top: 0, + animate: true) .animate(layout.animDuration, Curves.easeOut), homeMenuResizer.positioned(left: layout.homePageLOffset - 5), bubble @@ -206,7 +232,8 @@ class _HomeScreenState extends State { closeX: layout.editPannelWidth, isClosed: !layout.showEditPannel, ) - .positioned(right: 0, top: 0, bottom: 0, width: layout.editPannelWidth), + .positioned( + right: 0, top: 0, bottom: 0, width: layout.editPannelWidth), ], ); } diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart index 07bd99deb1..d58f849cd7 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart @@ -2,6 +2,7 @@ import 'dart:io' show Platform; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/application/home/home_bloc.dart'; +import 'package:app_flowy/plugins/blank/blank.dart'; import 'package:app_flowy/workspace/presentation/home/toast.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_sdk/log.dart'; @@ -9,8 +10,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:provider/provider.dart'; import 'package:time/time.dart'; -import 'package:app_flowy/plugin/plugin.dart'; -import 'package:app_flowy/workspace/presentation/plugins/blank/blank.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/workspace/presentation/home/home_sizes.dart'; import 'package:app_flowy/workspace/presentation/home/navigation.dart'; import 'package:app_flowy/core/frameless_window.dart'; @@ -107,7 +107,8 @@ class HomeStackNotifier extends ChangeNotifier { Widget get titleWidget => _plugin.display.leftBarItem; - HomeStackNotifier({Plugin? plugin}) : _plugin = plugin ?? makePlugin(pluginType: DefaultPlugin.blank.type()); + HomeStackNotifier({Plugin? plugin}) + : _plugin = plugin ?? makePlugin(pluginType: DefaultPlugin.blank.type()); set plugin(Plugin newPlugin) { if (newPlugin.id == _plugin.id) { @@ -166,7 +167,9 @@ class HomeStackManager { index: getIt().indexOf(notifier.plugin.ty), children: getIt().supportPluginTypes.map((pluginType) { if (pluginType == notifier.plugin.ty) { - return notifier.plugin.display.buildWidget().padding(horizontal: 40, vertical: 28); + return notifier.plugin.display + .buildWidget() + .padding(horizontal: 40, vertical: 28); } else { return const BlankPage(); } @@ -190,7 +193,8 @@ class HomeTopBar extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, children: [ BlocBuilder( - buildWhen: ((previous, current) => previous.isMenuCollapsed != current.isMenuCollapsed), + buildWhen: ((previous, current) => + previous.isMenuCollapsed != current.isMenuCollapsed), builder: (context, state) { if (state.isMenuCollapsed && Platform.isMacOS) { return const HSpace(80); @@ -202,7 +206,8 @@ class HomeTopBar extends StatelessWidget { ChangeNotifierProvider.value( value: Provider.of(context, listen: false), child: Consumer( - builder: (BuildContext context, HomeStackNotifier notifier, Widget? child) { + builder: (BuildContext context, HomeStackNotifier notifier, + Widget? child) { return notifier.plugin.display.rightBarItem ?? const SizedBox(); }, ), diff --git a/frontend/app_flowy/lib/workspace/presentation/home/menu/app/header/add_button.dart b/frontend/app_flowy/lib/workspace/presentation/home/menu/app/header/add_button.dart index 5b15fecc52..5b06d2c3a2 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/menu/app/header/add_button.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/menu/app/header/add_button.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; @@ -28,7 +28,8 @@ class AddButton extends StatelessWidget { onSelected: onSelected, ).show(context); }, - icon: svgWidget("home/add", color: theme.iconColor).padding(horizontal: 3, vertical: 3), + icon: svgWidget("home/add", color: theme.iconColor) + .padding(horizontal: 3, vertical: 3), ); } } diff --git a/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart b/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart index 3976598b7b..6732d88925 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart @@ -2,9 +2,9 @@ export './app/header/header.dart'; export './app/menu_app.dart'; import 'dart:io' show Platform; +import 'package:app_flowy/plugins/trash/menu.dart'; import 'package:app_flowy/workspace/presentation/home/home_sizes.dart'; import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; -import 'package:app_flowy/workspace/presentation/plugins/trash/menu.dart'; import 'package:flowy_infra/notifier.dart'; import 'package:flowy_infra/size.dart'; import 'package:flowy_infra/theme.dart'; @@ -49,7 +49,8 @@ class HomeMenu extends StatelessWidget { providers: [ BlocProvider( create: (context) { - final menuBloc = getIt(param1: user, param2: workspaceSetting.workspace.id); + final menuBloc = getIt( + param1: user, param2: workspaceSetting.workspace.id); menuBloc.add(const MenuEvent.initial()); return menuBloc; }, @@ -106,18 +107,22 @@ class HomeMenu extends StatelessWidget { Widget _renderApps(BuildContext context) { return ExpandableTheme( - data: ExpandableThemeData(useInkWell: true, animationDuration: Durations.medium), + data: ExpandableThemeData( + useInkWell: true, animationDuration: Durations.medium), child: Expanded( child: ScrollConfiguration( behavior: const ScrollBehavior().copyWith(scrollbars: false), child: BlocSelector>( - selector: (state) => state.apps.map((app) => MenuApp(app, key: ValueKey(app.id))).toList(), + selector: (state) => state.apps + .map((app) => MenuApp(app, key: ValueKey(app.id))) + .toList(), builder: (context, menuItems) { return ReorderableListView.builder( itemCount: menuItems.length, buildDefaultDragHandles: false, header: Padding( - padding: EdgeInsets.only(bottom: 20.0 - MenuAppSizes.appVPadding), + padding: + EdgeInsets.only(bottom: 20.0 - MenuAppSizes.appVPadding), child: MenuUser(user), ), onReorder: (oldIndex, newIndex) { @@ -126,7 +131,9 @@ class HomeMenu extends StatelessWidget { // receive: oldIndex: 0, newIndex: 2 // Workaround: if newIndex > oldIndex, we just minus one int index = newIndex > oldIndex ? newIndex - 1 : newIndex; - context.read().add(MenuEvent.moveApp(oldIndex, index)); + context + .read() + .add(MenuEvent.moveApp(oldIndex, index)); }, physics: StyledScrollPhysics(), itemBuilder: (BuildContext context, int index) { @@ -134,7 +141,8 @@ class HomeMenu extends StatelessWidget { key: ValueKey(menuItems[index].key), index: index, child: Padding( - padding: EdgeInsets.symmetric(vertical: MenuAppSizes.appVPadding / 2), + padding: EdgeInsets.symmetric( + vertical: MenuAppSizes.appVPadding / 2), child: menuItems[index], ), ); @@ -149,7 +157,8 @@ class HomeMenu extends StatelessWidget { Widget _renderNewAppButton(BuildContext context) { return NewAppButton( - press: (appName) => context.read().add(MenuEvent.createApp(appName, desc: "")), + press: (appName) => + context.read().add(MenuEvent.createApp(appName, desc: "")), ); } } @@ -210,7 +219,9 @@ class MenuTopBar extends StatelessWidget { const Spacer(), FlowyIconButton( width: 28, - onPressed: () => context.read().add(const HomeEvent.collapseMenu()), + onPressed: () => context + .read() + .add(const HomeEvent.collapseMenu()), iconPadding: const EdgeInsets.fromLTRB(4, 4, 4, 4), icon: svgWidget("home/hide_menu", color: theme.iconColor), ) diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/emoji_button.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/emoji_button.dart index de8434a1dd..37ce933618 100644 --- a/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/emoji_button.dart +++ b/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/emoji_button.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/presentation/plugins/doc/document.dart'; +import 'package:app_flowy/plugins/doc/presentation/toolbar/toolbar_icon_button.dart'; import 'package:flutter/material.dart'; import 'package:flutter_quill/flutter_quill.dart'; import 'package:app_flowy/workspace/presentation/widgets/emoji_picker/emoji_picker.dart'; @@ -88,7 +88,8 @@ class _EmojiStyleButtonState extends State { _entry = null; setState(() => _isToggled = false); } else { - RenderBox box = emojiButtonKey.currentContext?.findRenderObject() as RenderBox; + RenderBox box = + emojiButtonKey.currentContext?.findRenderObject() as RenderBox; Offset position = box.localToGlobal(Offset.zero); // final window = await getWindowInfo(); @@ -118,7 +119,8 @@ class _EmojiStyleButtonState extends State { } class BuildEmojiPickerView extends StatefulWidget { - const BuildEmojiPickerView({Key? key, required this.controller, this.offset}) : super(key: key); + const BuildEmojiPickerView({Key? key, required this.controller, this.offset}) + : super(key: key); final QuillController controller; final Offset? offset; @@ -134,8 +136,11 @@ class _BuildEmojiPickerViewState extends State { children: [ Positioned( //TODO @gaganyadav80: Not sure about the calculated position. - top: widget.offset!.dy - MediaQuery.of(context).size.height / 2.83 - 30, - left: widget.offset!.dx - MediaQuery.of(context).size.width / 3.92 + 40, + top: widget.offset!.dy - + MediaQuery.of(context).size.height / 2.83 - + 30, + left: + widget.offset!.dx - MediaQuery.of(context).size.width / 3.92 + 40, child: Material( borderRadius: BorderRadius.circular(8.0), child: SizedBox( @@ -175,6 +180,7 @@ class _BuildEmojiPickerViewState extends State { extentOffset: baseOffset + emoji.emoji.length, ); - widget.controller.replaceText(baseOffset, replaceLen, emoji.emoji, selection); + widget.controller + .replaceText(baseOffset, replaceLen, emoji.emoji, selection); } } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/widgets/left_bar_item.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/left_bar_item.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/widgets/left_bar_item.dart rename to frontend/app_flowy/lib/workspace/presentation/widgets/left_bar_item.dart diff --git a/frontend/app_flowy/pubspec.lock b/frontend/app_flowy/pubspec.lock index 1c8bdf6211..c8ef9fe47a 100644 --- a/frontend/app_flowy/pubspec.lock +++ b/frontend/app_flowy/pubspec.lock @@ -22,6 +22,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.3" + appflowy_board: + dependency: "direct main" + description: + path: "packages/appflowy_board" + relative: true + source: path + version: "0.0.4" args: dependency: transitive description: From 9e090b01836ab160ed22954be6ac026d3f8c446e Mon Sep 17 00:00:00 2001 From: appflowy Date: Tue, 9 Aug 2022 11:59:22 +0800 Subject: [PATCH 3/3] chore: fix typo: pannel -> panel --- .../cell/cell_service/context_builder.dart | 35 +++++++++++----- .../{grid_listenr.dart => grid_listener.dart} | 0 .../grid/application/grid_service.dart | 10 ++--- .../widgets/cell/cell_cotainer.dart | 1 - .../app_flowy/lib/startup/deps_resolver.dart | 4 +- .../edit_context.dart | 5 ++- .../edit_panel/edit_panel_bloc.dart | 41 +++++++++++++++++++ .../edit_pannel/edit_pannel_bloc.dart | 41 ------------------- .../workspace/application/home/home_bloc.dart | 38 +++++++++-------- .../presentation/home/home_layout.dart | 13 +++--- .../presentation/home/home_screen.dart | 38 ++++++++--------- .../presentation/home/home_sizes.dart | 4 +- .../edit_panel.dart} | 26 ++++++------ .../panel_animation.dart} | 0 14 files changed, 138 insertions(+), 118 deletions(-) rename frontend/app_flowy/lib/plugins/grid/application/field/{grid_listenr.dart => grid_listener.dart} (100%) rename frontend/app_flowy/lib/workspace/application/{edit_pannel => edit_panel}/edit_context.dart (57%) create mode 100644 frontend/app_flowy/lib/workspace/application/edit_panel/edit_panel_bloc.dart delete mode 100644 frontend/app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart rename frontend/app_flowy/lib/workspace/presentation/widgets/{edit_pannel/edit_pannel.dart => edit_panel/edit_panel.dart} (66%) rename frontend/app_flowy/lib/workspace/presentation/widgets/{edit_pannel/pannel_animation.dart => edit_panel/panel_animation.dart} (100%) diff --git a/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/context_builder.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/context_builder.dart index 48e88e56ac..8f78793a2c 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/context_builder.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/context_builder.dart @@ -1,8 +1,10 @@ part of 'cell_service.dart'; typedef GridCellController = IGridCellController; -typedef GridSelectOptionCellController = IGridCellController; -typedef GridDateCellController = IGridCellController; +typedef GridSelectOptionCellController + = IGridCellController; +typedef GridDateCellController + = IGridCellController; typedef GridURLCellController = IGridCellController; class GridCellControllerBuilder { @@ -19,7 +21,8 @@ class GridCellControllerBuilder { _cellId = cellId; IGridCellController build() { - final cellFieldNotifier = GridCellFieldNotifier(notifier: _GridFieldChangedNotifierImpl(_fieldCache)); + final cellFieldNotifier = GridCellFieldNotifier( + notifier: _GridFieldChangedNotifierImpl(_fieldCache)); switch (_cellId.fieldType) { case FieldType.Checkbox: @@ -142,8 +145,10 @@ class IGridCellController extends Equatable { _cellDataLoader = cellDataLoader, _cellDataPersistence = cellDataPersistence, _fieldNotifier = fieldNotifier, - _fieldService = FieldService(gridId: cellId.gridId, fieldId: cellId.field.id), - _cacheKey = GridCellCacheKey(rowId: cellId.rowId, fieldId: cellId.field.id); + _fieldService = + FieldService(gridId: cellId.gridId, fieldId: cellId.field.id), + _cacheKey = + GridCellCacheKey(rowId: cellId.rowId, fieldId: cellId.field.id); IGridCellController clone() { return IGridCellController( @@ -164,7 +169,9 @@ class IGridCellController extends Equatable { FieldType get fieldType => cellId.field.fieldType; - VoidCallback? startListening({required void Function(T?) onCellChanged, VoidCallback? onCellFieldChanged}) { + VoidCallback? startListening( + {required void Function(T?) onCellChanged, + VoidCallback? onCellFieldChanged}) { if (isListening) { Log.error("Already started. It seems like you should call clone first"); return null; @@ -226,8 +233,11 @@ class IGridCellController extends Equatable { /// Return the FieldTypeOptionDataPB that can be parsed into corresponding class using the [parser]. /// [PD] is the type that the parser return. - Future> getFieldTypeOption(P parser) { - return _fieldService.getFieldTypeOptionData(fieldType: fieldType).then((result) { + Future> + getFieldTypeOption(P parser) { + return _fieldService + .getFieldTypeOptionData(fieldType: fieldType) + .then((result) { return result.fold( (data) => parser.fromBuffer(data.typeOptionData), (err) => right(err), @@ -239,7 +249,9 @@ class IGridCellController extends Equatable { /// You can set [dedeplicate] to true (default is false) to reduce the save operation. /// It's useful when you call this method when user editing the [TextField]. /// The default debounce interval is 300 milliseconds. - void saveCellData(D data, {bool deduplicate = false, void Function(Option)? resultCallback}) async { + void saveCellData(D data, + {bool deduplicate = false, + void Function(Option)? resultCallback}) async { if (deduplicate) { _loadDataOperation?.cancel(); @@ -288,7 +300,8 @@ class IGridCellController extends Equatable { } @override - List get props => [_cellsCache.get(_cacheKey) ?? "", cellId.rowId + cellId.field.id]; + List get props => + [_cellsCache.get(_cacheKey) ?? "", cellId.rowId + cellId.field.id]; } class _GridFieldChangedNotifierImpl extends GridFieldChangedNotifier { @@ -300,7 +313,7 @@ class _GridFieldChangedNotifierImpl extends GridFieldChangedNotifier { @override void dispose() { if (_onChangesetFn != null) { - _cache.removeListener(onChangsetListener: _onChangesetFn!); + _cache.removeListener(onChangesetListener: _onChangesetFn!); _onChangesetFn = null; } } diff --git a/frontend/app_flowy/lib/plugins/grid/application/field/grid_listenr.dart b/frontend/app_flowy/lib/plugins/grid/application/field/grid_listener.dart similarity index 100% rename from frontend/app_flowy/lib/plugins/grid/application/field/grid_listenr.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/grid_listener.dart diff --git a/frontend/app_flowy/lib/plugins/grid/application/grid_service.dart b/frontend/app_flowy/lib/plugins/grid/application/grid_service.dart index 14fbf2bf62..dff03f636e 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/grid_service.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/grid_service.dart @@ -1,6 +1,6 @@ import 'dart:collection'; -import 'package:app_flowy/plugins/grid/application/field/grid_listenr.dart'; +import 'package:app_flowy/plugins/grid/application/field/grid_listener.dart'; import 'package:dartz/dartz.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart'; import 'package:flowy_sdk/log.dart'; @@ -132,7 +132,7 @@ class GridFieldCache { void removeListener({ FieldsCallback? onFieldsListener, - FieldChangesetCallback? onChangsetListener, + FieldChangesetCallback? onChangesetListener, }) { if (onFieldsListener != null) { final fn = _fieldsCallbackMap.remove(onFieldsListener); @@ -141,8 +141,8 @@ class GridFieldCache { } } - if (onChangsetListener != null) { - _changesetCallbackMap.remove(onChangsetListener); + if (onChangesetListener != null) { + _changesetCallbackMap.remove(onChangesetListener); } } @@ -225,7 +225,7 @@ class GridRowCacheFieldNotifierImpl extends GridRowCacheFieldNotifier { } if (_onChangesetFn != null) { - _cache.removeListener(onChangsetListener: _onChangesetFn!); + _cache.removeListener(onChangesetListener: _onChangesetFn!); _onChangesetFn = null; } } diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_cotainer.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_cotainer.dart index b88508837c..b2d174e3e2 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_cotainer.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_cotainer.dart @@ -113,7 +113,6 @@ class CellEnterRegion extends StatelessWidget { class CellContainerNotifier extends ChangeNotifier { final CellEditable cellEditable; - bool mouted = false; VoidCallback? _onCellFocusListener; bool _isFocus = false; bool _onEnter = false; diff --git a/frontend/app_flowy/lib/startup/deps_resolver.dart b/frontend/app_flowy/lib/startup/deps_resolver.dart index 6627546c72..8b173a4002 100644 --- a/frontend/app_flowy/lib/startup/deps_resolver.dart +++ b/frontend/app_flowy/lib/startup/deps_resolver.dart @@ -6,7 +6,7 @@ import 'package:app_flowy/plugins/doc/application/prelude.dart'; import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:app_flowy/workspace/application/user/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/edit_panel/edit_panel_bloc.dart'; import 'package:app_flowy/workspace/application/view/prelude.dart'; import 'package:app_flowy/workspace/application/menu/prelude.dart'; import 'package:app_flowy/workspace/application/settings/prelude.dart'; @@ -43,7 +43,7 @@ void _resolveUserDeps(GetIt getIt) { getIt.registerFactory(() => SignUpBloc(getIt())); getIt.registerFactory(() => SplashRoute()); - getIt.registerFactory(() => EditPannelBloc()); + getIt.registerFactory(() => EditPanelBloc()); getIt.registerFactory(() => SplashBloc()); getIt.registerLazySingleton(() => NetworkListener()); } diff --git a/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_context.dart b/frontend/app_flowy/lib/workspace/application/edit_panel/edit_context.dart similarity index 57% rename from frontend/app_flowy/lib/workspace/application/edit_pannel/edit_context.dart rename to frontend/app_flowy/lib/workspace/application/edit_panel/edit_context.dart index 571461b365..6234858f60 100644 --- a/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_context.dart +++ b/frontend/app_flowy/lib/workspace/application/edit_panel/edit_context.dart @@ -1,11 +1,12 @@ import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; -abstract class EditPannelContext extends Equatable { +abstract class EditPanelContext extends Equatable { final String identifier; final String title; final Widget child; - const EditPannelContext({required this.child, required this.identifier, required this.title}); + const EditPanelContext( + {required this.child, required this.identifier, required this.title}); @override List get props => [identifier]; diff --git a/frontend/app_flowy/lib/workspace/application/edit_panel/edit_panel_bloc.dart b/frontend/app_flowy/lib/workspace/application/edit_panel/edit_panel_bloc.dart new file mode 100644 index 0000000000..d739c25559 --- /dev/null +++ b/frontend/app_flowy/lib/workspace/application/edit_panel/edit_panel_bloc.dart @@ -0,0 +1,41 @@ +import 'package:app_flowy/workspace/application/edit_panel/edit_context.dart'; +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +part 'edit_panel_bloc.freezed.dart'; + +class EditPanelBloc extends Bloc { + EditPanelBloc() : super(EditPanelState.initial()) { + on((event, emit) async { + await event.map( + startEdit: (e) async { + emit(state.copyWith(isEditing: true, editContext: some(e.context))); + }, + endEdit: (value) async { + emit(state.copyWith(isEditing: false, editContext: none())); + }, + ); + }); + } +} + +@freezed +class EditPanelEvent with _$EditPanelEvent { + const factory EditPanelEvent.startEdit(EditPanelContext context) = _StartEdit; + + const factory EditPanelEvent.endEdit(EditPanelContext context) = _EndEdit; +} + +@freezed +class EditPanelState with _$EditPanelState { + const factory EditPanelState({ + required bool isEditing, + required Option editContext, + }) = _EditPanelState; + + factory EditPanelState.initial() => EditPanelState( + isEditing: false, + editContext: none(), + ); +} diff --git a/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart b/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart deleted file mode 100644 index e1f2f5835d..0000000000 --- a/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart +++ /dev/null @@ -1,41 +0,0 @@ -import 'package:app_flowy/workspace/application/edit_pannel/edit_context.dart'; -import 'package:dartz/dartz.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; - -part 'edit_pannel_bloc.freezed.dart'; - -class EditPannelBloc extends Bloc { - EditPannelBloc() : super(EditPannelState.initial()) { - on((event, emit) async { - await event.map( - startEdit: (e) async { - emit(state.copyWith(isEditing: true, editContext: some(e.context))); - }, - endEdit: (value) async { - emit(state.copyWith(isEditing: false, editContext: none())); - }, - ); - }); - } -} - -@freezed -class EditPannelEvent with _$EditPannelEvent { - const factory EditPannelEvent.startEdit(EditPannelContext context) = _StartEdit; - - const factory EditPannelEvent.endEdit(EditPannelContext context) = _EndEdit; -} - -@freezed -class EditPannelState with _$EditPannelState { - const factory EditPannelState({ - required bool isEditing, - required Option editContext, - }) = _EditPannelState; - - factory EditPannelState.initial() => EditPannelState( - isEditing: false, - editContext: none(), - ); -} diff --git a/frontend/app_flowy/lib/workspace/application/home/home_bloc.dart b/frontend/app_flowy/lib/workspace/application/home/home_bloc.dart index af637ea1c7..87bac230da 100644 --- a/frontend/app_flowy/lib/workspace/application/home/home_bloc.dart +++ b/frontend/app_flowy/lib/workspace/application/home/home_bloc.dart @@ -1,9 +1,10 @@ import 'package:app_flowy/user/application/user_listener.dart'; -import 'package:app_flowy/workspace/application/edit_pannel/edit_context.dart'; +import 'package:app_flowy/workspace/application/edit_panel/edit_context.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-error-code/code.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; -import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart' show CurrentWorkspaceSettingPB; +import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart' + show CurrentWorkspaceSettingPB; import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; @@ -24,7 +25,8 @@ class HomeBloc extends Bloc { onAuthChanged: (result) => _authDidChanged(result), onSettingUpdated: (result) { result.fold( - (setting) => add(HomeEvent.didReceiveWorkspaceSetting(setting)), + (setting) => + add(HomeEvent.didReceiveWorkspaceSetting(setting)), (r) => Log.error(r), ); }, @@ -33,11 +35,11 @@ class HomeBloc extends Bloc { showLoading: (e) async { emit(state.copyWith(isLoading: e.isLoading)); }, - setEditPannel: (e) async { - emit(state.copyWith(pannelContext: some(e.editContext))); + setEditPanel: (e) async { + emit(state.copyWith(panelContext: some(e.editContext))); }, - dismissEditPannel: (value) async { - emit(state.copyWith(pannelContext: none())); + dismissEditPanel: (value) async { + emit(state.copyWith(panelContext: none())); }, forceCollapse: (e) async { emit(state.copyWith(forceCollapse: e.forceCollapse)); @@ -51,8 +53,9 @@ class HomeBloc extends Bloc { collapseMenu: (e) { emit(state.copyWith(isMenuCollapsed: !state.isMenuCollapsed)); }, - editPannelResized: (e) { - final newOffset = (state.resizeOffset + e.offset).clamp(-50, 200).toDouble(); + editPanelResized: (e) { + final newOffset = + (state.resizeOffset + e.offset).clamp(-50, 200).toDouble(); emit(state.copyWith(resizeOffset: newOffset)); }, ); @@ -80,12 +83,14 @@ class HomeEvent with _$HomeEvent { const factory HomeEvent.initial() = _Initial; 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; - const factory HomeEvent.didReceiveWorkspaceSetting(CurrentWorkspaceSettingPB setting) = _DidReceiveWorkspaceSetting; + const factory HomeEvent.setEditPanel(EditPanelContext editContext) = + _ShowEditPanel; + const factory HomeEvent.dismissEditPanel() = _DismissEditPanel; + const factory HomeEvent.didReceiveWorkspaceSetting( + CurrentWorkspaceSettingPB setting) = _DidReceiveWorkspaceSetting; const factory HomeEvent.unauthorized(String msg) = _Unauthorized; const factory HomeEvent.collapseMenu() = _CollapseMenu; - const factory HomeEvent.editPannelResized(double offset) = _EditPannelResized; + const factory HomeEvent.editPanelResized(double offset) = _EditPanelResized; } @freezed @@ -93,17 +98,18 @@ class HomeState with _$HomeState { const factory HomeState({ required bool isLoading, required bool forceCollapse, - required Option pannelContext, + required Option panelContext, required CurrentWorkspaceSettingPB workspaceSetting, required bool unauthorized, required bool isMenuCollapsed, required double resizeOffset, }) = _HomeState; - factory HomeState.initial(CurrentWorkspaceSettingPB workspaceSetting) => HomeState( + factory HomeState.initial(CurrentWorkspaceSettingPB workspaceSetting) => + HomeState( isLoading: false, forceCollapse: false, - pannelContext: none(), + panelContext: none(), workspaceSetting: workspaceSetting, unauthorized: false, isMenuCollapsed: false, diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart index e7e02b9767..dde5091d44 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart @@ -11,16 +11,17 @@ import 'home_sizes.dart'; class HomeLayout { late double menuWidth; late bool showMenu; - late bool showEditPannel; - late double editPannelWidth; + late bool showEditPanel; + late double editPanelWidth; late double homePageLOffset; late double homePageROffset; late Duration animDuration; - HomeLayout(BuildContext context, BoxConstraints homeScreenConstraint, bool forceCollapse) { + HomeLayout(BuildContext context, BoxConstraints homeScreenConstraint, + bool forceCollapse) { final homeBlocState = context.read().state; - showEditPannel = homeBlocState.pannelContext.isSome(); + showEditPanel = homeBlocState.panelContext.isSome(); menuWidth = Sizes.sideBarMed; if (context.widthPx >= PageBreaks.desktop) { @@ -38,7 +39,7 @@ class HomeLayout { homePageLOffset = showMenu ? menuWidth : 0.0; animDuration = .35.seconds; - editPannelWidth = HomeSizes.editPannelWidth; - homePageROffset = showEditPannel ? editPannelWidth : 0; + editPanelWidth = HomeSizes.editPanelWidth; + homePageROffset = showEditPanel ? editPanelWidth : 0; } } diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart index 3aca4dd9ff..e38a2f4614 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart @@ -1,6 +1,6 @@ import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/workspace/application/home/home_bloc.dart'; -import 'package:app_flowy/workspace/presentation/widgets/edit_pannel/pannel_animation.dart'; +import 'package:app_flowy/workspace/presentation/widgets/edit_panel/panel_animation.dart'; import 'package:app_flowy/workspace/presentation/widgets/float_bubble/question_bubble.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:flowy_sdk/log.dart'; @@ -12,7 +12,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:styled_widget/styled_widget.dart'; -import '../widgets/edit_pannel/edit_pannel.dart'; +import '../widgets/edit_panel/edit_panel.dart'; import 'home_layout.dart'; import 'home_stack.dart'; @@ -64,9 +64,9 @@ class _HomeScreenState extends State { child: BlocBuilder( buildWhen: (previous, current) => previous != current, builder: (context, state) { - final collapasedNotifier = + final collapsedNotifier = getIt().collapsedNotifier; - collapasedNotifier.addPublishListener((isCollapsed) { + collapsedNotifier.addPublishListener((isCollapsed) { context .read() .add(HomeEvent.forceCollapse(isCollapsed)); @@ -94,7 +94,7 @@ class _HomeScreenState extends State { state: state, ); final homeMenuResizer = _buildHomeMenuResizer(context: context); - final editPannel = _buildEditPannel( + final editPanel = _buildEditPanel( homeState: state, layout: layout, context: context, @@ -104,7 +104,7 @@ class _HomeScreenState extends State { layout: layout, homeStack: homeStack, homeMenu: menu, - editPannel: editPannel, + editPanel: editPanel, bubble: bubble, homeMenuResizer: homeMenuResizer, ); @@ -142,23 +142,23 @@ class _HomeScreenState extends State { return FocusTraversalGroup(child: RepaintBoundary(child: homeMenu)); } - Widget _buildEditPannel( + Widget _buildEditPanel( {required HomeState homeState, required BuildContext context, required HomeLayout layout}) { final homeBloc = context.read(); return BlocBuilder( buildWhen: (previous, current) => - previous.pannelContext != current.pannelContext, + previous.panelContext != current.panelContext, builder: (context, state) { - return state.pannelContext.fold( + return state.panelContext.fold( () => const SizedBox(), - (pannelContext) => FocusTraversalGroup( + (panelContext) => FocusTraversalGroup( child: RepaintBoundary( - child: EditPannel( - pannelContext: pannelContext, + child: EditPanel( + panelContext: panelContext, onEndEdit: () => - homeBloc.add(const HomeEvent.dismissEditPannel()), + homeBloc.add(const HomeEvent.dismissEditPanel()), ), ), ), @@ -177,7 +177,7 @@ class _HomeScreenState extends State { onPanUpdate: ((details) { context .read() - .add(HomeEvent.editPannelResized(details.delta.dx)); + .add(HomeEvent.editPanelResized(details.delta.dx)); }), behavior: HitTestBehavior.translucent, child: SizedBox( @@ -191,7 +191,7 @@ class _HomeScreenState extends State { required HomeLayout layout, required Widget homeMenu, required Widget homeStack, - required Widget editPannel, + required Widget editPanel, required Widget bubble, required Widget homeMenuResizer, }) { @@ -226,14 +226,14 @@ class _HomeScreenState extends State { animate: true, ) .animate(layout.animDuration, Curves.easeOut), - editPannel + editPanel .animatedPanelX( duration: layout.animDuration.inMilliseconds * 0.001, - closeX: layout.editPannelWidth, - isClosed: !layout.showEditPannel, + closeX: layout.editPanelWidth, + isClosed: !layout.showEditPanel, ) .positioned( - right: 0, top: 0, bottom: 0, width: layout.editPannelWidth), + right: 0, top: 0, bottom: 0, width: layout.editPanelWidth), ], ); } diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_sizes.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_sizes.dart index 350a1e49be..299d3fe03c 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_sizes.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_sizes.dart @@ -1,8 +1,8 @@ class HomeSizes { static double get menuAddButtonHeight => 60; static double get topBarHeight => 60; - static double get editPannelTopBarHeight => 60; - static double get editPannelWidth => 400; + static double get editPanelTopBarHeight => 60; + static double get editPanelWidth => 400; } class HomeInsets { diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/edit_pannel/edit_pannel.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/edit_panel/edit_panel.dart similarity index 66% rename from frontend/app_flowy/lib/workspace/presentation/widgets/edit_pannel/edit_pannel.dart rename to frontend/app_flowy/lib/workspace/presentation/widgets/edit_panel/edit_panel.dart index f9e5e0e6b5..ef0b61865e 100644 --- a/frontend/app_flowy/lib/workspace/presentation/widgets/edit_pannel/edit_pannel.dart +++ b/frontend/app_flowy/lib/workspace/presentation/widgets/edit_panel/edit_panel.dart @@ -1,5 +1,5 @@ -import 'package:app_flowy/workspace/application/edit_pannel/edit_pannel_bloc.dart'; -import 'package:app_flowy/workspace/application/edit_pannel/edit_context.dart'; +import 'package:app_flowy/workspace/application/edit_panel/edit_panel_bloc.dart'; +import 'package:app_flowy/workspace/application/edit_panel/edit_context.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/presentation/home/home_sizes.dart'; import 'package:easy_localization/easy_localization.dart'; @@ -9,12 +9,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; -class EditPannel extends StatelessWidget { - final EditPannelContext pannelContext; +class EditPanel extends StatelessWidget { + final EditPanelContext panelContext; final VoidCallback onEndEdit; - const EditPannel({ + const EditPanel({ Key? key, - required this.pannelContext, + required this.panelContext, required this.onEndEdit, }) : super(key: key); @@ -23,15 +23,15 @@ class EditPannel extends StatelessWidget { return Container( color: Theme.of(context).colorScheme.secondary, child: BlocProvider( - create: (context) => getIt(), - child: BlocBuilder( + create: (context) => getIt(), + child: BlocBuilder( builder: (context, state) { return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - EditPannelTopBar(onClose: () => onEndEdit()), + EditPanelTopBar(onClose: () => onEndEdit()), Expanded( - child: pannelContext.child, + child: panelContext.child, ), ], ); @@ -42,13 +42,13 @@ class EditPannel extends StatelessWidget { } } -class EditPannelTopBar extends StatelessWidget { +class EditPanelTopBar extends StatelessWidget { final VoidCallback onClose; - const EditPannelTopBar({Key? key, required this.onClose}) : super(key: key); + const EditPanelTopBar({Key? key, required this.onClose}) : super(key: key); @override Widget build(BuildContext context) { return SizedBox( - height: HomeSizes.editPannelTopBarHeight, + height: HomeSizes.editPanelTopBarHeight, child: Padding( padding: const EdgeInsets.all(8.0), child: Row( diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/edit_pannel/pannel_animation.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/edit_panel/panel_animation.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/widgets/edit_pannel/pannel_animation.dart rename to frontend/app_flowy/lib/workspace/presentation/widgets/edit_panel/panel_animation.dart