From aac5c2a4da69cb8dbbb596b31c52191289c0a58f Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Mon, 10 Apr 2023 15:10:42 +0800 Subject: [PATCH] feat: add require_trailing_commas to analysis_options.ymal. (#2227) --- .github/workflows/flutter_ci.yaml | 3 +- .../appflowy_flutter/analysis_options.yaml | 7 +- .../integration_test/board_test.dart | 4 +- .../integration_test/empty_document_test.dart | 55 ++++--- .../integration_test/util/data.dart | 4 +- .../integration_test/util/keyboard.dart | 6 +- .../lib/core/folder_notification.dart | 7 +- .../lib/core/grid_notification.dart | 11 +- .../lib/core/notification_helper.dart | 11 +- .../lib/core/user_notification.dart | 11 +- .../application/cell/cell_controller.dart | 50 +++--- .../application/cell/cell_listener.dart | 4 +- .../application/database_controller.dart | 97 +++++++----- .../application/database_view_service.dart | 13 +- .../application/field/field_cell_bloc.dart | 24 +-- .../application/field/field_controller.dart | 102 ++++++------ .../application/field/field_editor_bloc.dart | 12 +- .../application/field/field_listener.dart | 10 +- .../field/type_option/date_bloc.dart | 21 ++- .../field/type_option/number_format_bloc.dart | 24 +-- .../select_option_type_option_bloc.dart | 6 +- .../type_option/type_option_context.dart | 4 +- .../application/filter/filter_listener.dart | 3 +- .../application/filter/filter_service.dart | 3 +- .../layout/calendar_setting_listener.dart | 5 +- .../application/row/row_cache.dart | 19 ++- .../application/row/row_data_controller.dart | 10 +- .../application/row/row_list.dart | 10 +- .../application/setting/group_bloc.dart | 7 +- .../application/setting/property_bloc.dart | 17 +- .../application/setting/setting_bloc.dart | 11 +- .../setting/setting_controller.dart | 14 +- .../application/view/view_cache.dart | 8 +- .../board/application/board_bloc.dart | 49 +++--- .../board/application/group_controller.dart | 70 +++++---- .../toolbar/board_setting_bloc.dart | 8 +- .../calendar/application/calendar_bloc.dart | 47 ++++-- .../application/calendar_setting_bloc.dart | 10 +- .../calendar/presentation/calendar_day.dart | 45 +++--- .../calendar/presentation/calendar_page.dart | 8 +- .../toolbar/calendar_layout_setting.dart | 28 ++-- .../filter/checkbox_filter_editor_bloc.dart | 13 +- .../filter/checklist_filter_bloc.dart | 13 +- .../application/filter/filter_menu_bloc.dart | 15 +- .../filter/select_option_filter_bloc.dart | 22 ++- .../select_option_filter_list_bloc.dart | 36 +++-- .../filter/text_filter_editor_bloc.dart | 13 +- .../grid/application/grid_accessory_bloc.dart | 8 +- .../grid/application/grid_bloc.dart | 23 +-- .../grid/application/grid_header_bloc.dart | 9 +- .../grid/application/row/row_bloc.dart | 17 +- .../grid/application/row/row_detail_bloc.dart | 3 +- .../application/sort/sort_create_bloc.dart | 7 +- .../application/sort/sort_editor_bloc.dart | 4 +- .../grid/application/sort/sort_menu_bloc.dart | 12 +- .../grid/presentation/grid_page.dart | 18 ++- .../grid/presentation/grid_scroll.dart | 6 +- .../presentation/widgets/accessory_menu.dart | 9 +- .../widgets/filter/choicechip/checkbox.dart | 4 +- .../choicechip/checklist/checklist.dart | 8 +- .../widgets/filter/choicechip/choicechip.dart | 6 +- .../select_option/select_option.dart | 12 +- .../widgets/filter/choicechip/text.dart | 4 +- .../widgets/filter/condition_button.dart | 6 +- .../widgets/filter/create_filter_list.dart | 5 +- .../widgets/header/field_cell.dart | 15 +- .../header/field_cell_action_sheet.dart | 40 ++--- .../header/field_type_option_editor.dart | 12 +- .../widgets/header/grid_header.dart | 37 +++-- .../widgets/header/type_option/builder.dart | 13 +- .../widgets/header/type_option/checklist.dart | 3 +- .../widgets/header/type_option/number.dart | 29 ++-- .../type_option/select_option_editor.dart | 23 ++- .../grid/presentation/widgets/row/row.dart | 33 ++-- .../widgets/sort/create_sort_list.dart | 5 +- .../widgets/sort/sort_editor.dart | 16 +- .../widgets/toolbar/grid_property.dart | 12 +- .../widgets/toolbar/grid_setting.dart | 13 +- .../card/bloc/checkbox_card_cell_bloc.dart | 3 +- .../card/bloc/date_card_cell_bloc.dart | 8 +- .../bloc/select_option_card_cell_bloc.dart | 11 +- .../widgets/card/bloc/url_card_cell_bloc.dart | 10 +- .../database_view/widgets/card/card_bloc.dart | 14 +- .../card/cells/select_option_card_cell.dart | 68 ++++---- .../card/container/card_container.dart | 11 +- .../widgets/row/accessory/cell_accessory.dart | 10 +- .../widgets/row/cell_builder.dart | 6 +- .../widgets/row/cells/cell_container.dart | 3 +- .../cells/checkbox_cell/checkbox_cell.dart | 5 +- .../checkbox_cell/checkbox_cell_bloc.dart | 13 +- .../checklist_cell/checklist_cell_bloc.dart | 15 +- .../checklist_cell_editor_bloc.dart | 28 ++-- .../checklist_progress_bar.dart | 5 +- .../row/cells/date_cell/date_cal_bloc.dart | 94 +++++++---- .../row/cells/date_cell/date_cell_bloc.dart | 8 +- .../row/cells/date_cell/date_editor.dart | 17 +- .../cells/number_cell/number_cell_bloc.dart | 15 +- .../select_option_cell.dart | 10 +- .../select_option_cell_bloc.dart | 16 +- .../select_option_editor.dart | 45 +++--- .../select_option_editor_bloc.dart | 47 +++--- .../select_option_service.dart | 21 ++- .../cells/select_option_cell/text_field.dart | 12 +- .../widgets/row/cells/url_cell/url_cell.dart | 46 +++--- .../row/cells/url_cell/url_cell_bloc.dart | 10 +- .../cells/url_cell/url_cell_editor_bloc.dart | 10 +- .../document/application/doc_bloc.dart | 11 +- .../document/application/share_bloc.dart | 16 +- .../document/application/share_service.dart | 4 +- .../lib/plugins/document/document_page.dart | 55 +++---- .../lib/plugins/document/editor_styles.dart | 6 +- .../plugins/document/presentation/banner.dart | 73 +++++---- .../more/cubit/document_appearance_cubit.dart | 16 +- .../presentation/more/font_size_switcher.dart | 69 ++++---- .../plugins/base/built_in_page_widget.dart | 8 +- .../plugins/base/insert_page_command.dart | 3 +- .../plugins/base/link_to_page_widget.dart | 47 +++--- .../plugins/cover/change_cover_popover.dart | 147 ++++++++++-------- .../plugins/cover/cover_image_picker.dart | 96 +++++++----- .../cover/cover_image_picker_bloc.dart | 14 +- .../plugins/cover/cover_node_widget.dart | 60 +++---- .../openai/util/learn_more_action.dart | 3 +- .../widgets/auto_completion_node_widget.dart | 42 ++--- .../widgets/smart_edit_toolbar_item.dart | 3 +- .../plugins/trash/application/trash_bloc.dart | 73 +++++---- .../trash/application/trash_service.dart | 3 +- .../lib/plugins/trash/src/sizes.dart | 5 +- .../lib/plugins/trash/src/trash_cell.dart | 12 +- .../lib/plugins/trash/src/trash_header.dart | 20 ++- .../appflowy_flutter/lib/plugins/util.dart | 31 ++-- .../lib/startup/deps_resolver.dart | 8 +- .../lib/startup/plugin/src/sandbox.dart | 15 +- .../lib/startup/tasks/load_plugin.dart | 4 +- .../lib/user/application/auth_service.dart | 15 +- .../lib/user/application/sign_in_bloc.dart | 59 ++++--- .../lib/user/application/sign_up_bloc.dart | 126 +++++++++------ .../lib/user/application/user_listener.dart | 8 +- .../lib/user/application/user_service.dart | 9 +- .../application/user_settings_service.dart | 3 +- .../presentation/folder/folder_widget.dart | 5 +- .../lib/user/presentation/router.dart | 50 +++--- .../lib/user/presentation/sign_in_screen.dart | 10 +- .../lib/user/presentation/sign_up_screen.dart | 7 +- .../lib/user/presentation/welcome_screen.dart | 14 +- .../util/file_picker/file_picker_impl.dart | 23 +-- .../workspace/application/app/app_bloc.dart | 77 +++++---- .../application/app/app_listener.dart | 7 +- .../application/app/app_service.dart | 9 +- .../lib/workspace/application/appearance.dart | 26 ++-- .../application/edit_panel/edit_context.dart | 7 +- .../workspace/application/home/home_bloc.dart | 13 +- .../application/home/home_setting_bloc.dart | 23 +-- .../workspace/application/menu/menu_bloc.dart | 45 ++++-- .../application/menu/menu_user_bloc.dart | 9 +- .../menu/menu_view_section_bloc.dart | 4 +- .../settings/settings_dialog_bloc.dart | 3 +- .../application/user/settings_user_bloc.dart | 3 +- .../workspace/application/view/view_bloc.dart | 8 +- .../application/view/view_listener.dart | 4 +- .../application/view/view_service.dart | 7 +- .../application/workspace/welcome_bloc.dart | 114 ++++++++------ .../workspace/workspace_listener.dart | 4 +- .../workspace/workspace_service.dart | 12 +- .../presentation/home/home_screen.dart | 139 +++++++++-------- .../presentation/home/home_stack.dart | 42 ++--- .../home/menu/app/header/add_button.dart | 12 +- .../home/menu/app/header/header.dart | 57 ++++--- .../presentation/home/menu/app/menu_app.dart | 4 +- .../home/menu/app/section/section.dart | 4 +- .../home/menu/favorite/favorite.dart | 1 + .../home/menu/favorite/section.dart | 1 + .../presentation/home/menu/menu.dart | 7 +- .../presentation/home/menu/menu_user.dart | 11 +- .../presentation/home/navigation.dart | 60 +++---- ...settings_file_customize_location_view.dart | 145 ++++++++--------- .../widgets/settings_menu_element.dart | 26 ++-- .../settings/widgets/settings_user_view.dart | 17 +- .../presentation/widgets/dialogs.dart | 57 +++---- .../widgets/edit_panel/panel_animation.dart | 88 ++++++----- .../widgets/emoji_picker/src/config.dart | 39 ++--- .../src/default_emoji_picker_view.dart | 87 ++++++----- .../emoji_picker/src/emoji_picker.dart | 74 ++++++--- .../src/emoji_picker_builder.dart | 3 +- .../widgets/float_bubble/question_bubble.dart | 10 +- .../presentation/widgets/left_bar_item.dart | 22 +-- .../example/integration_test/driver.dart | 1 - .../lib/appflowy_editor_plugins.dart | 2 +- .../lib/src/emoji_picker/src/config.dart | 3 +- .../src/emoji_picker_builder.dart | 3 +- .../math_equation_node_widget.dart | 0 .../flowy_infra_ui_platform_interface.dart | 6 +- .../lib/src/flowy_overlay/option_overlay.dart | 6 +- .../board_test/create_card_test.dart | 12 +- .../board_test/create_or_edit_field_test.dart | 24 ++- .../group_by_checkbox_field_test.dart | 10 +- .../group_by_multi_select_field_test.dart | 37 +++-- .../group_by_unsupport_field_test.dart | 6 +- .../cell/select_option_cell_test.dart | 60 +++++-- .../grid_test/filter/create_filter_test.dart | 35 +++-- .../filter/edit_filter_field_test.dart | 7 +- .../grid_test/filter/filter_menu_test.dart | 39 +++-- .../filter/filter_rows_by_checkbox_test.dart | 12 +- .../filter/filter_rows_by_text_test.dart | 100 +++++++----- .../grid_test/filter/filter_util.dart | 11 +- .../bloc_test/grid_test/grid_bloc_test.dart | 26 ++-- .../grid_test/grid_header_bloc_test.dart | 3 +- .../test/bloc_test/grid_test/util.dart | 28 ++-- .../bloc_test/home_test/trash_bloc_test.dart | 26 ++-- .../bloc_test/home_test/view_bloc_test.dart | 30 ++-- .../unit_test/editor/share_markdown_test.dart | 27 ++-- 210 files changed, 2927 insertions(+), 1984 deletions(-) rename frontend/appflowy_flutter/packages/appflowy_editor_plugins/lib/src/{math_ equation => math_equation}/math_equation_node_widget.dart (100%) diff --git a/.github/workflows/flutter_ci.yaml b/.github/workflows/flutter_ci.yaml index 842608e5ec..eae3e2c4ae 100644 --- a/.github/workflows/flutter_ci.yaml +++ b/.github/workflows/flutter_ci.yaml @@ -99,7 +99,8 @@ jobs: - name: Flutter Analyzer working-directory: frontend/appflowy_flutter - run: flutter analyze + run: | + flutter analyze . - name: Run Flutter unit tests working-directory: frontend diff --git a/frontend/appflowy_flutter/analysis_options.yaml b/frontend/appflowy_flutter/analysis_options.yaml index e345c3da76..e6f72adac0 100644 --- a/frontend/appflowy_flutter/analysis_options.yaml +++ b/frontend/appflowy_flutter/analysis_options.yaml @@ -14,9 +14,7 @@ analyzer: exclude: - "**/*.g.dart" - "**/*.freezed.dart" - - "packages/appflowy_editor/**" - - "packages/editor/**" - # - "packages/flowy_infra_ui/**" + linter: # The lint rules applied to this project can be customized in the # section below to disable rules from the `package:flutter_lints/flutter.yaml` @@ -30,8 +28,7 @@ linter: # `// ignore_for_file: name_of_lint` syntax on the line or in the file # producing the lint. rules: - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + - require_trailing_commas # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options diff --git a/frontend/appflowy_flutter/integration_test/board_test.dart b/frontend/appflowy_flutter/integration_test/board_test.dart index 3900843207..c67f7b0624 100644 --- a/frontend/appflowy_flutter/integration_test/board_test.dart +++ b/frontend/appflowy_flutter/integration_test/board_test.dart @@ -35,7 +35,9 @@ void main() { setUpAll(() async => await service.setUpAll()); setUp(() async => await service.setUp()); - testWidgets('integration test unzips the proper workspace and loads it correctly.', (tester) async { + testWidgets( + 'integration test unzips the proper workspace and loads it correctly.', + (tester) async { await tester.initializeAppFlowy(); expect(find.byType(AppFlowyBoard), findsOneWidget); }); diff --git a/frontend/appflowy_flutter/integration_test/empty_document_test.dart b/frontend/appflowy_flutter/integration_test/empty_document_test.dart index 51f92c4c35..11b8b5e118 100644 --- a/frontend/appflowy_flutter/integration_test/empty_document_test.dart +++ b/frontend/appflowy_flutter/integration_test/empty_document_test.dart @@ -31,7 +31,8 @@ void main() { setUpAll(() async => await service.setUpAll()); setUp(() async => await service.setUp()); - testWidgets('/board shortcut creates a new board and view of the board', (tester) async { + testWidgets('/board shortcut creates a new board and view of the board', + (tester) async { await tester.initializeAppFlowy(); // Needs tab to obtain focus for the app flowy editor. @@ -44,24 +45,30 @@ void main() { // does not contain any EditableText widgets. // to interact with the app during an integration test, // simulate physical keyboard events. - await FlowyTestKeyboard.simulateKeyDownEvent([ - LogicalKeyboardKey.slash, - LogicalKeyboardKey.keyB, - LogicalKeyboardKey.keyO, - LogicalKeyboardKey.keyA, - LogicalKeyboardKey.keyR, - LogicalKeyboardKey.keyD, - LogicalKeyboardKey.arrowDown, - ], tester: tester); + await FlowyTestKeyboard.simulateKeyDownEvent( + [ + LogicalKeyboardKey.slash, + LogicalKeyboardKey.keyB, + LogicalKeyboardKey.keyO, + LogicalKeyboardKey.keyA, + LogicalKeyboardKey.keyR, + LogicalKeyboardKey.keyD, + LogicalKeyboardKey.arrowDown, + ], + tester: tester, + ); // Checks whether the options in the selection menu // for /board exist. expect(find.byType(SelectionMenuItemWidget), findsAtLeastNWidgets(2)); // Finalizes the slash command that creates the board. - await FlowyTestKeyboard.simulateKeyDownEvent([ - LogicalKeyboardKey.enter, - ], tester: tester); + await FlowyTestKeyboard.simulateKeyDownEvent( + [ + LogicalKeyboardKey.enter, + ], + tester: tester, + ); // Checks whether new board is referenced and properly on the page. expect(find.byType(BuiltInPageWidget), findsOneWidget); @@ -75,7 +82,8 @@ void main() { expect(find.text(viewOfBoardLabel), findsNWidgets(2)); }); - testWidgets('/grid shortcut creates a new grid and view of the grid', (tester) async { + testWidgets('/grid shortcut creates a new grid and view of the grid', + (tester) async { await tester.initializeAppFlowy(); // Needs tab to obtain focus for the app flowy editor. @@ -88,14 +96,17 @@ void main() { // does not contain any EditableText widgets. // to interact with the app during an integration test, // simulate physical keyboard events. - await FlowyTestKeyboard.simulateKeyDownEvent([ - LogicalKeyboardKey.slash, - LogicalKeyboardKey.keyG, - LogicalKeyboardKey.keyR, - LogicalKeyboardKey.keyI, - LogicalKeyboardKey.keyD, - LogicalKeyboardKey.arrowDown, - ], tester: tester); + await FlowyTestKeyboard.simulateKeyDownEvent( + [ + LogicalKeyboardKey.slash, + LogicalKeyboardKey.keyG, + LogicalKeyboardKey.keyR, + LogicalKeyboardKey.keyI, + LogicalKeyboardKey.keyD, + LogicalKeyboardKey.arrowDown, + ], + tester: tester, + ); // Checks whether the options in the selection menu // for /grid exist. diff --git a/frontend/appflowy_flutter/integration_test/util/data.dart b/frontend/appflowy_flutter/integration_test/util/data.dart index a527950489..4cbb1a34f2 100644 --- a/frontend/appflowy_flutter/integration_test/util/data.dart +++ b/frontend/appflowy_flutter/integration_test/util/data.dart @@ -61,6 +61,8 @@ class TestWorkspaceService { InputFileStream(await workspace.zip.then((value) => value.path)); final archive = ZipDecoder().decodeBuffer(inputStream); extractArchiveToDisk( - archive, await TestWorkspace._parent.then((value) => value.path)); + archive, + await TestWorkspace._parent.then((value) => value.path), + ); } } diff --git a/frontend/appflowy_flutter/integration_test/util/keyboard.dart b/frontend/appflowy_flutter/integration_test/util/keyboard.dart index 02bbdb79f1..d792b92c66 100644 --- a/frontend/appflowy_flutter/integration_test/util/keyboard.dart +++ b/frontend/appflowy_flutter/integration_test/util/keyboard.dart @@ -2,8 +2,10 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart' as flutter_test; class FlowyTestKeyboard { - static Future simulateKeyDownEvent(List keys, - {required flutter_test.WidgetTester tester}) async { + static Future simulateKeyDownEvent( + List keys, { + required flutter_test.WidgetTester tester, + }) async { for (final LogicalKeyboardKey key in keys) { await flutter_test.simulateKeyDownEvent(key); await tester.pumpAndSettle(); diff --git a/frontend/appflowy_flutter/lib/core/folder_notification.dart b/frontend/appflowy_flutter/lib/core/folder_notification.dart index 4d147da88e..360fc96f17 100644 --- a/frontend/appflowy_flutter/lib/core/folder_notification.dart +++ b/frontend/appflowy_flutter/lib/core/folder_notification.dart @@ -16,9 +16,10 @@ typedef FolderNotificationCallback = void Function( class FolderNotificationParser extends NotificationParser { - FolderNotificationParser( - {String? id, required FolderNotificationCallback callback}) - : super( + FolderNotificationParser({ + String? id, + required FolderNotificationCallback callback, + }) : super( id: id, callback: callback, tyParser: (ty) => FolderNotification.valueOf(ty), diff --git a/frontend/appflowy_flutter/lib/core/grid_notification.dart b/frontend/appflowy_flutter/lib/core/grid_notification.dart index 16fa0a207c..d27015cd05 100644 --- a/frontend/appflowy_flutter/lib/core/grid_notification.dart +++ b/frontend/appflowy_flutter/lib/core/grid_notification.dart @@ -16,9 +16,10 @@ typedef DatabaseNotificationCallback = void Function( class DatabaseNotificationParser extends NotificationParser { - DatabaseNotificationParser( - {String? id, required DatabaseNotificationCallback callback}) - : super( + DatabaseNotificationParser({ + String? id, + required DatabaseNotificationCallback callback, + }) : super( id: id, callback: callback, tyParser: (ty) => DatabaseNotification.valueOf(ty), @@ -27,7 +28,9 @@ class DatabaseNotificationParser } typedef DatabaseNotificationHandler = Function( - DatabaseNotification ty, Either result); + DatabaseNotification ty, + Either result, +); class DatabaseNotificationListener { StreamSubscription? _subscription; diff --git a/frontend/appflowy_flutter/lib/core/notification_helper.dart b/frontend/appflowy_flutter/lib/core/notification_helper.dart index 5faed47730..4869fb14d4 100644 --- a/frontend/appflowy_flutter/lib/core/notification_helper.dart +++ b/frontend/appflowy_flutter/lib/core/notification_helper.dart @@ -9,11 +9,12 @@ class NotificationParser { T? Function(int) tyParser; E Function(Uint8List) errorParser; - NotificationParser( - {this.id, - required this.callback, - required this.errorParser, - required this.tyParser}); + NotificationParser({ + this.id, + required this.callback, + required this.errorParser, + required this.tyParser, + }); void parse(SubscribeObject subject) { if (id != null) { if (subject.id != id) { diff --git a/frontend/appflowy_flutter/lib/core/user_notification.dart b/frontend/appflowy_flutter/lib/core/user_notification.dart index 8fa2399459..1da65d12c6 100644 --- a/frontend/appflowy_flutter/lib/core/user_notification.dart +++ b/frontend/appflowy_flutter/lib/core/user_notification.dart @@ -16,9 +16,10 @@ typedef UserNotificationCallback = void Function( class UserNotificationParser extends NotificationParser { - UserNotificationParser( - {required String id, required UserNotificationCallback callback}) - : super( + UserNotificationParser({ + required String id, + required UserNotificationCallback callback, + }) : super( id: id, callback: callback, tyParser: (ty) => UserNotification.valueOf(ty), @@ -27,7 +28,9 @@ class UserNotificationParser } typedef UserNotificationHandler = Function( - UserNotification ty, Either result); + UserNotification ty, + Either result, +); class UserNotificationListener { StreamSubscription? _subscription; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_controller.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_controller.dart index 9fa76e7963..25799ddaa2 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_controller.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_controller.dart @@ -73,28 +73,35 @@ class CellController extends Equatable { /// For example: /// user input: 12 /// cell display: $12 - _cellListener?.start(onCellChanged: (result) { - result.fold( - (_) { - _cellCache.remove(_cacheKey); - _loadData(); - }, - (err) => Log.error(err), - ); - }); + _cellListener?.start( + onCellChanged: (result) { + result.fold( + (_) { + _cellCache.remove(_cacheKey); + _loadData(); + }, + (err) => Log.error(err), + ); + }, + ); /// 2.Listen on the field event and load the cell data if needed. - _fieldListener.start(onFieldChanged: (result) { - result.fold((fieldPB) { - /// reloadOnFieldChanged should be true if you need to load the data when the corresponding field is changed - /// For example: - /// ¥12 -> $12 - if (_cellDataLoader.reloadOnFieldChanged) { - _loadData(); - } - _onCellFieldChanged?.call(); - }, (err) => Log.error(err)); - }); + _fieldListener.start( + onFieldChanged: (result) { + result.fold( + (fieldPB) { + /// reloadOnFieldChanged should be true if you need to load the data when the corresponding field is changed + /// For example: + /// ¥12 -> $12 + if (_cellDataLoader.reloadOnFieldChanged) { + _loadData(); + } + _onCellFieldChanged?.call(); + }, + (err) => Log.error(err), + ); + }, + ); } /// Listen on the cell content or field changes @@ -130,7 +137,8 @@ class CellController extends Equatable { /// Return the TypeOptionPB that can be parsed into corresponding class using the [parser]. /// [PD] is the type that the parser return. Future> getTypeOption( - P parser) { + P parser, + ) { return _fieldBackendSvc .getFieldTypeOptionData(fieldType: fieldType) .then((result) { diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_listener.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_listener.dart index 749d2b2baa..89d3e2597c 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_listener.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_listener.dart @@ -19,7 +19,9 @@ class CellListener { void start({required void Function(UpdateFieldNotifiedValue) onCellChanged}) { _updateCellNotifier?.addPublishListener(onCellChanged); _listener = DatabaseNotificationListener( - objectId: "$rowId:$fieldId", handler: _handler); + objectId: "$rowId:$fieldId", + handler: _handler, + ); } void _handler(DatabaseNotification ty, Either result) { diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/database_controller.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/database_controller.dart index 6cdbc964e4..15976a74f3 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/database_controller.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/database_controller.dart @@ -187,8 +187,10 @@ class DatabaseController { ); } - Future> moveGroup( - {required String fromGroupId, required String toGroupId}) { + Future> moveGroup({ + required String fromGroupId, + required String toGroupId, + }) { return _databaseViewBackendSvc.moveGroup( fromGroupId: fromGroupId, toGroupId: toGroupId, @@ -196,7 +198,8 @@ class DatabaseController { } Future updateCalenderLayoutSetting( - CalendarLayoutSettingsPB layoutSetting) async { + CalendarLayoutSettingsPB layoutSetting, + ) async { await _databaseViewBackendSvc .updateLayoutSetting(calendarLayoutSetting: layoutSetting) .then((result) { @@ -234,16 +237,20 @@ class DatabaseController { } void _listenOnRowsChanged() { - final callbacks = - DatabaseViewCallbacks(onRowsChanged: (rows, rowByRowId, reason) { - _databaseCallbacks?.onRowsChanged?.call(rows, rowByRowId, reason); - }, onRowsDeleted: (ids) { - _databaseCallbacks?.onRowsDeleted?.call(ids); - }, onRowsUpdated: (ids) { - _databaseCallbacks?.onRowsUpdated?.call(ids); - }, onRowsCreated: (ids) { - _databaseCallbacks?.onRowsCreated?.call(ids); - }); + final callbacks = DatabaseViewCallbacks( + onRowsChanged: (rows, rowByRowId, reason) { + _databaseCallbacks?.onRowsChanged?.call(rows, rowByRowId, reason); + }, + onRowsDeleted: (ids) { + _databaseCallbacks?.onRowsDeleted?.call(ids); + }, + onRowsUpdated: (ids) { + _databaseCallbacks?.onRowsUpdated?.call(ids); + }, + onRowsCreated: (ids) { + _databaseCallbacks?.onRowsCreated?.call(ids); + }, + ); _viewCache.addListener(callbacks); } @@ -261,42 +268,58 @@ class DatabaseController { void _listenOnGroupChanged() { groupListener.start( onNumOfGroupsChanged: (result) { - result.fold((changeset) { - if (changeset.updateGroups.isNotEmpty) { - _groupCallbacks?.onUpdateGroup?.call(changeset.updateGroups); - } + result.fold( + (changeset) { + if (changeset.updateGroups.isNotEmpty) { + _groupCallbacks?.onUpdateGroup?.call(changeset.updateGroups); + } - if (changeset.deletedGroups.isNotEmpty) { - _groupCallbacks?.onDeleteGroup?.call(changeset.deletedGroups); - } + if (changeset.deletedGroups.isNotEmpty) { + _groupCallbacks?.onDeleteGroup?.call(changeset.deletedGroups); + } - for (final insertedGroup in changeset.insertedGroups) { - _groupCallbacks?.onInsertGroup?.call(insertedGroup); - } - }, (r) => Log.error(r)); + for (final insertedGroup in changeset.insertedGroups) { + _groupCallbacks?.onInsertGroup?.call(insertedGroup); + } + }, + (r) => Log.error(r), + ); }, onGroupByNewField: (result) { - result.fold((groups) { - _groupCallbacks?.onGroupByField?.call(groups); - }, (r) => Log.error(r)); + result.fold( + (groups) { + _groupCallbacks?.onGroupByField?.call(groups); + }, + (r) => Log.error(r), + ); }, ); } void _listenOnLayoutChanged() { - layoutListener.start(onLayoutChanged: (result) { - result.fold((l) { - _layoutCallbacks?.onLayoutChanged(l); - }, (r) => Log.error(r)); - }); + layoutListener.start( + onLayoutChanged: (result) { + result.fold( + (l) { + _layoutCallbacks?.onLayoutChanged(l); + }, + (r) => Log.error(r), + ); + }, + ); } void _listenOnCalendarLayoutChanged() { - calendarLayoutListener.start(onCalendarLayoutChanged: (result) { - result.fold((l) { - _calendarLayoutCallbacks?.onCalendarLayoutChanged(l); - }, (r) => Log.error(r)); - }); + calendarLayoutListener.start( + onCalendarLayoutChanged: (result) { + result.fold( + (l) { + _calendarLayoutCallbacks?.onCalendarLayoutChanged(l); + }, + (r) => Log.error(r), + ); + }, + ); } } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/database_view_service.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/database_view_service.dart index 5ecaad6ef3..7bb09dea50 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/database_view_service.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/database_view_service.dart @@ -73,8 +73,9 @@ class DatabaseViewBackendService { return DatabaseEventMoveGroup(payload).send(); } - Future, FlowyError>> getFields( - {List? fieldIds}) { + Future, FlowyError>> getFields({ + List? fieldIds, + }) { var payload = GetFieldPayloadPB.create()..viewId = viewId; if (fieldIds != null) { @@ -86,15 +87,17 @@ class DatabaseViewBackendService { } Future> getLayoutSetting( - LayoutTypePB layoutType) { + LayoutTypePB layoutType, + ) { final payload = DatabaseLayoutIdPB.create() ..viewId = viewId ..layout = layoutType; return DatabaseEventGetLayoutSetting(payload).send(); } - Future> updateLayoutSetting( - {CalendarLayoutSettingsPB? calendarLayoutSetting}) { + Future> updateLayoutSetting({ + CalendarLayoutSettingsPB? calendarLayoutSetting, + }) { final layoutSetting = LayoutSettingPB.create(); if (calendarLayoutSetting != null) { layoutSetting.calendar = calendarLayoutSetting; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_cell_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_cell_bloc.dart index d96e08e86b..5ccb3dff63 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_cell_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_cell_bloc.dart @@ -17,7 +17,9 @@ class FieldCellBloc extends Bloc { required FieldCellContext cellContext, }) : _fieldListener = SingleFieldListener(fieldId: cellContext.field.id), _fieldBackendSvc = FieldBackendService( - viewId: cellContext.viewId, fieldId: cellContext.field.id), + viewId: cellContext.viewId, + fieldId: cellContext.field.id, + ), super(FieldCellState.initial(cellContext)) { on( (event, emit) async { @@ -49,15 +51,17 @@ class FieldCellBloc extends Bloc { } void _startListening() { - _fieldListener.start(onFieldChanged: (result) { - if (isClosed) { - return; - } - result.fold( - (field) => add(FieldCellEvent.didReceiveFieldUpdate(field)), - (err) => Log.error(err), - ); - }); + _fieldListener.start( + onFieldChanged: (result) { + if (isClosed) { + return; + } + result.fold( + (field) => add(FieldCellEvent.didReceiveFieldUpdate(field)), + (err) => Log.error(err), + ); + }, + ); } } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_controller.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_controller.dart index 231582621e..df2528b96b 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_controller.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_controller.dart @@ -255,24 +255,26 @@ class FieldController { } } - _filtersListener.start(onFilterChanged: (result) { - result.fold( - (FilterChangesetNotificationPB changeset) { - final List filters = filterInfos; - // Deletes the filters - deleteFilterFromChangeset(filters, changeset); + _filtersListener.start( + onFilterChanged: (result) { + result.fold( + (FilterChangesetNotificationPB changeset) { + final List filters = filterInfos; + // Deletes the filters + deleteFilterFromChangeset(filters, changeset); - // Inserts the new filter if it's not exist - insertFilterFromChangeset(filters, changeset); + // Inserts the new filter if it's not exist + insertFilterFromChangeset(filters, changeset); - updateFilterFromChangeset(filters, changeset); + updateFilterFromChangeset(filters, changeset); - _updateFieldInfos(); - _filterNotifier?.filters = filters; - }, - (err) => Log.error(err), - ); - }); + _updateFieldInfos(); + _filterNotifier?.filters = filters; + }, + (err) => Log.error(err), + ); + }, + ); } void _listenOnSortChanged() { @@ -347,48 +349,54 @@ class FieldController { } } - _sortsListener.start(onSortChanged: (result) { - result.fold( - (SortChangesetNotificationPB changeset) { - final List newSortInfos = sortInfos; - deleteSortFromChangeset(newSortInfos, changeset); - insertSortFromChangeset(newSortInfos, changeset); - updateSortFromChangeset(newSortInfos, changeset); + _sortsListener.start( + onSortChanged: (result) { + result.fold( + (SortChangesetNotificationPB changeset) { + final List newSortInfos = sortInfos; + deleteSortFromChangeset(newSortInfos, changeset); + insertSortFromChangeset(newSortInfos, changeset); + updateSortFromChangeset(newSortInfos, changeset); - _updateFieldInfos(); - _sortNotifier?.sorts = newSortInfos; - }, - (err) => Log.error(err), - ); - }); + _updateFieldInfos(); + _sortNotifier?.sorts = newSortInfos; + }, + (err) => Log.error(err), + ); + }, + ); } void _listenOnSettingChanges() { //Listen on setting changes - _settingListener.start(onSettingUpdated: (result) { - result.fold( - (setting) => _updateSetting(setting), - (r) => Log.error(r), - ); - }); + _settingListener.start( + onSettingUpdated: (result) { + result.fold( + (setting) => _updateSetting(setting), + (r) => Log.error(r), + ); + }, + ); } void _listenOnFieldChanges() { //Listen on field's changes - _fieldListener.start(onFieldsChanged: (result) { - result.fold( - (changeset) { - _deleteFields(changeset.deletedFields); - _insertFields(changeset.insertedFields); + _fieldListener.start( + onFieldsChanged: (result) { + result.fold( + (changeset) { + _deleteFields(changeset.deletedFields); + _insertFields(changeset.insertedFields); - final updatedFields = _updateFields(changeset.updatedFields); - for (final listener in _updatedFieldCallbacks.values) { - listener(updatedFields); - } - }, - (err) => Log.error(err), - ); - }); + final updatedFields = _updateFields(changeset.updatedFields); + for (final listener in _updatedFieldCallbacks.values) { + listener(updatedFields); + } + }, + (err) => Log.error(err), + ); + }, + ); } void _updateSetting(DatabaseViewSettingPB setting) { diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_editor_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_editor_bloc.dart index 491d266b7d..9376cf9d1e 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_editor_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_editor_bloc.dart @@ -36,11 +36,13 @@ class FieldEditorBloc extends Bloc { } }, didReceiveFieldChanged: (FieldPB field) { - emit(state.copyWith( - field: Some(field), - name: field.name, - canDelete: field.isPrimary, - )); + emit( + state.copyWith( + field: Some(field), + name: field.name, + canDelete: field.isPrimary, + ), + ); }, deleteField: () { state.field.fold( diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_listener.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_listener.dart index bc6125859a..e26fa398b5 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_listener.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_listener.dart @@ -17,8 +17,9 @@ class SingleFieldListener { SingleFieldListener({required this.fieldId}); - void start( - {required void Function(UpdateFieldNotifiedValue) onFieldChanged}) { + void start({ + required void Function(UpdateFieldNotifiedValue) onFieldChanged, + }) { _updateFieldNotifier?.addPublishListener(onFieldChanged); _listener = DatabaseNotificationListener( objectId: fieldId, @@ -60,8 +61,9 @@ class FieldsListener { DatabaseNotificationListener? _listener; FieldsListener({required this.viewId}); - void start( - {required void Function(UpdateFieldsNotifiedValue) onFieldsChanged}) { + void start({ + required void Function(UpdateFieldsNotifiedValue) onFieldsChanged, + }) { updateFieldsNotifier?.addPublishListener(onFieldsChanged); _listener = DatabaseNotificationListener( objectId: viewId, diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/date_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/date_bloc.dart index 6762e0d7d3..c66681ff76 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/date_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/date_bloc.dart @@ -15,16 +15,25 @@ class DateTypeOptionBloc (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), + ), + ); }, ); }, diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/number_format_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/number_format_bloc.dart index 4145e90aff..e5e6be7b34 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/number_format_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/number_format_bloc.dart @@ -7,16 +7,20 @@ class NumberFormatBloc extends Bloc { NumberFormatBloc() : super(NumberFormatState.initial()) { on( (event, emit) async { - event.map(setFilter: (_SetFilter value) { - final List formats = List.from(NumberFormat.values); - if (value.filter.isNotEmpty) { - formats.retainWhere((element) => element - .title() - .toLowerCase() - .contains(value.filter.toLowerCase())); - } - emit(state.copyWith(formats: formats, filter: value.filter)); - }); + event.map( + setFilter: (_SetFilter value) { + final List formats = List.from(NumberFormat.values); + if (value.filter.isNotEmpty) { + formats.retainWhere( + (element) => element + .title() + .toLowerCase() + .contains(value.filter.toLowerCase()), + ); + } + emit(state.copyWith(formats: formats, filter: value.filter)); + }, + ); }, ); } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/select_option_type_option_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/select_option_type_option_bloc.dart index 75c472f96d..89db8be458 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/select_option_type_option_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/select_option_type_option_bloc.dart @@ -59,9 +59,11 @@ class SelectOptionTypeOptionEvent with _$SelectOptionTypeOptionEvent { const factory SelectOptionTypeOptionEvent.endAddingOption() = _EndAddingOption; const factory SelectOptionTypeOptionEvent.updateOption( - SelectOptionPB option) = _UpdateOption; + SelectOptionPB option, + ) = _UpdateOption; const factory SelectOptionTypeOptionEvent.deleteOption( - SelectOptionPB option) = _DeleteOption; + SelectOptionPB option, + ) = _DeleteOption; } @freezed diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/type_option_context.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/type_option_context.dart index 279792ed34..f9dd370e45 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/type_option_context.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/type_option_context.dart @@ -158,7 +158,9 @@ abstract class IFieldTypeOptionLoader { Future> load(); Future> switchToField( - String fieldId, FieldType fieldType) { + String fieldId, + FieldType fieldType, + ) { final payload = UpdateFieldTypePayloadPB.create() ..viewId = viewId ..fieldId = fieldId diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/filter/filter_listener.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/filter/filter_listener.dart index d309f995f1..fd217e50fb 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/filter/filter_listener.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/filter/filter_listener.dart @@ -107,7 +107,8 @@ class FilterListener { case DatabaseNotification.DidUpdateFilter: result.fold( (payload) => handleChangeset( - FilterChangesetNotificationPB.fromBuffer(payload)), + FilterChangesetNotificationPB.fromBuffer(payload), + ), (error) {}, ); break; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/filter/filter_service.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/filter/filter_service.dart index 86cdb513a5..d0de02a9cf 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/filter/filter_service.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/filter/filter_service.dart @@ -97,7 +97,8 @@ class FilterBackendService { filter.end = $fixnum.Int64(end); } else { throw Exception( - "Start and end should not be null if the timestamp is null"); + "Start and end should not be null if the timestamp is null", + ); } } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/layout/calendar_setting_listener.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/layout/calendar_setting_listener.dart index 9ec8c1f656..52a492201b 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/layout/calendar_setting_listener.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/layout/calendar_setting_listener.dart @@ -15,8 +15,9 @@ class DatabaseCalendarLayoutListener { DatabaseNotificationListener? _listener; DatabaseCalendarLayoutListener(this.viewId); - void start( - {required void Function(NewLayoutFieldValue) onCalendarLayoutChanged}) { + void start({ + required void Function(NewLayoutFieldValue) onCalendarLayoutChanged, + }) { _newLayoutFieldNotifier?.addPublishListener(onCalendarLayoutChanged); _listener = DatabaseNotificationListener( objectId: viewId, diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_cache.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_cache.dart index 608cc7b907..2bea00fc83 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_cache.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_cache.dart @@ -102,11 +102,16 @@ class RowCache { final rowInfo = _rowList.get(reorderRow.rowId); if (rowInfo != null) { _rowList.moveRow( - reorderRow.rowId, reorderRow.oldIndex, reorderRow.newIndex); - _rowChangeReasonNotifier.receive(RowsChangedReason.reorderSingleRow( - reorderRow, - rowInfo, - )); + reorderRow.rowId, + reorderRow.oldIndex, + reorderRow.newIndex, + ); + _rowChangeReasonNotifier.receive( + RowsChangedReason.reorderSingleRow( + reorderRow, + rowInfo, + ), + ); } } @@ -325,7 +330,9 @@ class RowsChangedReason with _$RowsChangedReason { const factory RowsChangedReason.initial() = InitialListState; const factory RowsChangedReason.reorderRows() = _ReorderRows; const factory RowsChangedReason.reorderSingleRow( - ReorderSingleRowPB reorderRow, RowInfo rowInfo) = _ReorderSingleRow; + ReorderSingleRowPB reorderRow, + RowInfo rowInfo, + ) = _ReorderSingleRow; } class InsertedIndex { diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_data_controller.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_data_controller.dart index c810ea7c8e..731cbc5f3d 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_data_controller.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_data_controller.dart @@ -23,10 +23,12 @@ class RowController { } void addListener({OnRowChanged? onRowChanged}) { - _onRowChangedListeners.add(_rowCache.addListener( - rowId: rowId, - onCellUpdated: onRowChanged, - )); + _onRowChangedListeners.add( + _rowCache.addListener( + rowId: rowId, + onCellUpdated: onRowChanged, + ), + ); } void dispose() { diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_list.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_list.dart index f6d4114495..eae593fa64 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_list.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_list.dart @@ -85,10 +85,12 @@ class RowList { insert(index, builder(insertRow.row)); if (!isContains) { - insertIndexs.add(InsertedIndex( - index: index, - rowId: insertRow.row.id, - )); + insertIndexs.add( + InsertedIndex( + index: index, + rowId: insertRow.row.id, + ), + ); } } return insertIndexs; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/group_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/group_bloc.dart index 075c48c58d..1e22879423 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/group_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/group_bloc.dart @@ -67,7 +67,8 @@ class DatabaseGroupEvent with _$DatabaseGroupEvent { FieldType fieldType, ) = _DatabaseGroupEvent; const factory DatabaseGroupEvent.didReceiveFieldUpdate( - List fields) = _DidReceiveFieldUpdate; + List fields, + ) = _DidReceiveFieldUpdate; } @freezed @@ -78,7 +79,9 @@ class DatabaseGroupState with _$DatabaseGroupState { }) = _DatabaseGroupState; factory DatabaseGroupState.initial( - String viewId, List fieldContexts) => + String viewId, + List fieldContexts, + ) => DatabaseGroupState( viewId: viewId, fieldContexts: fieldContexts, diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/property_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/property_bloc.dart index b49367034a..117dd1c3aa 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/property_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/property_bloc.dart @@ -13,11 +13,13 @@ class DatabasePropertyBloc final FieldController _fieldController; Function(List)? _onFieldsFn; - DatabasePropertyBloc( - {required String viewId, required FieldController fieldController}) - : _fieldController = fieldController, + DatabasePropertyBloc({ + required String viewId, + required FieldController fieldController, + }) : _fieldController = fieldController, super( - DatabasePropertyState.initial(viewId, fieldController.fieldInfos)) { + DatabasePropertyState.initial(viewId, fieldController.fieldInfos), + ) { on( (event, emit) async { await event.map( @@ -68,9 +70,12 @@ class DatabasePropertyBloc class DatabasePropertyEvent with _$DatabasePropertyEvent { const factory DatabasePropertyEvent.initial() = _Initial; const factory DatabasePropertyEvent.setFieldVisibility( - String fieldId, bool visibility) = _SetFieldVisibility; + String fieldId, + bool visibility, + ) = _SetFieldVisibility; const factory DatabasePropertyEvent.didReceiveFieldUpdate( - List fields) = _DidReceiveFieldUpdate; + List fields, + ) = _DidReceiveFieldUpdate; const factory DatabasePropertyEvent.moveField(int fromIndex, int toIndex) = _MoveField; } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/setting_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/setting_bloc.dart index 8c59036f56..b0e9595592 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/setting_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/setting_bloc.dart @@ -11,9 +11,11 @@ class DatabaseSettingBloc : super(DatabaseSettingState.initial()) { on( (event, emit) async { - event.map(performAction: (_PerformAction value) { - emit(state.copyWith(selectedAction: Some(value.action))); - }); + event.map( + performAction: (_PerformAction value) { + emit(state.copyWith(selectedAction: Some(value.action))); + }, + ); }, ); } @@ -22,7 +24,8 @@ class DatabaseSettingBloc @freezed class DatabaseSettingEvent with _$DatabaseSettingEvent { const factory DatabaseSettingEvent.performAction( - DatabaseSettingAction action) = _PerformAction; + DatabaseSettingAction action, + ) = _PerformAction; } @freezed diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/setting_controller.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/setting_controller.dart index a2b687332c..005a9bf967 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/setting_controller.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/setting_controller.dart @@ -28,12 +28,14 @@ class SettingController { }); // Listen on the setting changes - _listener.start(onSettingUpdated: (result) { - result.fold( - (newSetting) => updateSetting(newSetting), - (err) => _onError?.call(err), - ); - }); + _listener.start( + onSettingUpdated: (result) { + result.fold( + (newSetting) => updateSetting(newSetting), + (err) => _onError?.call(err), + ); + }, + ); } void startListening({ diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/view/view_cache.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/view/view_cache.dart index 002bc40ec0..5d8251c82f 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/view/view_cache.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/view/view_cache.dart @@ -69,9 +69,11 @@ class DatabaseViewCache { } if (changeset.insertedRows.isNotEmpty) { - _callbacks?.onRowsCreated?.call(changeset.insertedRows - .map((insertedRow) => insertedRow.row.id) - .toList()); + _callbacks?.onRowsCreated?.call( + changeset.insertedRows + .map((insertedRow) => insertedRow.row.id) + .toList(), + ); } }, (err) => Log.error(err), diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/board/application/board_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/board/application/board_bloc.dart index 61911b5318..eab6093a4a 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/board/application/board_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/board/application/board_bloc.dart @@ -105,23 +105,31 @@ class BoardBloc extends Bloc { ); }, didCreateRow: (group, row, int? index) { - emit(state.copyWith( - editingRow: Some(BoardEditingRow( - group: group, - row: row, - index: index, - )), - )); + emit( + state.copyWith( + editingRow: Some( + BoardEditingRow( + group: group, + row: row, + index: index, + ), + ), + ), + ); _groupItemStartEditing(group, row, true); }, startEditingRow: (group, row) { - emit(state.copyWith( - editingRow: Some(BoardEditingRow( - group: group, - row: row, - index: null, - )), - )); + emit( + state.copyWith( + editingRow: Some( + BoardEditingRow( + group: group, + row: row, + index: null, + ), + ), + ), + ); _groupItemStartEditing(group, row, true); }, endEditingRow: (rowId) { @@ -175,10 +183,12 @@ class BoardBloc extends Bloc { groupControllers.clear(); boardController.clear(); - boardController.addGroups(groups - .where((group) => fieldController.getField(group.fieldId) != null) - .map((group) => initializeGroupData(group)) - .toList()); + boardController.addGroups( + groups + .where((group) => fieldController.getField(group.fieldId) != null) + .map((group) => initializeGroupData(group)) + .toList(), + ); for (final group in groups) { final controller = initializeGroupController(group); @@ -334,7 +344,8 @@ class BoardState with _$BoardState { class GridLoadingState with _$GridLoadingState { const factory GridLoadingState.loading() = _Loading; const factory GridLoadingState.finish( - Either successOrFail) = _Finish; + Either successOrFail, + ) = _Finish; } class GridFieldEquatable extends Equatable { diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/board/application/group_controller.dart b/frontend/appflowy_flutter/lib/plugins/database_view/board/application/group_controller.dart index a1f87796d2..6786c58850 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/board/application/group_controller.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/board/application/group_controller.dart @@ -41,44 +41,46 @@ class GroupController { } void startListening() { - _listener.start(onGroupChanged: (result) { - result.fold( - (GroupRowsNotificationPB changeset) { - for (final deletedRow in changeset.deletedRows) { - group.rows.removeWhere((rowPB) => rowPB.id == deletedRow); - delegate.removeRow(group, deletedRow); - } - - for (final insertedRow in changeset.insertedRows) { - final index = insertedRow.hasIndex() ? insertedRow.index : null; - if (insertedRow.hasIndex() && - group.rows.length > insertedRow.index) { - group.rows.insert(insertedRow.index, insertedRow.row); - } else { - group.rows.add(insertedRow.row); + _listener.start( + onGroupChanged: (result) { + result.fold( + (GroupRowsNotificationPB changeset) { + for (final deletedRow in changeset.deletedRows) { + group.rows.removeWhere((rowPB) => rowPB.id == deletedRow); + delegate.removeRow(group, deletedRow); } - if (insertedRow.isNew) { - delegate.addNewRow(group, insertedRow.row, index); - } else { - delegate.insertRow(group, insertedRow.row, index); - } - } + for (final insertedRow in changeset.insertedRows) { + final index = insertedRow.hasIndex() ? insertedRow.index : null; + if (insertedRow.hasIndex() && + group.rows.length > insertedRow.index) { + group.rows.insert(insertedRow.index, insertedRow.row); + } else { + group.rows.add(insertedRow.row); + } - for (final updatedRow in changeset.updatedRows) { - final index = group.rows.indexWhere( - (rowPB) => rowPB.id == updatedRow.id, - ); - - if (index != -1) { - group.rows[index] = updatedRow; - delegate.updateRow(group, updatedRow); + if (insertedRow.isNew) { + delegate.addNewRow(group, insertedRow.row, index); + } else { + delegate.insertRow(group, insertedRow.row, index); + } } - } - }, - (err) => Log.error(err), - ); - }); + + for (final updatedRow in changeset.updatedRows) { + final index = group.rows.indexWhere( + (rowPB) => rowPB.id == updatedRow.id, + ); + + if (index != -1) { + group.rows[index] = updatedRow; + delegate.updateRow(group, updatedRow); + } + } + }, + (err) => Log.error(err), + ); + }, + ); } Future dispose() async { diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/board/application/toolbar/board_setting_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/board/application/toolbar/board_setting_bloc.dart index e64072db56..4eb4440f11 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/board/application/toolbar/board_setting_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/board/application/toolbar/board_setting_bloc.dart @@ -10,9 +10,11 @@ class BoardSettingBloc extends Bloc { : super(BoardSettingState.initial()) { on( (event, emit) async { - event.when(performAction: (action) { - emit(state.copyWith(selectedAction: Some(action))); - }); + event.when( + performAction: (action) { + emit(state.copyWith(selectedAction: Some(action))); + }, + ); }, ); } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/calendar_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/calendar_bloc.dart index f0cfb43b48..9d66e50252 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/calendar_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/calendar_bloc.dart @@ -67,16 +67,20 @@ class CalendarBloc extends Bloc { if (index != -1) { allEvents[index] = eventData; } - emit(state.copyWith( - allEvents: allEvents, - updateEvent: eventData, - )); + emit( + state.copyWith( + allEvents: allEvents, + updateEvent: eventData, + ), + ); }, didReceiveNewEvent: (CalendarEventData event) { - emit(state.copyWith( - allEvents: [...state.allEvents, event], - newEvent: event, - )); + emit( + state.copyWith( + allEvents: [...state.allEvents, event], + newEvent: event, + ), + ); }, didDeleteEvents: (List deletedRowIds) { var events = [...state.allEvents]; @@ -155,7 +159,8 @@ class CalendarBloc extends Bloc { } Future _updateCalendarLayoutSetting( - CalendarLayoutSettingsPB layoutSetting) async { + CalendarLayoutSettingsPB layoutSetting, + ) async { return _databaseController.updateCalenderLayoutSetting(layoutSetting); } @@ -198,7 +203,8 @@ class CalendarBloc extends Bloc { } CalendarEventData? _calendarEventDataFromEventPB( - CalendarEventPB eventPB) { + CalendarEventPB eventPB, + ) { final fieldInfo = fieldInfoByFieldId[eventPB.titleFieldId]; if (fieldInfo != null) { final cellId = CellIdentifier( @@ -267,7 +273,8 @@ class CalendarBloc extends Bloc { ); final onCalendarLayoutFieldChanged = CalendarLayoutCallbacks( - onCalendarLayoutChanged: _didReceiveNewLayoutField); + onCalendarLayoutChanged: _didReceiveNewLayoutField, + ); _databaseController.addListener( onDatabaseChanged: onDatabaseChanged, @@ -299,7 +306,8 @@ class CalendarEvent with _$CalendarEvent { // Called after loading the calendar layout setting from the backend const factory CalendarEvent.didReceiveCalendarSettings( - CalendarLayoutSettingsPB settings) = _ReceiveCalendarSettings; + CalendarLayoutSettingsPB settings, + ) = _ReceiveCalendarSettings; // Called after loading all the current evnets const factory CalendarEvent.didLoadAllEvents(Events events) = @@ -307,11 +315,13 @@ class CalendarEvent with _$CalendarEvent { // Called when specific event was updated const factory CalendarEvent.didUpdateEvent( - CalendarEventData event) = _DidUpdateEvent; + CalendarEventData event, + ) = _DidUpdateEvent; // Called after creating a new event const factory CalendarEvent.didReceiveNewEvent( - CalendarEventData event) = _DidReceiveNewEvent; + CalendarEventData event, + ) = _DidReceiveNewEvent; // Called when deleting events const factory CalendarEvent.didDeleteEvents(List rowIds) = @@ -323,13 +333,15 @@ class CalendarEvent with _$CalendarEvent { // Called when updating the calendar's layout settings const factory CalendarEvent.updateCalendarLayoutSetting( - CalendarLayoutSettingsPB layoutSetting) = _UpdateCalendarLayoutSetting; + CalendarLayoutSettingsPB layoutSetting, + ) = _UpdateCalendarLayoutSetting; const factory CalendarEvent.didReceiveDatabaseUpdate(DatabasePB database) = _ReceiveDatabaseUpdate; const factory CalendarEvent.didReceiveNewLayoutField( - CalendarLayoutSettingsPB layoutSettings) = _DidReceiveNewLayoutField; + CalendarLayoutSettingsPB layoutSettings, + ) = _DidReceiveNewLayoutField; } @freezed @@ -361,7 +373,8 @@ class CalendarState with _$CalendarState { class DatabaseLoadingState with _$DatabaseLoadingState { const factory DatabaseLoadingState.loading() = _Loading; const factory DatabaseLoadingState.finish( - Either successOrFail) = _Finish; + Either successOrFail, + ) = _Finish; } class CalendarEditingRow { diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/calendar_setting_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/calendar_setting_bloc.dart index 074836236f..f42c1c049e 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/calendar_setting_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/calendar_setting_bloc.dart @@ -22,7 +22,6 @@ class CalendarSettingBloc ); }); } - } @freezed @@ -33,7 +32,8 @@ class CalendarSettingState with _$CalendarSettingState { }) = _CalendarSettingState; factory CalendarSettingState.initial( - CalendarLayoutSettingsPB? layoutSettings) => + CalendarLayoutSettingsPB? layoutSettings, + ) => CalendarSettingState( selectedAction: none(), layoutSetting: layoutSettings == null ? none() : Some(layoutSettings), @@ -43,9 +43,11 @@ class CalendarSettingState with _$CalendarSettingState { @freezed class CalendarSettingEvent with _$CalendarSettingEvent { const factory CalendarSettingEvent.performAction( - CalendarSettingAction action) = _PerformAction; + CalendarSettingAction action, + ) = _PerformAction; const factory CalendarSettingEvent.updateLayoutSetting( - CalendarLayoutSettingsPB setting) = _UpdateLayoutSetting; + CalendarLayoutSettingsPB setting, + ) = _UpdateLayoutSetting; } enum CalendarSettingAction { diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/calendar/presentation/calendar_day.dart b/frontend/appflowy_flutter/lib/plugins/database_view/calendar/presentation/calendar_day.dart index 0b835f8a39..72c3655a16 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/calendar/presentation/calendar_day.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/calendar/presentation/calendar_day.dart @@ -63,29 +63,30 @@ class CalendarDayCard extends StatelessWidget { }).toList(); final child = Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - _Header( - date: date, - isInMonth: isInMonth, - isToday: isToday, - onCreate: () => onCreateEvent(date), + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + _Header( + date: date, + isInMonth: isInMonth, + isToday: isToday, + onCreate: () => onCreateEvent(date), + ), + VSpace(GridSize.typeOptionSeparatorHeight), + Flexible( + child: ListView.separated( + itemBuilder: (BuildContext context, int index) { + return children[index]; + }, + itemCount: children.length, + separatorBuilder: (BuildContext context, int index) => + VSpace(GridSize.typeOptionSeparatorHeight), ), - VSpace(GridSize.typeOptionSeparatorHeight), - Flexible( - child: ListView.separated( - itemBuilder: (BuildContext context, int index) { - return children[index]; - }, - itemCount: children.length, - separatorBuilder: (BuildContext context, int index) => - VSpace(GridSize.typeOptionSeparatorHeight), - ), - ), - ], - )); + ), + ], + ), + ); return Container( color: backgroundColor, diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/calendar/presentation/calendar_page.dart b/frontend/appflowy_flutter/lib/plugins/database_view/calendar/presentation/calendar_page.dart index 988654a8ec..889fe651f2 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/calendar/presentation/calendar_page.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/calendar/presentation/calendar_page.dart @@ -73,9 +73,11 @@ class _CalendarPageState extends State { listenWhen: (p, c) => p.updateEvent != c.updateEvent, listener: (context, state) { if (state.updateEvent != null) { - _eventController.removeWhere((element) => - state.updateEvent!.event!.eventId == - element.event!.eventId); + _eventController.removeWhere( + (element) => + state.updateEvent!.event!.eventId == + element.event!.eventId, + ); _eventController.add(state.updateEvent!); } }, diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/calendar/presentation/toolbar/calendar_layout_setting.dart b/frontend/appflowy_flutter/lib/plugins/database_view/calendar/presentation/toolbar/calendar_layout_setting.dart index ff69888813..c946fa64c2 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/calendar/presentation/toolbar/calendar_layout_setting.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/calendar/presentation/toolbar/calendar_layout_setting.dart @@ -96,16 +96,22 @@ class _CalendarLayoutSettingState extends State { fieldId: settings.layoutFieldId, popoverMutex: popoverMutex, onUpdated: (fieldId) { - _updateLayoutSettings(context, - onUpdated: widget.onUpdated, layoutFieldId: fieldId); + _updateLayoutSettings( + context, + onUpdated: widget.onUpdated, + layoutFieldId: fieldId, + ); }, ); default: return ShowWeekends( showWeekends: settings.showWeekends, onUpdated: (showWeekends) { - _updateLayoutSettings(context, - onUpdated: widget.onUpdated, showWeekends: showWeekends); + _updateLayoutSettings( + context, + onUpdated: widget.onUpdated, + showWeekends: showWeekends, + ); }, ); } @@ -129,7 +135,8 @@ class _CalendarLayoutSettingState extends State { } List _availableCalendarSettings( - CalendarLayoutSettingsPB layoutSettings) { + CalendarLayoutSettingsPB layoutSettings, + ) { List settings = [ CalendarLayoutSettingAction.layoutField, // CalendarLayoutSettingAction.layoutType, @@ -220,8 +227,9 @@ class LayoutDateField extends StatelessWidget { popupBuilder: (context) { return BlocProvider( create: (context) => getIt( - param1: viewId, param2: fieldController) - ..add(const DatabasePropertyEvent.initial()), + param1: viewId, + param2: fieldController, + )..add(const DatabasePropertyEvent.initial()), child: BlocBuilder( builder: (context, state) { final items = state.fieldContexts @@ -264,7 +272,8 @@ class LayoutDateField extends StatelessWidget { child: FlowyButton( margin: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 10.0), text: FlowyText.medium( - LocaleKeys.calendar_settings_layoutDateField.tr()), + LocaleKeys.calendar_settings_layoutDateField.tr(), + ), ), ), ); @@ -368,7 +377,8 @@ class FirstDayOfWeek extends StatelessWidget { child: FlowyButton( margin: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 10.0), text: FlowyText.medium( - LocaleKeys.calendar_settings_firstDayOfWeek.tr()), + LocaleKeys.calendar_settings_firstDayOfWeek.tr(), + ), ), ), ); diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/checkbox_filter_editor_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/checkbox_filter_editor_bloc.dart index 588ddd5346..10552297bb 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/checkbox_filter_editor_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/checkbox_filter_editor_bloc.dart @@ -45,10 +45,12 @@ class CheckboxFilterEditorBloc didReceiveFilter: (FilterPB filter) { final filterInfo = state.filterInfo.copyWith(filter: filter); final checkboxFilter = filterInfo.checkboxFilter()!; - emit(state.copyWith( - filterInfo: filterInfo, - filter: checkboxFilter, - )); + emit( + state.copyWith( + filterInfo: filterInfo, + filter: checkboxFilter, + ), + ); }, ); }, @@ -79,7 +81,8 @@ class CheckboxFilterEditorEvent with _$CheckboxFilterEditorEvent { const factory CheckboxFilterEditorEvent.didReceiveFilter(FilterPB filter) = _DidReceiveFilter; const factory CheckboxFilterEditorEvent.updateCondition( - CheckboxFilterConditionPB condition) = _UpdateCondition; + CheckboxFilterConditionPB condition, + ) = _UpdateCondition; const factory CheckboxFilterEditorEvent.delete() = _Delete; } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/checklist_filter_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/checklist_filter_bloc.dart index 17e4397821..4decd23034 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/checklist_filter_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/checklist_filter_bloc.dart @@ -46,10 +46,12 @@ class ChecklistFilterEditorBloc didReceiveFilter: (FilterPB filter) { final filterInfo = state.filterInfo.copyWith(filter: filter); final checklistFilter = filterInfo.checklistFilter()!; - emit(state.copyWith( - filterInfo: filterInfo, - filter: checklistFilter, - )); + emit( + state.copyWith( + filterInfo: filterInfo, + filter: checklistFilter, + ), + ); }, ); }, @@ -82,7 +84,8 @@ class ChecklistFilterEditorEvent with _$ChecklistFilterEditorEvent { const factory ChecklistFilterEditorEvent.didReceiveFilter(FilterPB filter) = _DidReceiveFilter; const factory ChecklistFilterEditorEvent.updateCondition( - ChecklistFilterConditionPB condition) = _UpdateCondition; + ChecklistFilterConditionPB condition, + ) = _UpdateCondition; const factory ChecklistFilterEditorEvent.delete() = _Delete; } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/filter_menu_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/filter_menu_bloc.dart index 0931fade8b..76b135db1d 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/filter_menu_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/filter_menu_bloc.dart @@ -14,11 +14,13 @@ class GridFilterMenuBloc void Function(List)? _onFieldFn; GridFilterMenuBloc({required this.viewId, required this.fieldController}) - : super(GridFilterMenuState.initial( - viewId, - fieldController.filterInfos, - fieldController.fieldInfos, - )) { + : super( + GridFilterMenuState.initial( + viewId, + fieldController.filterInfos, + fieldController.fieldInfos, + ), + ) { on( (event, emit) async { event.when( @@ -82,7 +84,8 @@ class GridFilterMenuBloc class GridFilterMenuEvent with _$GridFilterMenuEvent { const factory GridFilterMenuEvent.initial() = _Initial; const factory GridFilterMenuEvent.didReceiveFilters( - List filters) = _DidReceiveFilters; + List filters, + ) = _DidReceiveFilters; const factory GridFilterMenuEvent.didReceiveFields(List fields) = _DidReceiveFields; const factory GridFilterMenuEvent.toggleMenu() = _SetMenuVisibility; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/select_option_filter_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/select_option_filter_bloc.dart index b547b9ebe5..f88f6a557a 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/select_option_filter_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/select_option_filter_bloc.dart @@ -61,10 +61,12 @@ class SelectOptionFilterEditorBloc didReceiveFilter: (FilterPB filter) { final filterInfo = state.filterInfo.copyWith(filter: filter); final selectOptionFilter = filterInfo.selectOptionFilter()!; - emit(state.copyWith( - filterInfo: filterInfo, - filter: selectOptionFilter, - )); + emit( + state.copyWith( + filterInfo: filterInfo, + filter: selectOptionFilter, + ), + ); }, updateFilterDescription: (String desc) { emit(state.copyWith(filterDesc: desc)); @@ -112,13 +114,17 @@ class SelectOptionFilterEditorBloc class SelectOptionFilterEditorEvent with _$SelectOptionFilterEditorEvent { const factory SelectOptionFilterEditorEvent.initial() = _Initial; const factory SelectOptionFilterEditorEvent.didReceiveFilter( - FilterPB filter) = _DidReceiveFilter; + FilterPB filter, + ) = _DidReceiveFilter; const factory SelectOptionFilterEditorEvent.updateCondition( - SelectOptionConditionPB condition) = _UpdateCondition; + SelectOptionConditionPB condition, + ) = _UpdateCondition; const factory SelectOptionFilterEditorEvent.updateContent( - List optionIds) = _UpdateContent; + List optionIds, + ) = _UpdateContent; const factory SelectOptionFilterEditorEvent.updateFilterDescription( - String desc) = _UpdateDesc; + String desc, + ) = _UpdateDesc; const factory SelectOptionFilterEditorEvent.delete() = _Delete; } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/select_option_filter_list_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/select_option_filter_list_bloc.dart index cd95541905..0456537780 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/select_option_filter_list_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/select_option_filter_list_bloc.dart @@ -43,15 +43,22 @@ class SelectOptionFilterListBloc didReceiveOptions: (newOptions) { List options = List.from(newOptions); options.retainWhere( - (element) => element.name.contains(state.predicate)); + (element) => element.name.contains(state.predicate), + ); final visibleOptions = options.map((option) { return VisibleSelectOption( - option, state.selectedOptionIds.contains(option.id)); + option, + state.selectedOptionIds.contains(option.id), + ); }).toList(); - emit(state.copyWith( - options: options, visibleOptions: visibleOptions)); + emit( + state.copyWith( + options: options, + visibleOptions: visibleOptions, + ), + ); }, filterOption: (optionName) { _updateSelectOptions(predicate: optionName, emit: emit); @@ -71,11 +78,13 @@ class SelectOptionFilterListBloc selectedOptionIds ?? state.selectedOptionIds, ); - emit(state.copyWith( - predicate: predicate ?? state.predicate, - visibleOptions: visibleOptions, - selectedOptionIds: selectedOptionIds ?? state.selectedOptionIds, - )); + emit( + state.copyWith( + predicate: predicate ?? state.predicate, + visibleOptions: visibleOptions, + selectedOptionIds: selectedOptionIds ?? state.selectedOptionIds, + ), + ); } List _makeVisibleOptions( @@ -105,11 +114,14 @@ class SelectOptionFilterListBloc class SelectOptionFilterListEvent with _$SelectOptionFilterListEvent { const factory SelectOptionFilterListEvent.initial() = _Initial; const factory SelectOptionFilterListEvent.selectOption( - SelectOptionPB option) = _SelectOption; + SelectOptionPB option, + ) = _SelectOption; const factory SelectOptionFilterListEvent.unselectOption( - SelectOptionPB option) = _UnSelectOption; + SelectOptionPB option, + ) = _UnSelectOption; const factory SelectOptionFilterListEvent.didReceiveOptions( - List options) = _DidReceiveOptions; + List options, + ) = _DidReceiveOptions; const factory SelectOptionFilterListEvent.filterOption(String optionName) = _SelectOptionFilter; } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/text_filter_editor_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/text_filter_editor_bloc.dart index 50a45ff2ee..0e3eedecb8 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/text_filter_editor_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/text_filter_editor_bloc.dart @@ -54,10 +54,12 @@ class TextFilterEditorBloc didReceiveFilter: (FilterPB filter) { final filterInfo = state.filterInfo.copyWith(filter: filter); final textFilter = filterInfo.textFilter()!; - emit(state.copyWith( - filterInfo: filterInfo, - filter: textFilter, - )); + emit( + state.copyWith( + filterInfo: filterInfo, + filter: textFilter, + ), + ); }, ); }, @@ -88,7 +90,8 @@ class TextFilterEditorEvent with _$TextFilterEditorEvent { const factory TextFilterEditorEvent.didReceiveFilter(FilterPB filter) = _DidReceiveFilter; const factory TextFilterEditorEvent.updateCondition( - TextFilterConditionPB condition) = _UpdateCondition; + TextFilterConditionPB condition, + ) = _UpdateCondition; const factory TextFilterEditorEvent.updateContent(String content) = _UpdateContent; const factory TextFilterEditorEvent.delete() = _Delete; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_accessory_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_accessory_bloc.dart index 46b905c25b..993e42a3b0 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_accessory_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_accessory_bloc.dart @@ -8,9 +8,11 @@ class GridAccessoryMenuBloc final String viewId; GridAccessoryMenuBloc({required this.viewId}) - : super(GridAccessoryMenuState.initial( - viewId, - )) { + : super( + GridAccessoryMenuState.initial( + viewId, + ), + ) { on( (event, emit) async { event.when( diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_bloc.dart index 7d73ab9b4a..962745e165 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_bloc.dart @@ -39,16 +39,20 @@ class GridBloc extends Bloc { emit(state.copyWith(grid: Some(grid))); }, didReceiveFieldUpdate: (fields) { - emit(state.copyWith( - fields: GridFieldEquatable(fields), - )); + emit( + state.copyWith( + fields: GridFieldEquatable(fields), + ), + ); }, didReceiveRowUpdate: (newRowInfos, reason) { - emit(state.copyWith( - rowInfos: newRowInfos, - rowCount: newRowInfos.length, - reason: reason, - )); + emit( + state.copyWith( + rowInfos: newRowInfos, + rowCount: newRowInfos.length, + reason: reason, + ), + ); }, ); }, @@ -146,7 +150,8 @@ class GridState with _$GridState { class GridLoadingState with _$GridLoadingState { const factory GridLoadingState.loading() = _Loading; const factory GridLoadingState.finish( - Either successOrFail) = _Finish; + Either successOrFail, + ) = _Finish; } class GridFieldEquatable extends Equatable { diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_header_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_header_bloc.dart index 92486a699b..a3df312191 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_header_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_header_bloc.dart @@ -40,7 +40,9 @@ class GridHeaderBloc extends Bloc { } Future _moveField( - _MoveField value, Emitter emit) async { + _MoveField value, + Emitter emit, + ) async { final fields = List.from(state.fields); fields.insert(value.toIndex, fields.removeAt(value.fromIndex)); emit(state.copyWith(fields: fields)); @@ -69,7 +71,10 @@ class GridHeaderEvent with _$GridHeaderEvent { const factory GridHeaderEvent.didReceiveFieldUpdate(List fields) = _DidReceiveFieldUpdate; const factory GridHeaderEvent.moveField( - FieldPB field, int fromIndex, int toIndex) = _MoveField; + FieldPB field, + int fromIndex, + int toIndex, + ) = _MoveField; } @freezed diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/row/row_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/row/row_bloc.dart index aa1071f01c..650c905c8e 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/row/row_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/row/row_bloc.dart @@ -35,11 +35,13 @@ class RowBloc extends Bloc { final cells = cellByFieldId.values .map((e) => GridCellEquatable(e.fieldInfo)) .toList(); - emit(state.copyWith( - cellByFieldId: cellByFieldId, - cells: UnmodifiableListView(cells), - changeReason: reason, - )); + emit( + state.copyWith( + cellByFieldId: cellByFieldId, + cells: UnmodifiableListView(cells), + changeReason: reason, + ), + ); }, ); }, @@ -68,8 +70,9 @@ class RowEvent with _$RowEvent { const factory RowEvent.initial() = _InitialRow; const factory RowEvent.createRow() = _CreateRow; const factory RowEvent.didReceiveCells( - CellByFieldId cellsByFieldId, RowsChangedReason reason) = - _DidReceiveCells; + CellByFieldId cellsByFieldId, + RowsChangedReason reason, + ) = _DidReceiveCells; } @freezed diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/row/row_detail_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/row/row_detail_bloc.dart index 9a53a04a77..0bff716fa7 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/row/row_detail_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/row/row_detail_bloc.dart @@ -59,7 +59,8 @@ class RowDetailEvent with _$RowDetailEvent { const factory RowDetailEvent.initial() = _Initial; const factory RowDetailEvent.deleteField(String fieldId) = _DeleteField; const factory RowDetailEvent.didReceiveCellDatas( - List gridCells) = _DidReceiveCellDatas; + List gridCells, + ) = _DidReceiveCellDatas; } @freezed diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_create_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_create_bloc.dart index c5bd4932fe..1c8fad5e55 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_create_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_create_bloc.dart @@ -82,9 +82,10 @@ class CreateSortBloc extends Bloc { Future> _createDefaultSort(FieldInfo field) async { final result = await _sortBackendSvc.insertSort( - fieldId: field.id, - fieldType: field.fieldType, - condition: SortConditionPB.Ascending); + fieldId: field.id, + fieldType: field.fieldType, + condition: SortConditionPB.Ascending, + ); return result; } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_editor_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_editor_bloc.dart index 7f792d62db..c01bbc9b6d 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_editor_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_editor_bloc.dart @@ -100,7 +100,9 @@ class SortEditorEvent with _$SortEditorEvent { const factory SortEditorEvent.didReceiveSorts(List sortInfos) = _DidReceiveSorts; const factory SortEditorEvent.setCondition( - SortInfo sortInfo, SortConditionPB condition) = _SetCondition; + SortInfo sortInfo, + SortConditionPB condition, + ) = _SetCondition; const factory SortEditorEvent.deleteSort(SortInfo sortInfo) = _DeleteSort; const factory SortEditorEvent.deleteAllSorts() = _DeleteAllSorts; } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_menu_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_menu_bloc.dart index fb1bb81bd1..3b039be5b3 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_menu_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_menu_bloc.dart @@ -14,11 +14,13 @@ class SortMenuBloc extends Bloc { void Function(List)? _onFieldFn; SortMenuBloc({required this.viewId, required this.fieldController}) - : super(SortMenuState.initial( - viewId, - fieldController.sortInfos, - fieldController.fieldInfos, - )) { + : super( + SortMenuState.initial( + viewId, + fieldController.sortInfos, + fieldController.fieldInfos, + ), + ) { on( (event, emit) async { event.when( diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/grid_page.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/grid_page.dart index 2b8f9a060c..95f38e4ffd 100755 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/grid_page.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/grid_page.dart @@ -117,7 +117,8 @@ class FlowyGrid extends StatefulWidget { class _FlowyGridState extends State { final _scrollController = GridScrollController( - scrollGroupController: LinkedScrollControllerGroup()); + scrollGroupController: LinkedScrollControllerGroup(), + ); late ScrollController headerScrollController; @override @@ -319,13 +320,14 @@ class _GridRowsState extends State<_GridRows> { ); FlowyOverlay.show( - context: context, - builder: (BuildContext context) { - return RowDetailPage( - cellBuilder: cellBuilder, - dataController: dataController, - ); - }); + context: context, + builder: (BuildContext context) { + return RowDetailPage( + cellBuilder: cellBuilder, + dataController: dataController, + ); + }, + ); } } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/grid_scroll.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/grid_scroll.dart index 72b5152aea..90e29d6716 100755 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/grid_scroll.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/grid_scroll.dart @@ -8,9 +8,9 @@ class GridScrollController { final List _linkHorizontalControllers = []; - GridScrollController( - {required LinkedScrollControllerGroup scrollGroupController}) - : _scrollGroupController = scrollGroupController, + GridScrollController({ + required LinkedScrollControllerGroup scrollGroupController, + }) : _scrollGroupController = scrollGroupController, verticalController = ScrollController(), horizontalController = scrollGroupController.addAndGet(); diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/accessory_menu.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/accessory_menu.dart index c2cbaf30b3..898c11951e 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/accessory_menu.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/accessory_menu.dart @@ -21,10 +21,11 @@ class GridAccessoryMenu extends StatelessWidget { child: MultiBlocListener( listeners: [ BlocListener( - listenWhen: (p, c) => p.isVisible != c.isVisible, - listener: (context, state) => context - .read() - .add(const GridAccessoryMenuEvent.toggleMenu())), + listenWhen: (p, c) => p.isVisible != c.isVisible, + listener: (context, state) => context + .read() + .add(const GridAccessoryMenuEvent.toggleMenu()), + ), BlocListener( listenWhen: (p, c) => p.isVisible != c.isVisible, listener: (context, state) => context diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/checkbox.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/checkbox.dart index 1b0ae521ef..ea5af95929 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/checkbox.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/checkbox.dart @@ -100,7 +100,9 @@ class _CheckboxFilterEditorState extends State { } Widget _buildFilterPanel( - BuildContext context, CheckboxFilterEditorState state) { + BuildContext context, + CheckboxFilterEditorState state, + ) { return SizedBox( height: 20, child: Row( diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/checklist/checklist.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/checklist/checklist.dart index 2178d255f9..5c43762ed5 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/checklist/checklist.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/checklist/checklist.dart @@ -70,9 +70,11 @@ class _ChecklistFilterChoicechipState extends State { class ChecklistFilterEditor extends StatefulWidget { final ChecklistFilterEditorBloc bloc; final PopoverMutex popoverMutex; - const ChecklistFilterEditor( - {required this.bloc, required this.popoverMutex, Key? key}) - : super(key: key); + const ChecklistFilterEditor({ + required this.bloc, + required this.popoverMutex, + Key? key, + }) : super(key: key); @override ChecklistState createState() => ChecklistState(); diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/choicechip.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/choicechip.dart index 46fb701441..144839220b 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/choicechip.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/choicechip.dart @@ -65,8 +65,10 @@ class _ChoicechipFilterDesc extends StatelessWidget { Widget build(BuildContext context) { final arrow = Transform.rotate( angle: -math.pi / 2, - child: svgWidget("home/arrow_left", - color: AFThemeExtension.of(context).textColor), + child: svgWidget( + "home/arrow_left", + color: AFThemeExtension.of(context).textColor, + ), ); return Padding( padding: const EdgeInsets.symmetric(horizontal: 2), diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/select_option/select_option.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/select_option/select_option.dart index 3ffc07b6c9..f7f121a0c7 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/select_option/select_option.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/select_option/select_option.dart @@ -110,7 +110,10 @@ class _SelectOptionFilterEditorState extends State { selectedOptionIds: state.filter.optionIds, onSelectedOptions: (optionIds) { context.read().add( - SelectOptionFilterEditorEvent.updateContent(optionIds)); + SelectOptionFilterEditorEvent.updateContent( + optionIds, + ), + ); }, ), ), @@ -132,7 +135,9 @@ class _SelectOptionFilterEditorState extends State { } Widget _buildFilterPanel( - BuildContext context, SelectOptionFilterEditorState state) { + BuildContext context, + SelectOptionFilterEditorState state, + ) { return SizedBox( height: 20, child: Row( @@ -144,7 +149,8 @@ class _SelectOptionFilterEditorState extends State { popoverMutex: popoverMutex, onCondition: (condition) { context.read().add( - SelectOptionFilterEditorEvent.updateCondition(condition)); + SelectOptionFilterEditorEvent.updateCondition(condition), + ); }, ), const Spacer(), diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/text.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/text.dart index 0eaebbc4cb..11e547adea 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/text.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/text.dart @@ -147,7 +147,9 @@ class _TextFilterEditorState extends State { } Widget _buildFilterTextField( - BuildContext context, TextFilterEditorState state) { + BuildContext context, + TextFilterEditorState state, + ) { return FlowyTextField( text: state.filter.content, hintText: LocaleKeys.grid_settings_typeAValue.tr(), diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/condition_button.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/condition_button.dart index 660c0b0316..58c625348f 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/condition_button.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/condition_button.dart @@ -18,8 +18,10 @@ class ConditionButton extends StatelessWidget { Widget build(BuildContext context) { final arrow = Transform.rotate( angle: -math.pi / 2, - child: svgWidget("home/arrow_left", - color: AFThemeExtension.of(context).textColor), + child: svgWidget( + "home/arrow_left", + color: AFThemeExtension.of(context).textColor, + ), ); return SizedBox( diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/create_filter_list.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/create_filter_list.dart index 42ba35640e..1ae3fa2294 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/create_filter_list.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/create_filter_list.dart @@ -117,7 +117,10 @@ class _FilterTextFieldDelegate extends SliverPersistentHeaderDelegate { @override Widget build( - BuildContext context, double shrinkOffset, bool overlapsContent) { + BuildContext context, + double shrinkOffset, + bool overlapsContent, + ) { return Container( padding: const EdgeInsets.only(top: 4), height: fixHeight, diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/field_cell.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/field_cell.dart index 526276e0f2..2265cf199a 100755 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/field_cell.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/field_cell.dart @@ -95,17 +95,20 @@ class _GridHeaderCellContainer extends StatelessWidget { width: 1.0, ); final decoration = BoxDecoration( - border: Border( - top: borderSide, - right: borderSide, - bottom: borderSide, - )); + border: Border( + top: borderSide, + right: borderSide, + bottom: borderSide, + ), + ); return Container( width: width, decoration: decoration, child: ConstrainedBox( - constraints: const BoxConstraints.expand(), child: child), + constraints: const BoxConstraints.expand(), + child: child, + ), ); } } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/field_cell_action_sheet.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/field_cell_action_sheet.dart index cf44799a88..0f1fdf5d30 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/field_cell_action_sheet.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/field_cell_action_sheet.dart @@ -101,25 +101,27 @@ class _FieldOperationList extends StatelessWidget { @override Widget build(BuildContext context) { - return Column(children: [ - Flex( - direction: Axis.horizontal, - children: [ - _actionCell(FieldAction.hide), - HSpace(GridSize.typeOptionSeparatorHeight), - _actionCell(FieldAction.duplicate), - ], - ), - VSpace(GridSize.typeOptionSeparatorHeight), - Flex( - direction: Axis.horizontal, - children: [ - _actionCell(FieldAction.delete), - HSpace(GridSize.typeOptionSeparatorHeight), - const Spacer(), - ], - ), - ]); + return Column( + children: [ + Flex( + direction: Axis.horizontal, + children: [ + _actionCell(FieldAction.hide), + HSpace(GridSize.typeOptionSeparatorHeight), + _actionCell(FieldAction.duplicate), + ], + ), + VSpace(GridSize.typeOptionSeparatorHeight), + Flex( + direction: Axis.horizontal, + children: [ + _actionCell(FieldAction.delete), + HSpace(GridSize.typeOptionSeparatorHeight), + const Spacer(), + ], + ), + ], + ); } Widget _actionCell(FieldAction action) { diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/field_type_option_editor.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/field_type_option_editor.dart index b8d1e9a26a..0b421a00af 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/field_type_option_editor.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/field_type_option_editor.dart @@ -90,11 +90,13 @@ class _SwitchFieldButton extends StatelessWidget { mutex: popoverMutex, offset: const Offset(8, 0), popupBuilder: (popOverContext) { - return FieldTypeList(onSelectField: (newFieldType) { - context - .read() - .add(FieldTypeOptionEditEvent.switchToField(newFieldType)); - }); + return FieldTypeList( + onSelectField: (newFieldType) { + context + .read() + .add(FieldTypeOptionEditEvent.switchToField(newFieldType)); + }, + ); }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 12.0), diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/grid_header.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/grid_header.dart index 6a77ac83ee..3414c18ec6 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/grid_header.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/grid_header.dart @@ -39,7 +39,9 @@ class _GridHeaderSliverAdaptorState extends State { return BlocProvider( create: (context) { final bloc = getIt( - param1: widget.viewId, param2: widget.fieldController); + param1: widget.viewId, + param2: widget.fieldController, + ); bloc.add(const GridHeaderEvent.initial()); return bloc; }, @@ -98,10 +100,16 @@ class _GridHeaderState extends State<_GridHeader> { builder: (context, state) { final cells = state.fields .where((field) => field.visibility) - .map((field) => - FieldCellContext(viewId: widget.viewId, field: field.field)) - .map((ctx) => - GridFieldCell(key: _getKeyById(ctx.field.id), cellContext: ctx)) + .map( + (field) => + FieldCellContext(viewId: widget.viewId, field: field.field), + ) + .map( + (ctx) => GridFieldCell( + key: _getKeyById(ctx.field.id), + cellContext: ctx, + ), + ) .toList(); return Container( @@ -124,8 +132,12 @@ 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 @@ -197,12 +209,17 @@ class SliverHeaderDelegateImplementation 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) { + BuildContext context, + double shrinkOffset, + bool overlapsContent, + ) { return _GridHeader(viewId: gridId); } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/builder.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/builder.dart index 8c1ed332d8..879950a59b 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/builder.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/builder.dart @@ -76,12 +76,13 @@ TypeOptionWidgetBuilder makeTypeOptionWidgetBuilder({ ); case FieldType.DateTime: return DateTypeOptionWidgetBuilder( - makeTypeOptionContextWithDataController( - viewId: viewId, - fieldType: fieldType, - dataController: dataController, - ), - popoverMutex); + makeTypeOptionContextWithDataController( + viewId: viewId, + fieldType: fieldType, + dataController: dataController, + ), + popoverMutex, + ); case FieldType.SingleSelect: return SingleSelectTypeOptionWidgetBuilder( makeTypeOptionContextWithDataController( diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/checklist.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/checklist.dart index 75e3f5d505..c010df7b96 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/checklist.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/checklist.dart @@ -4,7 +4,8 @@ import 'builder.dart'; class ChecklistTypeOptionWidgetBuilder extends TypeOptionWidgetBuilder { ChecklistTypeOptionWidgetBuilder( - ChecklistTypeOptionContext typeOptionContext); + ChecklistTypeOptionContext typeOptionContext, + ); @override Widget? build(BuildContext context) => null; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/number.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/number.dart index 45479046c5..410bcfc70c 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/number.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/number.dart @@ -28,10 +28,12 @@ class NumberTypeOptionWidgetBuilder extends TypeOptionWidgetBuilder { @override Widget? build(BuildContext context) { - return Column(children: [ - VSpace(GridSize.typeOptionSeparatorHeight), - _widget, - ]); + return Column( + children: [ + VSpace(GridSize.typeOptionSeparatorHeight), + _widget, + ], + ); } } @@ -108,9 +110,11 @@ 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) { @@ -127,11 +131,12 @@ class NumberFormatList extends StatelessWidget { builder: (context, state) { final cells = state.formats.map((format) { return NumberFormatCell( - isSelected: format == selectedFormat, - format: format, - onSelected: (format) { - onSelected(format); - }); + isSelected: format == selectedFormat, + format: format, + onSelected: (format) { + onSelected(format); + }, + ); }).toList(); final list = ListView.separated( diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/select_option_editor.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/select_option_editor.dart index 36ebffa692..4e2db973ea 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/select_option_editor.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/select_option_editor.dart @@ -66,7 +66,8 @@ class SelectOptionTypeOptionEditor extends StatelessWidget { if (showOptions) { cells.add(const TypeOptionSeparator()); cells.add( - SelectOptionColorList(selectedColor: state.option.color)); + SelectOptionColorList(selectedColor: state.option.color), + ); } return SizedBox( @@ -126,9 +127,11 @@ class _DeleteTag extends StatelessWidget { class _OptionNameTextField extends StatelessWidget { final String name; final bool autoFocus; - const _OptionNameTextField( - {required this.name, required this.autoFocus, Key? key}) - : super(key: key); + const _OptionNameTextField({ + required this.name, + required this.autoFocus, + Key? key, + }) : super(key: key); @override Widget build(BuildContext context) { @@ -157,7 +160,9 @@ class SelectOptionColorList extends StatelessWidget { Widget build(BuildContext context) { final cells = SelectOptionColorPB.values.map((color) { return _SelectOptionColorCell( - color: color, isSelected: selectedColor == color); + color: color, + isSelected: selectedColor == color, + ); }).toList(); return Column( @@ -195,9 +200,11 @@ 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) { diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/row/row.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/row/row.dart index 425dec6317..52ba6fccb5 100755 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/row/row.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/row/row.dart @@ -68,11 +68,13 @@ class _GridRowState extends State { ), ); - return Row(children: [ - const _RowLeading(), - content, - const _RowTrailing(), - ]); + return Row( + children: [ + const _RowLeading(), + content, + const _RowTrailing(), + ], + ); }, ), ), @@ -129,9 +131,11 @@ class _RowLeadingState extends State<_RowLeading> { mainAxisAlignment: MainAxisAlignment.center, children: [ const _InsertButton(), - _MenuButton(openMenu: () { - popoverController.show(); - }), + _MenuButton( + openMenu: () { + popoverController.show(); + }, + ), ], ); } @@ -216,12 +220,13 @@ class RowContent extends StatelessWidget { !listEquals(previous.cells, current.cells), builder: (context, state) { return IntrinsicHeight( - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: _makeCells(context, state.cellByFieldId), - )); + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: _makeCells(context, state.cellByFieldId), + ), + ); }, ); } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/sort/create_sort_list.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/sort/create_sort_list.dart index 6dea5acb43..c7214a5759 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/sort/create_sort_list.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/sort/create_sort_list.dart @@ -116,7 +116,10 @@ class _FilterTextFieldDelegate extends SliverPersistentHeaderDelegate { @override Widget build( - BuildContext context, double shrinkOffset, bool overlapsContent) { + BuildContext context, + double shrinkOffset, + bool overlapsContent, + ) { return Container( padding: const EdgeInsets.only(top: 4), height: fixHeight, diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/sort/sort_editor.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/sort/sort_editor.dart index 9895c08c43..6673ad9372 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/sort/sort_editor.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/sort/sort_editor.dart @@ -76,13 +76,15 @@ class _SortList extends StatelessWidget { return BlocBuilder( builder: (context, state) { final List children = state.sortInfos - .map((info) => Padding( - padding: const EdgeInsets.symmetric(vertical: 6), - child: _SortItem( - sortInfo: info, - popoverMutex: popoverMutex, - ), - )) + .map( + (info) => Padding( + padding: const EdgeInsets.symmetric(vertical: 6), + child: _SortItem( + sortInfo: info, + popoverMutex: popoverMutex, + ), + ), + ) .toList(); return Column( diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/toolbar/grid_property.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/toolbar/grid_property.dart index 0dc81d26b6..4da4d78c9b 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/toolbar/grid_property.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/toolbar/grid_property.dart @@ -40,8 +40,9 @@ class _GridPropertyListState extends State { Widget build(BuildContext context) { return BlocProvider( create: (context) => getIt( - param1: widget.viewId, param2: widget.fieldController) - ..add(const DatabasePropertyEvent.initial()), + param1: widget.viewId, + param2: widget.fieldController, + )..add(const DatabasePropertyEvent.initial()), child: BlocBuilder( builder: (context, state) { final cells = state.fieldContexts.map((field) { @@ -129,8 +130,11 @@ class _GridPropertyCellState extends State<_GridPropertyCell> { hoverColor: Colors.transparent, onPressed: () { context.read().add( - DatabasePropertyEvent.setFieldVisibility( - widget.fieldInfo.id, !widget.fieldInfo.visibility)); + DatabasePropertyEvent.setFieldVisibility( + widget.fieldInfo.id, + !widget.fieldInfo.visibility, + ), + ); }, icon: checkmark.padding(all: 6.0), ), diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/toolbar/grid_setting.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/toolbar/grid_setting.dart index 875f752106..9f5cd54cf9 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/toolbar/grid_setting.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/toolbar/grid_setting.dart @@ -25,9 +25,11 @@ class GridSettingContext { class GridSettingList extends StatelessWidget { final GridSettingContext settingContext; final Function(DatabaseSettingAction, 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); @override Widget build(BuildContext context) { @@ -35,8 +37,9 @@ class GridSettingList extends StatelessWidget { .where((value) => value.enable()) .map((action) { return _SettingItem( - action: action, - onAction: (action) => onAction(action, settingContext)); + action: action, + onAction: (action) => onAction(action, settingContext), + ); }).toList(); return SizedBox( diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/checkbox_card_cell_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/checkbox_card_cell_bloc.dart index c6e13befad..809f57a390 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/checkbox_card_cell_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/checkbox_card_cell_bloc.dart @@ -66,7 +66,8 @@ class CheckboxCardCellState with _$CheckboxCardCellState { factory CheckboxCardCellState.initial(TextCellController context) { return CheckboxCardCellState( - isSelected: _isSelected(context.getCellData())); + isSelected: _isSelected(context.getCellData()), + ); } } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/date_card_cell_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/date_card_cell_bloc.dart index 68433184e7..9d710bbe42 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/date_card_cell_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/date_card_cell_bloc.dart @@ -18,8 +18,12 @@ class DateCardCellBloc extends Bloc { event.when( initial: () => _startListening(), didReceiveCellUpdate: (DateCellDataPB? cellData) { - emit(state.copyWith( - data: cellData, dateStr: _dateStrFromCellData(cellData))); + emit( + state.copyWith( + data: cellData, + dateStr: _dateStrFromCellData(cellData), + ), + ); }, ); }, diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/select_option_card_cell_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/select_option_card_cell_bloc.dart index 549ef8e24d..8ee2007ba3 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/select_option_card_cell_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/select_option_card_cell_bloc.dart @@ -42,9 +42,11 @@ class SelectOptionCardCellBloc _onCellChangedFn = cellController.startListening( onCellChanged: ((selectOptionContext) { if (!isClosed) { - add(SelectOptionCardCellEvent.didReceiveOptions( - selectOptionContext?.selectOptions ?? [], - )); + add( + SelectOptionCardCellEvent.didReceiveOptions( + selectOptionContext?.selectOptions ?? [], + ), + ); } }), ); @@ -66,7 +68,8 @@ class SelectOptionCardCellState with _$SelectOptionCardCellState { }) = _SelectOptionCardCellState; factory SelectOptionCardCellState.initial( - SelectOptionCellController context) { + SelectOptionCellController context, + ) { final data = context.getCellData(); return SelectOptionCardCellState( selectedOptions: data?.selectOptions ?? [], diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/url_card_cell_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/url_card_cell_bloc.dart index 616619c672..870b1d996a 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/url_card_cell_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/url_card_cell_bloc.dart @@ -19,10 +19,12 @@ class URLCardCellBloc extends Bloc { _startListening(); }, didReceiveCellUpdate: (cellData) { - emit(state.copyWith( - content: cellData?.content ?? "", - url: cellData?.url ?? "", - )); + emit( + state.copyWith( + content: cellData?.content ?? "", + url: cellData?.url ?? "", + ), + ); }, updateURL: (String url) { cellController.saveCellData(url, deduplicate: true); diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/card_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/card_bloc.dart index d10c4c713a..f84e509913 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/card_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/card_bloc.dart @@ -41,10 +41,12 @@ class CardBloc extends Bloc { await _startListening(); }, didReceiveCells: (cells, reason) async { - emit(state.copyWith( - cells: cells, - changeReason: reason, - )); + emit( + state.copyWith( + cells: cells, + changeReason: reason, + ), + ); }, setIsEditing: (bool isEditing) { emit(state.copyWith(isEditing: isEditing)); @@ -87,7 +89,9 @@ class CardBloc extends Bloc { } List _makeCells( - String groupFieldId, CellByFieldId originalCellMap) { + String groupFieldId, + CellByFieldId originalCellMap, +) { List cells = []; for (final entry in originalCellMap.entries) { // Filter out the cell if it's fieldId equal to the groupFieldId diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/cells/select_option_card_cell.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/cells/select_option_card_cell.dart index 2251af0cf1..1a38f727ad 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/cells/select_option_card_cell.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/cells/select_option_card_cell.dart @@ -50,45 +50,49 @@ class _SelectOptionCardCellState extends State { return BlocProvider.value( value: _cellBloc, child: BlocBuilder( - buildWhen: (previous, current) { - return previous.selectedOptions != current.selectedOptions; - }, builder: (context, state) { - Widget? custom = widget.renderHook?.call( - state.selectedOptions, - widget.cardData, - ); - if (custom != null) { - return custom; - } + buildWhen: (previous, current) { + return previous.selectedOptions != current.selectedOptions; + }, + builder: (context, state) { + Widget? custom = widget.renderHook?.call( + state.selectedOptions, + widget.cardData, + ); + if (custom != null) { + return custom; + } - final children = state.selectedOptions.map( - (option) { - final tag = SelectOptionTag.fromOption( - context: context, - option: option, - onSelected: () => _popover.show(), - ); - return _wrapPopover(tag); - }, - ).toList(); + final children = state.selectedOptions.map( + (option) { + final tag = SelectOptionTag.fromOption( + context: context, + option: option, + onSelected: () => _popover.show(), + ); + return _wrapPopover(tag); + }, + ).toList(); - return IntrinsicHeight( - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 6), - child: SizedBox.expand( - child: Wrap(spacing: 4, runSpacing: 2, children: children), + return IntrinsicHeight( + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 6), + child: SizedBox.expand( + child: Wrap(spacing: 4, runSpacing: 2, children: children), + ), ), - ), - ); - }), + ); + }, + ), ); } Widget _wrapPopover(Widget child) { - final constraints = BoxConstraints.loose(Size( - SelectOptionCellEditor.editorPanelWidth, - 300, - )); + final constraints = BoxConstraints.loose( + Size( + SelectOptionCellEditor.editorPanelWidth, + 300, + ), + ); return AppFlowyPopover( controller: _popover, constraints: constraints, diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/container/card_container.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/container/card_container.dart index ccdfc3fc3e..6281aa80b7 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/container/card_container.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/container/card_container.dart @@ -93,11 +93,12 @@ class _CardEnterRegion extends StatelessWidget { Provider.of<_CardContainerNotifier>(context, listen: false) .onEnter = false, child: IntrinsicHeight( - child: Stack( - alignment: AlignmentDirectional.topEnd, - fit: StackFit.expand, - children: children, - )), + child: Stack( + alignment: AlignmentDirectional.topEnd, + fit: StackFit.expand, + children: children, + ), + ), ); }, ); diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/accessory/cell_accessory.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/accessory/cell_accessory.dart index 4433c9f43b..24d5743bb2 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/accessory/cell_accessory.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/accessory/cell_accessory.dart @@ -127,10 +127,12 @@ class _AccessoryHoverState extends State { final accessoryBuilder = widget.child.accessoryBuilder; if (accessoryBuilder != null) { - final accessories = accessoryBuilder((GridCellAccessoryBuildContext( - anchorContext: context, - isCellEditing: false, - ))); + final accessories = accessoryBuilder( + (GridCellAccessoryBuildContext( + anchorContext: context, + isCellEditing: false, + )), + ); children.add( Padding( padding: const EdgeInsets.only(right: 6), diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cell_builder.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cell_builder.dart index fb7d605d2d..203da7f26e 100755 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cell_builder.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cell_builder.dart @@ -96,7 +96,8 @@ abstract class CellEditable { } typedef AccessoryBuilder = List Function( - GridCellAccessoryBuildContext buildContext); + GridCellAccessoryBuildContext buildContext, +); abstract class CellAccessory extends Widget { const CellAccessory({Key? key}) : super(key: key); @@ -127,7 +128,8 @@ abstract class GridCellWidget extends StatefulWidget @override List Function( - GridCellAccessoryBuildContext buildContext)? get accessoryBuilder => null; + GridCellAccessoryBuildContext buildContext, + )? get accessoryBuilder => null; @override final GridCellFocusListener beginFocus = GridCellFocusListener(); diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/cell_container.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/cell_container.dart index d17301d0c6..5fb04100b0 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/cell_container.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/cell_container.dart @@ -77,7 +77,8 @@ class CellContainer extends StatelessWidget { width: 1.0, ); return BoxDecoration( - border: Border(right: borderSide, bottom: borderSide)); + border: Border(right: borderSide, bottom: borderSide), + ); } } } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checkbox_cell/checkbox_cell.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checkbox_cell/checkbox_cell.dart index 1a3382e2a6..05e136d833 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checkbox_cell/checkbox_cell.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checkbox_cell/checkbox_cell.dart @@ -27,8 +27,9 @@ class _CheckboxCellState extends GridCellState { final cellController = widget.cellControllerBuilder.build() as CheckboxCellController; _cellBloc = CheckboxCellBloc( - service: CellBackendService(), cellController: cellController) - ..add(const CheckboxCellEvent.initial()); + service: CellBackendService(), + cellController: cellController, + )..add(const CheckboxCellEvent.initial()); super.initState(); } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checkbox_cell/checkbox_cell_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checkbox_cell/checkbox_cell_bloc.dart index e9ccb23ed9..e0a2ac58db 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checkbox_cell/checkbox_cell_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checkbox_cell/checkbox_cell_bloc.dart @@ -43,12 +43,13 @@ class CheckboxCellBloc extends Bloc { } void _startListening() { - _onCellChangedFn = - cellController.startListening(onCellChanged: ((cellData) { - if (!isClosed) { - add(CheckboxCellEvent.didReceiveCellUpdate(cellData)); - } - })); + _onCellChangedFn = cellController.startListening( + onCellChanged: ((cellData) { + if (!isClosed) { + add(CheckboxCellEvent.didReceiveCellUpdate(cellData)); + } + }), + ); } } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_cell_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_cell_bloc.dart index ebf16a1e8c..1c90b2583a 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_cell_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_cell_bloc.dart @@ -26,11 +26,13 @@ class ChecklistCardCellBloc _loadOptions(); }, didReceiveOptions: (data) { - emit(state.copyWith( - allOptions: data.options, - selectedOptions: data.selectOptions, - percent: percentFromSelectOptionCellData(data), - )); + emit( + state.copyWith( + allOptions: data.options, + selectedOptions: data.selectOptions, + percent: percentFromSelectOptionCellData(data), + ), + ); }, ); }, @@ -76,7 +78,8 @@ class ChecklistCardCellBloc class ChecklistCellEvent with _$ChecklistCellEvent { const factory ChecklistCellEvent.initial() = _InitialCell; const factory ChecklistCellEvent.didReceiveOptions( - SelectOptionCellDataPB data) = _DidReceiveCellUpdate; + SelectOptionCellDataPB data, + ) = _DidReceiveCellUpdate; } @freezed diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_cell_editor_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_cell_editor_bloc.dart index fa81a062db..c9b0a5dff4 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_cell_editor_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_cell_editor_bloc.dart @@ -28,16 +28,20 @@ class ChecklistCellEditorBloc _loadOptions(); }, didReceiveOptions: (data) { - emit(state.copyWith( - allOptions: _makeChecklistSelectOptions(data, state.predicate), - percent: percentFromSelectOptionCellData(data), - )); + emit( + state.copyWith( + allOptions: _makeChecklistSelectOptions(data, state.predicate), + percent: percentFromSelectOptionCellData(data), + ), + ); }, newOption: (optionName) { _createOption(optionName); - emit(state.copyWith( - predicate: '', - )); + emit( + state.copyWith( + predicate: '', + ), + ); }, deleteOption: (option) { _deleteOption([option]); @@ -114,11 +118,13 @@ class ChecklistCellEditorBloc class ChecklistCellEditorEvent with _$ChecklistCellEditorEvent { const factory ChecklistCellEditorEvent.initial() = _Initial; const factory ChecklistCellEditorEvent.didReceiveOptions( - SelectOptionCellDataPB data) = _DidReceiveOptions; + SelectOptionCellDataPB data, + ) = _DidReceiveOptions; const factory ChecklistCellEditorEvent.newOption(String optionName) = _NewOption; const factory ChecklistCellEditorEvent.selectOption( - ChecklistSelectOption option) = _SelectOption; + ChecklistSelectOption option, + ) = _SelectOption; const factory ChecklistCellEditorEvent.updateOption(SelectOptionPB option) = _UpdateOption; const factory ChecklistCellEditorEvent.deleteOption(SelectOptionPB option) = @@ -163,7 +169,9 @@ double percentFromSelectOptionCellData(SelectOptionCellDataPB? data) { } List _makeChecklistSelectOptions( - SelectOptionCellDataPB? data, String predicate) { + SelectOptionCellDataPB? data, + String predicate, +) { if (data == null) { return []; } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_progress_bar.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_progress_bar.dart index f997eb7768..5bce9e86e4 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_progress_bar.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_progress_bar.dart @@ -46,7 +46,10 @@ class _SliverChecklistProgressBarDelegate @override Widget build( - BuildContext context, double shrinkOffset, bool overlapsContent) { + BuildContext context, + double shrinkOffset, + bool overlapsContent, + ) { return BlocBuilder( builder: (context, state) { return Container( diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/date_cell/date_cal_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/date_cell/date_cal_bloc.dart index 058782ebcb..1a0a78894c 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/date_cell/date_cal_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/date_cell/date_cal_bloc.dart @@ -44,7 +44,9 @@ class DateCellCalendarBloc didReceiveCellUpdate: (DateCellDataPB? cellData) { final dateCellData = calDataFromCellData(cellData); final time = dateCellData.foldRight( - "", (dateData, previous) => dateData.time ?? ''); + "", + (dateData, previous) => dateData.time ?? '', + ); emit(state.copyWith(dateCellData: dateCellData, time: time)); }, setIncludeTime: (includeTime) async { @@ -63,16 +65,24 @@ class DateCellCalendarBloc }, didUpdateCalData: (Option data, Option timeFormatError) { - emit(state.copyWith( - dateCellData: data, timeFormatError: timeFormatError)); + emit( + state.copyWith( + dateCellData: data, + timeFormatError: timeFormatError, + ), + ); }, ); }, ); } - Future _updateDateData(Emitter emit, - {DateTime? date, String? time, bool? includeTime}) { + Future _updateDateData( + Emitter emit, { + DateTime? date, + String? time, + bool? includeTime, + }) { final DateCellData newDateData = state.dateCellData.fold( () => DateCellData( date: date ?? DateTime.now(), @@ -101,33 +111,44 @@ class DateCellCalendarBloc } Future _saveDateData( - Emitter emit, DateCellData newCalData) async { + Emitter emit, + DateCellData newCalData, + ) async { if (state.dateCellData == Some(newCalData)) { return; } updateCalData( - Option dateCellData, Option timeFormatError) { + Option dateCellData, + Option timeFormatError, + ) { if (!isClosed) { - add(DateCellCalendarEvent.didUpdateCalData( - dateCellData, timeFormatError)); + add( + DateCellCalendarEvent.didUpdateCalData( + dateCellData, + timeFormatError, + ), + ); } } - cellController.saveCellData(newCalData, onFinish: (result) { - result.fold( - () => updateCalData(Some(newCalData), none()), - (err) { - switch (ErrorCode.valueOf(err.code)!) { - case ErrorCode.InvalidDateTimeFormat: - updateCalData(state.dateCellData, Some(timeFormatPrompt(err))); - break; - default: - Log.error(err); - } - }, - ); - }); + cellController.saveCellData( + newCalData, + onFinish: (result) { + result.fold( + () => updateCalData(Some(newCalData), none()), + (err) { + switch (ErrorCode.valueOf(err.code)!) { + case ErrorCode.InvalidDateTimeFormat: + updateCalData(state.dateCellData, Some(timeFormatPrompt(err))); + break; + default: + Log.error(err); + } + }, + ); + }, + ); } String timeFormatPrompt(FlowyError error) { @@ -188,9 +209,12 @@ class DateCellCalendarBloc ); result.fold( - (l) => emit(state.copyWith( + (l) => emit( + state.copyWith( dateTypeOptionPB: newDateTypeOption, - timeHintText: _timeHintText(newDateTypeOption))), + timeHintText: _timeHintText(newDateTypeOption), + ), + ), (err) => Log.error(err), ); } @@ -211,10 +235,12 @@ class DateCellCalendarEvent with _$DateCellCalendarEvent { _IncludeTime; const factory DateCellCalendarEvent.setTime(String time) = _Time; const factory DateCellCalendarEvent.didReceiveCellUpdate( - DateCellDataPB? data) = _DidReceiveCellUpdate; + DateCellDataPB? data, + ) = _DidReceiveCellUpdate; const factory DateCellCalendarEvent.didUpdateCalData( - Option data, Option timeFormatError) = - _DidUpdateCalData; + Option data, + Option timeFormatError, + ) = _DidUpdateCalData; } @freezed @@ -268,11 +294,13 @@ Option calDataFromCellData(DateCellDataPB? cellData) { timestamp.toInt(), isUtc: true, ); - dateData = Some(DateCellData( - date: date, - time: time, - includeTime: cellData.includeTime, - )); + dateData = Some( + DateCellData( + date: date, + time: time, + includeTime: cellData.includeTime, + ), + ); } return dateData; } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/date_cell/date_cell_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/date_cell/date_cell_bloc.dart index 95c389649d..24b6a91de2 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/date_cell/date_cell_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/date_cell/date_cell_bloc.dart @@ -17,8 +17,12 @@ class DateCellBloc extends Bloc { event.when( initial: () => _startListening(), didReceiveCellUpdate: (DateCellDataPB? cellData) { - emit(state.copyWith( - data: cellData, dateStr: _dateStrFromCellData(cellData))); + emit( + state.copyWith( + data: cellData, + dateStr: _dateStrFromCellData(cellData), + ), + ); }, ); }, diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/date_cell/date_editor.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/date_cell/date_editor.dart index ae4de41db5..afcc9e2a1f 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/date_cell/date_editor.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/date_cell/date_editor.dart @@ -193,9 +193,11 @@ class _CellCalendarWidgetState extends State<_CellCalendarWidget> { cellMargin: const EdgeInsets.all(3), defaultDecoration: boxDecoration, selectedDecoration: boxDecoration.copyWith( - color: Theme.of(context).colorScheme.primary), + color: Theme.of(context).colorScheme.primary, + ), todayDecoration: boxDecoration.copyWith( - color: AFThemeExtension.of(context).lightGreyHover), + color: AFThemeExtension.of(context).lightGreyHover, + ), weekendDecoration: boxDecoration, outsideDecoration: boxDecoration, defaultTextStyle: textStyle, @@ -448,11 +450,12 @@ class _CalDateTimeSettingState extends State<_CalDateTimeSetting> { offset: const Offset(8, 0), popupBuilder: (BuildContext context) { return TimeFormatList( - selectedFormat: widget.dateTypeOptionPB.timeFormat, - onSelected: (format) { - widget.onEvent(DateCellCalendarEvent.setTimeFormat(format)); - timeSettingPopoverMutex.close(); - }); + selectedFormat: widget.dateTypeOptionPB.timeFormat, + onSelected: (format) { + widget.onEvent(DateCellCalendarEvent.setTimeFormat(format)); + timeSettingPopoverMutex.close(); + }, + ); }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 6.0), diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/number_cell/number_cell_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/number_cell/number_cell_bloc.dart index e106e31dc8..aab00be5c4 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/number_cell/number_cell_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/number_cell/number_cell_bloc.dart @@ -25,12 +25,15 @@ class NumberCellBloc extends Bloc { updateCell: (text) { if (state.cellContent != text) { emit(state.copyWith(cellContent: text)); - cellController.saveCellData(text, onFinish: (result) { - result.fold( - () {}, - (err) => Log.error(err), - ); - }); + cellController.saveCellData( + text, + onFinish: (result) { + result.fold( + () {}, + (err) => Log.error(err), + ); + }, + ); } }, ); diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_cell.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_cell.dart index 70f864ad80..66017e38a9 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_cell.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_cell.dart @@ -169,10 +169,12 @@ class _SelectOptionWrapState extends State { Widget build(BuildContext context) { Widget child = _buildOptions(context); - final constraints = BoxConstraints.loose(Size( - SelectOptionCellEditor.editorPanelWidth, - 300, - )); + final constraints = BoxConstraints.loose( + Size( + SelectOptionCellEditor.editorPanelWidth, + 300, + ), + ); return AppFlowyPopover( controller: widget.popoverController, constraints: constraints, diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_cell_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_cell_bloc.dart index a0654910bf..03332f025f 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_cell_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_cell_bloc.dart @@ -21,9 +21,11 @@ class SelectOptionCellBloc _startListening(); }, didReceiveOptions: (_DidReceiveOptions value) { - emit(state.copyWith( - selectedOptions: value.selectedOptions, - )); + emit( + state.copyWith( + selectedOptions: value.selectedOptions, + ), + ); }, ); }, @@ -44,9 +46,11 @@ class SelectOptionCellBloc _onCellChangedFn = cellController.startListening( onCellChanged: ((selectOptionContext) { if (!isClosed) { - add(SelectOptionCellEvent.didReceiveOptions( - selectOptionContext?.selectOptions ?? [], - )); + add( + SelectOptionCellEvent.didReceiveOptions( + selectOptionContext?.selectOptions ?? [], + ), + ); } }), ); diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_editor.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_editor.dart index 1d8ca404d8..24c74ed527 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_editor.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_editor.dart @@ -77,13 +77,15 @@ class _OptionList extends StatelessWidget { builder: (context, state) { List cells = []; cells.add(const _Title()); - cells.addAll(state.options.map((option) { - return _SelectOptionCell( - option: option, - isSelected: state.selectedOptions.contains(option), - popoverMutex: popoverMutex, - ); - }).toList()); + cells.addAll( + state.options.map((option) { + return _SelectOptionCell( + option: option, + isSelected: state.selectedOptions.contains(option), + popoverMutex: popoverMutex, + ); + }).toList(), + ); state.createOption.fold( () => null, @@ -124,9 +126,10 @@ class _TextField extends StatelessWidget { return BlocBuilder( builder: (context, state) { final optionMap = LinkedHashMap.fromIterable( - state.selectedOptions, - key: (option) => option.name, - value: (option) => option); + state.selectedOptions, + key: (option) => option.name, + value: (option) => option, + ); return Padding( padding: const EdgeInsets.all(_padding), @@ -149,19 +152,19 @@ class _TextField extends StatelessWidget { .add(SelectOptionEditorEvent.trySelectOption(tagName)); }, onPaste: (tagNames, remainder) { - context - .read() - .add(SelectOptionEditorEvent.selectMultipleOptions( - tagNames, - remainder, - )); + context.read().add( + SelectOptionEditorEvent.selectMultipleOptions( + tagNames, + remainder, + ), + ); }, onRemove: (optionName) { - context - .read() - .add(SelectOptionEditorEvent.unSelectOption( - optionMap[optionName]!.id, - )); + context.read().add( + SelectOptionEditorEvent.unSelectOption( + optionMap[optionName]!.id, + ), + ); }, ), ); diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_editor_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_editor_bloc.dart index 19c950476c..46358c5349 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_editor_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_editor_bloc.dart @@ -28,18 +28,22 @@ class SelectOptionCellEditorBloc }, didReceiveOptions: (_DidReceiveOptions value) { final result = _makeOptions(state.filter, value.options); - emit(state.copyWith( - allOptions: value.options, - options: result.options, - createOption: result.createOption, - selectedOptions: value.selectedOptions, - )); + emit( + state.copyWith( + allOptions: value.options, + options: result.options, + createOption: result.createOption, + selectedOptions: value.selectedOptions, + ), + ); }, newOption: (_NewOption value) async { await _createOption(value.optionName); - emit(state.copyWith( - filter: none(), - )); + emit( + state.copyWith( + filter: none(), + ), + ); }, deleteOption: (_DeleteOption value) async { await _deleteOption([value.option]); @@ -100,7 +104,9 @@ class SelectOptionCellEditorBloc } void _trySelectOption( - String optionName, Emitter emit) { + String optionName, + Emitter emit, + ) { SelectOptionPB? matchingOption; bool optionExistsButSelected = false; @@ -151,11 +157,13 @@ class SelectOptionCellEditorBloc Some(optionName), state.allOptions, ); - emit(state.copyWith( - filter: Some(optionName), - options: result.options, - createOption: result.createOption, - )); + emit( + state.copyWith( + filter: Some(optionName), + options: result.options, + createOption: result.createOption, + ), + ); } Future _loadOptions() async { @@ -225,8 +233,9 @@ class SelectOptionCellEditorBloc class SelectOptionEditorEvent with _$SelectOptionEditorEvent { const factory SelectOptionEditorEvent.initial() = _Initial; const factory SelectOptionEditorEvent.didReceiveOptions( - List options, List selectedOptions) = - _DidReceiveOptions; + List options, + List selectedOptions, + ) = _DidReceiveOptions; const factory SelectOptionEditorEvent.newOption(String optionName) = _NewOption; const factory SelectOptionEditorEvent.selectOption(String optionId) = @@ -243,7 +252,9 @@ class SelectOptionEditorEvent with _$SelectOptionEditorEvent { const factory SelectOptionEditorEvent.trySelectOption(String optionName) = _TrySelectOption; const factory SelectOptionEditorEvent.selectMultipleOptions( - List optionNames, String remainder) = _SelectMultipleOptions; + List optionNames, + String remainder, + ) = _SelectMultipleOptions; } @freezed diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_service.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_service.dart index a7f6e82755..0ca1cfac0f 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_service.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_service.dart @@ -14,8 +14,10 @@ class SelectOptionBackendService { String get fieldId => cellId.fieldInfo.id; String get rowId => cellId.rowId; - Future> create( - {required String name, bool isSelected = true}) { + Future> create({ + required String name, + bool isSelected = true, + }) { return TypeOptionBackendService(viewId: viewId, fieldId: fieldId) .newOption(name: name) .then( @@ -51,8 +53,9 @@ class SelectOptionBackendService { return DatabaseEventUpdateSelectOption(payload).send(); } - Future> delete( - {required Iterable options}) { + Future> delete({ + required Iterable options, + }) { final payload = SelectOptionChangesetPB.create() ..deleteOptions.addAll(options) ..cellIdentifier = _cellIdentifier(); @@ -69,16 +72,18 @@ class SelectOptionBackendService { return DatabaseEventGetSelectOptionCellData(payload).send(); } - Future> select( - {required Iterable optionIds}) { + Future> select({ + required Iterable optionIds, + }) { final payload = SelectOptionCellChangesetPB.create() ..cellIdentifier = _cellIdentifier() ..insertOptionIds.addAll(optionIds); return DatabaseEventUpdateSelectOptionCell(payload).send(); } - Future> unSelect( - {required Iterable optionIds}) { + Future> unSelect({ + required Iterable optionIds, + }) { final payload = SelectOptionCellChangesetPB.create() ..cellIdentifier = _cellIdentifier() ..deleteOptionIds.addAll(optionIds); diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/text_field.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/text_field.dart index dc015509ed..86c7b1163f 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/text_field.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/text_field.dart @@ -165,11 +165,13 @@ class _SelectOptionTextFieldState extends State { } final children = widget.selectedOptionMap.values - .map((option) => SelectOptionTag.fromOption( - context: context, - option: option, - onRemove: (option) => widget.onRemove(option), - )) + .map( + (option) => SelectOptionTag.fromOption( + context: context, + option: option, + onRemove: (option) => widget.onRemove(option), + ), + ) .toList(); return MouseRegion( cursor: SystemMouseCursors.basic, diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/url_cell/url_cell.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/url_cell/url_cell.dart index 470fd31b26..4b44dfb633 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/url_cell/url_cell.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/url_cell/url_cell.dart @@ -52,7 +52,9 @@ class GridURLCell extends GridCellWidget { GridCellState createState() => _GridURLCellState(); GridCellAccessoryBuilder accessoryFromType( - GridURLCellAccessoryType ty, GridCellAccessoryBuildContext buildContext) { + GridURLCellAccessoryType ty, + GridCellAccessoryBuildContext buildContext, + ) { switch (ty) { case GridURLCellAccessoryType.edit: return GridCellAccessoryBuilder( @@ -76,23 +78,29 @@ class GridURLCell extends GridCellWidget { @override List Function( - GridCellAccessoryBuildContext buildContext) - get accessoryBuilder => (buildContext) { - final List accessories = []; - if (cellStyle != null) { - accessories.addAll(cellStyle!.accessoryTypes.map((ty) { - return accessoryFromType(ty, buildContext); - })); - } + 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 { @@ -212,8 +220,10 @@ class _EditURLAccessoryState extends State<_EditURLAccessory> controller: _popoverController, direction: PopoverDirection.bottomWithLeftAligned, offset: const Offset(0, 8), - child: svgWidget("editor/edit", - color: AFThemeExtension.of(context).textColor), + child: svgWidget( + "editor/edit", + color: AFThemeExtension.of(context).textColor, + ), popupBuilder: (BuildContext popoverContext) { return URLEditorPopover( cellController: diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/url_cell/url_cell_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/url_cell/url_cell_bloc.dart index 35550d8a1a..68beb7d773 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/url_cell/url_cell_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/url_cell/url_cell_bloc.dart @@ -19,10 +19,12 @@ class URLCellBloc extends Bloc { _startListening(); }, didReceiveCellUpdate: (cellData) { - emit(state.copyWith( - content: cellData?.content ?? "", - url: cellData?.url ?? "", - )); + emit( + state.copyWith( + content: cellData?.content ?? "", + url: cellData?.url ?? "", + ), + ); }, updateURL: (String url) { cellController.saveCellData(url, deduplicate: true); diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/url_cell/url_cell_editor_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/url_cell/url_cell_editor_bloc.dart index e38588f38f..70000d6d6a 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/url_cell/url_cell_editor_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/url_cell/url_cell_editor_bloc.dart @@ -20,10 +20,12 @@ class URLCellEditorBloc extends Bloc { }, updateText: (text) async { await cellController.saveCellData(text); - emit(state.copyWith( - content: text, - isFinishEditing: true, - )); + emit( + state.copyWith( + content: text, + isFinishEditing: true, + ), + ); }, didReceiveCellUpdate: (cellData) { emit(state.copyWith(content: cellData?.content ?? "")); diff --git a/frontend/appflowy_flutter/lib/plugins/document/application/doc_bloc.dart b/frontend/appflowy_flutter/lib/plugins/document/application/doc_bloc.dart index ae47a120ca..317769f248 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/application/doc_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/application/doc_bloc.dart @@ -53,13 +53,17 @@ class DocumentBloc extends Bloc { .deleteViews([Tuple2(view.id, TrashType.TrashView)]); final newState = result.fold( - (l) => state.copyWith(forceClose: true), (r) => state); + (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); + (l) => state.copyWith(isDeleted: false), + (r) => state, + ); emit(newState); }, ); @@ -187,7 +191,8 @@ class DocumentState with _$DocumentState { class DocumentLoadingState with _$DocumentLoadingState { const factory DocumentLoadingState.loading() = _Loading; const factory DocumentLoadingState.finish( - Either successOrFail) = _Finish; + Either successOrFail, + ) = _Finish; } /// Uses to erase the different between appflowy editor and the backend diff --git a/frontend/appflowy_flutter/lib/plugins/document/application/share_bloc.dart b/frontend/appflowy_flutter/lib/plugins/document/application/share_bloc.dart index ddb4fe915d..9fd5c5f3ee 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/application/share_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/application/share_bloc.dart @@ -51,11 +51,14 @@ class DocShareBloc extends Bloc { String _convertDocumentToMarkdown(ExportDataPB value) { final json = jsonDecode(value.data); final document = Document.fromJson(json); - return documentToMarkdown(document, customParsers: [ - const DividerNodeParser(), - const MathEquationNodeParser(), - const CodeBlockNodeParser(), - ]); + return documentToMarkdown( + document, + customParsers: [ + const DividerNodeParser(), + const MathEquationNodeParser(), + const CodeBlockNodeParser(), + ], + ); } } @@ -71,5 +74,6 @@ class DocShareState with _$DocShareState { const factory DocShareState.initial() = _Initial; const factory DocShareState.loading() = _Loading; const factory DocShareState.finish( - Either successOrFail) = _Finish; + Either successOrFail, + ) = _Finish; } diff --git a/frontend/appflowy_flutter/lib/plugins/document/application/share_service.dart b/frontend/appflowy_flutter/lib/plugins/document/application/share_service.dart index cf07dc0054..11c992d0a0 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/application/share_service.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/application/share_service.dart @@ -7,7 +7,9 @@ import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; class ShareService { Future> export( - ViewPB view, ExportType type) { + ViewPB view, + ExportType type, + ) { var payload = ExportPayloadPB.create() ..viewId = view.id ..exportType = type diff --git a/frontend/appflowy_flutter/lib/plugins/document/document_page.dart b/frontend/appflowy_flutter/lib/plugins/document/document_page.dart index 8c87000722..acd4953a88 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/document_page.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/document_page.dart @@ -61,27 +61,28 @@ class _DocumentPageState extends State { providers: [ BlocProvider.value(value: documentBloc), ], - child: - BlocBuilder(builder: (context, state) { - return state.loadingState.map( - loading: (_) => SizedBox.expand( - child: Container(color: Colors.transparent), - ), - finish: (result) => result.successOrFail.fold( - (_) { - if (state.forceClose) { - widget.onDeleted(); - return const SizedBox(); - } else if (documentBloc.editorState == null) { - return const SizedBox(); - } else { - return _renderDocument(context, state); - } - }, - (err) => FlowyErrorPage(err.toString()), - ), - ); - }), + child: BlocBuilder( + builder: (context, state) { + return state.loadingState.map( + loading: (_) => SizedBox.expand( + child: Container(color: Colors.transparent), + ), + finish: (result) => result.successOrFail.fold( + (_) { + if (state.forceClose) { + widget.onDeleted(); + return const SizedBox(); + } else if (documentBloc.editorState == null) { + return const SizedBox(); + } else { + return _renderDocument(context, state); + } + }, + (err) => FlowyErrorPage(err.toString()), + ), + ); + }, + ), ); } @@ -191,11 +192,13 @@ class _AppFlowyEditorPageState extends State<_AppFlowyEditorPage> { toolbarItems: [ smartEditItem, ], - themeData: theme.copyWith(extensions: [ - ...theme.extensions.values, - customEditorTheme(context), - ...customPluginTheme(context), - ]), + themeData: theme.copyWith( + extensions: [ + ...theme.extensions.values, + customEditorTheme(context), + ...customPluginTheme(context), + ], + ), ); return Expanded( child: Center( diff --git a/frontend/appflowy_flutter/lib/plugins/document/editor_styles.dart b/frontend/appflowy_flutter/lib/plugins/document/editor_styles.dart index 16a286e7e3..5d52fc8804 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/editor_styles.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/editor_styles.dart @@ -85,8 +85,10 @@ Iterable> customPluginTheme(BuildContext context) { ? darkPluginStyleExtension : lightPluginStyleExtension; return pluginTheme.toList() - ..removeWhere((element) => - element is HeadingPluginStyle || element is NumberListPluginStyle) + ..removeWhere( + (element) => + element is HeadingPluginStyle || element is NumberListPluginStyle, + ) ..add(headingPluginStyle) ..add(numberListPluginStyle); } diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/banner.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/banner.dart index 8cd8e4decc..49a76846a0 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/banner.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/banner.dart @@ -9,9 +9,11 @@ import 'package:appflowy/generated/locale_keys.g.dart'; class DocumentBanner extends StatelessWidget { final void Function() onRestore; final void Function() onDelete; - const DocumentBanner( - {required this.onRestore, required this.onDelete, Key? key}) - : super(key: key); + const DocumentBanner({ + required this.onRestore, + required this.onDelete, + Key? key, + }) : super(key: key); @override Widget build(BuildContext context) { @@ -25,41 +27,44 @@ class DocumentBanner extends StatelessWidget { fit: BoxFit.scaleDown, child: Row( children: [ - FlowyText.medium(LocaleKeys.deletePagePrompt_text.tr(), - color: Colors.white), + FlowyText.medium( + LocaleKeys.deletePagePrompt_text.tr(), + color: Colors.white, + ), const HSpace(20), BaseStyledButton( - minWidth: 160, - minHeight: 40, - contentPadding: EdgeInsets.zero, - bgColor: Colors.transparent, - hoverColor: Theme.of(context).colorScheme.primary, - highlightColor: - Theme.of(context).colorScheme.primaryContainer, - outlineColor: Colors.white, - borderRadius: Corners.s8Border, - onPressed: onRestore, - child: FlowyText.medium( - LocaleKeys.deletePagePrompt_restore.tr(), - color: Theme.of(context).colorScheme.onPrimary, - fontSize: 14, - )), + minWidth: 160, + minHeight: 40, + contentPadding: EdgeInsets.zero, + bgColor: Colors.transparent, + hoverColor: Theme.of(context).colorScheme.primary, + highlightColor: Theme.of(context).colorScheme.primaryContainer, + outlineColor: Colors.white, + borderRadius: Corners.s8Border, + onPressed: onRestore, + child: FlowyText.medium( + LocaleKeys.deletePagePrompt_restore.tr(), + color: Theme.of(context).colorScheme.onPrimary, + fontSize: 14, + ), + ), const HSpace(20), BaseStyledButton( - minWidth: 220, - minHeight: 40, - contentPadding: EdgeInsets.zero, - bgColor: Colors.transparent, - hoverColor: Theme.of(context).colorScheme.primaryContainer, - highlightColor: Theme.of(context).colorScheme.primary, - outlineColor: Colors.white, - borderRadius: Corners.s8Border, - onPressed: onDelete, - child: FlowyText.medium( - LocaleKeys.deletePagePrompt_deletePermanent.tr(), - color: Theme.of(context).colorScheme.onPrimary, - fontSize: 14, - )), + minWidth: 220, + minHeight: 40, + contentPadding: EdgeInsets.zero, + bgColor: Colors.transparent, + hoverColor: Theme.of(context).colorScheme.primaryContainer, + highlightColor: Theme.of(context).colorScheme.primary, + outlineColor: Colors.white, + borderRadius: Corners.s8Border, + onPressed: onDelete, + child: FlowyText.medium( + LocaleKeys.deletePagePrompt_deletePermanent.tr(), + color: Theme.of(context).colorScheme.onPrimary, + fontSize: 14, + ), + ), ], ), ), diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/more/cubit/document_appearance_cubit.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/more/cubit/document_appearance_cubit.dart index 80a52a9f3e..31088c7437 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/more/cubit/document_appearance_cubit.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/more/cubit/document_appearance_cubit.dart @@ -25,16 +25,20 @@ class DocumentAppearanceCubit extends Cubit { void fetch() async { final prefs = await SharedPreferences.getInstance(); final fontSize = prefs.getDouble(_kDocumentAppearanceFontSize) ?? 14.0; - emit(state.copyWith( - fontSize: fontSize, - )); + emit( + state.copyWith( + fontSize: fontSize, + ), + ); } void syncFontSize(double fontSize) async { final prefs = await SharedPreferences.getInstance(); prefs.setDouble(_kDocumentAppearanceFontSize, fontSize); - emit(state.copyWith( - fontSize: fontSize, - )); + emit( + state.copyWith( + fontSize: fontSize, + ), + ); } } diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/more/font_size_switcher.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/more/font_size_switcher.dart index 13814ac186..274c652553 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/more/font_size_switcher.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/more/font_size_switcher.dart @@ -25,42 +25,45 @@ class _FontSizeSwitcherState extends State { @override Widget build(BuildContext context) { return BlocBuilder( - builder: (context, state) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FlowyText.semibold( - LocaleKeys.moreAction_fontSize.tr(), - fontSize: 12, - color: Theme.of(context).colorScheme.tertiary, - ), - const SizedBox( - height: 5, - ), - ToggleButtons( - isSelected: - _fontSizes.map((e) => e.item2 == state.fontSize).toList(), - onPressed: (int index) { - _updateSelectedFontSize(_fontSizes[index].item2); - }, - borderRadius: const BorderRadius.all(Radius.circular(5)), - selectedColor: Theme.of(context).colorScheme.tertiary, - fillColor: Theme.of(context).colorScheme.primary, - color: Theme.of(context).hintColor, - constraints: const BoxConstraints( - minHeight: 40.0, - minWidth: 80.0, + builder: (context, state) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FlowyText.semibold( + LocaleKeys.moreAction_fontSize.tr(), + fontSize: 12, + color: Theme.of(context).colorScheme.tertiary, ), - children: _fontSizes - .map((e) => Text( + const SizedBox( + height: 5, + ), + ToggleButtons( + isSelected: + _fontSizes.map((e) => e.item2 == state.fontSize).toList(), + onPressed: (int index) { + _updateSelectedFontSize(_fontSizes[index].item2); + }, + borderRadius: const BorderRadius.all(Radius.circular(5)), + selectedColor: Theme.of(context).colorScheme.tertiary, + fillColor: Theme.of(context).colorScheme.primary, + color: Theme.of(context).hintColor, + constraints: const BoxConstraints( + minHeight: 40.0, + minWidth: 80.0, + ), + children: _fontSizes + .map( + (e) => Text( e.item1, style: TextStyle(fontSize: e.item2), - )) - .toList(), - ), - ], - ); - }); + ), + ) + .toList(), + ), + ], + ); + }, + ); } void _updateSelectedFontSize(double fontSize) { diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/built_in_page_widget.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/built_in_page_widget.dart index 0df834c355..6f6c6e1f77 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/built_in_page_widget.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/built_in_page_widget.dart @@ -111,9 +111,11 @@ class _BuiltInPageWidgetState extends State { children: [ // information FlowyIconButton( - tooltipText: LocaleKeys.tooltip_referencePage.tr(namedArgs: { - 'name': viewPB.layout.name, - }), + tooltipText: LocaleKeys.tooltip_referencePage.tr( + namedArgs: { + 'name': viewPB.layout.name, + }, + ), width: 24, height: 24, iconPadding: const EdgeInsets.all(3), diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/insert_page_command.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/insert_page_command.dart index ff12cc9afd..a00ff3b966 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/insert_page_command.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/insert_page_command.dart @@ -28,7 +28,8 @@ extension InsertPage on EditorState { if (database == null) { throw StateError( - 'The database associated with ${viewPB.id} could not be found while attempting to create a referenced ${viewPB.layout.name}.'); + 'The database associated with ${viewPB.id} could not be found while attempting to create a referenced ${viewPB.layout.name}.', + ); } final prefix = referencedBoardPrefix(viewPB.layout); diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/link_to_page_widget.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/link_to_page_widget.dart index d59d679141..bf9bcf703d 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/link_to_page_widget.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/link_to_page_widget.dart @@ -40,24 +40,26 @@ void showLinkToPageMenu( } _linkToPageMenu?.remove(); - _linkToPageMenu = OverlayEntry(builder: (context) { - return Positioned( - top: alignment == Alignment.bottomLeft ? offset.dy : null, - bottom: alignment == Alignment.topLeft ? offset.dy : null, - left: offset.dx, - child: Material( - color: Colors.transparent, - child: LinkToPageMenu( - editorState: editorState, - layoutType: pageType, - hintText: hintText, - onSelected: (appPB, viewPB) { - editorState.insertPage(appPB, viewPB); - }, + _linkToPageMenu = OverlayEntry( + builder: (context) { + return Positioned( + top: alignment == Alignment.bottomLeft ? offset.dy : null, + bottom: alignment == Alignment.topLeft ? offset.dy : null, + left: offset.dx, + child: Material( + color: Colors.transparent, + child: LinkToPageMenu( + editorState: editorState, + layoutType: pageType, + hintText: hintText, + onSelected: (appPB, viewPB) { + editorState.insertPage(appPB, viewPB); + }, + ), ), - ), - ); - }); + ); + }, + ); Overlay.of(context).insert(_linkToPageMenu!); @@ -184,7 +186,9 @@ class _LinkToPageMenuState extends State { newSelectedIndex %= _totalItems; } else if (event.logicalKey == LogicalKeyboardKey.enter) { widget.onSelected( - _items[_selectedIndex]!.value1, _items[_selectedIndex]!.value2); + _items[_selectedIndex]!.value1, + _items[_selectedIndex]!.value2, + ); } setState(() { @@ -194,8 +198,11 @@ class _LinkToPageMenuState extends State { return KeyEventResult.handled; } - Widget _buildListWidget(BuildContext context, int selectedIndex, - Future>>>? items) { + Widget _buildListWidget( + BuildContext context, + int selectedIndex, + Future>>>? items, + ) { int index = 0; return FutureBuilder>>>( builder: (context, snapshot) { diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/change_cover_popover.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/change_cover_popover.dart index 95a33a04da..7777d2fe7b 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/change_cover_popover.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/change_cover_popover.dart @@ -89,16 +89,18 @@ class _ChangeCoverPopoverState extends State { child: isAddingImage ? CoverImagePicker( onBackPressed: () => setState(() { - isAddingImage = false; - }), + isAddingImage = false; + }), onFileSubmit: (List path) { context.read().add( - const ChangeCoverPopoverEvent - .fetchPickedImagePaths()); + const ChangeCoverPopoverEvent + .fetchPickedImagePaths(), + ); setState(() { isAddingImage = false; }); - }) + }, + ) : _buildCoverSelection(), ), ); @@ -164,10 +166,11 @@ class _ChangeCoverPopoverState extends State { return GridView.builder( shrinkWrap: true, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 3, - childAspectRatio: 1 / 0.65, - crossAxisSpacing: 7, - mainAxisSpacing: 7), + crossAxisCount: 3, + childAspectRatio: 1 / 0.65, + crossAxisSpacing: 7, + mainAxisSpacing: 7, + ), itemCount: builtInAssetImages.length, itemBuilder: (BuildContext ctx, index) { return InkWell( @@ -215,66 +218,69 @@ class _ChangeCoverPopoverState extends State { Widget _buildFileImagePicker() { return BlocBuilder( - builder: (context, state) { - if (state is Loaded) { - List images = state.imageNames; - return GridView.builder( - shrinkWrap: true, - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 3, - childAspectRatio: 1 / 0.65, - crossAxisSpacing: 7, - mainAxisSpacing: 7, - ), - itemCount: images.length + 1, - itemBuilder: (BuildContext ctx, index) { - if (index == 0) { - return Container( - decoration: BoxDecoration( - color: - Theme.of(context).colorScheme.primary.withOpacity(0.15), - border: Border.all( - color: Theme.of(context).colorScheme.primary, + builder: (context, state) { + if (state is Loaded) { + List images = state.imageNames; + return GridView.builder( + shrinkWrap: true, + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + childAspectRatio: 1 / 0.65, + crossAxisSpacing: 7, + mainAxisSpacing: 7, + ), + itemCount: images.length + 1, + itemBuilder: (BuildContext ctx, index) { + if (index == 0) { + return Container( + decoration: BoxDecoration( + color: + Theme.of(context).colorScheme.primary.withOpacity(0.15), + border: Border.all( + color: Theme.of(context).colorScheme.primary, + ), + borderRadius: Corners.s8Border, ), - borderRadius: Corners.s8Border, - ), - child: FlowyIconButton( - iconPadding: EdgeInsets.zero, - icon: Icon( - Icons.add, - color: Theme.of(context).colorScheme.primary, + child: FlowyIconButton( + iconPadding: EdgeInsets.zero, + icon: Icon( + Icons.add, + color: Theme.of(context).colorScheme.primary, + ), + width: 20, + onPressed: () { + setState(() { + isAddingImage = true; + }); + }, ), - width: 20, - onPressed: () { - setState(() { - isAddingImage = true; - }); - }, - ), - ); - } - return ImageGridItem( - onImageSelect: () { - widget.onCoverChanged( - CoverSelectionType.file, - images[index - 1], ); - }, - imagePath: images[index - 1], - ); - }, - ); - } - return Container(); - }); + } + return ImageGridItem( + onImageSelect: () { + widget.onCoverChanged( + CoverSelectionType.file, + images[index - 1], + ); + }, + imagePath: images[index - 1], + ); + }, + ); + } + return Container(); + }, + ); } List _generateBackgroundColorOptions(EditorState editorState) { return FlowyTint.values - .map((t) => ColorOption( - colorHex: t.color(context).toHex(), - name: t.tintName(AppFlowyEditorLocalizations.current), - )) + .map( + (t) => ColorOption( + colorHex: t.color(context).toHex(), + name: t.tintName(AppFlowyEditorLocalizations.current), + ), + ) .toList(); } } @@ -339,7 +345,8 @@ class _ImageGridItemState extends State { ), onPressed: () { context.read().add( - ChangeCoverPopoverEvent.deleteImage(widget.imagePath)); + ChangeCoverPopoverEvent.deleteImage(widget.imagePath), + ); }, ), ), @@ -358,10 +365,13 @@ class _CoverColorPickerState extends State { height: 30, alignment: Alignment.center, child: ScrollConfiguration( - behavior: ScrollConfiguration.of(context).copyWith(dragDevices: { - PointerDeviceKind.touch, - PointerDeviceKind.mouse, - }, platform: TargetPlatform.windows), + behavior: ScrollConfiguration.of(context).copyWith( + dragDevices: { + PointerDeviceKind.touch, + PointerDeviceKind.mouse, + }, + platform: TargetPlatform.windows, + ), child: ListView.builder( controller: scrollController, shrinkWrap: true, @@ -404,7 +414,8 @@ class _CoverColorPickerState extends State { : Color(int.tryParse(option.colorHex) ?? 0xFFFFFFFF), border: isChecked ? Border.all( - color: Color(int.tryParse(option.colorHex) ?? 0xFFFFFF)) + color: Color(int.tryParse(option.colorHex) ?? 0xFFFFFF), + ) : null, shape: BoxShape.circle, ), diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/cover_image_picker.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/cover_image_picker.dart index 5e6d59be81..a06c725cd9 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/cover_image_picker.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/cover_image_picker.dart @@ -1,4 +1,3 @@ - import 'dart:io'; import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/plugins/document/presentation/plugins/cover/cover_image_picker_bloc.dart'; @@ -18,8 +17,11 @@ class CoverImagePicker extends StatefulWidget { final VoidCallback onBackPressed; final Function(List paths) onFileSubmit; - const CoverImagePicker( - {super.key, required this.onBackPressed, required this.onFileSubmit}); + const CoverImagePicker({ + super.key, + required this.onBackPressed, + required this.onFileSubmit, + }); @override State createState() => _CoverImagePickerState(); @@ -35,17 +37,21 @@ class _CoverImagePickerState extends State { listener: (context, state) { if (state is NetworkImagePicked) { state.successOrFail.isRight() - ? showSnapBar(context, - LocaleKeys.document_plugins_cover_invalidImageUrl.tr()) + ? showSnapBar( + context, + LocaleKeys.document_plugins_cover_invalidImageUrl.tr(), + ) : null; } if (state is Done) { state.successOrFail.fold( - (l) => widget.onFileSubmit(l), - (r) => showSnapBar( - context, - LocaleKeys.document_plugins_cover_failedToAddImageToGallery - .tr())); + (l) => widget.onFileSubmit(l), + (r) => showSnapBar( + context, + LocaleKeys.document_plugins_cover_failedToAddImageToGallery + .tr(), + ), + ); } }, child: BlocBuilder( @@ -155,8 +161,11 @@ class ImagePickerActionButtons extends StatelessWidget { final VoidCallback onBackPressed; final VoidCallback onSave; - const ImagePickerActionButtons( - {super.key, required this.onBackPressed, required this.onSave}); + const ImagePickerActionButtons({ + super.key, + required this.onBackPressed, + required this.onSave, + }); @override Widget build(BuildContext context) { @@ -250,8 +259,9 @@ class _CoverImagePreviewWidgetState extends State { }, child: Container( decoration: BoxDecoration( - shape: BoxShape.circle, - color: Theme.of(context).colorScheme.onPrimary), + shape: BoxShape.circle, + color: Theme.of(context).colorScheme.onPrimary, + ), child: svgWidget( "editor/close", size: const Size(20, 20), @@ -266,38 +276,46 @@ class _CoverImagePreviewWidgetState extends State { return Stack( children: [ Container( - height: 180, - alignment: Alignment.center, - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.secondary, - borderRadius: Corners.s6Border, - image: widget.state is Initial - ? null - : widget.state is NetworkImagePicked - ? widget.state.successOrFail.fold( - (path) => DecorationImage( - image: NetworkImage(path), fit: BoxFit.cover), - (r) => null) - : widget.state is FileImagePicked - ? DecorationImage( - image: FileImage(File(widget.state.path)), - fit: BoxFit.cover) - : null), - child: (widget.state is Initial) - ? _buildFilePickerWidget(context) - : (widget.state is NetworkImagePicked) + height: 180, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.secondary, + borderRadius: Corners.s6Border, + image: widget.state is Initial + ? null + : widget.state is NetworkImagePicked ? widget.state.successOrFail.fold( - (l) => null, - (r) => _buildFilePickerWidget( - context, + (path) => DecorationImage( + image: NetworkImage(path), + fit: BoxFit.cover, ), + (r) => null, ) - : null), + : widget.state is FileImagePicked + ? DecorationImage( + image: FileImage(File(widget.state.path)), + fit: BoxFit.cover, + ) + : null, + ), + child: (widget.state is Initial) + ? _buildFilePickerWidget(context) + : (widget.state is NetworkImagePicked) + ? widget.state.successOrFail.fold( + (l) => null, + (r) => _buildFilePickerWidget( + context, + ), + ) + : null, + ), (widget.state is FileImagePicked) ? _buildImageDeleteButton(context) : (widget.state is NetworkImagePicked) ? widget.state.successOrFail.fold( - (l) => _buildImageDeleteButton(context), (r) => Container()) + (l) => _buildImageDeleteButton(context), + (r) => Container(), + ) : Container() ], ); diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/cover_image_picker_bloc.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/cover_image_picker_bloc.dart index 70651da937..3c375ad7ee 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/cover_image_picker_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/cover_image_picker_bloc.dart @@ -67,8 +67,9 @@ class CoverImagePickerBloc CoverImagePickerState.done( right( FlowyError( - msg: LocaleKeys.document_plugins_cover_imageSavingFailed - .tr()), + msg: LocaleKeys.document_plugins_cover_imageSavingFailed + .tr(), + ), ), ), ); @@ -187,7 +188,8 @@ class CoverImagePickerEvent with _$CoverImagePickerEvent { const factory CoverImagePickerEvent.pickFileImage() = PickFileImage; const factory CoverImagePickerEvent.deleteImage() = DeleteImage; const factory CoverImagePickerEvent.saveToGallery( - CoverImagePickerState previousState) = SaveToGallery; + CoverImagePickerState previousState, + ) = SaveToGallery; const factory CoverImagePickerEvent.initialEvent() = InitialEvent; } @@ -196,9 +198,11 @@ class CoverImagePickerState with _$CoverImagePickerState { const factory CoverImagePickerState.initial() = Initial; const factory CoverImagePickerState.loading() = Loading; const factory CoverImagePickerState.networkImage( - Either successOrFail) = NetworkImagePicked; + Either successOrFail, + ) = NetworkImagePicked; const factory CoverImagePickerState.fileImage(String path) = FileImagePicked; const factory CoverImagePickerState.done( - Either, FlowyError> successOrFail) = Done; + Either, FlowyError> successOrFail, + ) = Done; } diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/cover_node_widget.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/cover_node_widget.dart index 8a7ac2807a..7051bd2128 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/cover_node_widget.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/cover/cover_node_widget.dart @@ -174,9 +174,9 @@ class _AddCoverButtonState extends State<_AddCoverButton> { color: Theme.of(context).iconTheme.color, size: 18, ), - text: FlowyText.regular(LocaleKeys - .document_plugins_cover_removeIcon - .tr()), + text: FlowyText.regular( + LocaleKeys.document_plugins_cover_removeIcon.tr(), + ), ) : AppFlowyPopover( mutex: mutex, @@ -194,22 +194,26 @@ class _AddCoverButtonState extends State<_AddCoverButton> { child: FlowyButton( leftIconSize: const Size.square(18), useIntrinsicWidth: true, - leftIcon: const Icon(Icons.emoji_emotions_outlined, - size: 18), + leftIcon: const Icon( + Icons.emoji_emotions_outlined, + size: 18, + ), text: FlowyText.regular( - LocaleKeys.document_plugins_cover_addIcon.tr()), + LocaleKeys.document_plugins_cover_addIcon.tr(), + ), ), popupBuilder: (BuildContext popoverContext) { isPopoverOpen = true; return EmojiPopover( - showRemoveButton: widget.hasIcon, - removeIcon: _removeIcon, - node: widget.node, - editorState: widget.editorState, - onEmojiChanged: (Emoji emoji) { - _insertIcon(emoji); - widget.iconPopoverController.close(); - }); + showRemoveButton: widget.hasIcon, + removeIcon: _removeIcon, + node: widget.node, + editorState: widget.editorState, + onEmojiChanged: (Emoji emoji) { + _insertIcon(emoji); + widget.iconPopoverController.close(); + }, + ); }, ) ], @@ -273,9 +277,10 @@ class _CoverImageState extends State<_CoverImage> { CoverSelectionType get selectionType => CoverSelectionType.fromString( widget.node.attributes[kCoverSelectionTypeAttribute], ); - Color get color => - Color(int.tryParse(widget.node.attributes[kCoverSelectionAttribute]) ?? - 0xFFFFFFFF); + Color get color => Color( + int.tryParse(widget.node.attributes[kCoverSelectionAttribute]) ?? + 0xFFFFFFFF, + ); bool get hasIcon => widget.node.attributes[kIconSelectionAttribute] == null ? false : widget.node.attributes[kIconSelectionAttribute].isNotEmpty; @@ -315,14 +320,15 @@ class _CoverImageState extends State<_CoverImage> { ), popupBuilder: (BuildContext popoverContext) { return EmojiPopover( - node: widget.node, - showRemoveButton: hasIcon, - removeIcon: _removeIcon, - editorState: widget.editorState, - onEmojiChanged: (Emoji emoji) { - _insertIcon(emoji); - iconPopoverController.close(); - }); + node: widget.node, + showRemoveButton: hasIcon, + removeIcon: _removeIcon, + editorState: widget.editorState, + onEmojiChanged: (Emoji emoji) { + _insertIcon(emoji); + iconPopoverController.close(); + }, + ); }, ), ) @@ -332,7 +338,9 @@ class _CoverImageState extends State<_CoverImage> { : _AddCoverButton( onTap: () { _insertCover( - CoverSelectionType.asset, builtInAssetImages.first); + CoverSelectionType.asset, + builtInAssetImages.first, + ); }, node: widget.node, editorState: widget.editorState, diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/openai/util/learn_more_action.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/openai/util/learn_more_action.dart index abdeeb162e..49b047c758 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/openai/util/learn_more_action.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/openai/util/learn_more_action.dart @@ -2,7 +2,8 @@ import 'package:url_launcher/url_launcher.dart'; Future openLearnMorePage() async { final uri = Uri.parse( - 'https://appflowy.gitbook.io/docs/essential-documentation/appflowy-x-openai'); + 'https://appflowy.gitbook.io/docs/essential-documentation/appflowy-x-openai', + ); if (await canLaunchUrl(uri)) { await launchUrl(uri); } diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/openai/widgets/auto_completion_node_widget.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/openai/widgets/auto_completion_node_widget.dart index 046f99f65a..ad8f2402db 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/openai/widgets/auto_completion_node_widget.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/openai/widgets/auto_completion_node_widget.dart @@ -66,28 +66,30 @@ class _AutoCompletionInputState extends State<_AutoCompletionInput> { textFieldFocusNode.addListener(_onFocusChanged); textFieldFocusNode.requestFocus(); - widget.editorState.service.selectionService.register(interceptor - ..canTap = (details) { - final renderBox = context.findRenderObject() as RenderBox?; - if (renderBox != null) { - if (!isTapDownDetailsInRenderBox(details, renderBox)) { - if (text.isNotEmpty || controller.text.isNotEmpty) { - showDialog( - context: context, - builder: (context) { - return DiscardDialog( - onConfirm: () => _onDiscard(), - onCancel: () {}, - ); - }, - ); - } else if (controller.text.isEmpty) { - _onExit(); + widget.editorState.service.selectionService.register( + interceptor + ..canTap = (details) { + final renderBox = context.findRenderObject() as RenderBox?; + if (renderBox != null) { + if (!isTapDownDetailsInRenderBox(details, renderBox)) { + if (text.isNotEmpty || controller.text.isNotEmpty) { + showDialog( + context: context, + builder: (context) { + return DiscardDialog( + onConfirm: () => _onDiscard(), + onCancel: () {}, + ); + }, + ); + } else if (controller.text.isEmpty) { + _onExit(); + } } } - } - return false; - }); + return false; + }, + ); } bool isTapDownDetailsInRenderBox(TapDownDetails details, RenderBox box) { diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/openai/widgets/smart_edit_toolbar_item.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/openai/widgets/smart_edit_toolbar_item.dart index 8db094e1dc..217a9880ad 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/openai/widgets/smart_edit_toolbar_item.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/openai/widgets/smart_edit_toolbar_item.dart @@ -87,7 +87,8 @@ class _SmartEditWidgetState extends State<_SmartEditWidget> { } Future _insertSmartEditNode( - SmartEditActionWrapper actionWrapper) async { + SmartEditActionWrapper actionWrapper, + ) async { final selection = widget.editorState.service.selectionService.currentSelection.value; if (selection == null) { diff --git a/frontend/appflowy_flutter/lib/plugins/trash/application/trash_bloc.dart b/frontend/appflowy_flutter/lib/plugins/trash/application/trash_bloc.dart index 2a744817e4..03c48df67d 100644 --- a/frontend/appflowy_flutter/lib/plugins/trash/application/trash_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/trash/application/trash_bloc.dart @@ -17,39 +17,54 @@ class TrashBloc extends Bloc { _listener = TrashListener(), 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)), - (error) => state.copyWith(successOrFailure: right(error)), - )); - }, didReceiveTrash: (e) async { - emit(state.copyWith(objects: e.trash)); - }, putback: (e) async { - 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)]); - await _handleResult(result, emit); - }, deleteAll: (e) async { - final result = await _service.deleteAll(); - await _handleResult(result, emit); - }, restoreAll: (e) async { - final result = await _service.restoreAll(); - await _handleResult(result, emit); - }); + 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), + ), + (error) => state.copyWith(successOrFailure: right(error)), + ), + ); + }, + didReceiveTrash: (e) async { + emit(state.copyWith(objects: e.trash)); + }, + putback: (e) async { + 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)]); + await _handleResult(result, emit); + }, + deleteAll: (e) async { + final result = await _service.deleteAll(); + await _handleResult(result, emit); + }, + restoreAll: (e) async { + final result = await _service.restoreAll(); + await _handleResult(result, emit); + }, + ); }); } Future _handleResult( - Either result, Emitter emit) async { - emit(result.fold( - (l) => state.copyWith(successOrFailure: left(unit)), - (error) => state.copyWith(successOrFailure: right(error)), - )); + Either result, + Emitter emit, + ) async { + emit( + result.fold( + (l) => state.copyWith(successOrFailure: left(unit)), + (error) => state.copyWith(successOrFailure: right(error)), + ), + ); } void _listenTrashUpdated(Either, FlowyError> trashOrFailed) { diff --git a/frontend/appflowy_flutter/lib/plugins/trash/application/trash_service.dart b/frontend/appflowy_flutter/lib/plugins/trash/application/trash_service.dart index 5b2e350435..64d8e200ed 100644 --- a/frontend/appflowy_flutter/lib/plugins/trash/application/trash_service.dart +++ b/frontend/appflowy_flutter/lib/plugins/trash/application/trash_service.dart @@ -16,7 +16,8 @@ class TrashService { } Future> deleteViews( - List> trashList) { + List> trashList, + ) { final items = trashList.map((trash) { return TrashIdPB.create() ..id = trash.value1 diff --git a/frontend/appflowy_flutter/lib/plugins/trash/src/sizes.dart b/frontend/appflowy_flutter/lib/plugins/trash/src/sizes.dart index d3c7d90bdc..20c7757d3e 100644 --- a/frontend/appflowy_flutter/lib/plugins/trash/src/sizes.dart +++ b/frontend/appflowy_flutter/lib/plugins/trash/src/sizes.dart @@ -6,5 +6,8 @@ class TrashSizes { static double get createTimeWidth => 230 * scale; static double get padding => 100 * scale; static double get totalWidth => - TrashSizes.fileNameWidth + TrashSizes.lashModifyWidth + TrashSizes.createTimeWidth + TrashSizes.padding; + TrashSizes.fileNameWidth + + TrashSizes.lashModifyWidth + + TrashSizes.createTimeWidth + + TrashSizes.padding; } diff --git a/frontend/appflowy_flutter/lib/plugins/trash/src/trash_cell.dart b/frontend/appflowy_flutter/lib/plugins/trash/src/trash_cell.dart index a46cca2a3b..9ed764dba6 100644 --- a/frontend/appflowy_flutter/lib/plugins/trash/src/trash_cell.dart +++ b/frontend/appflowy_flutter/lib/plugins/trash/src/trash_cell.dart @@ -13,12 +13,12 @@ class TrashCell extends StatelessWidget { final VoidCallback onRestore; final VoidCallback onDelete; final TrashPB object; - const TrashCell( - {required this.object, - required this.onRestore, - required this.onDelete, - Key? key}) - : super(key: key); + const TrashCell({ + required this.object, + required this.onRestore, + required this.onDelete, + Key? key, + }) : super(key: key); @override Widget build(BuildContext context) { diff --git a/frontend/appflowy_flutter/lib/plugins/trash/src/trash_header.dart b/frontend/appflowy_flutter/lib/plugins/trash/src/trash_header.dart index a691e8bb61..79cdb5d08f 100644 --- a/frontend/appflowy_flutter/lib/plugins/trash/src/trash_header.dart +++ b/frontend/appflowy_flutter/lib/plugins/trash/src/trash_header.dart @@ -10,7 +10,10 @@ class TrashHeaderDelegate extends SliverPersistentHeaderDelegate { @override Widget build( - BuildContext context, double shrinkOffset, bool overlapsContent) { + BuildContext context, + double shrinkOffset, + bool overlapsContent, + ) { return TrashHeader(); } @@ -36,14 +39,17 @@ class TrashHeaderItem { class TrashHeader extends StatelessWidget { final List items = [ TrashHeaderItem( - title: LocaleKeys.trash_pageHeader_fileName.tr(), - width: TrashSizes.fileNameWidth), + title: LocaleKeys.trash_pageHeader_fileName.tr(), + width: TrashSizes.fileNameWidth, + ), TrashHeaderItem( - title: LocaleKeys.trash_pageHeader_lastModified.tr(), - width: TrashSizes.lashModifyWidth), + title: LocaleKeys.trash_pageHeader_lastModified.tr(), + width: TrashSizes.lashModifyWidth, + ), TrashHeaderItem( - title: LocaleKeys.trash_pageHeader_created.tr(), - width: TrashSizes.createTimeWidth), + title: LocaleKeys.trash_pageHeader_created.tr(), + width: TrashSizes.createTimeWidth, + ), ]; TrashHeader({Key? key}) : super(key: key); diff --git a/frontend/appflowy_flutter/lib/plugins/util.dart b/frontend/appflowy_flutter/lib/plugins/util.dart index f689511c44..9df02f00c5 100644 --- a/frontend/appflowy_flutter/lib/plugins/util.dart +++ b/frontend/appflowy_flutter/lib/plugins/util.dart @@ -18,20 +18,23 @@ class ViewPluginNotifier extends PluginNotifier> { ViewPluginNotifier({ required this.view, }) : _viewListener = ViewListener(view: view) { - _viewListener?.start(onViewUpdated: (result) { - result.fold( - (updatedView) { - view = updatedView; - isDisplayChanged.value = updatedView.hashCode; - }, - (err) => Log.error(err), - ); - }, onViewMoveToTrash: (result) { - result.fold( - (deletedView) => isDeleted.value = some(deletedView), - (err) => Log.error(err), - ); - }); + _viewListener?.start( + onViewUpdated: (result) { + result.fold( + (updatedView) { + view = updatedView; + isDisplayChanged.value = updatedView.hashCode; + }, + (err) => Log.error(err), + ); + }, + onViewMoveToTrash: (result) { + result.fold( + (deletedView) => isDeleted.value = some(deletedView), + (err) => Log.error(err), + ); + }, + ); } @override diff --git a/frontend/appflowy_flutter/lib/startup/deps_resolver.dart b/frontend/appflowy_flutter/lib/startup/deps_resolver.dart index b8e219125e..17ae094ca4 100644 --- a/frontend/appflowy_flutter/lib/startup/deps_resolver.dart +++ b/frontend/appflowy_flutter/lib/startup/deps_resolver.dart @@ -83,14 +83,16 @@ void _resolveHomeDeps(GetIt getIt) { // share getIt.registerLazySingleton(() => ShareService()); getIt.registerFactoryParam( - (view, _) => DocShareBloc(view: view, service: getIt())); + (view, _) => DocShareBloc(view: view, service: 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( diff --git a/frontend/appflowy_flutter/lib/startup/plugin/src/sandbox.dart b/frontend/appflowy_flutter/lib/startup/plugin/src/sandbox.dart index ca32ec4217..4876262d4a 100644 --- a/frontend/appflowy_flutter/lib/startup/plugin/src/sandbox.dart +++ b/frontend/appflowy_flutter/lib/startup/plugin/src/sandbox.dart @@ -21,7 +21,9 @@ class PluginSandbox { _pluginBuilders.keys.toList().indexWhere((ty) => ty == pluginType); if (index == -1) { throw PlatformException( - code: '-1', message: "Can't find the flowy plugin type: $pluginType"); + code: '-1', + message: "Can't find the flowy plugin type: $pluginType", + ); } return index; } @@ -31,11 +33,16 @@ class PluginSandbox { return plugin; } - void registerPlugin(PluginType pluginType, PluginBuilder builder, - {PluginConfig? config}) { + void registerPlugin( + PluginType pluginType, + PluginBuilder builder, { + PluginConfig? config, + }) { if (_pluginBuilders.containsKey(pluginType)) { throw PlatformException( - code: '-1', message: "$pluginType was registered before"); + code: '-1', + message: "$pluginType was registered before", + ); } _pluginBuilders[pluginType] = builder; diff --git a/frontend/appflowy_flutter/lib/startup/tasks/load_plugin.dart b/frontend/appflowy_flutter/lib/startup/tasks/load_plugin.dart index 4ced403fa9..26896a3c3d 100644 --- a/frontend/appflowy_flutter/lib/startup/tasks/load_plugin.dart +++ b/frontend/appflowy_flutter/lib/startup/tasks/load_plugin.dart @@ -19,6 +19,8 @@ class PluginLoadTask extends LaunchTask { registerPlugin(builder: GridPluginBuilder(), config: GridPluginConfig()); registerPlugin(builder: BoardPluginBuilder(), config: BoardPluginConfig()); registerPlugin( - builder: CalendarPluginBuilder(), config: CalendarPluginConfig()); + builder: CalendarPluginBuilder(), + config: CalendarPluginConfig(), + ); } } diff --git a/frontend/appflowy_flutter/lib/user/application/auth_service.dart b/frontend/appflowy_flutter/lib/user/application/auth_service.dart index d32087c6ad..c6e684d611 100644 --- a/frontend/appflowy_flutter/lib/user/application/auth_service.dart +++ b/frontend/appflowy_flutter/lib/user/application/auth_service.dart @@ -9,8 +9,10 @@ import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart' import '../../generated/locale_keys.g.dart'; class AuthService { - Future> signIn( - {required String? email, required String? password}) { + Future> signIn({ + required String? email, + required String? password, + }) { // final request = SignInPayloadPB.create() ..email = email ?? '' @@ -19,10 +21,11 @@ class AuthService { return UserEventSignIn(request).send(); } - Future> signUp( - {required String? name, - required String? password, - required String? email}) { + Future> signUp({ + required String? name, + required String? password, + required String? email, + }) { final request = SignUpPayloadPB.create() ..email = email ?? '' ..name = name ?? '' diff --git a/frontend/appflowy_flutter/lib/user/application/sign_in_bloc.dart b/frontend/appflowy_flutter/lib/user/application/sign_in_bloc.dart index 714f1c3307..69b0fe7a62 100644 --- a/frontend/appflowy_flutter/lib/user/application/sign_in_bloc.dart +++ b/frontend/appflowy_flutter/lib/user/application/sign_in_bloc.dart @@ -21,53 +21,74 @@ class SignInBloc extends Bloc { ); }, emailChanged: (EmailChanged value) async { - emit(state.copyWith( - email: value.email, emailError: none(), successOrFail: none())); + emit( + state.copyWith( + email: value.email, + emailError: none(), + successOrFail: none(), + ), + ); }, passwordChanged: (PasswordChanged value) async { - emit(state.copyWith( + emit( + state.copyWith( password: value.password, passwordError: none(), - successOrFail: none())); + successOrFail: none(), + ), + ); }, ); }); } Future _performActionOnSignIn( - SignInState state, Emitter emit) async { - emit(state.copyWith( + SignInState state, + Emitter emit, + ) async { + emit( + state.copyWith( isSubmitting: true, emailError: none(), passwordError: none(), - successOrFail: none())); + successOrFail: none(), + ), + ); final result = await authService.signIn( email: state.email, password: state.password, ); - emit(result.fold( - (userProfile) => state.copyWith( - isSubmitting: false, successOrFail: some(left(userProfile))), - (error) => stateFromCode(error), - )); + emit( + result.fold( + (userProfile) => state.copyWith( + isSubmitting: false, + successOrFail: some(left(userProfile)), + ), + (error) => stateFromCode(error), + ), + ); } SignInState stateFromCode(FlowyError error) { switch (ErrorCode.valueOf(error.code)!) { case ErrorCode.EmailFormatInvalid: return state.copyWith( - isSubmitting: false, - emailError: some(error.msg), - passwordError: none()); + isSubmitting: false, + emailError: some(error.msg), + passwordError: none(), + ); case ErrorCode.PasswordFormatInvalid: return state.copyWith( - isSubmitting: false, - passwordError: some(error.msg), - emailError: none()); + isSubmitting: false, + passwordError: some(error.msg), + emailError: none(), + ); default: return state.copyWith( - isSubmitting: false, successOrFail: some(right(error))); + isSubmitting: false, + successOrFail: some(right(error)), + ); } } } diff --git a/frontend/appflowy_flutter/lib/user/application/sign_up_bloc.dart b/frontend/appflowy_flutter/lib/user/application/sign_up_bloc.dart index 964baeb952..bb3e99f51c 100644 --- a/frontend/appflowy_flutter/lib/user/application/sign_up_bloc.dart +++ b/frontend/appflowy_flutter/lib/user/application/sign_up_bloc.dart @@ -15,79 +15,107 @@ class SignUpBloc extends Bloc { final AuthService authService; SignUpBloc(this.authService) : super(SignUpState.initial()) { on((event, emit) async { - await event.map(signUpWithUserEmailAndPassword: (e) async { - await _performActionOnSignUp(emit); - }, emailChanged: (_EmailChanged value) async { - emit(state.copyWith( - email: value.email, emailError: none(), successOrFail: none())); - }, passwordChanged: (_PasswordChanged value) async { - emit(state.copyWith( - password: value.password, - passwordError: none(), - successOrFail: none())); - }, repeatPasswordChanged: (_RepeatPasswordChanged value) async { - emit(state.copyWith( - repeatedPassword: value.password, - repeatPasswordError: none(), - successOrFail: none())); - }); + await event.map( + signUpWithUserEmailAndPassword: (e) async { + await _performActionOnSignUp(emit); + }, + emailChanged: (_EmailChanged value) async { + emit( + state.copyWith( + email: value.email, + emailError: none(), + successOrFail: none(), + ), + ); + }, + passwordChanged: (_PasswordChanged value) async { + emit( + state.copyWith( + password: value.password, + passwordError: none(), + successOrFail: none(), + ), + ); + }, + repeatPasswordChanged: (_RepeatPasswordChanged value) async { + emit( + state.copyWith( + repeatedPassword: value.password, + repeatPasswordError: none(), + successOrFail: none(), + ), + ); + }, + ); }); } Future _performActionOnSignUp(Emitter emit) async { - emit(state.copyWith( - isSubmitting: true, - successOrFail: none(), - )); + emit( + state.copyWith( + isSubmitting: true, + successOrFail: none(), + ), + ); final password = state.password; final repeatedPassword = state.repeatedPassword; if (password == null) { - emit(state.copyWith( - isSubmitting: false, - passwordError: some(LocaleKeys.signUp_emptyPasswordError.tr()), - )); + emit( + state.copyWith( + isSubmitting: false, + passwordError: some(LocaleKeys.signUp_emptyPasswordError.tr()), + ), + ); return; } if (repeatedPassword == null) { - emit(state.copyWith( - isSubmitting: false, - repeatPasswordError: - some(LocaleKeys.signUp_repeatPasswordEmptyError.tr()), - )); + emit( + state.copyWith( + isSubmitting: false, + repeatPasswordError: + some(LocaleKeys.signUp_repeatPasswordEmptyError.tr()), + ), + ); return; } if (password != repeatedPassword) { - emit(state.copyWith( - isSubmitting: false, - repeatPasswordError: - some(LocaleKeys.signUp_unmatchedPasswordError.tr()), - )); + emit( + state.copyWith( + isSubmitting: false, + repeatPasswordError: + some(LocaleKeys.signUp_unmatchedPasswordError.tr()), + ), + ); return; } - emit(state.copyWith( - passwordError: none(), - repeatPasswordError: none(), - )); + emit( + state.copyWith( + passwordError: none(), + repeatPasswordError: none(), + ), + ); final result = await authService.signUp( name: state.email, password: state.password, email: state.email, ); - emit(result.fold( - (profile) => state.copyWith( - isSubmitting: false, - successOrFail: some(left(profile)), - emailError: none(), - passwordError: none(), - repeatPasswordError: none(), + emit( + result.fold( + (profile) => state.copyWith( + isSubmitting: false, + successOrFail: some(left(profile)), + emailError: none(), + passwordError: none(), + repeatPasswordError: none(), + ), + (error) => stateFromCode(error), ), - (error) => stateFromCode(error), - )); + ); } SignUpState stateFromCode(FlowyError error) { @@ -108,7 +136,9 @@ class SignUpBloc extends Bloc { ); default: return state.copyWith( - isSubmitting: false, successOrFail: some(right(error))); + isSubmitting: false, + successOrFail: some(right(error)), + ); } } } diff --git a/frontend/appflowy_flutter/lib/user/application/user_listener.dart b/frontend/appflowy_flutter/lib/user/application/user_listener.dart index 8dc182a48b..34ab016978 100644 --- a/frontend/appflowy_flutter/lib/user/application/user_listener.dart +++ b/frontend/appflowy_flutter/lib/user/application/user_listener.dart @@ -40,7 +40,9 @@ class UserListener { } _userParser = UserNotificationParser( - id: _userProfile.token, callback: _userNotificationCallback); + id: _userProfile.token, + callback: _userNotificationCallback, + ); _subscription = RustStreamReceiver.listen((observable) { _userParser?.parse(observable); }); @@ -57,7 +59,9 @@ class UserListener { } void _userNotificationCallback( - user.UserNotification ty, Either result) { + user.UserNotification ty, + Either result, + ) { switch (ty) { case user.UserNotification.DidUpdateUserProfile: result.fold( diff --git a/frontend/appflowy_flutter/lib/user/application/user_service.dart b/frontend/appflowy_flutter/lib/user/application/user_service.dart index 295c1c4f01..ad2789ee84 100644 --- a/frontend/appflowy_flutter/lib/user/application/user_service.dart +++ b/frontend/appflowy_flutter/lib/user/application/user_service.dart @@ -49,8 +49,9 @@ class UserBackendService { return UserEventUpdateUserProfile(payload).send(); } - Future> deleteWorkspace( - {required String workspaceId}) { + Future> deleteWorkspace({ + required String workspaceId, + }) { throw UnimplementedError(); } @@ -84,7 +85,9 @@ class UserBackendService { } Future> createWorkspace( - String name, String desc) { + String name, + String desc, + ) { final request = CreateWorkspacePayloadPB.create() ..name = name ..desc = desc; diff --git a/frontend/appflowy_flutter/lib/user/application/user_settings_service.dart b/frontend/appflowy_flutter/lib/user/application/user_settings_service.dart index bdf9b54747..ae1debfc5b 100644 --- a/frontend/appflowy_flutter/lib/user/application/user_settings_service.dart +++ b/frontend/appflowy_flutter/lib/user/application/user_settings_service.dart @@ -24,7 +24,8 @@ class UserSettingsBackendService { } Future> setAppearanceSetting( - AppearanceSettingsPB setting) { + AppearanceSettingsPB setting, + ) { return UserEventSetAppearanceSetting(setting).send(); } } diff --git a/frontend/appflowy_flutter/lib/user/presentation/folder/folder_widget.dart b/frontend/appflowy_flutter/lib/user/presentation/folder/folder_widget.dart index 50de6ad88d..4033d59e13 100644 --- a/frontend/appflowy_flutter/lib/user/presentation/folder/folder_widget.dart +++ b/frontend/appflowy_flutter/lib/user/presentation/folder/folder_widget.dart @@ -220,7 +220,10 @@ class CreateFolderWidgetState extends State { } Widget _buildTextButton( - BuildContext context, String title, VoidCallback onPressed) { + BuildContext context, + String title, + VoidCallback onPressed, +) { return FlowyTextButton( title, onPressed: onPressed, diff --git a/frontend/appflowy_flutter/lib/user/presentation/router.dart b/frontend/appflowy_flutter/lib/user/presentation/router.dart index 665b261b66..0d46be283c 100644 --- a/frontend/appflowy_flutter/lib/user/presentation/router.dart +++ b/frontend/appflowy_flutter/lib/user/presentation/router.dart @@ -28,17 +28,21 @@ class AuthRouter { ); } - void pushHomeScreen(BuildContext context, UserProfilePB profile, - WorkspaceSettingPB workspaceSetting) { + void pushHomeScreen( + BuildContext context, + UserProfilePB profile, + WorkspaceSettingPB workspaceSetting, + ) { Navigator.push( context, PageRoutes.fade( - () => HomeScreen( - profile, - workspaceSetting, - key: ValueKey(profile.id), - ), - RouteDurations.slow.inMilliseconds * .001), + () => HomeScreen( + profile, + workspaceSetting, + key: ValueKey(profile.id), + ), + RouteDurations.slow.inMilliseconds * .001, + ), ); } } @@ -73,20 +77,23 @@ class SplashRoute { Navigator.push( context, PageRoutes.fade( - () => HomeScreen( - userProfile, - workspaceSetting, - key: ValueKey(userProfile.id), - ), - RouteDurations.slow.inMilliseconds * .001), + () => HomeScreen( + userProfile, + workspaceSetting, + key: ValueKey(userProfile.id), + ), + RouteDurations.slow.inMilliseconds * .001, + ), ); } void pushSignInScreen(BuildContext context) { Navigator.push( context, - PageRoutes.fade(() => SignInScreen(router: getIt()), - RouteDurations.slow.inMilliseconds * .001), + PageRoutes.fade( + () => SignInScreen(router: getIt()), + RouteDurations.slow.inMilliseconds * .001, + ), ); } @@ -94,11 +101,12 @@ class SplashRoute { Navigator.push( context, PageRoutes.fade( - () => SkipLogInScreen( - router: getIt(), - authService: getIt(), - ), - RouteDurations.slow.inMilliseconds * .001), + () => SkipLogInScreen( + router: getIt(), + authService: getIt(), + ), + RouteDurations.slow.inMilliseconds * .001, + ), ); } } diff --git a/frontend/appflowy_flutter/lib/user/presentation/sign_in_screen.dart b/frontend/appflowy_flutter/lib/user/presentation/sign_in_screen.dart index f6a6ca290f..44b339a31e 100644 --- a/frontend/appflowy_flutter/lib/user/presentation/sign_in_screen.dart +++ b/frontend/appflowy_flutter/lib/user/presentation/sign_in_screen.dart @@ -41,7 +41,9 @@ class SignInScreen extends StatelessWidget { } void _handleSuccessOrFail( - Either result, BuildContext context) { + Either result, + BuildContext context, + ) { result.fold( (user) => router.pushWelcomeScreen(context, user), (error) => showSnapBar(context, error.msg), @@ -103,7 +105,8 @@ class SignUpPrompt extends StatelessWidget { ), TextButton( style: TextButton.styleFrom( - textStyle: Theme.of(context).textTheme.bodyMedium), + textStyle: Theme.of(context).textTheme.bodyMedium, + ), onPressed: () => router.pushSignUpScreen(context), child: Text( LocaleKeys.signUp_buttonText.tr(), @@ -145,7 +148,8 @@ class ForgetPasswordButton extends StatelessWidget { Widget build(BuildContext context) { return TextButton( style: TextButton.styleFrom( - textStyle: Theme.of(context).textTheme.bodyMedium), + textStyle: Theme.of(context).textTheme.bodyMedium, + ), onPressed: () => router.pushForgetPasswordScreen(context), child: Text( LocaleKeys.signIn_forgotPassword.tr(), diff --git a/frontend/appflowy_flutter/lib/user/presentation/sign_up_screen.dart b/frontend/appflowy_flutter/lib/user/presentation/sign_up_screen.dart index 5d7eceefeb..7b8b796fd1 100644 --- a/frontend/appflowy_flutter/lib/user/presentation/sign_up_screen.dart +++ b/frontend/appflowy_flutter/lib/user/presentation/sign_up_screen.dart @@ -38,7 +38,9 @@ class SignUpScreen extends StatelessWidget { } void _handleSuccessOrFail( - BuildContext context, Either result) { + BuildContext context, + Either result, + ) { result.fold( (user) => router.pushWelcomeScreen(context, user), (error) => showSnapBar(context, error.msg), @@ -95,7 +97,8 @@ class SignUpPrompt extends StatelessWidget { ), TextButton( style: TextButton.styleFrom( - textStyle: Theme.of(context).textTheme.bodyMedium), + textStyle: Theme.of(context).textTheme.bodyMedium, + ), onPressed: () => Navigator.pop(context), child: FlowyText.medium( LocaleKeys.signIn_buttonText.tr(), diff --git a/frontend/appflowy_flutter/lib/user/presentation/welcome_screen.dart b/frontend/appflowy_flutter/lib/user/presentation/welcome_screen.dart index 5e21d4c69d..752dd84b40 100644 --- a/frontend/appflowy_flutter/lib/user/presentation/welcome_screen.dart +++ b/frontend/appflowy_flutter/lib/user/presentation/welcome_screen.dart @@ -59,7 +59,11 @@ class WelcomeScreen extends StatelessWidget { hoverColor: AFThemeExtension.of(context).lightGreyHover, onPressed: () { context.read().add( - WelcomeEvent.createWorkspace(LocaleKeys.workspace_hint.tr(), "")); + WelcomeEvent.createWorkspace( + LocaleKeys.workspace_hint.tr(), + "", + ), + ); }, ), ); @@ -90,9 +94,11 @@ class WelcomeScreen extends StatelessWidget { class WorkspaceItem extends StatelessWidget { final WorkspacePB workspace; final void Function(WorkspacePB workspace) onPressed; - const WorkspaceItem( - {Key? key, required this.workspace, required this.onPressed}) - : super(key: key); + const WorkspaceItem({ + Key? key, + required this.workspace, + required this.onPressed, + }) : super(key: key); @override Widget build(BuildContext context) { diff --git a/frontend/appflowy_flutter/lib/util/file_picker/file_picker_impl.dart b/frontend/appflowy_flutter/lib/util/file_picker/file_picker_impl.dart index 07edd7b012..637228da33 100644 --- a/frontend/appflowy_flutter/lib/util/file_picker/file_picker_impl.dart +++ b/frontend/appflowy_flutter/lib/util/file_picker/file_picker_impl.dart @@ -8,17 +8,18 @@ class FilePicker implements FilePickerService { } @override - Future pickFiles( - {String? dialogTitle, - String? initialDirectory, - fp.FileType type = fp.FileType.any, - List? allowedExtensions, - Function(fp.FilePickerStatus p1)? onFileLoading, - bool allowCompression = true, - bool allowMultiple = false, - bool withData = false, - bool withReadStream = false, - bool lockParentWindow = false}) async { + Future pickFiles({ + String? dialogTitle, + String? initialDirectory, + fp.FileType type = fp.FileType.any, + List? allowedExtensions, + Function(fp.FilePickerStatus p1)? onFileLoading, + bool allowCompression = true, + bool allowMultiple = false, + bool withData = false, + bool withReadStream = false, + bool lockParentWindow = false, + }) async { final result = await fp.FilePicker.platform.pickFiles( dialogTitle: dialogTitle, initialDirectory: initialDirectory, diff --git a/frontend/appflowy_flutter/lib/workspace/application/app/app_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/app/app_bloc.dart index df9d203974..cfabc73f26 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/app/app_bloc.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/app/app_bloc.dart @@ -26,35 +26,43 @@ class AppBloc extends Bloc { appListener = AppListener(appId: app.id), super(AppState.initial(app)) { on((event, emit) async { - await event.map(initial: (e) async { - _startListening(); - await _loadViews(emit); - }, createView: (CreateView value) async { - await _createView(value, emit); - }, loadViews: (_) async { - await _loadViews(emit); - }, delete: (e) async { - await _deleteApp(emit); - }, deleteView: (deletedView) async { - await _deleteView(emit, deletedView.viewId); - }, rename: (e) async { - await _renameView(e, emit); - }, appDidUpdate: (e) async { - final latestCreatedView = state.latestCreatedView; - final views = e.app.belongings.items; - AppState newState = state.copyWith( - views: views, - app: e.app, - ); - if (latestCreatedView != null) { - final index = - views.indexWhere((element) => element.id == latestCreatedView.id); - if (index == -1) { - newState = newState.copyWith(latestCreatedView: null); + await event.map( + initial: (e) async { + _startListening(); + await _loadViews(emit); + }, + createView: (CreateView value) async { + await _createView(value, emit); + }, + loadViews: (_) async { + await _loadViews(emit); + }, + delete: (e) async { + await _deleteApp(emit); + }, + deleteView: (deletedView) async { + await _deleteView(emit, deletedView.viewId); + }, + rename: (e) async { + await _renameView(e, emit); + }, + appDidUpdate: (e) async { + final latestCreatedView = state.latestCreatedView; + final views = e.app.belongings.items; + AppState newState = state.copyWith( + views: views, + app: e.app, + ); + if (latestCreatedView != null) { + final index = views + .indexWhere((element) => element.id == latestCreatedView.id); + if (index == -1) { + newState = newState.copyWith(latestCreatedView: null); + } } - } - emit(newState); - }); + emit(newState); + }, + ); }); } @@ -104,10 +112,12 @@ class AppBloc extends Bloc { ext: value.ext ?? {}, ); result.fold( - (view) => emit(state.copyWith( - latestCreatedView: view, - successOrFailure: left(unit), - )), + (view) => emit( + state.copyWith( + latestCreatedView: view, + successOrFailure: left(unit), + ), + ), (error) { Log.error(error); emit(state.copyWith(successOrFailure: right(error))); @@ -222,7 +232,8 @@ class AppViewDataContext extends ChangeNotifier { UnmodifiableListView(_viewsNotifier.value); VoidCallback addViewsChangeListener( - void Function(UnmodifiableListView) callback) { + void Function(UnmodifiableListView) callback, + ) { listener() { callback(views); } diff --git a/frontend/appflowy_flutter/lib/workspace/application/app/app_listener.dart b/frontend/appflowy_flutter/lib/workspace/application/app/app_listener.dart index 1186068c75..5c3f12bbda 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/app/app_listener.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/app/app_listener.dart @@ -12,7 +12,8 @@ import 'package:appflowy_backend/rust_stream.dart'; typedef AppDidUpdateCallback = void Function(AppPB app); typedef ViewsDidChangeCallback = void Function( - Either, FlowyError> viewsOrFailed); + Either, FlowyError> viewsOrFailed, +); class AppListener { StreamSubscription? _subscription; @@ -32,7 +33,9 @@ class AppListener { } void _handleCallback( - FolderNotification ty, Either result) { + FolderNotification ty, + Either result, + ) { switch (ty) { case FolderNotification.DidUpdateApp: if (_updated != null) { diff --git a/frontend/appflowy_flutter/lib/workspace/application/app/app_service.dart b/frontend/appflowy_flutter/lib/workspace/application/app/app_service.dart index c54d2ad602..705ef93cc2 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/app/app_service.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/app/app_service.dart @@ -72,8 +72,10 @@ class AppBackendService { return FolderEventDeleteView(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) { @@ -97,7 +99,8 @@ class AppBackendService { } Future>>> fetchViews( - ViewLayoutTypePB layoutType) async { + ViewLayoutTypePB layoutType, + ) async { final result = >>[]; return FolderEventReadCurrentWorkspace().send().then((value) async { final workspaces = value.getLeftOrNull(); diff --git a/frontend/appflowy_flutter/lib/workspace/application/appearance.dart b/frontend/appflowy_flutter/lib/workspace/application/appearance.dart index a88db56714..6e52f01857 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/appearance.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/appearance.dart @@ -22,15 +22,17 @@ class AppearanceSettingsCubit extends Cubit { AppearanceSettingsCubit(AppearanceSettingsPB setting) : _setting = setting, - super(AppearanceSettingsState.initial( - setting.theme, - setting.themeMode, - setting.font, - setting.monospaceFont, - setting.locale, - setting.isMenuCollapsed, - setting.menuOffset, - )); + super( + AppearanceSettingsState.initial( + setting.theme, + setting.themeMode, + setting.font, + setting.monospaceFont, + setting.locale, + setting.isMenuCollapsed, + setting.menuOffset, + ), + ); /// Update selected theme in the user's settings and emit an updated state /// with the AppTheme named [themeName]. @@ -342,8 +344,10 @@ class AppearanceSettingsState with _$AppearanceSettingsState { height: lineHeight, ); - TextTheme _getTextTheme( - {required String fontFamily, required Color fontColor}) { + TextTheme _getTextTheme({ + required String fontFamily, + required Color fontColor, + }) { return TextTheme( displayLarge: _getFontStyle( fontFamily: fontFamily, diff --git a/frontend/appflowy_flutter/lib/workspace/application/edit_panel/edit_context.dart b/frontend/appflowy_flutter/lib/workspace/application/edit_panel/edit_context.dart index 6234858f60..95fabf8396 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/edit_panel/edit_context.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/edit_panel/edit_context.dart @@ -5,8 +5,11 @@ abstract class EditPanelContext extends Equatable { final String identifier; final String title; final Widget child; - const EditPanelContext( - {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/appflowy_flutter/lib/workspace/application/home/home_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/home/home_bloc.dart index 9163710b96..410eed91f3 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/home/home_bloc.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/home/home_bloc.dart @@ -49,10 +49,12 @@ class HomeBloc extends Bloc { ? workspaceSetting.latestView : state.latestView; - emit(state.copyWith( - workspaceSetting: value.setting, - latestView: latestView, - )); + emit( + state.copyWith( + workspaceSetting: value.setting, + latestView: latestView, + ), + ); }, unauthorized: (_Unauthorized value) { emit(state.copyWith(unauthorized: true)); @@ -98,7 +100,8 @@ class HomeEvent with _$HomeEvent { const factory HomeEvent.initial() = _Initial; const factory HomeEvent.showLoading(bool isLoading) = _ShowLoading; const factory HomeEvent.didReceiveWorkspaceSetting( - WorkspaceSettingPB setting) = _DidReceiveWorkspaceSetting; + WorkspaceSettingPB setting, + ) = _DidReceiveWorkspaceSetting; const factory HomeEvent.unauthorized(String msg) = _Unauthorized; } diff --git a/frontend/appflowy_flutter/lib/workspace/application/home/home_setting_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/home/home_setting_bloc.dart index 44e8518760..706b9d2c08 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/home/home_setting_bloc.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/home/home_setting_bloc.dart @@ -21,10 +21,12 @@ class HomeSettingBloc extends Bloc { AppearanceSettingsCubit appearanceSettingsCubit, ) : _listener = UserWorkspaceListener(userProfile: user), _appearanceSettingsCubit = appearanceSettingsCubit, - super(HomeSettingState.initial( - workspaceSetting, - appearanceSettingsCubit.state, - )) { + super( + HomeSettingState.initial( + workspaceSetting, + appearanceSettingsCubit.state, + ), + ) { on( (event, emit) async { await event.map( @@ -44,10 +46,12 @@ class HomeSettingBloc extends Bloc { emit(state.copyWith(isMenuCollapsed: isMenuCollapsed)); }, editPanelResizeStart: (_EditPanelResizeStart e) { - emit(state.copyWith( - resizeType: MenuResizeType.drag, - resizeStart: state.resizeOffset, - )); + emit( + state.copyWith( + resizeType: MenuResizeType.drag, + resizeStart: state.resizeOffset, + ), + ); }, editPanelResized: (_EditPanelResized e) { final newPosition = @@ -95,7 +99,8 @@ class HomeSettingEvent with _$HomeSettingEvent { _ShowEditPanel; const factory HomeSettingEvent.dismissEditPanel() = _DismissEditPanel; const factory HomeSettingEvent.didReceiveWorkspaceSetting( - WorkspaceSettingPB setting) = _DidReceiveWorkspaceSetting; + WorkspaceSettingPB setting, + ) = _DidReceiveWorkspaceSetting; const factory HomeSettingEvent.collapseMenu() = _CollapseMenu; const factory HomeSettingEvent.editPanelResized(double offset) = _EditPanelResized; diff --git a/frontend/appflowy_flutter/lib/workspace/application/menu/menu_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/menu/menu_bloc.dart index c687938652..94415821f7 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/menu/menu_bloc.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/menu/menu_bloc.dart @@ -41,18 +41,22 @@ class MenuBloc extends Bloc { await _performActionOnCreateApp(event, emit); }, didReceiveApps: (e) async { - emit(e.appsOrFail.fold( - (apps) => state.copyWith(apps: apps, successOrFailure: left(unit)), - (err) => state.copyWith(successOrFailure: right(err)), - )); + emit( + e.appsOrFail.fold( + (apps) => + state.copyWith(apps: apps, successOrFailure: left(unit)), + (err) => state.copyWith(successOrFailure: right(err)), + ), + ); }, 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); + 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)); @@ -69,9 +73,13 @@ class MenuBloc extends Bloc { } Future _performActionOnCreateApp( - _CreateApp event, Emitter emit) async { + _CreateApp event, + Emitter emit, + ) async { final result = await _workspaceService.createApp( - name: event.name, desc: event.desc ?? ""); + name: event.name, + desc: event.desc ?? "", + ); result.fold( (app) => {}, (error) { @@ -84,13 +92,15 @@ class MenuBloc extends Bloc { // ignore: unused_element Future _fetchApps(Emitter emit) async { final appsOrFail = await _workspaceService.getApps(); - emit(appsOrFail.fold( - (apps) => state.copyWith(apps: apps), - (error) { - Log.error(error); - return state.copyWith(successOrFailure: right(error)); - }, - )); + emit( + appsOrFail.fold( + (apps) => state.copyWith(apps: apps), + (error) { + Log.error(error); + return state.copyWith(successOrFailure: right(error)); + }, + ), + ); } void _handleAppsOrFail(Either, FlowyError> appsOrFail) { @@ -108,7 +118,8 @@ class MenuEvent with _$MenuEvent { 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; + Either, FlowyError> appsOrFail, + ) = _ReceiveApps; } @freezed diff --git a/frontend/appflowy_flutter/lib/workspace/application/menu/menu_user_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/menu/menu_user_bloc.dart index f12627dca9..ffe200305b 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/menu/menu_user_bloc.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/menu/menu_user_bloc.dart @@ -27,7 +27,8 @@ class MenuUserBloc extends Bloc { initial: () async { _userListener.start(onProfileUpdated: _profileUpdated); _userWorkspaceListener.start( - onWorkspacesUpdated: _workspaceListUpdated); + onWorkspacesUpdated: _workspaceListUpdated, + ); await _initUser(); }, fetchWorkspaces: () async { @@ -69,7 +70,8 @@ class MenuUserBloc extends Bloc { } void _workspaceListUpdated( - Either, FlowyError> workspacesOrFailed) { + Either, FlowyError> workspacesOrFailed, + ) { // Do nothing by now } } @@ -80,7 +82,8 @@ class MenuUserEvent with _$MenuUserEvent { const factory MenuUserEvent.fetchWorkspaces() = _FetchWorkspaces; const factory MenuUserEvent.updateUserName(String name) = _UpdateUserName; const factory MenuUserEvent.didReceiveUserProfile( - UserProfilePB newUserProfile) = _DidReceiveUserProfile; + UserProfilePB newUserProfile, + ) = _DidReceiveUserProfile; } @freezed diff --git a/frontend/appflowy_flutter/lib/workspace/application/menu/menu_view_section_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/menu/menu_view_section_bloc.dart index fdf82a91a2..10aaf350c8 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/menu/menu_view_section_bloc.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/menu/menu_view_section_bloc.dart @@ -60,7 +60,9 @@ class ViewSectionBloc extends Bloc { } Future _moveView( - _MoveView value, Emitter emit) async { + _MoveView value, + Emitter emit, + ) async { if (value.fromIndex < state.views.length) { final viewId = state.views[value.fromIndex].id; final views = List.from(state.views); diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/settings_dialog_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/settings_dialog_bloc.dart index e74158af30..4b0f3de9df 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/settings/settings_dialog_bloc.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/settings/settings_dialog_bloc.dart @@ -57,7 +57,8 @@ class SettingsDialogBloc class SettingsDialogEvent with _$SettingsDialogEvent { const factory SettingsDialogEvent.initial() = _Initial; const factory SettingsDialogEvent.didReceiveUserProfile( - UserProfilePB newUserProfile) = _DidReceiveUserProfile; + UserProfilePB newUserProfile, + ) = _DidReceiveUserProfile; const factory SettingsDialogEvent.setSelectedPage(SettingsPage page) = _SetViewIndex; } diff --git a/frontend/appflowy_flutter/lib/workspace/application/user/settings_user_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/user/settings_user_bloc.dart index afd3f02c6a..1c1e8b4689 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/user/settings_user_bloc.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/user/settings_user_bloc.dart @@ -84,7 +84,8 @@ class SettingsUserEvent with _$SettingsUserEvent { const factory SettingsUserEvent.updateUserOpenAIKey(String openAIKey) = _UpdateUserOpenaiKey; const factory SettingsUserEvent.didReceiveUserProfile( - UserProfilePB newUserProfile) = _DidReceiveUserProfile; + UserProfilePB newUserProfile, + ) = _DidReceiveUserProfile; } @freezed diff --git a/frontend/appflowy_flutter/lib/workspace/application/view/view_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/view/view_bloc.dart index 1951fd0a88..a112a4e0cc 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/view/view_bloc.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/view/view_bloc.dart @@ -21,9 +21,11 @@ class ViewBloc extends Bloc { on((event, emit) async { await event.map( initial: (e) { - listener.start(onViewUpdated: (result) { - add(ViewEvent.viewDidUpdate(result)); - }); + listener.start( + onViewUpdated: (result) { + add(ViewEvent.viewDidUpdate(result)); + }, + ); emit(state); }, setIsEditing: (e) { diff --git a/frontend/appflowy_flutter/lib/workspace/application/view/view_listener.dart b/frontend/appflowy_flutter/lib/workspace/application/view/view_listener.dart index 1af4a8e57b..894a42b5d8 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/view/view_listener.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/view/view_listener.dart @@ -73,7 +73,9 @@ class ViewListener { } void _handleObservableType( - FolderNotification ty, Either result) { + FolderNotification ty, + Either result, + ) { switch (ty) { case FolderNotification.DidUpdateView: result.fold( diff --git a/frontend/appflowy_flutter/lib/workspace/application/view/view_service.dart b/frontend/appflowy_flutter/lib/workspace/application/view/view_service.dart index 7524a39e2c..780568d5ce 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/view/view_service.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/view/view_service.dart @@ -5,8 +5,11 @@ import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart'; class ViewService { - Future> updateView( - {required String viewId, String? name, String? desc}) { + Future> updateView({ + required String viewId, + String? name, + String? desc, + }) { final request = UpdateViewPayloadPB.create()..viewId = viewId; if (name != null) { diff --git a/frontend/appflowy_flutter/lib/workspace/application/workspace/welcome_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/workspace/welcome_bloc.dart index aef0464cee..d780c06165 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/workspace/welcome_bloc.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/workspace/welcome_bloc.dart @@ -16,24 +16,33 @@ class WelcomeBloc extends Bloc { : super(WelcomeState.initial()) { on( (event, emit) async { - await event.map(initial: (e) async { - userWorkspaceListener.start( - onWorkspacesUpdated: (result) => - add(WelcomeEvent.workspacesReveived(result)), - ); - // - await _fetchWorkspaces(emit); - }, openWorkspace: (e) async { - await _openWorkspace(e.workspace, emit); - }, createWorkspace: (e) async { - await _createWorkspace(e.name, e.desc, emit); - }, workspacesReveived: (e) async { - emit(e.workspacesOrFail.fold( - (workspaces) => state.copyWith( - workspaces: workspaces, successOrFailure: left(unit)), - (error) => state.copyWith(successOrFailure: right(error)), - )); - }); + await event.map( + initial: (e) async { + userWorkspaceListener.start( + onWorkspacesUpdated: (result) => + add(WelcomeEvent.workspacesReveived(result)), + ); + // + await _fetchWorkspaces(emit); + }, + openWorkspace: (e) async { + await _openWorkspace(e.workspace, emit); + }, + createWorkspace: (e) async { + await _createWorkspace(e.name, e.desc, emit); + }, + workspacesReveived: (e) async { + emit( + e.workspacesOrFail.fold( + (workspaces) => state.copyWith( + workspaces: workspaces, + successOrFailure: left(unit), + ), + (error) => state.copyWith(successOrFailure: right(error)), + ), + ); + }, + ); }, ); } @@ -46,40 +55,53 @@ class WelcomeBloc extends Bloc { Future _fetchWorkspaces(Emitter emit) async { final workspacesOrFailed = await userService.getWorkspaces(); - emit(workspacesOrFailed.fold( - (workspaces) => - state.copyWith(workspaces: workspaces, successOrFailure: left(unit)), - (error) { - Log.error(error); - return state.copyWith(successOrFailure: right(error)); - }, - )); + emit( + workspacesOrFailed.fold( + (workspaces) => state.copyWith( + workspaces: workspaces, + successOrFailure: left(unit), + ), + (error) { + Log.error(error); + return state.copyWith(successOrFailure: right(error)); + }, + ), + ); } Future _openWorkspace( - WorkspacePB workspace, Emitter emit) async { + WorkspacePB workspace, + Emitter emit, + ) async { final result = await userService.openWorkspace(workspace.id); - emit(result.fold( - (workspaces) => state.copyWith(successOrFailure: left(unit)), - (error) { - Log.error(error); - return state.copyWith(successOrFailure: right(error)); - }, - )); + emit( + result.fold( + (workspaces) => state.copyWith(successOrFailure: left(unit)), + (error) { + Log.error(error); + return state.copyWith(successOrFailure: right(error)); + }, + ), + ); } Future _createWorkspace( - String name, String desc, Emitter emit) async { + String name, + String desc, + Emitter emit, + ) async { final result = await userService.createWorkspace(name, desc); - emit(result.fold( - (workspace) { - return state.copyWith(successOrFailure: left(unit)); - }, - (error) { - Log.error(error); - return state.copyWith(successOrFailure: right(error)); - }, - )); + emit( + result.fold( + (workspace) { + return state.copyWith(successOrFailure: left(unit)); + }, + (error) { + Log.error(error); + return state.copyWith(successOrFailure: right(error)); + }, + ), + ); } } @@ -92,8 +114,8 @@ class WelcomeEvent with _$WelcomeEvent { const factory WelcomeEvent.openWorkspace(WorkspacePB workspace) = OpenWorkspace; const factory WelcomeEvent.workspacesReveived( - Either, FlowyError> workspacesOrFail) = - WorkspacesReceived; + Either, FlowyError> workspacesOrFail, + ) = WorkspacesReceived; } @freezed diff --git a/frontend/appflowy_flutter/lib/workspace/application/workspace/workspace_listener.dart b/frontend/appflowy_flutter/lib/workspace/application/workspace/workspace_listener.dart index 73019c34e1..bab3643535 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/workspace/workspace_listener.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/workspace/workspace_listener.dart @@ -46,7 +46,9 @@ class WorkspaceListener { } void _handleObservableType( - FolderNotification ty, Either result) { + FolderNotification ty, + Either result, + ) { switch (ty) { case FolderNotification.DidUpdateWorkspace: result.fold( diff --git a/frontend/appflowy_flutter/lib/workspace/application/workspace/workspace_service.dart b/frontend/appflowy_flutter/lib/workspace/application/workspace/workspace_service.dart index 425154f353..d08e15ec38 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/workspace/workspace_service.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/workspace/workspace_service.dart @@ -16,8 +16,10 @@ class WorkspaceService { WorkspaceService({ required this.workspaceId, }); - Future> createApp( - {required String name, String? desc}) { + Future> createApp({ + required String name, + String? desc, + }) { final payload = CreateAppPayloadPB.create() ..name = name ..workspaceId = workspaceId @@ -33,8 +35,10 @@ class WorkspaceService { assert(workspaces.items.length == 1); if (workspaces.items.isEmpty) { - return right(FlowyError.create() - ..msg = LocaleKeys.workspace_notFoundError.tr()); + return right( + FlowyError.create() + ..msg = LocaleKeys.workspace_notFoundError.tr(), + ); } else { return left(workspaces.items[0]); } diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/home_screen.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/home_screen.dart index 57ca5182aa..39020982b5 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/home_screen.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/home_screen.dart @@ -56,47 +56,51 @@ class _HomeScreenState extends State { ), ], child: HomeHotKeys( - child: Scaffold( - body: MultiBlocListener( - listeners: [ - BlocListener( - listenWhen: (p, c) => p.unauthorized != c.unauthorized, - listener: (context, state) { - if (state.unauthorized) { - Log.error("Push to login screen when user token was invalid"); - } - }, - ), - BlocListener( - listenWhen: (p, c) => p.latestView != c.latestView, - listener: (context, state) { - final view = state.latestView; - if (view != null) { - // Only open the last opened view if the [HomeStackManager] current opened plugin is blank and the last opened view is not null. - // All opened widgets that display on the home screen are in the form of plugins. There is a list of built-in plugins defined in the [PluginType] enum, including board, grid and trash. - if (getIt().plugin.ty == PluginType.blank) { - final plugin = makePlugin( - pluginType: view.pluginType, - data: view, + child: Scaffold( + body: MultiBlocListener( + listeners: [ + BlocListener( + listenWhen: (p, c) => p.unauthorized != c.unauthorized, + listener: (context, state) { + if (state.unauthorized) { + Log.error( + "Push to login screen when user token was invalid", ); - getIt().setPlugin(plugin); - getIt().latestOpenView = view; } - } + }, + ), + BlocListener( + listenWhen: (p, c) => p.latestView != c.latestView, + listener: (context, state) { + final view = state.latestView; + if (view != null) { + // Only open the last opened view if the [HomeStackManager] current opened plugin is blank and the last opened view is not null. + // All opened widgets that display on the home screen are in the form of plugins. There is a list of built-in plugins defined in the [PluginType] enum, including board, grid and trash. + if (getIt().plugin.ty == + PluginType.blank) { + final plugin = makePlugin( + pluginType: view.pluginType, + data: view, + ); + getIt().setPlugin(plugin); + getIt().latestOpenView = view; + } + } + }, + ), + ], + child: BlocBuilder( + buildWhen: (previous, current) => previous != current, + builder: (context, state) { + return FlowyContainer( + Theme.of(context).colorScheme.surface, + child: _buildBody(context), + ); }, ), - ], - child: BlocBuilder( - buildWhen: (previous, current) => previous != current, - builder: (context, state) { - return FlowyContainer( - Theme.of(context).colorScheme.surface, - child: _buildBody(context), - ); - }, ), ), - )), + ), ); } @@ -176,24 +180,25 @@ class _HomeScreenState extends State { return MouseRegion( cursor: SystemMouseCursors.resizeLeftRight, child: GestureDetector( - dragStartBehavior: DragStartBehavior.down, - onHorizontalDragStart: (details) => context - .read() - .add(const HomeSettingEvent.editPanelResizeStart()), - onHorizontalDragUpdate: (details) => context - .read() - .add(HomeSettingEvent.editPanelResized(details.localPosition.dx)), - onHorizontalDragEnd: (details) => context - .read() - .add(const HomeSettingEvent.editPanelResizeEnd()), - onHorizontalDragCancel: () => context - .read() - .add(const HomeSettingEvent.editPanelResizeEnd()), - behavior: HitTestBehavior.translucent, - child: SizedBox( - width: 10, - height: MediaQuery.of(context).size.height, - )), + dragStartBehavior: DragStartBehavior.down, + onHorizontalDragStart: (details) => context + .read() + .add(const HomeSettingEvent.editPanelResizeStart()), + onHorizontalDragUpdate: (details) => context + .read() + .add(HomeSettingEvent.editPanelResized(details.localPosition.dx)), + onHorizontalDragEnd: (details) => context + .read() + .add(const HomeSettingEvent.editPanelResizeEnd()), + onHorizontalDragCancel: () => context + .read() + .add(const HomeSettingEvent.editPanelResizeEnd()), + behavior: HitTestBehavior.translucent, + child: SizedBox( + width: 10, + height: MediaQuery.of(context).size.height, + ), + ), ); } @@ -210,11 +215,12 @@ class _HomeScreenState extends State { homeStack .constrained(minWidth: 500) .positioned( - left: layout.homePageLOffset, - right: layout.homePageROffset, - bottom: 0, - top: 0, - animate: true) + left: layout.homePageLOffset, + right: layout.homePageROffset, + bottom: 0, + top: 0, + animate: true, + ) .animate(layout.animDuration, Curves.easeOut), bubble .positioned( @@ -230,18 +236,23 @@ class _HomeScreenState extends State { isClosed: !layout.showEditPanel, ) .positioned( - right: 0, top: 0, bottom: 0, width: layout.editPanelWidth), + right: 0, + top: 0, + bottom: 0, + width: layout.editPanelWidth, + ), homeMenu .animatedPanelX( closeX: -layout.menuWidth, isClosed: !layout.showMenu, ) .positioned( - left: 0, - top: 0, - width: layout.menuWidth, - bottom: 0, - animate: true) + left: 0, + top: 0, + width: layout.menuWidth, + bottom: 0, + animate: true, + ) .animate(layout.animDuration, Curves.easeOut), homeMenuResizer .positioned(left: layout.menuWidth - 5) diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart index e73577d818..1ed67d05e8 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart @@ -169,24 +169,27 @@ class HomeStackManager { Widget stackWidget({required Function(ViewPB, int?) onDeleted}) { return MultiProvider( providers: [ChangeNotifierProvider.value(value: _notifier)], - child: Consumer(builder: (ctx, HomeStackNotifier notifier, child) { - return FadingIndexedStack( - index: getIt().indexOf(notifier.plugin.ty), - children: getIt().supportPluginTypes.map((pluginType) { - if (pluginType == notifier.plugin.ty) { - final pluginWidget = notifier.plugin.display - .buildWidget(PluginContext(onDeleted: onDeleted)); - if (pluginType == PluginType.editor) { - return pluginWidget; + child: Consumer( + builder: (ctx, HomeStackNotifier notifier, child) { + return FadingIndexedStack( + index: getIt().indexOf(notifier.plugin.ty), + children: + getIt().supportPluginTypes.map((pluginType) { + if (pluginType == notifier.plugin.ty) { + final pluginWidget = notifier.plugin.display + .buildWidget(PluginContext(onDeleted: onDeleted)); + if (pluginType == PluginType.editor) { + return pluginWidget; + } else { + return pluginWidget.padding(horizontal: 40, vertical: 28); + } } else { - return pluginWidget.padding(horizontal: 40, vertical: 28); + return const BlankPage(); } - } else { - return const BlankPage(); - } - }).toList(), - ); - }), + }).toList(), + ); + }, + ), ); } } @@ -210,8 +213,11 @@ 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/appflowy_flutter/lib/workspace/presentation/home/menu/app/header/add_button.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/app/header/add_button.dart index 2b55fd736d..9e54123ee6 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/app/header/add_button.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/app/header/add_button.dart @@ -30,8 +30,10 @@ class AddButton extends StatelessWidget { // Plugins actions.addAll( pluginBuilders() - .map((pluginBuilder) => - AddButtonActionWrapper(pluginBuilder: pluginBuilder)) + .map( + (pluginBuilder) => + AddButtonActionWrapper(pluginBuilder: pluginBuilder), + ) .toList(), ); @@ -40,8 +42,10 @@ class AddButton extends StatelessWidget { getIt() .builders .whereType() - .map((pluginBuilder) => - ImportActionWrapper(pluginBuilder: pluginBuilder)) + .map( + (pluginBuilder) => + ImportActionWrapper(pluginBuilder: pluginBuilder), + ) .toList(), ); diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/app/header/header.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/app/header/header.dart index c2161066c9..555d8bd8df 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/app/header/header.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/app/header/header.dart @@ -48,9 +48,11 @@ class MenuAppHeader extends StatelessWidget { height: MenuAppSizes.headerHeight, child: InkWell( onTap: () { - ExpandableController.of(context, - rebuildOnChange: false, required: true) - ?.toggle(); + ExpandableController.of( + context, + rebuildOnChange: false, + required: true, + )?.toggle(); }, child: ExpandableIcon( theme: ExpandableThemeData( @@ -72,29 +74,34 @@ class MenuAppHeader extends StatelessWidget { listenWhen: (p, c) => (p.latestCreatedView == null && c.latestCreatedView != null), listener: (context, state) { - final expandableController = ExpandableController.of(context, - rebuildOnChange: false, required: true)!; + final expandableController = ExpandableController.of( + context, + rebuildOnChange: false, + required: true, + )!; if (!expandableController.expanded) { expandableController.toggle(); } }, - child: AppActionList(onSelected: (action) { - switch (action) { - case AppDisclosureAction.rename: - NavigatorTextFieldDialog( - title: LocaleKeys.menuAppHeader_renameDialog.tr(), - value: context.read().state.app.name, - confirm: (newValue) { - context.read().add(AppEvent.rename(newValue)); - }, - ).show(context); + child: AppActionList( + onSelected: (action) { + switch (action) { + case AppDisclosureAction.rename: + NavigatorTextFieldDialog( + title: LocaleKeys.menuAppHeader_renameDialog.tr(), + value: context.read().state.app.name, + confirm: (newValue) { + context.read().add(AppEvent.rename(newValue)); + }, + ).show(context); - break; - case AppDisclosureAction.delete: - context.read().add(const AppEvent.delete()); - break; - } - }), + break; + case AppDisclosureAction.delete: + context.read().add(const AppEvent.delete()); + break; + } + }, + ), ), ); } @@ -160,9 +167,11 @@ class AppActionList extends StatelessWidget { buildChild: (controller) { return GestureDetector( behavior: HitTestBehavior.opaque, - onTap: () => ExpandableController.of(context, - rebuildOnChange: false, required: true) - ?.toggle(), + onTap: () => ExpandableController.of( + context, + rebuildOnChange: false, + required: true, + )?.toggle(), onSecondaryTap: () { controller.show(); }, diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/app/menu_app.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/app/menu_app.dart index 653f67fa5a..a2711166db 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/app/menu_app.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/app/menu_app.dart @@ -69,7 +69,9 @@ class _MenuAppState extends State { } ExpandableNotifier expandableWrapper( - BuildContext context, AppViewDataContext viewDataContext) { + BuildContext context, + AppViewDataContext viewDataContext, + ) { return ExpandableNotifier( controller: viewDataContext.expandController, child: ScrollOnExpand( diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/app/section/section.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/app/section/section.dart index b16d9b0e57..eced25bf7b 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/app/section/section.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/app/section/section.dart @@ -41,7 +41,9 @@ class ViewSection extends StatelessWidget { } ReorderableColumn _reorderableColumn( - BuildContext context, ViewSectionState state) { + BuildContext context, + ViewSectionState state, + ) { final children = state.views.map((view) { return ViewSectionItem( key: ValueKey(view.id), diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/favorite/favorite.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/favorite/favorite.dart index e69de29bb2..8b13789179 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/favorite/favorite.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/favorite/favorite.dart @@ -0,0 +1 @@ + diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/favorite/section.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/favorite/section.dart index e69de29bb2..8b13789179 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/favorite/section.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/favorite/section.dart @@ -0,0 +1 @@ + diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/menu.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/menu.dart index 11cfa05042..f1354f64ed 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/menu.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/menu.dart @@ -107,7 +107,9 @@ class HomeMenu extends StatelessWidget { Widget _renderApps(BuildContext context) { return ExpandableTheme( data: ExpandableThemeData( - useInkWell: true, animationDuration: Durations.medium), + useInkWell: true, + animationDuration: Durations.medium, + ), child: Expanded( child: ScrollConfiguration( behavior: const ScrollBehavior().copyWith(scrollbars: false), @@ -141,7 +143,8 @@ class HomeMenu extends StatelessWidget { index: index, child: Padding( padding: EdgeInsets.symmetric( - vertical: MenuAppSizes.appVPadding / 2), + vertical: MenuAppSizes.appVPadding / 2, + ), child: menuItems[index], ), ); diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/menu_user.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/menu_user.dart index 236dd60479..c75f8372a7 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/menu_user.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/menu_user.dart @@ -51,11 +51,12 @@ class MenuUser extends StatelessWidget { width: 25, height: 25, child: ClipRRect( - borderRadius: Corners.s5Border, - child: CircleAvatar( - backgroundColor: Colors.transparent, - child: svgWidget('emoji/$iconUrl'), - )), + borderRadius: Corners.s5Border, + child: CircleAvatar( + backgroundColor: Colors.transparent, + child: svgWidget('emoji/$iconUrl'), + ), + ), ); } diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/navigation.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/navigation.dart index 8fcc3b2f19..6669803a97 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/navigation.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/navigation.dart @@ -46,18 +46,20 @@ class FlowyNavigation extends StatelessWidget { }, update: (_, notifier, controller) => controller!..update(notifier), child: Expanded( - child: Row(children: [ - _renderCollapse(context), - Selector>( - selector: (context, notifier) => notifier.navigationItems, - builder: (ctx, items, child) => Expanded( - child: Row( - children: _renderNavigationItems(items), - // crossAxisAlignment: WrapCrossAlignment.start, + child: Row( + children: [ + _renderCollapse(context), + Selector>( + selector: (context, notifier) => notifier.navigationItems, + builder: (ctx, items, child) => Expanded( + child: Row( + children: _renderNavigationItems(items), + // crossAxisAlignment: WrapCrossAlignment.start, + ), ), ), - ), - ]), + ], + ), ), ); } @@ -70,24 +72,25 @@ class FlowyNavigation extends StatelessWidget { return RotationTransition( turns: const AlwaysStoppedAnimation(180 / 360), child: Tooltip( - richMessage: sidebarTooltipTextSpan( - context, - LocaleKeys.sideBar_openSidebar.tr(), + richMessage: sidebarTooltipTextSpan( + context, + LocaleKeys.sideBar_openSidebar.tr(), + ), + child: FlowyIconButton( + width: 24, + hoverColor: Colors.transparent, + onPressed: () { + context + .read() + .add(const HomeSettingEvent.collapseMenu()); + }, + iconPadding: const EdgeInsets.fromLTRB(2, 2, 2, 2), + icon: svgWidget( + "home/hide_menu", + color: Theme.of(context).iconTheme.color, ), - child: FlowyIconButton( - width: 24, - hoverColor: Colors.transparent, - onPressed: () { - context - .read() - .add(const HomeSettingEvent.collapseMenu()); - }, - iconPadding: const EdgeInsets.fromLTRB(2, 2, 2, 2), - icon: svgWidget( - "home/hide_menu", - color: Theme.of(context).iconTheme.color, - ), - )), + ), + ), ); } else { return Container(); @@ -141,7 +144,8 @@ class NaviItemWidget extends StatelessWidget { @override Widget build(BuildContext context) { return Expanded( - child: item.leftBarItem.padding(horizontal: 2, vertical: 2)); + child: item.leftBarItem.padding(horizontal: 2, vertical: 2), + ); } } diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_file_customize_location_view.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_file_customize_location_view.dart index d807f0c4e2..f956df50d4 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_file_customize_location_view.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_file_customize_location_view.dart @@ -33,82 +33,85 @@ class SettingsFileLocationCustomzierState return BlocProvider.value( value: widget.cubit, child: BlocBuilder( - builder: (context, state) { - return ListTile( - title: FlowyText.regular( - LocaleKeys.settings_files_defaultLocation.tr(), - fontSize: 15.0, - overflow: TextOverflow.ellipsis, - ), - subtitle: Tooltip( - message: LocaleKeys.settings_files_doubleTapToCopy.tr(), - child: GestureDetector( - onDoubleTap: () { - Clipboard.setData(ClipboardData( - text: state.path, - )).then((_) { - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: FlowyText( - LocaleKeys.settings_files_pathCopiedSnackbar.tr(), - color: Theme.of(context).colorScheme.onSurface, + builder: (context, state) { + return ListTile( + title: FlowyText.regular( + LocaleKeys.settings_files_defaultLocation.tr(), + fontSize: 15.0, + overflow: TextOverflow.ellipsis, + ), + subtitle: Tooltip( + message: LocaleKeys.settings_files_doubleTapToCopy.tr(), + child: GestureDetector( + onDoubleTap: () { + Clipboard.setData( + ClipboardData( + text: state.path, + ), + ).then((_) { + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: FlowyText( + LocaleKeys.settings_files_pathCopiedSnackbar.tr(), + color: Theme.of(context).colorScheme.onSurface, + ), ), - ), - ); - } - }); - }, - child: FlowyText.regular( - state.path ?? '', - fontSize: 10.0, - overflow: TextOverflow.ellipsis, + ); + } + }); + }, + child: FlowyText.regular( + state.path ?? '', + fontSize: 10.0, + overflow: TextOverflow.ellipsis, + ), ), ), - ), - trailing: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Tooltip( - message: LocaleKeys.settings_files_restoreLocation.tr(), - child: FlowyIconButton( - icon: const Icon(Icons.restore_outlined), - onPressed: () async { - final result = await appFlowyDocumentDirectory(); - await _setCustomLocation(result.path); - await FlowyRunner.run( - FlowyApp(), - config: const LaunchConfiguration( - autoRegistrationSupported: true, - ), - ); - if (mounted) { - Navigator.of(context).pop(); - } - }, + trailing: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Tooltip( + message: LocaleKeys.settings_files_restoreLocation.tr(), + child: FlowyIconButton( + icon: const Icon(Icons.restore_outlined), + onPressed: () async { + final result = await appFlowyDocumentDirectory(); + await _setCustomLocation(result.path); + await FlowyRunner.run( + FlowyApp(), + config: const LaunchConfiguration( + autoRegistrationSupported: true, + ), + ); + if (mounted) { + Navigator.of(context).pop(); + } + }, + ), ), - ), - const SizedBox( - width: 5, - ), - Tooltip( - message: LocaleKeys.settings_files_customizeLocation.tr(), - child: FlowyIconButton( - icon: const Icon(Icons.folder_open_outlined), - onPressed: () async { - final result = - await getIt().getDirectoryPath(); - if (result != null) { - await _setCustomLocation(result); - await reloadApp(); - } - }, + const SizedBox( + width: 5, ), - ) - ], - ), - ); - }), + Tooltip( + message: LocaleKeys.settings_files_customizeLocation.tr(), + child: FlowyIconButton( + icon: const Icon(Icons.folder_open_outlined), + onPressed: () async { + final result = + await getIt().getDirectoryPath(); + if (result != null) { + await _setCustomLocation(result); + await reloadApp(); + } + }, + ), + ) + ], + ), + ); + }, + ), ); } diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_menu_element.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_menu_element.dart index 207b03c78f..46a11cabcb 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_menu_element.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_menu_element.dart @@ -27,11 +27,13 @@ class SettingsMenuElement extends StatelessWidget { hoverColor: Theme.of(context).colorScheme.primary, ), child: ListTile( - leading: Icon(icon, - size: 16, - color: page == selectedPage - ? Theme.of(context).colorScheme.onSurface - : null), + leading: Icon( + icon, + size: 16, + color: page == selectedPage + ? Theme.of(context).colorScheme.onSurface + : null, + ), onTap: () { changeSelectedPage(page); }, @@ -42,12 +44,14 @@ class SettingsMenuElement extends StatelessWidget { borderRadius: BorderRadius.circular(5), ), minLeadingWidth: 0, - title: FlowyText.semibold(label, - fontSize: FontSizes.s14, - overflow: TextOverflow.ellipsis, - color: page == selectedPage - ? Theme.of(context).colorScheme.onSurface - : null), + title: FlowyText.semibold( + label, + fontSize: FontSizes.s14, + overflow: TextOverflow.ellipsis, + color: page == selectedPage + ? Theme.of(context).colorScheme.onSurface + : null, + ), ), ); } diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_user_view.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_user_view.dart index 1b6f7a9a6f..9bcb2007e9 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_user_view.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_user_view.dart @@ -186,11 +186,12 @@ class _CurrentIcon extends StatelessWidget { child: Column( children: [ Align( - alignment: Alignment.topLeft, - child: Text( - LocaleKeys.settings_user_icon.tr(), - style: const TextStyle(color: Colors.grey), - )), + alignment: Alignment.topLeft, + child: Text( + LocaleKeys.settings_user_icon.tr(), + style: const TextStyle(color: Colors.grey), + ), + ), Align( alignment: Alignment.centerLeft, child: Container( @@ -218,8 +219,10 @@ class IconGallery extends StatelessWidget { final Map manifestMap = json.decode(manifestContent); final iconUrls = manifestMap.keys - .where((String key) => - key.startsWith('assets/images/emoji/') && key.endsWith('.svg')) + .where( + (String key) => + key.startsWith('assets/images/emoji/') && key.endsWith('.svg'), + ) .map((String key) => key.split('/').last.split('.').first) .toList(); diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialogs.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialogs.dart index 88b3395e57..59c002f4ea 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialogs.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialogs.dart @@ -124,13 +124,16 @@ class _CreateFlowyAlertDialog extends State { ], if (widget.confirm != null) ...[ const VSpace(20), - OkCancelButton(onOkPressed: () { - widget.confirm?.call(); - Navigator.of(context).pop(); - }, onCancelPressed: () { - widget.cancel?.call(); - Navigator.of(context).pop(); - }) + OkCancelButton( + onOkPressed: () { + widget.confirm?.call(); + Navigator.of(context).pop(); + }, + onCancelPressed: () { + widget.cancel?.call(); + Navigator.of(context).pop(); + }, + ) ] ], ), @@ -147,16 +150,16 @@ class NavigatorOkCancelDialog extends StatelessWidget { final String message; final double? maxWidth; - const NavigatorOkCancelDialog( - {Key? key, - this.onOkPressed, - this.onCancelPressed, - this.okTitle, - this.cancelTitle, - this.title, - required this.message, - this.maxWidth}) - : super(key: key); + const NavigatorOkCancelDialog({ + Key? key, + this.onOkPressed, + this.onCancelPressed, + this.okTitle, + this.cancelTitle, + this.title, + required this.message, + this.maxWidth, + }) : super(key: key); @override Widget build(BuildContext context) { @@ -172,7 +175,9 @@ class NavigatorOkCancelDialog extends StatelessWidget { ), VSpace(Insets.sm * 1.5), Container( - color: Theme.of(context).colorScheme.surfaceVariant, height: 1), + color: Theme.of(context).colorScheme.surfaceVariant, + height: 1, + ), VSpace(Insets.m * 1.5), ], FlowyText.medium(message), @@ -202,14 +207,14 @@ class OkCancelButton extends StatelessWidget { final String? cancelTitle; final double? minHeight; - const OkCancelButton( - {Key? key, - this.onOkPressed, - this.onCancelPressed, - this.okTitle, - this.cancelTitle, - this.minHeight}) - : super(key: key); + const OkCancelButton({ + Key? key, + this.onOkPressed, + this.onCancelPressed, + this.okTitle, + this.cancelTitle, + this.minHeight, + }) : super(key: key); @override Widget build(BuildContext context) { diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/edit_panel/panel_animation.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/edit_panel/panel_animation.dart index 614ff356cb..3bec8f86a6 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/edit_panel/panel_animation.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/edit_panel/panel_animation.dart @@ -8,15 +8,15 @@ class AnimatedPanel extends StatefulWidget { final Curve? curve; final Widget? child; - const AnimatedPanel( - {Key? key, - this.isClosed = false, - this.closedX = 0.0, - this.closedY = 0.0, - this.duration = 0.0, - this.curve, - this.child}) - : super(key: key); + const AnimatedPanel({ + Key? key, + this.isClosed = false, + this.closedX = 0.0, + this.closedY = 0.0, + this.duration = 0.0, + this.curve, + this.child, + }) : super(key: key); @override AnimatedPanelState createState() => AnimatedPanelState(); @@ -49,39 +49,45 @@ class AnimatedPanelState extends State { } extension AnimatedPanelExtensions on Widget { - Widget animatedPanelX( - {double closeX = 0.0, - bool? isClosed, - double? duration, - Curve? curve}) => + Widget animatedPanelX({ + double closeX = 0.0, + bool? isClosed, + double? duration, + Curve? curve, + }) => animatedPanel( - closePos: Offset(closeX, 0), - isClosed: isClosed, - curve: curve, - duration: duration); - - Widget animatedPanelY( - {double closeY = 0.0, - bool? isClosed, - double? duration, - Curve? curve}) => - animatedPanel( - closePos: Offset(0, closeY), - isClosed: isClosed, - curve: curve, - duration: duration); - - Widget animatedPanel( - {required Offset closePos, - bool? isClosed, - double? duration, - Curve? curve}) { - return AnimatedPanel( - closedX: closePos.dx, - closedY: closePos.dy, - isClosed: isClosed ?? false, - duration: duration ?? .35, + closePos: Offset(closeX, 0), + isClosed: isClosed, curve: curve, - child: this); + duration: duration, + ); + + Widget animatedPanelY({ + double closeY = 0.0, + bool? isClosed, + double? duration, + Curve? curve, + }) => + animatedPanel( + closePos: Offset(0, closeY), + isClosed: isClosed, + curve: curve, + duration: duration, + ); + + Widget animatedPanel({ + required Offset closePos, + bool? isClosed, + double? duration, + Curve? curve, + }) { + return AnimatedPanel( + closedX: closePos.dx, + closedY: closePos.dy, + isClosed: isClosed ?? false, + duration: duration ?? .35, + curve: curve, + child: this, + ); } } diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/emoji_picker/src/config.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/emoji_picker/src/config.dart index 26046af5bb..e8ddc7f883 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/emoji_picker/src/config.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/emoji_picker/src/config.dart @@ -8,25 +8,26 @@ import 'emoji_picker.dart'; /// Config for customizations class Config { /// Constructor - const Config( - {this.columns = 7, - this.emojiSizeMax = 32.0, - this.verticalSpacing = 0, - this.horizontalSpacing = 0, - this.initCategory = Category.RECENT, - this.bgColor = const Color(0xFFEBEFF2), - this.indicatorColor = Colors.blue, - this.iconColor = Colors.grey, - this.iconColorSelected = Colors.blue, - this.progressIndicatorColor = Colors.blue, - this.backspaceColor = Colors.blue, - this.showRecentsTab = true, - this.recentsLimit = 28, - this.noRecentsText = 'No Recents', - this.noRecentsStyle = const TextStyle(fontSize: 20, color: Colors.black26), - this.tabIndicatorAnimDuration = kTabScrollDuration, - this.categoryIcons = const CategoryIcons(), - this.buttonMode = ButtonMode.MATERIAL}); + const Config({ + this.columns = 7, + this.emojiSizeMax = 32.0, + this.verticalSpacing = 0, + this.horizontalSpacing = 0, + this.initCategory = Category.RECENT, + this.bgColor = const Color(0xFFEBEFF2), + this.indicatorColor = Colors.blue, + this.iconColor = Colors.grey, + this.iconColorSelected = Colors.blue, + this.progressIndicatorColor = Colors.blue, + this.backspaceColor = Colors.blue, + this.showRecentsTab = true, + this.recentsLimit = 28, + this.noRecentsText = 'No Recents', + this.noRecentsStyle = const TextStyle(fontSize: 20, color: Colors.black26), + this.tabIndicatorAnimDuration = kTabScrollDuration, + this.categoryIcons = const CategoryIcons(), + this.buttonMode = ButtonMode.MATERIAL, + }); /// Number of emojis per row final int columns; diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/emoji_picker/src/default_emoji_picker_view.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/emoji_picker/src/default_emoji_picker_view.dart index 271a3b6dd2..1f81c71669 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/emoji_picker/src/default_emoji_picker_view.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/emoji_picker/src/default_emoji_picker_view.dart @@ -30,14 +30,16 @@ class DefaultEmojiPickerViewState extends State @override void initState() { var initCategory = widget.state.categoryEmoji.indexWhere( - (element) => element.category == widget.config.initCategory); + (element) => element.category == widget.config.initCategory, + ); if (initCategory == -1) { initCategory = 0; } _tabController = TabController( - initialIndex: initCategory, - length: widget.state.categoryEmoji.length, - vsync: this); + initialIndex: initCategory, + length: widget.state.categoryEmoji.length, + vsync: this, + ); _pageController = PageController(initialPage: initCategory); _emojiFocusNode.requestFocus(); @@ -75,14 +77,15 @@ class DefaultEmojiPickerViewState extends State return Material( type: MaterialType.transparency, child: IconButton( - padding: const EdgeInsets.only(bottom: 2), - icon: Icon( - Icons.backspace, - color: widget.config.backspaceColor, - ), - onPressed: () { - widget.state.onBackspacePressed!(); - }), + padding: const EdgeInsets.only(bottom: 2), + icon: Icon( + Icons.backspace, + color: widget.config.backspaceColor, + ), + onPressed: () { + widget.state.onBackspacePressed!(); + }, + ), ); } return Container(); @@ -163,8 +166,12 @@ class DefaultEmojiPickerViewState extends State : widget.state.categoryEmoji .asMap() .entries - .map((item) => _buildCategory( - item.value.category, emojiSize)) + .map( + (item) => _buildCategory( + item.value.category, + emojiSize, + ), + ) .toList(), ), ), @@ -209,8 +216,10 @@ class DefaultEmojiPickerViewState extends State ); } - Widget _buildButtonWidget( - {required VoidCallback onPressed, required Widget child}) { + Widget _buildButtonWidget({ + required VoidCallback onPressed, + required Widget child, + }) { if (widget.config.buttonMode == ButtonMode.MATERIAL) { return TextButton( onPressed: onPressed, @@ -219,7 +228,10 @@ class DefaultEmojiPickerViewState extends State ); } return CupertinoButton( - padding: EdgeInsets.zero, onPressed: onPressed, child: child); + padding: EdgeInsets.zero, + onPressed: onPressed, + child: child, + ); } Widget _buildPage(double emojiSize, CategoryEmoji categoryEmoji) { @@ -259,7 +271,8 @@ class DefaultEmojiPickerViewState extends State .toList() : categoryEmoji.emoji .map( - (item) => _buildEmoji(emojiSize, categoryEmoji, item)) + (item) => _buildEmoji(emojiSize, categoryEmoji, item), + ) .toList(), ), ), @@ -272,28 +285,30 @@ class DefaultEmojiPickerViewState extends State Emoji emoji, ) { return _buildButtonWidget( - onPressed: () { - widget.state.onEmojiSelected(categoryEmoji.category, emoji); - }, - child: FittedBox( - fit: BoxFit.fill, - child: Text( - emoji.emoji, - textScaleFactor: 1.0, - style: TextStyle( - fontSize: emojiSize, - backgroundColor: Colors.transparent, - ), + onPressed: () { + widget.state.onEmojiSelected(categoryEmoji.category, emoji); + }, + child: FittedBox( + fit: BoxFit.fill, + child: Text( + emoji.emoji, + textScaleFactor: 1.0, + style: TextStyle( + fontSize: emojiSize, + backgroundColor: Colors.transparent, ), - )); + ), + ), + ); } Widget _buildNoRecent() { return Center( - child: Text( - widget.config.noRecentsText, - style: widget.config.noRecentsStyle, - textAlign: TextAlign.center, - )); + child: Text( + widget.config.noRecentsText, + style: widget.config.noRecentsStyle, + textAlign: TextAlign.center, + ), + ); } } diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/emoji_picker/src/emoji_picker.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/emoji_picker/src/emoji_picker.dart index 8852b12799..7ec0d17884 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/emoji_picker/src/emoji_picker.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/emoji_picker/src/emoji_picker.dart @@ -190,30 +190,49 @@ class EmojiPickerState extends State { categoryEmoji.add(CategoryEmoji(Category.RECENT, recentEmojiMap)); } categoryEmoji.addAll([ - CategoryEmoji(Category.SMILEYS, - await _getAvailableEmojis(emoji_list.smileys, title: 'smileys')), - CategoryEmoji(Category.ANIMALS, - await _getAvailableEmojis(emoji_list.animals, title: 'animals')), - CategoryEmoji(Category.FOODS, - await _getAvailableEmojis(emoji_list.foods, title: 'foods')), CategoryEmoji( - Category.ACTIVITIES, - await _getAvailableEmojis(emoji_list.activities, - title: 'activities')), - CategoryEmoji(Category.TRAVEL, - await _getAvailableEmojis(emoji_list.travel, title: 'travel')), - CategoryEmoji(Category.OBJECTS, - await _getAvailableEmojis(emoji_list.objects, title: 'objects')), - CategoryEmoji(Category.SYMBOLS, - await _getAvailableEmojis(emoji_list.symbols, title: 'symbols')), - CategoryEmoji(Category.FLAGS, - await _getAvailableEmojis(emoji_list.flags, title: 'flags')) + Category.SMILEYS, + await _getAvailableEmojis(emoji_list.smileys, title: 'smileys'), + ), + CategoryEmoji( + Category.ANIMALS, + await _getAvailableEmojis(emoji_list.animals, title: 'animals'), + ), + CategoryEmoji( + Category.FOODS, + await _getAvailableEmojis(emoji_list.foods, title: 'foods'), + ), + CategoryEmoji( + Category.ACTIVITIES, + await _getAvailableEmojis( + emoji_list.activities, + title: 'activities', + ), + ), + CategoryEmoji( + Category.TRAVEL, + await _getAvailableEmojis(emoji_list.travel, title: 'travel'), + ), + CategoryEmoji( + Category.OBJECTS, + await _getAvailableEmojis(emoji_list.objects, title: 'objects'), + ), + CategoryEmoji( + Category.SYMBOLS, + await _getAvailableEmojis(emoji_list.symbols, title: 'symbols'), + ), + CategoryEmoji( + Category.FLAGS, + await _getAvailableEmojis(emoji_list.flags, title: 'flags'), + ) ]); } // Get available emoji for given category title - Future> _getAvailableEmojis(Map map, - {required String title}) async { + Future> _getAvailableEmojis( + Map map, { + required String title, + }) async { Map? newMap; // Get Emojis cached locally if available @@ -236,15 +255,18 @@ class EmojiPickerState extends State { // Check if emoji is available on current platform Future?> _getPlatformAvailableEmoji( - Map emoji) async { + Map emoji, + ) async { if (Platform.isAndroid) { Map? filtered = {}; var delimiter = '|'; try { var entries = emoji.values.join(delimiter); var keys = emoji.keys.join(delimiter); - var result = (await platform.invokeMethod('checkAvailability', - {'emojiKeys': keys, 'emojiEntries': entries})) as String; + var result = (await platform.invokeMethod( + 'checkAvailability', + {'emojiKeys': keys, 'emojiEntries': entries}, + )) as String; var resultKeys = result.split(delimiter); for (var i = 0; i < resultKeys.length; i++) { filtered[resultKeys[i]] = emoji[resultKeys[i]]!; @@ -272,7 +294,9 @@ class EmojiPickerState extends State { // Stores filtered emoji locally for faster access next time Future _cacheFilteredEmojis( - String title, Map emojis) async { + String title, + Map emojis, + ) async { final prefs = await SharedPreferences.getInstance(); var emojiJson = jsonEncode(emojis); prefs.setString(title, emojiJson); @@ -305,7 +329,9 @@ class EmojiPickerState extends State { recentEmoji.sort((a, b) => b.counter - a.counter); // Limit entries to recentsLimit recentEmoji = recentEmoji.sublist( - 0, min(widget.config.recentsLimit, recentEmoji.length)); + 0, + min(widget.config.recentsLimit, recentEmoji.length), + ); // save locally prefs.setString('recent', jsonEncode(recentEmoji)); } diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/emoji_picker/src/emoji_picker_builder.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/emoji_picker/src/emoji_picker_builder.dart index ee00569852..fe526e01db 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/emoji_picker/src/emoji_picker_builder.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/emoji_picker/src/emoji_picker_builder.dart @@ -7,7 +7,8 @@ import 'emoji_view_state.dart'; /// Inherit this class to create your own EmojiPicker abstract class EmojiPickerBuilder extends StatefulWidget { /// Constructor - const EmojiPickerBuilder(this.config, this.state, {Key? key}) : super(key: key); + const EmojiPickerBuilder(this.config, this.state, {Key? key}) + : super(key: key); /// Config for customizations final Config config; diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart index aae2882d3c..82f4619fdf 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart @@ -70,7 +70,8 @@ class BubbleActionList extends StatelessWidget { break; case BubbleAction.shortcuts: _launchURL( - "https://appflowy.gitbook.io/docs/essential-documentation/shortcuts"); + "https://appflowy.gitbook.io/docs/essential-documentation/shortcuts", + ); break; } } @@ -146,9 +147,10 @@ class FlowyVersionDescription extends CustomActionCell { crossAxisAlignment: CrossAxisAlignment.start, children: [ Divider( - height: 1, - color: Theme.of(context).dividerColor, - thickness: 1.0), + height: 1, + color: Theme.of(context).dividerColor, + thickness: 1.0, + ), const VSpace(6), FlowyText( "$appName $version", diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/left_bar_item.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/left_bar_item.dart index e697262492..c00f084c3b 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/left_bar_item.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/left_bar_item.dart @@ -27,16 +27,18 @@ class _ViewLeftBarItemState extends State { _viewService = ViewService(); _focusNode.addListener(_handleFocusChanged); _viewListener = ViewListener(view: widget.view); - _viewListener.start(onViewUpdated: (result) { - result.fold( - (updatedView) { - if (mounted) { - setState(() => view = updatedView); - } - }, - (err) => Log.error(err), - ); - }); + _viewListener.start( + onViewUpdated: (result) { + result.fold( + (updatedView) { + if (mounted) { + setState(() => view = updatedView); + } + }, + (err) => Log.error(err), + ); + }, + ); super.initState(); } diff --git a/frontend/appflowy_flutter/packages/appflowy_backend/example/integration_test/driver.dart b/frontend/appflowy_flutter/packages/appflowy_backend/example/integration_test/driver.dart index 0e385dc6f2..d0ea799fe3 100644 --- a/frontend/appflowy_flutter/packages/appflowy_backend/example/integration_test/driver.dart +++ b/frontend/appflowy_flutter/packages/appflowy_backend/example/integration_test/driver.dart @@ -2,4 +2,3 @@ // flutter drive command. // // flutter drive --driver integration_test/driver.dart --target integration_test/app_test.dart - diff --git a/frontend/appflowy_flutter/packages/appflowy_editor_plugins/lib/appflowy_editor_plugins.dart b/frontend/appflowy_flutter/packages/appflowy_editor_plugins/lib/appflowy_editor_plugins.dart index 2a422eaf97..8cf0d189ab 100644 --- a/frontend/appflowy_flutter/packages/appflowy_editor_plugins/lib/appflowy_editor_plugins.dart +++ b/frontend/appflowy_flutter/packages/appflowy_editor_plugins/lib/appflowy_editor_plugins.dart @@ -11,6 +11,6 @@ export 'src/divider/divider_shortcut_event.dart'; // Emoji Picker export 'src/emoji_picker/emoji_menu_item.dart'; // Math Equation -export 'src/math_ equation/math_equation_node_widget.dart'; +export 'src/math_equation/math_equation_node_widget.dart'; export 'src/extensions/theme_extension.dart'; diff --git a/frontend/appflowy_flutter/packages/appflowy_editor_plugins/lib/src/emoji_picker/src/config.dart b/frontend/appflowy_flutter/packages/appflowy_editor_plugins/lib/src/emoji_picker/src/config.dart index 26046af5bb..7b76d5d7fb 100644 --- a/frontend/appflowy_flutter/packages/appflowy_editor_plugins/lib/src/emoji_picker/src/config.dart +++ b/frontend/appflowy_flutter/packages/appflowy_editor_plugins/lib/src/emoji_picker/src/config.dart @@ -23,7 +23,8 @@ class Config { this.showRecentsTab = true, this.recentsLimit = 28, this.noRecentsText = 'No Recents', - this.noRecentsStyle = const TextStyle(fontSize: 20, color: Colors.black26), + this.noRecentsStyle = + const TextStyle(fontSize: 20, color: Colors.black26), this.tabIndicatorAnimDuration = kTabScrollDuration, this.categoryIcons = const CategoryIcons(), this.buttonMode = ButtonMode.MATERIAL}); diff --git a/frontend/appflowy_flutter/packages/appflowy_editor_plugins/lib/src/emoji_picker/src/emoji_picker_builder.dart b/frontend/appflowy_flutter/packages/appflowy_editor_plugins/lib/src/emoji_picker/src/emoji_picker_builder.dart index ee00569852..fe526e01db 100644 --- a/frontend/appflowy_flutter/packages/appflowy_editor_plugins/lib/src/emoji_picker/src/emoji_picker_builder.dart +++ b/frontend/appflowy_flutter/packages/appflowy_editor_plugins/lib/src/emoji_picker/src/emoji_picker_builder.dart @@ -7,7 +7,8 @@ import 'emoji_view_state.dart'; /// Inherit this class to create your own EmojiPicker abstract class EmojiPickerBuilder extends StatefulWidget { /// Constructor - const EmojiPickerBuilder(this.config, this.state, {Key? key}) : super(key: key); + const EmojiPickerBuilder(this.config, this.state, {Key? key}) + : super(key: key); /// Config for customizations final Config config; diff --git a/frontend/appflowy_flutter/packages/appflowy_editor_plugins/lib/src/math_ equation/math_equation_node_widget.dart b/frontend/appflowy_flutter/packages/appflowy_editor_plugins/lib/src/math_equation/math_equation_node_widget.dart similarity index 100% rename from frontend/appflowy_flutter/packages/appflowy_editor_plugins/lib/src/math_ equation/math_equation_node_widget.dart rename to frontend/appflowy_flutter/packages/appflowy_editor_plugins/lib/src/math_equation/math_equation_node_widget.dart diff --git a/frontend/appflowy_flutter/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/lib/flowy_infra_ui_platform_interface.dart b/frontend/appflowy_flutter/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/lib/flowy_infra_ui_platform_interface.dart index 9c57883407..717d8e125d 100644 --- a/frontend/appflowy_flutter/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/lib/flowy_infra_ui_platform_interface.dart +++ b/frontend/appflowy_flutter/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/lib/flowy_infra_ui_platform_interface.dart @@ -18,10 +18,12 @@ abstract class FlowyInfraUIPlatform extends PlatformInterface { } Stream get onKeyboardVisibilityChange { - throw UnimplementedError('`onKeyboardChange` should be overridden by subclass.'); + throw UnimplementedError( + '`onKeyboardChange` should be overridden by subclass.'); } Future getPlatformVersion() { - throw UnimplementedError('`getPlatformVersion` should be overridden by subclass.'); + throw UnimplementedError( + '`getPlatformVersion` should be overridden by subclass.'); } } diff --git a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/src/flowy_overlay/option_overlay.dart b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/src/flowy_overlay/option_overlay.dart index 09c28459b1..d6dfc4607d 100644 --- a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/src/flowy_overlay/option_overlay.dart +++ b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/src/flowy_overlay/option_overlay.dart @@ -47,12 +47,14 @@ class OptionOverlay extends StatelessWidget { @override Widget build(BuildContext context) { - final List<_OptionListItem> listItems = items.map((e) => _OptionListItem(e)).toList(); + final List<_OptionListItem> listItems = + items.map((e) => _OptionListItem(e)).toList(); return ListOverlay( itemBuilder: (context, index) { return MouseRegion( cursor: SystemMouseCursors.click, - onHover: onHover != null ? (_) => onHover!(items[index], index) : null, + onHover: + onHover != null ? (_) => onHover!(items[index], index) : null, child: GestureDetector( onTap: onTap != null ? () => onTap!(items[index], index) : null, child: listItems[index], diff --git a/frontend/appflowy_flutter/test/bloc_test/board_test/create_card_test.dart b/frontend/appflowy_flutter/test/bloc_test/board_test/create_card_test.dart index cb7df23187..16cd6b8673 100644 --- a/frontend/appflowy_flutter/test/bloc_test/board_test/create_card_test.dart +++ b/frontend/appflowy_flutter/test/bloc_test/board_test/create_card_test.dart @@ -20,13 +20,17 @@ void main() { // the group at index 0 is the 'No status' group; assert(boardBloc.groupControllers[groupId]!.group.rows.isEmpty); - assert(boardBloc.state.groupIds.length == 4, - 'but receive ${boardBloc.state.groupIds.length}'); + assert( + boardBloc.state.groupIds.length == 4, + 'but receive ${boardBloc.state.groupIds.length}', + ); boardBloc.add(BoardEvent.createBottomRow(boardBloc.state.groupIds[0])); await boardResponseFuture(); - assert(boardBloc.groupControllers[groupId]!.group.rows.length == 1, - 'but receive ${boardBloc.groupControllers[groupId]!.group.rows.length}'); + assert( + boardBloc.groupControllers[groupId]!.group.rows.length == 1, + 'but receive ${boardBloc.groupControllers[groupId]!.group.rows.length}', + ); }); } diff --git a/frontend/appflowy_flutter/test/bloc_test/board_test/create_or_edit_field_test.dart b/frontend/appflowy_flutter/test/bloc_test/board_test/create_or_edit_field_test.dart index fdf72e54e0..a5e4a13eaa 100644 --- a/frontend/appflowy_flutter/test/bloc_test/board_test/create_or_edit_field_test.dart +++ b/frontend/appflowy_flutter/test/bloc_test/board_test/create_or_edit_field_test.dart @@ -46,11 +46,15 @@ void main() { await boardResponseFuture(); // assert the groups were not changed - assert(boardBloc.groupControllers.values.length == 4, - "Expected 4, but receive ${boardBloc.groupControllers.values.length}"); + assert( + boardBloc.groupControllers.values.length == 4, + "Expected 4, but receive ${boardBloc.groupControllers.values.length}", + ); - assert(context.fieldContexts.length == 2, - "Expected 2, but receive ${context.fieldContexts.length}"); + assert( + context.fieldContexts.length == 2, + "Expected 2, but receive ${context.fieldContexts.length}", + ); }); test('create a new field in kanban board test', () async { @@ -64,10 +68,14 @@ void main() { final checkboxField = context.fieldContexts.last.field; assert(checkboxField.fieldType == FieldType.Checkbox); - assert(boardBloc.groupControllers.values.length == 4, - "Expected 4, but receive ${boardBloc.groupControllers.values.length}"); + assert( + boardBloc.groupControllers.values.length == 4, + "Expected 4, but receive ${boardBloc.groupControllers.values.length}", + ); - assert(context.fieldContexts.length == 3, - "Expected 3, but receive ${context.fieldContexts.length}"); + assert( + context.fieldContexts.length == 3, + "Expected 3, but receive ${context.fieldContexts.length}", + ); }); } diff --git a/frontend/appflowy_flutter/test/bloc_test/board_test/group_by_checkbox_field_test.dart b/frontend/appflowy_flutter/test/bloc_test/board_test/group_by_checkbox_field_test.dart index 4054682560..da8aebc73f 100644 --- a/frontend/appflowy_flutter/test/bloc_test/board_test/group_by_checkbox_field_test.dart +++ b/frontend/appflowy_flutter/test/bloc_test/board_test/group_by_checkbox_field_test.dart @@ -34,10 +34,12 @@ void main() { viewId: context.gridView.id, fieldController: context.fieldController, )..add(const DatabaseGroupEvent.initial()); - gridGroupBloc.add(DatabaseGroupEvent.setGroupByField( - checkboxField.id, - checkboxField.fieldType, - )); + gridGroupBloc.add( + DatabaseGroupEvent.setGroupByField( + checkboxField.id, + checkboxField.fieldType, + ), + ); await boardResponseFuture(); assert(boardBloc.groupControllers.values.length == 2); diff --git a/frontend/appflowy_flutter/test/bloc_test/board_test/group_by_multi_select_field_test.dart b/frontend/appflowy_flutter/test/bloc_test/board_test/group_by_multi_select_field_test.dart index 0a97a1ec2b..ffb55a5957 100644 --- a/frontend/appflowy_flutter/test/bloc_test/board_test/group_by_multi_select_field_test.dart +++ b/frontend/appflowy_flutter/test/bloc_test/board_test/group_by_multi_select_field_test.dart @@ -30,22 +30,27 @@ void main() { )..add(const DatabaseGroupEvent.initial()); await boardResponseFuture(); - gridGroupBloc.add(DatabaseGroupEvent.setGroupByField( - multiSelectField.id, - multiSelectField.fieldType, - )); + gridGroupBloc.add( + DatabaseGroupEvent.setGroupByField( + multiSelectField.id, + multiSelectField.fieldType, + ), + ); await boardResponseFuture(); //assert only have the 'No status' group final boardBloc = BoardBloc(view: context.gridView) ..add(const BoardEvent.initial()); await boardResponseFuture(); - assert(boardBloc.groupControllers.values.length == 1, - "Expected 1, but receive ${boardBloc.groupControllers.values.length}"); + assert( + boardBloc.groupControllers.values.length == 1, + "Expected 1, but receive ${boardBloc.groupControllers.values.length}", + ); final expectedGroupName = "No ${multiSelectField.name}"; assert( - boardBloc.groupControllers.values.first.group.desc == expectedGroupName, - "Expected $expectedGroupName, but receive ${boardBloc.groupControllers.values.first.group.desc}"); + boardBloc.groupControllers.values.first.group.desc == expectedGroupName, + "Expected $expectedGroupName, but receive ${boardBloc.groupControllers.values.first.group.desc}", + ); }); test('group by multi select with no options test', () async { @@ -77,18 +82,22 @@ void main() { )..add(const DatabaseGroupEvent.initial()); await boardResponseFuture(); - gridGroupBloc.add(DatabaseGroupEvent.setGroupByField( - multiSelectField.id, - multiSelectField.fieldType, - )); + gridGroupBloc.add( + DatabaseGroupEvent.setGroupByField( + multiSelectField.id, + multiSelectField.fieldType, + ), + ); await boardResponseFuture(); // assert there are only three group final boardBloc = BoardBloc(view: context.gridView) ..add(const BoardEvent.initial()); await boardResponseFuture(); - assert(boardBloc.groupControllers.values.length == 3, - "Expected 3, but receive ${boardBloc.groupControllers.values.length}"); + assert( + boardBloc.groupControllers.values.length == 3, + "Expected 3, but receive ${boardBloc.groupControllers.values.length}", + ); final groups = boardBloc.groupControllers.values.map((e) => e.group).toList(); diff --git a/frontend/appflowy_flutter/test/bloc_test/board_test/group_by_unsupport_field_test.dart b/frontend/appflowy_flutter/test/bloc_test/board_test/group_by_unsupport_field_test.dart index a6e1cbb85a..14a3a58c65 100644 --- a/frontend/appflowy_flutter/test/bloc_test/board_test/group_by_unsupport_field_test.dart +++ b/frontend/appflowy_flutter/test/bloc_test/board_test/group_by_unsupport_field_test.dart @@ -43,8 +43,10 @@ void main() { BoardBloc(view: context.gridView)..add(const BoardEvent.initial()), wait: boardResponseDuration(), verify: (bloc) { - assert(bloc.groupControllers.values.length == 1, - "Expected 1, but receive ${bloc.groupControllers.values.length}"); + assert( + bloc.groupControllers.values.length == 1, + "Expected 1, but receive ${bloc.groupControllers.values.length}", + ); }, ); }); diff --git a/frontend/appflowy_flutter/test/bloc_test/grid_test/cell/select_option_cell_test.dart b/frontend/appflowy_flutter/test/bloc_test/grid_test/cell/select_option_cell_test.dart index d4ec928c70..15626fb7f8 100644 --- a/frontend/appflowy_flutter/test/bloc_test/grid_test/cell/select_option_cell_test.dart +++ b/frontend/appflowy_flutter/test/bloc_test/grid_test/cell/select_option_cell_test.dart @@ -16,7 +16,9 @@ void main() { await cellTest.createTestGrid(); await cellTest.createTestRow(); final cellController = await cellTest.makeSelectOptionCellController( - FieldType.SingleSelect, 0); + FieldType.SingleSelect, + 0, + ); final bloc = SelectOptionCellEditorBloc(cellController: cellController); bloc.add(const SelectOptionEditorEvent.initial()); @@ -33,7 +35,9 @@ void main() { await cellTest.createTestGrid(); await cellTest.createTestRow(); final cellController = await cellTest.makeSelectOptionCellController( - FieldType.SingleSelect, 0); + FieldType.SingleSelect, + 0, + ); final bloc = SelectOptionCellEditorBloc(cellController: cellController); bloc.add(const SelectOptionEditorEvent.initial()); @@ -56,7 +60,9 @@ void main() { await cellTest.createTestGrid(); await cellTest.createTestRow(); final cellController = await cellTest.makeSelectOptionCellController( - FieldType.SingleSelect, 0); + FieldType.SingleSelect, + 0, + ); final bloc = SelectOptionCellEditorBloc(cellController: cellController); bloc.add(const SelectOptionEditorEvent.initial()); @@ -64,31 +70,41 @@ void main() { bloc.add(const SelectOptionEditorEvent.newOption("A")); await gridResponseFuture(); - assert(bloc.state.options.length == 1, - "Expect 1 but receive ${bloc.state.options.length}, Options: ${bloc.state.options}"); + assert( + bloc.state.options.length == 1, + "Expect 1 but receive ${bloc.state.options.length}, Options: ${bloc.state.options}", + ); bloc.add(const SelectOptionEditorEvent.newOption("B")); await gridResponseFuture(); - assert(bloc.state.options.length == 2, - "Expect 2 but receive ${bloc.state.options.length}, Options: ${bloc.state.options}"); + assert( + bloc.state.options.length == 2, + "Expect 2 but receive ${bloc.state.options.length}, Options: ${bloc.state.options}", + ); bloc.add(const SelectOptionEditorEvent.newOption("C")); await gridResponseFuture(); - assert(bloc.state.options.length == 3, - "Expect 3 but receive ${bloc.state.options.length}. Options: ${bloc.state.options}"); + assert( + bloc.state.options.length == 3, + "Expect 3 but receive ${bloc.state.options.length}. Options: ${bloc.state.options}", + ); bloc.add(const SelectOptionEditorEvent.deleteAllOptions()); await gridResponseFuture(); - assert(bloc.state.options.isEmpty, - "Expect empty but receive ${bloc.state.options.length}"); + assert( + bloc.state.options.isEmpty, + "Expect empty but receive ${bloc.state.options.length}", + ); }); test('select/unselect option', () async { await cellTest.createTestGrid(); await cellTest.createTestRow(); final cellController = await cellTest.makeSelectOptionCellController( - FieldType.SingleSelect, 0); + FieldType.SingleSelect, + 0, + ); final bloc = SelectOptionCellEditorBloc(cellController: cellController); bloc.add(const SelectOptionEditorEvent.initial()); @@ -113,7 +129,9 @@ void main() { await cellTest.createTestGrid(); await cellTest.createTestRow(); final cellController = await cellTest.makeSelectOptionCellController( - FieldType.SingleSelect, 0); + FieldType.SingleSelect, + 0, + ); final bloc = SelectOptionCellEditorBloc(cellController: cellController); bloc.add(const SelectOptionEditorEvent.initial()); @@ -137,7 +155,9 @@ void main() { await cellTest.createTestGrid(); await cellTest.createTestRow(); final cellController = await cellTest.makeSelectOptionCellController( - FieldType.SingleSelect, 0); + FieldType.SingleSelect, + 0, + ); final bloc = SelectOptionCellEditorBloc(cellController: cellController); bloc.add(const SelectOptionEditorEvent.initial()); @@ -149,8 +169,12 @@ void main() { bloc.add(const SelectOptionEditorEvent.newOption("B")); await gridResponseFuture(); - bloc.add(const SelectOptionEditorEvent.selectMultipleOptions( - ["A", "B", "C"], "x")); + bloc.add( + const SelectOptionEditorEvent.selectMultipleOptions( + ["A", "B", "C"], + "x", + ), + ); await gridResponseFuture(); assert(bloc.state.selectedOptions.length == 1); @@ -162,7 +186,9 @@ void main() { await cellTest.createTestGrid(); await cellTest.createTestRow(); final cellController = await cellTest.makeSelectOptionCellController( - FieldType.SingleSelect, 0); + FieldType.SingleSelect, + 0, + ); final bloc = SelectOptionCellEditorBloc(cellController: cellController); bloc.add(const SelectOptionEditorEvent.initial()); diff --git a/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/create_filter_test.dart b/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/create_filter_test.dart index f6342904c2..2907d0334a 100644 --- a/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/create_filter_test.dart +++ b/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/create_filter_test.dart @@ -19,9 +19,10 @@ void main() { final service = FilterBackendService(viewId: context.gridView.id); final textField = context.textFieldContext(); await service.insertTextFilter( - fieldId: textField.id, - condition: TextFilterConditionPB.TextIsEmpty, - content: ""); + fieldId: textField.id, + condition: TextFilterConditionPB.TextIsEmpty, + content: "", + ); await gridResponseFuture(); assert(context.fieldController.filterInfos.length == 1); @@ -32,9 +33,10 @@ void main() { final service = FilterBackendService(viewId: context.gridView.id); final textField = context.textFieldContext(); await service.insertTextFilter( - fieldId: textField.id, - condition: TextFilterConditionPB.TextIsEmpty, - content: ""); + fieldId: textField.id, + condition: TextFilterConditionPB.TextIsEmpty, + content: "", + ); await gridResponseFuture(); final filterInfo = context.fieldController.filterInfos.first; @@ -63,9 +65,10 @@ void main() { final textField = context.textFieldContext(); service.insertTextFilter( - fieldId: textField.id, - condition: TextFilterConditionPB.TextIsEmpty, - content: ""); + fieldId: textField.id, + condition: TextFilterConditionPB.TextIsEmpty, + content: "", + ); await gridResponseFuture(); expect(gridBloc.state.rowInfos.length, 3); @@ -87,9 +90,10 @@ void main() { final textField = context.textFieldContext(); await service.insertTextFilter( - fieldId: textField.id, - condition: TextFilterConditionPB.TextIsEmpty, - content: ""); + fieldId: textField.id, + condition: TextFilterConditionPB.TextIsEmpty, + content: "", + ); await gridResponseFuture(); final controller = await context.makeTextCellController(0); @@ -108,9 +112,10 @@ void main() { final textField = context.textFieldContext(); await gridResponseFuture(); await service.insertTextFilter( - fieldId: textField.id, - condition: TextFilterConditionPB.TextIsNotEmpty, - content: ""); + fieldId: textField.id, + condition: TextFilterConditionPB.TextIsNotEmpty, + content: "", + ); await gridResponseFuture(); assert(context.rowInfos.isEmpty); }); diff --git a/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/edit_filter_field_test.dart b/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/edit_filter_field_test.dart index 1dcc3dec07..d88859bc0e 100644 --- a/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/edit_filter_field_test.dart +++ b/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/edit_filter_field_test.dart @@ -27,9 +27,10 @@ void main() { // Insert filter for the text field await service.insertTextFilter( - fieldId: textField.id, - condition: TextFilterConditionPB.TextIsEmpty, - content: ""); + fieldId: textField.id, + condition: TextFilterConditionPB.TextIsEmpty, + content: "", + ); await gridResponseFuture(); assert(menuBloc.state.filters.length == 1); diff --git a/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_menu_test.dart b/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_menu_test.dart index 6fff3517e7..6123bff918 100644 --- a/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_menu_test.dart +++ b/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_menu_test.dart @@ -14,17 +14,19 @@ void main() { test('test filter menu after create a text filter)', () async { final context = await gridTest.createTestGrid(); final menuBloc = GridFilterMenuBloc( - viewId: context.gridView.id, fieldController: context.fieldController) - ..add(const GridFilterMenuEvent.initial()); + viewId: context.gridView.id, + fieldController: context.fieldController, + )..add(const GridFilterMenuEvent.initial()); await gridResponseFuture(); assert(menuBloc.state.creatableFields.length == 3); final service = FilterBackendService(viewId: context.gridView.id); final textField = context.textFieldContext(); await service.insertTextFilter( - fieldId: textField.id, - condition: TextFilterConditionPB.TextIsEmpty, - content: ""); + fieldId: textField.id, + condition: TextFilterConditionPB.TextIsEmpty, + content: "", + ); await gridResponseFuture(); assert(menuBloc.state.creatableFields.length == 2); }); @@ -32,8 +34,9 @@ void main() { test('test filter menu after update existing text filter)', () async { final context = await gridTest.createTestGrid(); final menuBloc = GridFilterMenuBloc( - viewId: context.gridView.id, fieldController: context.fieldController) - ..add(const GridFilterMenuEvent.initial()); + viewId: context.gridView.id, + fieldController: context.fieldController, + )..add(const GridFilterMenuEvent.initial()); await gridResponseFuture(); final service = FilterBackendService(viewId: context.gridView.id); @@ -41,21 +44,25 @@ void main() { // Create filter await service.insertTextFilter( - fieldId: textField.id, - condition: TextFilterConditionPB.TextIsEmpty, - content: ""); + fieldId: textField.id, + condition: TextFilterConditionPB.TextIsEmpty, + content: "", + ); await gridResponseFuture(); final textFilter = context.fieldController.filterInfos.first; // Update the existing filter await service.insertTextFilter( - fieldId: textField.id, - filterId: textFilter.filter.id, - condition: TextFilterConditionPB.Is, - content: "ABC"); + fieldId: textField.id, + filterId: textFilter.filter.id, + condition: TextFilterConditionPB.Is, + content: "ABC", + ); await gridResponseFuture(); - assert(menuBloc.state.filters.first.textFilter()!.condition == - TextFilterConditionPB.Is); + assert( + menuBloc.state.filters.first.textFilter()!.condition == + TextFilterConditionPB.Is, + ); assert(menuBloc.state.filters.first.textFilter()!.content == "ABC"); }); } diff --git a/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_rows_by_checkbox_test.dart b/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_rows_by_checkbox_test.dart index fd54e41e73..1d2bd20ad9 100644 --- a/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_rows_by_checkbox_test.dart +++ b/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_rows_by_checkbox_test.dart @@ -26,8 +26,10 @@ void main() { condition: CheckboxFilterConditionPB.IsChecked, ); await gridResponseFuture(); - assert(context.rowInfos.length == 1, - "expect 1 but receive ${context.rowInfos.length}"); + assert( + context.rowInfos.length == 1, + "expect 1 but receive ${context.rowInfos.length}", + ); }); test('filter rows by checkbox is uncheck condition)', () async { @@ -45,7 +47,9 @@ void main() { condition: CheckboxFilterConditionPB.IsUnChecked, ); await gridResponseFuture(); - assert(context.rowInfos.length == 2, - "expect 2 but receive ${context.rowInfos.length}"); + assert( + context.rowInfos.length == 2, + "expect 2 but receive ${context.rowInfos.length}", + ); }); } diff --git a/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_rows_by_text_test.dart b/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_rows_by_text_test.dart index a55401b35e..51557b91d9 100644 --- a/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_rows_by_text_test.dart +++ b/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_rows_by_text_test.dart @@ -18,14 +18,19 @@ void main() { final textField = context.textFieldContext(); // create a new filter await service.insertTextFilter( - fieldId: textField.id, - condition: TextFilterConditionPB.TextIsEmpty, - content: ""); + fieldId: textField.id, + condition: TextFilterConditionPB.TextIsEmpty, + content: "", + ); await gridResponseFuture(); - assert(context.fieldController.filterInfos.length == 1, - "expect 1 but receive ${context.fieldController.filterInfos.length}"); - assert(context.rowInfos.length == 1, - "expect 1 but receive ${context.rowInfos.length}"); + assert( + context.fieldController.filterInfos.length == 1, + "expect 1 but receive ${context.fieldController.filterInfos.length}", + ); + assert( + context.rowInfos.length == 1, + "expect 1 but receive ${context.rowInfos.length}", + ); // delete the filter final textFilter = context.fieldController.filterInfos.first; @@ -45,12 +50,15 @@ void main() { final textField = context.textFieldContext(); // create a new filter await service.insertTextFilter( - fieldId: textField.id, - condition: TextFilterConditionPB.TextIsNotEmpty, - content: ""); + fieldId: textField.id, + condition: TextFilterConditionPB.TextIsNotEmpty, + content: "", + ); await gridResponseFuture(); - assert(context.rowInfos.length == 2, - "expect 2 but receive ${context.rowInfos.length}"); + assert( + context.rowInfos.length == 2, + "expect 2 but receive ${context.rowInfos.length}", + ); // delete the filter final textFilter = context.fieldController.filterInfos.first; @@ -70,22 +78,28 @@ void main() { final textField = context.textFieldContext(); // create a new filter await service.insertTextFilter( - fieldId: textField.id, - condition: TextFilterConditionPB.TextIsEmpty, - content: ""); + fieldId: textField.id, + condition: TextFilterConditionPB.TextIsEmpty, + content: "", + ); await gridResponseFuture(); - assert(context.fieldController.filterInfos.length == 1, - "expect 1 but receive ${context.fieldController.filterInfos.length}"); - assert(context.rowInfos.length == 1, - "expect 1 but receive ${context.rowInfos.length}"); + assert( + context.fieldController.filterInfos.length == 1, + "expect 1 but receive ${context.fieldController.filterInfos.length}", + ); + assert( + context.rowInfos.length == 1, + "expect 1 but receive ${context.rowInfos.length}", + ); // Update the existing filter final textFilter = context.fieldController.filterInfos.first; await service.insertTextFilter( - fieldId: textField.id, - filterId: textFilter.filter.id, - condition: TextFilterConditionPB.TextIsNotEmpty, - content: ""); + fieldId: textField.id, + filterId: textFilter.filter.id, + condition: TextFilterConditionPB.TextIsNotEmpty, + content: "", + ); await gridResponseFuture(); assert(context.rowInfos.length == 2); @@ -106,38 +120,44 @@ void main() { final textField = context.textFieldContext(); // create a new filter await service.insertTextFilter( - fieldId: textField.id, - condition: TextFilterConditionPB.Is, - content: "A"); + fieldId: textField.id, + condition: TextFilterConditionPB.Is, + content: "A", + ); await gridResponseFuture(); - assert(context.rowInfos.length == 1, - "expect 1 but receive ${context.rowInfos.length}"); + assert( + context.rowInfos.length == 1, + "expect 1 but receive ${context.rowInfos.length}", + ); // Update the existing filter's content from 'A' to 'B' final textFilter = context.fieldController.filterInfos.first; await service.insertTextFilter( - fieldId: textField.id, - filterId: textFilter.filter.id, - condition: TextFilterConditionPB.Is, - content: "B"); + fieldId: textField.id, + filterId: textFilter.filter.id, + condition: TextFilterConditionPB.Is, + content: "B", + ); await gridResponseFuture(); assert(context.rowInfos.length == 1); // Update the existing filter's content from 'B' to 'b' await service.insertTextFilter( - fieldId: textField.id, - filterId: textFilter.filter.id, - condition: TextFilterConditionPB.Is, - content: "b"); + fieldId: textField.id, + filterId: textFilter.filter.id, + condition: TextFilterConditionPB.Is, + content: "b", + ); await gridResponseFuture(); assert(context.rowInfos.length == 1); // Update the existing filter with content 'C' await service.insertTextFilter( - fieldId: textField.id, - filterId: textFilter.filter.id, - condition: TextFilterConditionPB.Is, - content: "C"); + fieldId: textField.id, + filterId: textFilter.filter.id, + condition: TextFilterConditionPB.Is, + content: "C", + ); await gridResponseFuture(); assert(context.rowInfos.isEmpty); diff --git a/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_util.dart b/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_util.dart index b7b409f0e5..c25a99b2f2 100644 --- a/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_util.dart +++ b/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_util.dart @@ -18,11 +18,12 @@ Future createTestFilterGrid(AppFlowyGridTest gridTest) async { return result.fold( (view) async { final context = GridTestContext( - view, - DatabaseController( - view: view, - layoutType: LayoutTypePB.Grid, - )); + view, + DatabaseController( + view: view, + layoutType: LayoutTypePB.Grid, + ), + ); final result = await context.gridController.open(); await editCells(context); diff --git a/frontend/appflowy_flutter/test/bloc_test/grid_test/grid_bloc_test.dart b/frontend/appflowy_flutter/test/bloc_test/grid_test/grid_bloc_test.dart index a2ccbbd164..352646d913 100644 --- a/frontend/appflowy_flutter/test/bloc_test/grid_test/grid_bloc_test.dart +++ b/frontend/appflowy_flutter/test/bloc_test/grid_test/grid_bloc_test.dart @@ -20,12 +20,12 @@ void main() { blocTest( "create a row", build: () => GridBloc( + view: context.gridView, + databaseController: DatabaseController( view: context.gridView, - databaseController: DatabaseController( - view: context.gridView, - layoutType: LayoutTypePB.Grid, - )) - ..add(const GridEvent.initial()), + layoutType: LayoutTypePB.Grid, + ), + )..add(const GridEvent.initial()), act: (bloc) => bloc.add(const GridEvent.createRow()), wait: const Duration(milliseconds: 300), verify: (bloc) { @@ -36,20 +36,22 @@ void main() { blocTest( "delete the last row", build: () => GridBloc( + view: context.gridView, + databaseController: DatabaseController( view: context.gridView, - databaseController: DatabaseController( - view: context.gridView, - layoutType: LayoutTypePB.Grid, - )) - ..add(const GridEvent.initial()), + layoutType: LayoutTypePB.Grid, + ), + )..add(const GridEvent.initial()), act: (bloc) async { await gridResponseFuture(); bloc.add(GridEvent.deleteRow(bloc.state.rowInfos.last)); }, wait: const Duration(milliseconds: 300), verify: (bloc) { - assert(bloc.state.rowInfos.length == 2, - "Expected 2, but receive ${bloc.state.rowInfos.length}"); + assert( + bloc.state.rowInfos.length == 2, + "Expected 2, but receive ${bloc.state.rowInfos.length}", + ); }, ); }); diff --git a/frontend/appflowy_flutter/test/bloc_test/grid_test/grid_header_bloc_test.dart b/frontend/appflowy_flutter/test/bloc_test/grid_test/grid_header_bloc_test.dart index 156c931f0b..571cb11d89 100644 --- a/frontend/appflowy_flutter/test/bloc_test/grid_test/grid_header_bloc_test.dart +++ b/frontend/appflowy_flutter/test/bloc_test/grid_test/grid_header_bloc_test.dart @@ -117,7 +117,8 @@ void main() { wait: gridResponseDuration(), verify: (bloc) { final field = bloc.state.fields.firstWhere( - (element) => element.id == actionSheetBloc.fieldService.fieldId); + (element) => element.id == actionSheetBloc.fieldService.fieldId, + ); expect(field.name, "Hello world"); }, diff --git a/frontend/appflowy_flutter/test/bloc_test/grid_test/util.dart b/frontend/appflowy_flutter/test/bloc_test/grid_test/util.dart index af85cc8bf2..fc3dba4446 100644 --- a/frontend/appflowy_flutter/test/bloc_test/grid_test/util.dart +++ b/frontend/appflowy_flutter/test/bloc_test/grid_test/util.dart @@ -60,7 +60,9 @@ class GridTestContext { } Future makeCellController( - String fieldId, int rowIndex) async { + String fieldId, + int rowIndex, + ) async { final builder = await makeCellControllerBuilder(fieldId, rowIndex); return builder.build(); } @@ -123,9 +125,12 @@ class GridTestContext { } Future makeSelectOptionCellController( - FieldType fieldType, int rowIndex) async { - assert(fieldType == FieldType.SingleSelect || - fieldType == FieldType.MultiSelect); + FieldType fieldType, + int rowIndex, + ) async { + assert( + fieldType == FieldType.SingleSelect || fieldType == FieldType.MultiSelect, + ); final field = fieldContexts.firstWhere((element) => element.fieldType == fieldType); @@ -175,11 +180,12 @@ class AppFlowyGridTest { return result.fold( (view) async { final context = GridTestContext( - view, - DatabaseController( - view: view, - layoutType: LayoutTypePB.Grid, - )); + view, + DatabaseController( + view: view, + layoutType: LayoutTypePB.Grid, + ), + ); final result = await context.gridController.open(); result.fold((l) => null, (r) => throw Exception(r)); return context; @@ -214,7 +220,9 @@ class AppFlowyGridCellTest { } Future makeSelectOptionCellController( - FieldType fieldType, int rowIndex) async { + FieldType fieldType, + int rowIndex, + ) async { return await context.makeSelectOptionCellController(fieldType, rowIndex); } } diff --git a/frontend/appflowy_flutter/test/bloc_test/home_test/trash_bloc_test.dart b/frontend/appflowy_flutter/test/bloc_test/home_test/trash_bloc_test.dart index da7d0159d3..5eee2648b8 100644 --- a/frontend/appflowy_flutter/test/bloc_test/home_test/trash_bloc_test.dart +++ b/frontend/appflowy_flutter/test/bloc_test/home_test/trash_bloc_test.dart @@ -20,16 +20,20 @@ class TrashTestContext { appBloc = AppBloc(app: app)..add(const AppEvent.initial()); await blocResponseFuture(); - appBloc.add(AppEvent.createView( - "Document 1", - DocumentPluginBuilder(), - )); + appBloc.add( + AppEvent.createView( + "Document 1", + DocumentPluginBuilder(), + ), + ); await blocResponseFuture(); - appBloc.add(AppEvent.createView( - "Document 2", - DocumentPluginBuilder(), - )); + appBloc.add( + AppEvent.createView( + "Document 2", + DocumentPluginBuilder(), + ), + ); await blocResponseFuture(); appBloc.add( @@ -95,8 +99,10 @@ void main() { // delete all view permanently trashBloc.add(const TrashEvent.deleteAll()); await blocResponseFuture(); - assert(trashBloc.state.objects.isEmpty, - "but receive ${trashBloc.state.objects.length}"); + assert( + trashBloc.state.objects.isEmpty, + "but receive ${trashBloc.state.objects.length}", + ); }); }); } diff --git a/frontend/appflowy_flutter/test/bloc_test/home_test/view_bloc_test.dart b/frontend/appflowy_flutter/test/bloc_test/home_test/view_bloc_test.dart index cc4c5ec832..bc67388fe4 100644 --- a/frontend/appflowy_flutter/test/bloc_test/home_test/view_bloc_test.dart +++ b/frontend/appflowy_flutter/test/bloc_test/home_test/view_bloc_test.dart @@ -14,10 +14,12 @@ void main() { test('rename view test', () async { final app = await testContext.createTestApp(); final appBloc = AppBloc(app: app)..add(const AppEvent.initial()); - appBloc.add(AppEvent.createView( - "Test document", - DocumentPluginBuilder(), - )); + appBloc.add( + AppEvent.createView( + "Test document", + DocumentPluginBuilder(), + ), + ); await blocResponseFuture(); final viewBloc = ViewBloc(view: appBloc.state.views.first) @@ -33,10 +35,12 @@ void main() { final appBloc = AppBloc(app: app)..add(const AppEvent.initial()); await blocResponseFuture(); - appBloc.add(AppEvent.createView( - "Test document", - DocumentPluginBuilder(), - )); + appBloc.add( + AppEvent.createView( + "Test document", + DocumentPluginBuilder(), + ), + ); await blocResponseFuture(); final viewBloc = ViewBloc(view: appBloc.state.views.first) @@ -54,10 +58,12 @@ void main() { final appBloc = AppBloc(app: app)..add(const AppEvent.initial()); await blocResponseFuture(); - appBloc.add(AppEvent.createView( - "Test document", - DocumentPluginBuilder(), - )); + appBloc.add( + AppEvent.createView( + "Test document", + DocumentPluginBuilder(), + ), + ); await blocResponseFuture(); expect(appBloc.state.views.length, 1); diff --git a/frontend/appflowy_flutter/test/unit_test/editor/share_markdown_test.dart b/frontend/appflowy_flutter/test/unit_test/editor/share_markdown_test.dart index 48afb2b614..691f800bab 100644 --- a/frontend/appflowy_flutter/test/unit_test/editor/share_markdown_test.dart +++ b/frontend/appflowy_flutter/test/unit_test/editor/share_markdown_test.dart @@ -27,9 +27,12 @@ void main() { final document = Document.fromJson( Map.from(json.decode(text)), ); - final result = documentToMarkdown(document, customParsers: [ - const MathEquationNodeParser(), - ]); + final result = documentToMarkdown( + document, + customParsers: [ + const MathEquationNodeParser(), + ], + ); expect(result, r'$$E = MC^2$$'); }); // Changes @@ -52,9 +55,12 @@ void main() { final document = Document.fromJson( Map.from(json.decode(text)), ); - final result = documentToMarkdown(document, customParsers: [ - const CodeBlockNodeParser(), - ]); + final result = documentToMarkdown( + document, + customParsers: [ + const CodeBlockNodeParser(), + ], + ); expect(result, '```\nSome Code\n```'); }); test('divider', () { @@ -73,9 +79,12 @@ void main() { final document = Document.fromJson( Map.from(json.decode(text)), ); - final result = documentToMarkdown(document, customParsers: [ - const DividerNodeParser(), - ]); + final result = documentToMarkdown( + document, + customParsers: [ + const DividerNodeParser(), + ], + ); expect(result, '---\n'); }); });