diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b0d97658e4..527b8acd31 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,7 +34,7 @@ jobs: with: channel: 'stable' cache: true - flutter-version: '3.0.0' + flutter-version: '3.0.5' - name: Cache Cargo uses: actions/cache@v2 diff --git a/.github/workflows/dart_lint.yml b/.github/workflows/dart_lint.yml index eb5703cd72..3ff87dc680 100644 --- a/.github/workflows/dart_lint.yml +++ b/.github/workflows/dart_lint.yml @@ -23,7 +23,7 @@ jobs: uses: actions/checkout@v2 - uses: subosito/flutter-action@v1 with: - flutter-version: '3.0.0' + flutter-version: '3.0.5' channel: "stable" - uses: actions-rs/toolchain@v1 with: diff --git a/.github/workflows/dart_test.yml b/.github/workflows/dart_test.yml index f0b42a506d..e2a858999c 100644 --- a/.github/workflows/dart_test.yml +++ b/.github/workflows/dart_test.yml @@ -26,7 +26,7 @@ jobs: - uses: subosito/flutter-action@v2 with: channel: 'stable' - flutter-version: '3.0.0' + flutter-version: '3.0.5' cache: true - name: Cache Cargo diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f574b63137..2b608276f8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,7 +50,7 @@ jobs: uses: subosito/flutter-action@v2 with: channel: 'stable' - flutter-version: '3.0.0' + flutter-version: '3.0.5' - name: Pre build working-directory: frontend @@ -99,7 +99,7 @@ jobs: uses: subosito/flutter-action@v2 with: channel: 'stable' - flutter-version: '3.0.0' + flutter-version: '3.0.5' - name: Pre build working-directory: frontend diff --git a/.github/workflows/rust_lint.yml b/.github/workflows/rust_lint.yml index 83ecd62280..471654083c 100644 --- a/.github/workflows/rust_lint.yml +++ b/.github/workflows/rust_lint.yml @@ -22,7 +22,7 @@ jobs: override: true - uses: subosito/flutter-action@v1 with: - flutter-version: '3.0.0' + flutter-version: '3.0.5' channel: "stable" - name: Rust Deps diff --git a/frontend/app_flowy/assets/translations/en.json b/frontend/app_flowy/assets/translations/en.json index 2dbb970611..a60ff02dc1 100644 --- a/frontend/app_flowy/assets/translations/en.json +++ b/frontend/app_flowy/assets/translations/en.json @@ -94,7 +94,8 @@ }, "tooltip": { "lightMode": "Switch to Light mode", - "darkMode": "Switch to Dark mode" + "darkMode": "Switch to Dark mode", + "openAsPage": "Open as a Page" }, "notifications": { "export": { @@ -215,4 +216,4 @@ "timeHintTextInTwentyFourHour": "12:00" } } -} \ No newline at end of file +} diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/blank/blank.dart b/frontend/app_flowy/lib/plugins/blank/blank.dart similarity index 91% rename from frontend/app_flowy/lib/workspace/presentation/plugins/blank/blank.dart rename to frontend/app_flowy/lib/plugins/blank/blank.dart index 05456f20f4..11f779eeb0 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/blank/blank.dart +++ b/frontend/app_flowy/lib/plugins/blank/blank.dart @@ -4,7 +4,7 @@ import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flutter/material.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; class BlankPluginBuilder extends PluginBuilder { @override @@ -42,7 +42,8 @@ class BlankPagePlugin extends Plugin { class BlankPagePluginDisplay extends PluginDisplay with NavigationItem { @override - Widget get leftBarItem => FlowyText.medium(LocaleKeys.blankPageTitle.tr(), fontSize: 12); + Widget get leftBarItem => + FlowyText.medium(LocaleKeys.blankPageTitle.tr(), fontSize: 12); @override Widget buildWidget() => const BlankPage(); diff --git a/frontend/app_flowy/lib/workspace/application/board/board_bloc.dart b/frontend/app_flowy/lib/plugins/board/application/board_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/board/board_bloc.dart rename to frontend/app_flowy/lib/plugins/board/application/board_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/board/board.dart b/frontend/app_flowy/lib/plugins/board/board.dart similarity index 87% rename from frontend/app_flowy/lib/workspace/presentation/plugins/board/board.dart rename to frontend/app_flowy/lib/plugins/board/board.dart index ab58176e50..11a6d415eb 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/board/board.dart +++ b/frontend/app_flowy/lib/plugins/board/board.dart @@ -1,10 +1,10 @@ import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; -import 'package:app_flowy/workspace/presentation/plugins/widgets/left_bar_item.dart'; +import 'package:app_flowy/workspace/presentation/widgets/left_bar_item.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:flutter/material.dart'; -import 'src/board_page.dart'; +import 'presentation/board_page.dart'; class BoardPluginBuilder implements PluginBuilder { @override @@ -28,7 +28,7 @@ class BoardPluginBuilder implements PluginBuilder { class BoardPluginConfig implements PluginConfig { @override - bool get creatable => false; + bool get creatable => true; } class BoardPlugin extends Plugin { diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/board/src/board_page.dart b/frontend/app_flowy/lib/plugins/board/presentation/board_page.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/board/src/board_page.dart rename to frontend/app_flowy/lib/plugins/board/presentation/board_page.dart diff --git a/frontend/app_flowy/lib/workspace/application/doc/doc_bloc.dart b/frontend/app_flowy/lib/plugins/doc/application/doc_bloc.dart similarity index 85% rename from frontend/app_flowy/lib/workspace/application/doc/doc_bloc.dart rename to frontend/app_flowy/lib/plugins/doc/application/doc_bloc.dart index 8be4c40d85..ed12227af0 100644 --- a/frontend/app_flowy/lib/workspace/application/doc/doc_bloc.dart +++ b/frontend/app_flowy/lib/plugins/doc/application/doc_bloc.dart @@ -1,7 +1,7 @@ import 'dart:convert'; -import 'package:app_flowy/workspace/application/doc/doc_service.dart'; -import 'package:app_flowy/workspace/application/trash/trash_service.dart'; +import 'package:app_flowy/plugins/trash/application/trash_service.dart'; import 'package:app_flowy/workspace/application/view/view_listener.dart'; +import 'package:app_flowy/plugins/doc/application/doc_service.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/trash.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; @@ -43,14 +43,17 @@ class DocumentBloc extends Bloc { emit(state.copyWith(isDeleted: false)); }, deletePermanently: (DeletePermanently value) async { - final result = await trashService.deleteViews([Tuple2(view.id, TrashType.TrashView)]); + final result = await trashService + .deleteViews([Tuple2(view.id, TrashType.TrashView)]); - final newState = result.fold((l) => state.copyWith(forceClose: true), (r) => state); + final newState = result.fold( + (l) => state.copyWith(forceClose: true), (r) => state); emit(newState); }, restorePage: (RestorePage value) async { final result = await trashService.putback(view.id); - final newState = result.fold((l) => state.copyWith(isDeleted: false), (r) => state); + final newState = result.fold( + (l) => state.copyWith(isDeleted: false), (r) => state); emit(newState); }, ); @@ -93,10 +96,12 @@ class DocumentBloc extends Bloc { final documentDelta = document.toDelta(); _composeDelta(delta, documentDelta); }); - emit(state.copyWith(loadingState: DocumentLoadingState.finish(left(unit)))); + emit(state.copyWith( + loadingState: DocumentLoadingState.finish(left(unit)))); }, (err) { - emit(state.copyWith(loadingState: DocumentLoadingState.finish(right(err)))); + emit(state.copyWith( + loadingState: DocumentLoadingState.finish(right(err)))); }, ); } @@ -156,5 +161,6 @@ class DocumentState with _$DocumentState { @freezed class DocumentLoadingState with _$DocumentLoadingState { const factory DocumentLoadingState.loading() = _Loading; - const factory DocumentLoadingState.finish(Either successOrFail) = _Finish; + const factory DocumentLoadingState.finish( + Either successOrFail) = _Finish; } diff --git a/frontend/app_flowy/lib/workspace/application/doc/doc_service.dart b/frontend/app_flowy/lib/plugins/doc/application/doc_service.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/doc/doc_service.dart rename to frontend/app_flowy/lib/plugins/doc/application/doc_service.dart diff --git a/frontend/app_flowy/lib/workspace/application/doc/prelude.dart b/frontend/app_flowy/lib/plugins/doc/application/prelude.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/doc/prelude.dart rename to frontend/app_flowy/lib/plugins/doc/application/prelude.dart diff --git a/frontend/app_flowy/lib/workspace/application/doc/share_bloc.dart b/frontend/app_flowy/lib/plugins/doc/application/share_bloc.dart similarity index 84% rename from frontend/app_flowy/lib/workspace/application/doc/share_bloc.dart rename to frontend/app_flowy/lib/plugins/doc/application/share_bloc.dart index ba3c7676c6..98904c035a 100644 --- a/frontend/app_flowy/lib/workspace/application/doc/share_bloc.dart +++ b/frontend/app_flowy/lib/plugins/doc/application/share_bloc.dart @@ -1,8 +1,8 @@ import 'dart:async'; import 'dart:io'; import 'package:app_flowy/startup/tasks/rust_sdk.dart'; -import 'package:app_flowy/workspace/application/doc/share_service.dart'; import 'package:app_flowy/workspace/application/markdown/delta_markdown.dart'; +import 'package:app_flowy/plugins/doc/application/share_service.dart'; import 'package:flowy_sdk/protobuf/flowy-text-block/entities.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; @@ -14,13 +14,15 @@ part 'share_bloc.freezed.dart'; class DocShareBloc extends Bloc { ShareService service; ViewPB view; - DocShareBloc({required this.view, required this.service}) : super(const DocShareState.initial()) { + DocShareBloc({required this.view, required this.service}) + : super(const DocShareState.initial()) { on((event, emit) async { await event.map( shareMarkdown: (ShareMarkdown value) async { await service.exportMarkdown(view.id).then((result) { result.fold( - (value) => emit(DocShareState.finish(left(_convertDeltaToMarkdown(value)))), + (value) => emit( + DocShareState.finish(left(_convertDeltaToMarkdown(value)))), (error) => emit(DocShareState.finish(right(error))), ); }); @@ -73,5 +75,6 @@ class DocShareEvent with _$DocShareEvent { class DocShareState with _$DocShareState { const factory DocShareState.initial() = _Initial; const factory DocShareState.loading() = _Loading; - const factory DocShareState.finish(Either successOrFail) = _Finish; + const factory DocShareState.finish( + Either successOrFail) = _Finish; } diff --git a/frontend/app_flowy/lib/workspace/application/doc/share_service.dart b/frontend/app_flowy/lib/plugins/doc/application/share_service.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/doc/share_service.dart rename to frontend/app_flowy/lib/plugins/doc/application/share_service.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/document.dart b/frontend/app_flowy/lib/plugins/doc/document.dart similarity index 85% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/document.dart rename to frontend/app_flowy/lib/plugins/doc/document.dart index c09843873d..91bae222c1 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/document.dart +++ b/frontend/app_flowy/lib/plugins/doc/document.dart @@ -1,14 +1,14 @@ library docuemnt_plugin; import 'package:app_flowy/generated/locale_keys.g.dart'; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/application/appearance.dart'; -import 'package:app_flowy/workspace/application/doc/share_bloc.dart'; import 'package:app_flowy/workspace/application/view/view_listener.dart'; +import 'package:app_flowy/plugins/doc/application/share_bloc.dart'; import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; import 'package:app_flowy/workspace/presentation/home/toast.dart'; -import 'package:app_flowy/workspace/presentation/plugins/widgets/left_bar_item.dart'; +import 'package:app_flowy/workspace/presentation/widgets/left_bar_item.dart'; import 'package:app_flowy/workspace/presentation/widgets/dialogs.dart'; import 'package:app_flowy/workspace/presentation/widgets/pop_up_action.dart'; import 'package:clipboard/clipboard.dart'; @@ -26,12 +26,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:provider/provider.dart'; -import 'src/document_page.dart'; - -export './src/document_page.dart'; -export './src/widget/toolbar/history_button.dart'; -export './src/widget/toolbar/tool_bar.dart'; -export './src/widget/toolbar/toolbar_icon_button.dart'; +import 'document_page.dart'; class DocumentPluginBuilder extends PluginBuilder { @override @@ -58,7 +53,9 @@ class DocumentPlugin implements Plugin { ViewListener? _listener; late PluginType _pluginType; - DocumentPlugin({required PluginType pluginType, required ViewPB view, Key? key}) : _view = view { + DocumentPlugin( + {required PluginType pluginType, required ViewPB view, Key? key}) + : _view = view { _pluginType = pluginType; _listener = getIt(param1: view); _listener?.start(onViewUpdated: (result) { @@ -112,7 +109,8 @@ class DocumentPluginDisplay extends PluginDisplay with NavigationItem { class DocumentShareButton extends StatelessWidget { final ViewPB view; - DocumentShareButton({Key? key, required this.view}) : super(key: ValueKey(view.hashCode)); + DocumentShareButton({Key? key, required this.view}) + : super(key: ValueKey(view.hashCode)); @override Widget build(BuildContext context) { @@ -149,7 +147,8 @@ class DocumentShareButton extends StatelessWidget { fontSize: 12, borderRadius: Corners.s6Border, color: Colors.lightBlue, - onPressed: () => _showActionList(context, Offset(-(buttonWidth / 2), 10)), + onPressed: () => _showActionList( + context, Offset(-(buttonWidth / 2), 10)), ), ), ), @@ -165,7 +164,8 @@ class DocumentShareButton extends StatelessWidget { case ExportType.Link: break; case ExportType.Markdown: - FlutterClipboard.copy(exportData.data).then((value) => Log.info('copied to clipboard')); + FlutterClipboard.copy(exportData.data) + .then((value) => Log.info('copied to clipboard')); break; case ExportType.Text: break; @@ -179,11 +179,15 @@ class DocumentShareButton extends StatelessWidget { result.fold(() {}, (action) { switch (action) { case ShareAction.markdown: - context.read().add(const DocShareEvent.shareMarkdown()); - showMessageToast('Exported to: ${LocaleKeys.notifications_export_path.tr()}'); + context + .read() + .add(const DocShareEvent.shareMarkdown()); + showMessageToast( + 'Exported to: ${LocaleKeys.notifications_export_path.tr()}'); break; case ShareAction.copyLink: - FlowyAlertDialog(title: LocaleKeys.shareAction_workInProgress.tr()).show(context); + FlowyAlertDialog(title: LocaleKeys.shareAction_workInProgress.tr()) + .show(context); break; } }); @@ -198,7 +202,8 @@ class DocumentShareButton extends StatelessWidget { class ShareActions with ActionList, FlowyOverlayDelegate { final Function(dartz.Option) onSelected; - final _items = ShareAction.values.map((action) => ShareActionWrapper(action)).toList(); + final _items = + ShareAction.values.map((action) => ShareActionWrapper(action)).toList(); ShareActions({required this.onSelected}); @@ -212,7 +217,8 @@ class ShareActions with ActionList, FlowyOverlayDelegate { List get items => _items; @override - void Function(dartz.Option p1) get selectCallback => (result) { + void Function(dartz.Option p1) get selectCallback => + (result) { result.fold( () => onSelected(dartz.none()), (wrapper) => onSelected( diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/document_page.dart b/frontend/app_flowy/lib/plugins/doc/document_page.dart similarity index 85% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/document_page.dart rename to frontend/app_flowy/lib/plugins/doc/document_page.dart index 3598c5a5ac..7a7550ed2c 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/document_page.dart +++ b/frontend/app_flowy/lib/plugins/doc/document_page.dart @@ -1,7 +1,7 @@ import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/application/appearance.dart'; -import 'package:app_flowy/workspace/application/doc/doc_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/doc/document.dart'; +import 'package:app_flowy/plugins/doc/presentation/banner.dart'; +import 'package:app_flowy/plugins/doc/presentation/toolbar/tool_bar.dart'; import 'package:flowy_infra_ui/style_widget/scrolling/styled_scroll_bar.dart'; import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flutter_quill/flutter_quill.dart' as quill; @@ -10,8 +10,8 @@ import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:provider/provider.dart'; +import 'application/doc_bloc.dart'; import 'styles.dart'; -import 'widget/banner.dart'; class DocumentPage extends StatefulWidget { final ViewPB view; @@ -29,7 +29,8 @@ class _DocumentPageState extends State { @override void initState() { - documentBloc = getIt(param1: super.widget.view)..add(const DocumentEvent.initial()); + documentBloc = getIt(param1: super.widget.view) + ..add(const DocumentEvent.initial()); super.initState(); } @@ -39,10 +40,12 @@ class _DocumentPageState extends State { providers: [ BlocProvider.value(value: documentBloc), ], - child: BlocBuilder(builder: (context, state) { + child: + BlocBuilder(builder: (context, state) { return state.loadingState.map( // loading: (_) => const FlowyProgressIndicator(), - loading: (_) => SizedBox.expand(child: Container(color: Colors.transparent)), + loading: (_) => + SizedBox.expand(child: Container(color: Colors.transparent)), finish: (result) => result.successOrFail.fold( (_) { if (state.forceClose) { @@ -90,8 +93,11 @@ class _DocumentPageState extends State { Widget _renderBanner(BuildContext context) { return DocumentBanner( - onRestore: () => context.read().add(const DocumentEvent.restorePage()), - onDelete: () => context.read().add(const DocumentEvent.deletePermanently()), + onRestore: () => + context.read().add(const DocumentEvent.restorePage()), + onDelete: () => context + .read() + .add(const DocumentEvent.deletePermanently()), ); } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/banner.dart b/frontend/app_flowy/lib/plugins/doc/presentation/banner.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/banner.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/banner.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/style_widgets.dart b/frontend/app_flowy/lib/plugins/doc/presentation/style_widgets.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/style_widgets.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/style_widgets.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/check_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/check_button.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/check_button.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/check_button.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/color_picker.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/color_picker.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/color_picker.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/color_picker.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/header_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/header_button.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/header_button.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/header_button.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/history_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/history_button.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/history_button.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/history_button.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/image_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/image_button.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/image_button.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/image_button.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/link_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/link_button.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/link_button.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/link_button.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/toggle_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/toggle_button.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/toggle_button.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/toggle_button.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/tool_bar.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/tool_bar.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/tool_bar.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/tool_bar.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/toolbar_icon_button.dart b/frontend/app_flowy/lib/plugins/doc/presentation/toolbar/toolbar_icon_button.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/widget/toolbar/toolbar_icon_button.dart rename to frontend/app_flowy/lib/plugins/doc/presentation/toolbar/toolbar_icon_button.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/styles.dart b/frontend/app_flowy/lib/plugins/doc/styles.dart similarity index 86% rename from frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/styles.dart rename to frontend/app_flowy/lib/plugins/doc/styles.dart index c6eb292c49..d3dee3f97a 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/doc/src/styles.dart +++ b/frontend/app_flowy/lib/plugins/doc/styles.dart @@ -1,11 +1,10 @@ +import 'package:app_flowy/plugins/doc/presentation/style_widgets.dart'; import 'package:flutter/material.dart'; import 'package:flutter_quill/flutter_quill.dart'; import 'package:provider/provider.dart'; import 'package:tuple/tuple.dart'; import 'package:flowy_infra/theme.dart'; -import 'widget/style_widgets.dart'; - DefaultStyles customStyles(BuildContext context) { const baseSpacing = Tuple2(6, 0); @@ -53,7 +52,8 @@ DefaultStyles customStyles(BuildContext context) { const Tuple2(8, 0), const Tuple2(0, 0), null), - paragraph: DefaultTextBlockStyle(baseStyle, const Tuple2(10, 0), const Tuple2(0, 0), null), + paragraph: DefaultTextBlockStyle( + baseStyle, const Tuple2(10, 0), const Tuple2(0, 0), null), bold: const TextStyle(fontWeight: FontWeight.bold), italic: const TextStyle(fontStyle: FontStyle.italic), small: const TextStyle(fontSize: 12, color: Colors.black45), @@ -78,8 +78,8 @@ DefaultStyles customStyles(BuildContext context) { const Tuple2(0, 0), const Tuple2(0, 0), null), - lists: - DefaultListBlockStyle(baseStyle, baseSpacing, const Tuple2(0, 6), null, StyleWidgetBuilder.checkbox(theme)), + lists: DefaultListBlockStyle(baseStyle, baseSpacing, const Tuple2(0, 6), + null, StyleWidgetBuilder.checkbox(theme)), quote: DefaultTextBlockStyle( TextStyle(color: baseStyle.color!.withOpacity(0.6)), baseSpacing, @@ -102,9 +102,12 @@ DefaultStyles customStyles(BuildContext context) { color: Colors.grey.shade50, borderRadius: BorderRadius.circular(2), )), - indent: DefaultTextBlockStyle(baseStyle, baseSpacing, const Tuple2(0, 6), null), - align: DefaultTextBlockStyle(baseStyle, const Tuple2(0, 0), const Tuple2(0, 0), null), - leading: DefaultTextBlockStyle(baseStyle, const Tuple2(0, 0), const Tuple2(0, 0), null), + indent: DefaultTextBlockStyle( + baseStyle, baseSpacing, const Tuple2(0, 6), null), + align: DefaultTextBlockStyle( + baseStyle, const Tuple2(0, 0), const Tuple2(0, 0), null), + leading: DefaultTextBlockStyle( + baseStyle, const Tuple2(0, 0), const Tuple2(0, 0), null), sizeSmall: const TextStyle(fontSize: 10), sizeLarge: const TextStyle(fontSize: 18), sizeHuge: const TextStyle(fontSize: 22)); diff --git a/frontend/app_flowy/lib/workspace/application/grid/block/block_cache.dart b/frontend/app_flowy/lib/plugins/grid/application/block/block_cache.dart similarity index 90% rename from frontend/app_flowy/lib/workspace/application/grid/block/block_cache.dart rename to frontend/app_flowy/lib/plugins/grid/application/block/block_cache.dart index 3c99c0e0e1..5ccff7c838 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/block/block_cache.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/block/block_cache.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:app_flowy/workspace/application/grid/grid_service.dart'; -import 'package:app_flowy/workspace/application/grid/row/row_service.dart'; +import 'package:app_flowy/plugins/grid/application/grid_service.dart'; +import 'package:app_flowy/plugins/grid/application/row/row_service.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/block_entities.pb.dart'; diff --git a/frontend/app_flowy/lib/workspace/application/grid/block/block_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/block/block_listener.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/block/block_listener.dart rename to frontend/app_flowy/lib/plugins/grid/application/block/block_listener.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_listener.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/cell_listener.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/cell_listener.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_cache.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_cache.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_cache.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_cache.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_data_loader.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_data_loader.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_data_loader.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_data_loader.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_data_persistence.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_data_persistence.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_data_persistence.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_data_persistence.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_field_notifier.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_field_notifier.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_field_notifier.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_field_notifier.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_service.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_service.dart similarity index 90% rename from frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_service.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_service.dart index 47cd67a55f..2bef94c16a 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_service.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_service.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'dart:collection'; -import 'package:app_flowy/workspace/application/grid/grid_service.dart'; +import 'package:app_flowy/plugins/grid/application/grid_service.dart'; import 'package:dartz/dartz.dart'; import 'package:equatable/equatable.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart'; @@ -14,8 +14,8 @@ import 'package:flowy_sdk/protobuf/flowy-grid/select_option.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/url_type_option_entities.pb.dart'; import 'package:flutter/foundation.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:app_flowy/workspace/application/grid/cell/cell_listener.dart'; -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_listener.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; import 'dart:convert' show utf8; import '../../field/type_option/type_option_service.dart'; diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/context_builder.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/context_builder.dart similarity index 89% rename from frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/context_builder.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/context_builder.dart index 48e88e56ac..8f78793a2c 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/context_builder.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/context_builder.dart @@ -1,8 +1,10 @@ part of 'cell_service.dart'; typedef GridCellController = IGridCellController; -typedef GridSelectOptionCellController = IGridCellController; -typedef GridDateCellController = IGridCellController; +typedef GridSelectOptionCellController + = IGridCellController; +typedef GridDateCellController + = IGridCellController; typedef GridURLCellController = IGridCellController; class GridCellControllerBuilder { @@ -19,7 +21,8 @@ class GridCellControllerBuilder { _cellId = cellId; IGridCellController build() { - final cellFieldNotifier = GridCellFieldNotifier(notifier: _GridFieldChangedNotifierImpl(_fieldCache)); + final cellFieldNotifier = GridCellFieldNotifier( + notifier: _GridFieldChangedNotifierImpl(_fieldCache)); switch (_cellId.fieldType) { case FieldType.Checkbox: @@ -142,8 +145,10 @@ class IGridCellController extends Equatable { _cellDataLoader = cellDataLoader, _cellDataPersistence = cellDataPersistence, _fieldNotifier = fieldNotifier, - _fieldService = FieldService(gridId: cellId.gridId, fieldId: cellId.field.id), - _cacheKey = GridCellCacheKey(rowId: cellId.rowId, fieldId: cellId.field.id); + _fieldService = + FieldService(gridId: cellId.gridId, fieldId: cellId.field.id), + _cacheKey = + GridCellCacheKey(rowId: cellId.rowId, fieldId: cellId.field.id); IGridCellController clone() { return IGridCellController( @@ -164,7 +169,9 @@ class IGridCellController extends Equatable { FieldType get fieldType => cellId.field.fieldType; - VoidCallback? startListening({required void Function(T?) onCellChanged, VoidCallback? onCellFieldChanged}) { + VoidCallback? startListening( + {required void Function(T?) onCellChanged, + VoidCallback? onCellFieldChanged}) { if (isListening) { Log.error("Already started. It seems like you should call clone first"); return null; @@ -226,8 +233,11 @@ class IGridCellController extends Equatable { /// Return the FieldTypeOptionDataPB that can be parsed into corresponding class using the [parser]. /// [PD] is the type that the parser return. - Future> getFieldTypeOption(P parser) { - return _fieldService.getFieldTypeOptionData(fieldType: fieldType).then((result) { + Future> + getFieldTypeOption(P parser) { + return _fieldService + .getFieldTypeOptionData(fieldType: fieldType) + .then((result) { return result.fold( (data) => parser.fromBuffer(data.typeOptionData), (err) => right(err), @@ -239,7 +249,9 @@ class IGridCellController extends Equatable { /// You can set [dedeplicate] to true (default is false) to reduce the save operation. /// It's useful when you call this method when user editing the [TextField]. /// The default debounce interval is 300 milliseconds. - void saveCellData(D data, {bool deduplicate = false, void Function(Option)? resultCallback}) async { + void saveCellData(D data, + {bool deduplicate = false, + void Function(Option)? resultCallback}) async { if (deduplicate) { _loadDataOperation?.cancel(); @@ -288,7 +300,8 @@ class IGridCellController extends Equatable { } @override - List get props => [_cellsCache.get(_cacheKey) ?? "", cellId.rowId + cellId.field.id]; + List get props => + [_cellsCache.get(_cacheKey) ?? "", cellId.rowId + cellId.field.id]; } class _GridFieldChangedNotifierImpl extends GridFieldChangedNotifier { @@ -300,7 +313,7 @@ class _GridFieldChangedNotifierImpl extends GridFieldChangedNotifier { @override void dispose() { if (_onChangesetFn != null) { - _cache.removeListener(onChangsetListener: _onChangesetFn!); + _cache.removeListener(onChangesetListener: _onChangesetFn!); _onChangesetFn = null; } } diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/checkbox_cell_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/checkbox_cell_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/checkbox_cell_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/checkbox_cell_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/date_cal_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/date_cal_bloc.dart similarity index 86% rename from frontend/app_flowy/lib/workspace/application/grid/cell/date_cal_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/date_cal_bloc.dart index d99bdbf817..85dbbb40be 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/cell/date_cal_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/date_cal_bloc.dart @@ -1,6 +1,7 @@ import 'package:app_flowy/generated/locale_keys.g.dart'; -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; -import 'package:easy_localization/easy_localization.dart' show StringTranslateExtension; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; +import 'package:easy_localization/easy_localization.dart' + show StringTranslateExtension; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-error-code/code.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; @@ -40,7 +41,8 @@ class DateCalBloc extends Bloc { }, didReceiveCellUpdate: (DateCellDataPB? cellData) { final calData = calDataFromCellData(cellData); - final time = calData.foldRight("", (dateData, previous) => dateData.time); + final time = + calData.foldRight("", (dateData, previous) => dateData.time); emit(state.copyWith(calData: calData, time: time)); }, setIncludeTime: (includeTime) async { @@ -57,15 +59,18 @@ class DateCalBloc extends Bloc { await _updateDateData(emit, time: time); } }, - didUpdateCalData: (Option data, Option timeFormatError) { - emit(state.copyWith(calData: data, timeFormatError: timeFormatError)); + didUpdateCalData: + (Option data, Option timeFormatError) { + emit(state.copyWith( + calData: data, timeFormatError: timeFormatError)); }, ); }, ); } - Future _updateDateData(Emitter emit, {DateTime? date, String? time}) { + Future _updateDateData(Emitter emit, + {DateTime? date, String? time}) { final CalendarData newDateData = state.calData.fold( () => CalendarData(date: date ?? DateTime.now(), time: time), (dateData) { @@ -84,13 +89,17 @@ class DateCalBloc extends Bloc { return _saveDateData(emit, newDateData); } - Future _saveDateData(Emitter emit, CalendarData newCalData) async { + Future _saveDateData( + Emitter emit, CalendarData newCalData) async { if (state.calData == Some(newCalData)) { return; } - updateCalData(Option calData, Option timeFormatError) { - if (!isClosed) add(DateCalEvent.didUpdateCalData(calData, timeFormatError)); + updateCalData( + Option calData, Option timeFormatError) { + if (!isClosed) { + add(DateCalEvent.didUpdateCalData(calData, timeFormatError)); + } } cellContext.saveCellData(newCalData, resultCallback: (result) { @@ -172,7 +181,9 @@ class DateCalBloc extends Bloc { ); result.fold( - (l) => emit(state.copyWith(dateTypeOption: newDateTypeOption, timeHintText: _timeHintText(newDateTypeOption))), + (l) => emit(state.copyWith( + dateTypeOption: newDateTypeOption, + timeHintText: _timeHintText(newDateTypeOption))), (err) => Log.error(err), ); } @@ -182,14 +193,17 @@ class DateCalBloc extends Bloc { class DateCalEvent with _$DateCalEvent { const factory DateCalEvent.initial() = _Initial; const factory DateCalEvent.selectDay(DateTime day) = _SelectDay; - const factory DateCalEvent.setCalFormat(CalendarFormat format) = _CalendarFormat; + const factory DateCalEvent.setCalFormat(CalendarFormat format) = + _CalendarFormat; const factory DateCalEvent.setFocusedDay(DateTime day) = _FocusedDay; const factory DateCalEvent.setTimeFormat(TimeFormat timeFormat) = _TimeFormat; const factory DateCalEvent.setDateFormat(DateFormat dateFormat) = _DateFormat; const factory DateCalEvent.setIncludeTime(bool includeTime) = _IncludeTime; const factory DateCalEvent.setTime(String time) = _Time; - const factory DateCalEvent.didReceiveCellUpdate(DateCellDataPB? data) = _DidReceiveCellUpdate; - const factory DateCalEvent.didUpdateCalData(Option data, Option timeFormatError) = + const factory DateCalEvent.didReceiveCellUpdate(DateCellDataPB? data) = + _DidReceiveCellUpdate; + const factory DateCalEvent.didUpdateCalData( + Option data, Option timeFormatError) = _DidUpdateCalData; } diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/date_cell_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/date_cell_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/date_cell_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/date_cell_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/number_cell_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/number_cell_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/number_cell_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/number_cell_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/select_option_cell_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_cell_bloc.dart similarity index 87% rename from frontend/app_flowy/lib/workspace/application/grid/cell/select_option_cell_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/select_option_cell_bloc.dart index d0db8669fa..d823568e17 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/cell/select_option_cell_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_cell_bloc.dart @@ -2,11 +2,12 @@ import 'dart:async'; import 'package:flowy_sdk/protobuf/flowy-grid/select_option.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; part 'select_option_cell_bloc.freezed.dart'; -class SelectOptionCellBloc extends Bloc { +class SelectOptionCellBloc + extends Bloc { final GridSelectOptionCellController cellContext; void Function()? _onCellChangedFn; @@ -66,7 +67,8 @@ class SelectOptionCellState with _$SelectOptionCellState { required List selectedOptions, }) = _SelectOptionCellState; - factory SelectOptionCellState.initial(GridSelectOptionCellController context) { + factory SelectOptionCellState.initial( + GridSelectOptionCellController context) { final data = context.getCellData(); return SelectOptionCellState( diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/select_option_editor_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_editor_bloc.dart similarity index 84% rename from frontend/app_flowy/lib/workspace/application/grid/cell/select_option_editor_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/select_option_editor_bloc.dart index 0990dca28a..6ee7fe9f32 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/cell/select_option_editor_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_editor_bloc.dart @@ -4,20 +4,22 @@ import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/select_option.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; import 'select_option_service.dart'; import 'package:collection/collection.dart'; part 'select_option_editor_bloc.freezed.dart'; -class SelectOptionCellEditorBloc extends Bloc { +class SelectOptionCellEditorBloc + extends Bloc { final SelectOptionService _selectOptionService; final GridSelectOptionCellController cellController; Timer? _delayOperation; SelectOptionCellEditorBloc({ required this.cellController, - }) : _selectOptionService = SelectOptionService(cellId: cellController.cellId), + }) : _selectOptionService = + SelectOptionService(cellId: cellController.cellId), super(SelectOptionEditorState.initial(cellController)) { on( (event, emit) async { @@ -87,7 +89,8 @@ class SelectOptionCellEditorBloc extends Bloc option.id == optionId); + final hasSelected = state.selectedOptions + .firstWhereOrNull((option) => option.id == optionId); if (hasSelected != null) { _selectOptionService.unSelect(optionId: optionId); } else { @@ -96,7 +99,8 @@ class SelectOptionCellEditorBloc extends Bloc emit) { - final _MakeOptionResult result = _makeOptions(Some(optionName), state.allOptions); + final _MakeOptionResult result = + _makeOptions(Some(optionName), state.allOptions); emit(state.copyWith( filter: Some(optionName), options: result.options, @@ -112,7 +116,8 @@ class SelectOptionCellEditorBloc extends Bloc add(SelectOptionEditorEvent.didReceiveOptions(data.options, data.selectOptions)), + (data) => add(SelectOptionEditorEvent.didReceiveOptions( + data.options, data.selectOptions)), (err) { Log.error(err); return null; @@ -122,7 +127,8 @@ class SelectOptionCellEditorBloc extends Bloc filter, List allOptions) { + _MakeOptionResult _makeOptions( + Option filter, List allOptions) { final List options = List.from(allOptions); Option createOption = filter; @@ -165,12 +171,18 @@ class SelectOptionCellEditorBloc extends Bloc options, List selectedOptions) = _DidReceiveOptions; - const factory SelectOptionEditorEvent.newOption(String optionName) = _NewOption; - const factory SelectOptionEditorEvent.selectOption(String optionId) = _SelectOption; - const factory SelectOptionEditorEvent.updateOption(SelectOptionPB option) = _UpdateOption; - const factory SelectOptionEditorEvent.deleteOption(SelectOptionPB option) = _DeleteOption; - const factory SelectOptionEditorEvent.filterOption(String optionName) = _SelectOptionFilter; + List options, List selectedOptions) = + _DidReceiveOptions; + const factory SelectOptionEditorEvent.newOption(String optionName) = + _NewOption; + const factory SelectOptionEditorEvent.selectOption(String optionId) = + _SelectOption; + const factory SelectOptionEditorEvent.updateOption(SelectOptionPB option) = + _UpdateOption; + const factory SelectOptionEditorEvent.deleteOption(SelectOptionPB option) = + _DeleteOption; + const factory SelectOptionEditorEvent.filterOption(String optionName) = + _SelectOptionFilter; } @freezed @@ -183,7 +195,8 @@ class SelectOptionEditorState with _$SelectOptionEditorState { required Option filter, }) = _SelectOptionEditorState; - factory SelectOptionEditorState.initial(GridSelectOptionCellController context) { + factory SelectOptionEditorState.initial( + GridSelectOptionCellController context) { final data = context.getCellData(loadIfNotExist: false); return SelectOptionEditorState( options: data?.options ?? [], diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/select_option_service.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_service.dart similarity index 92% rename from frontend/app_flowy/lib/workspace/application/grid/cell/select_option_service.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/select_option_service.dart index b6966a3e4e..9172450ef0 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/cell/select_option_service.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_service.dart @@ -2,7 +2,7 @@ import 'package:dartz/dartz.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/cell_entities.pb.dart'; -import 'package:app_flowy/workspace/application/grid/field/type_option/type_option_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_service.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/select_option.pb.dart'; import 'cell_service/cell_service.dart'; @@ -15,7 +15,9 @@ class SelectOptionService { String get rowId => cellId.rowId; Future> create({required String name}) { - return TypeOptionService(gridId: gridId, fieldId: fieldId).newOption(name: name).then( + return TypeOptionService(gridId: gridId, fieldId: fieldId) + .newOption(name: name) + .then( (result) { return result.fold( (option) { diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/text_cell_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/text_cell_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/text_cell_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/text_cell_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/url_cell_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/url_cell_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/url_cell_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/url_cell_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/url_cell_editor_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/url_cell_editor_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/cell/url_cell_editor_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/cell/url_cell_editor_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/field_action_sheet_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/field_action_sheet_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/field_action_sheet_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/field_action_sheet_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/field_cell_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/field_cell_bloc.dart similarity index 86% rename from frontend/app_flowy/lib/workspace/application/grid/field/field_cell_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/field_cell_bloc.dart index 8a2a0e2d06..ce09ba20bf 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/field/field_cell_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/field/field_cell_bloc.dart @@ -1,5 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/field/field_listener.dart'; -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_listener.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -15,7 +15,8 @@ class FieldCellBloc extends Bloc { FieldCellBloc({ required GridFieldCellContext cellContext, }) : _fieldListener = SingleFieldListener(fieldId: cellContext.field.id), - _fieldService = FieldService(gridId: cellContext.gridId, fieldId: cellContext.field.id), + _fieldService = FieldService( + gridId: cellContext.gridId, fieldId: cellContext.field.id), super(FieldCellState.initial(cellContext)) { on( (event, emit) async { @@ -62,8 +63,10 @@ class FieldCellBloc extends Bloc { @freezed class FieldCellEvent with _$FieldCellEvent { const factory FieldCellEvent.initial() = _InitialCell; - const factory FieldCellEvent.didReceiveFieldUpdate(GridFieldPB field) = _DidReceiveFieldUpdate; - const factory FieldCellEvent.startUpdateWidth(double offset) = _StartUpdateWidth; + const factory FieldCellEvent.didReceiveFieldUpdate(GridFieldPB field) = + _DidReceiveFieldUpdate; + const factory FieldCellEvent.startUpdateWidth(double offset) = + _StartUpdateWidth; const factory FieldCellEvent.endUpdateWidth() = _EndUpdateWidth; } @@ -75,7 +78,8 @@ class FieldCellState with _$FieldCellState { required double width, }) = _FieldCellState; - factory FieldCellState.initial(GridFieldCellContext cellContext) => FieldCellState( + factory FieldCellState.initial(GridFieldCellContext cellContext) => + FieldCellState( gridId: cellContext.gridId, field: cellContext.field, width: cellContext.field.width.toDouble(), diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/field_editor_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/field_editor_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/field_editor_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/field_editor_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/field_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/field/field_listener.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/field_listener.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/field_listener.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/field_service.dart b/frontend/app_flowy/lib/plugins/grid/application/field/field_service.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/field_service.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/field_service.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/field_type_option_edit_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/field_type_option_edit_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/field_type_option_edit_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/field_type_option_edit_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/grid_header_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/field/grid_header_listener.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/grid_header_listener.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/grid_header_listener.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/grid_listenr.dart b/frontend/app_flowy/lib/plugins/grid/application/field/grid_listener.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/grid_listenr.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/grid_listener.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/date_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/date_bloc.dart similarity index 76% rename from frontend/app_flowy/lib/workspace/application/grid/field/type_option/date_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/type_option/date_bloc.dart index 00deff56e7..f995a0bad0 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/date_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/date_bloc.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/type_option_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_service.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/date_type_option.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/date_type_option_entities.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -16,20 +16,24 @@ class DateTypeOptionDataParser extends TypeOptionDataParser { } } -class DateTypeOptionBloc extends Bloc { +class DateTypeOptionBloc + extends Bloc { DateTypeOptionBloc({required DateTypeOptionContext typeOptionContext}) : super(DateTypeOptionState.initial(typeOptionContext.typeOption)) { on( (event, emit) async { event.map( didSelectDateFormat: (_DidSelectDateFormat value) { - emit(state.copyWith(typeOption: _updateTypeOption(dateFormat: value.format))); + emit(state.copyWith( + typeOption: _updateTypeOption(dateFormat: value.format))); }, didSelectTimeFormat: (_DidSelectTimeFormat value) { - emit(state.copyWith(typeOption: _updateTypeOption(timeFormat: value.format))); + emit(state.copyWith( + typeOption: _updateTypeOption(timeFormat: value.format))); }, includeTime: (_IncludeTime value) { - emit(state.copyWith(typeOption: _updateTypeOption(includeTime: value.includeTime))); + emit(state.copyWith( + typeOption: _updateTypeOption(includeTime: value.includeTime))); }, ); }, @@ -65,9 +69,12 @@ class DateTypeOptionBloc extends Bloc @freezed class DateTypeOptionEvent with _$DateTypeOptionEvent { - const factory DateTypeOptionEvent.didSelectDateFormat(DateFormat format) = _DidSelectDateFormat; - const factory DateTypeOptionEvent.didSelectTimeFormat(TimeFormat format) = _DidSelectTimeFormat; - const factory DateTypeOptionEvent.includeTime(bool includeTime) = _IncludeTime; + const factory DateTypeOptionEvent.didSelectDateFormat(DateFormat format) = + _DidSelectDateFormat; + const factory DateTypeOptionEvent.didSelectTimeFormat(TimeFormat format) = + _DidSelectTimeFormat; + const factory DateTypeOptionEvent.includeTime(bool includeTime) = + _IncludeTime; } @freezed @@ -76,5 +83,6 @@ class DateTypeOptionState with _$DateTypeOptionState { required DateTypeOption typeOption, }) = _DateTypeOptionState; - factory DateTypeOptionState.initial(DateTypeOption typeOption) => DateTypeOptionState(typeOption: typeOption); + factory DateTypeOptionState.initial(DateTypeOption typeOption) => + DateTypeOptionState(typeOption: typeOption); } diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/edit_select_option_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/edit_select_option_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/type_option/edit_select_option_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/type_option/edit_select_option_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/multi_select_type_option.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/multi_select_type_option.dart similarity index 81% rename from frontend/app_flowy/lib/workspace/application/grid/field/type_option/multi_select_type_option.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/type_option/multi_select_type_option.dart index e0e242305b..ebc88aaf95 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/multi_select_type_option.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/multi_select_type_option.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/multi_select_type_option.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/select_option.pb.dart'; @@ -7,7 +7,8 @@ import 'package:protobuf/protobuf.dart'; import 'select_option_type_option_bloc.dart'; import 'type_option_service.dart'; -class MultiSelectTypeOptionContext extends TypeOptionWidgetContext +class MultiSelectTypeOptionContext + extends TypeOptionWidgetContext with SelectOptionTypeOptionAction { final TypeOptionService service; @@ -25,7 +26,8 @@ class MultiSelectTypeOptionContext extends TypeOptionWidgetContext element.id == option.id); + final index = + typeOption.options.indexWhere((element) => element.id == option.id); if (index != -1) { typeOption.options.removeAt(index); } @@ -61,7 +63,8 @@ class MultiSelectTypeOptionContext extends TypeOptionWidgetContext element.id == option.id); + final index = + typeOption.options.indexWhere((element) => element.id == option.id); if (index != -1) { typeOption.options[index] = option; } @@ -71,7 +74,8 @@ class MultiSelectTypeOptionContext extends TypeOptionWidgetContext { +class MultiSelectTypeOptionWidgetDataParser + extends TypeOptionDataParser { @override MultiSelectTypeOption fromBuffer(List buffer) { return MultiSelectTypeOption.fromBuffer(buffer); diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/number_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/number_bloc.dart similarity index 82% rename from frontend/app_flowy/lib/workspace/application/grid/field/type_option/number_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/type_option/number_bloc.dart index 804ce3ee11..7228adf90e 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/number_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/number_bloc.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/type_option_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_service.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/format.pbenum.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/number_type_option.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -10,14 +10,16 @@ part 'number_bloc.freezed.dart'; typedef NumberTypeOptionContext = TypeOptionWidgetContext; -class NumberTypeOptionWidgetDataParser extends TypeOptionDataParser { +class NumberTypeOptionWidgetDataParser + extends TypeOptionDataParser { @override NumberTypeOption fromBuffer(List buffer) { return NumberTypeOption.fromBuffer(buffer); } } -class NumberTypeOptionBloc extends Bloc { +class NumberTypeOptionBloc + extends Bloc { NumberTypeOptionBloc({required NumberTypeOptionContext typeOptionContext}) : super(NumberTypeOptionState.initial(typeOptionContext.typeOption)) { on( @@ -46,7 +48,8 @@ class NumberTypeOptionBloc extends Bloc NumberTypeOptionState( + factory NumberTypeOptionState.initial(NumberTypeOption typeOption) => + NumberTypeOptionState( typeOption: typeOption, ); } diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/number_format_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/number_format_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/type_option/number_format_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/type_option/number_format_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/select_option_type_option_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/select_option_type_option_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/field/type_option/select_option_type_option_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/type_option/select_option_type_option_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/single_select_type_option.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/single_select_type_option.dart similarity index 81% rename from frontend/app_flowy/lib/workspace/application/grid/field/type_option/single_select_type_option.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/type_option/single_select_type_option.dart index 857838de38..bdf89b5b78 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/single_select_type_option.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/single_select_type_option.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/select_option.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/single_select_type_option.pb.dart'; @@ -7,7 +7,8 @@ import 'package:protobuf/protobuf.dart'; import 'select_option_type_option_bloc.dart'; import 'type_option_service.dart'; -class SingleSelectTypeOptionContext extends TypeOptionWidgetContext +class SingleSelectTypeOptionContext + extends TypeOptionWidgetContext with SelectOptionTypeOptionAction { final TypeOptionService service; @@ -25,7 +26,8 @@ class SingleSelectTypeOptionContext extends TypeOptionWidgetContext element.id == option.id); + final index = + typeOption.options.indexWhere((element) => element.id == option.id); if (index != -1) { typeOption.options.removeAt(index); } @@ -61,7 +63,8 @@ class SingleSelectTypeOptionContext extends TypeOptionWidgetContext element.id == option.id); + final index = + typeOption.options.indexWhere((element) => element.id == option.id); if (index != -1) { typeOption.options[index] = option; } @@ -71,7 +74,8 @@ class SingleSelectTypeOptionContext extends TypeOptionWidgetContext { +class SingleSelectTypeOptionWidgetDataParser + extends TypeOptionDataParser { @override SingleSelectTypeOptionPB fromBuffer(List buffer) { return SingleSelectTypeOptionPB.fromBuffer(buffer); diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/type_option_service.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/type_option_service.dart similarity index 93% rename from frontend/app_flowy/lib/workspace/application/grid/field/type_option/type_option_service.dart rename to frontend/app_flowy/lib/plugins/grid/application/field/type_option/type_option_service.dart index fca6995b3f..d7873e0c86 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/field/type_option/type_option_service.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/type_option_service.dart @@ -1,6 +1,6 @@ import 'dart:typed_data'; -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; import 'package:dartz/dartz.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; @@ -92,7 +92,9 @@ class TypeOptionContext2 { return Future(() => left(_data!)); } - return _fieldService.getFieldTypeOptionData(fieldType: field.fieldType).then((result) { + return _fieldService + .getFieldTypeOptionData(fieldType: field.fieldType) + .then((result) { return result.fold( (data) { _data = dataBuilder.fromBuffer(data.typeOptionData); diff --git a/frontend/app_flowy/lib/workspace/application/grid/grid_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/grid_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/grid_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/grid_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/grid_header_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/grid_header_bloc.dart similarity index 83% rename from frontend/app_flowy/lib/workspace/application/grid/grid_header_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/grid_header_bloc.dart index b34064da13..06a6b791d8 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/grid_header_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/grid_header_bloc.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -33,7 +33,8 @@ class GridHeaderBloc extends Bloc { ); } - Future _moveField(_MoveField value, Emitter emit) async { + Future _moveField( + _MoveField value, Emitter emit) async { final fields = List.from(state.fields); fields.insert(value.toIndex, fields.removeAt(value.fromIndex)); emit(state.copyWith(fields: fields)); @@ -62,13 +63,16 @@ class GridHeaderBloc extends Bloc { @freezed class GridHeaderEvent with _$GridHeaderEvent { const factory GridHeaderEvent.initial() = _InitialHeader; - const factory GridHeaderEvent.didReceiveFieldUpdate(List fields) = _DidReceiveFieldUpdate; - const factory GridHeaderEvent.moveField(GridFieldPB field, int fromIndex, int toIndex) = _MoveField; + const factory GridHeaderEvent.didReceiveFieldUpdate( + List fields) = _DidReceiveFieldUpdate; + const factory GridHeaderEvent.moveField( + GridFieldPB field, int fromIndex, int toIndex) = _MoveField; } @freezed class GridHeaderState with _$GridHeaderState { - const factory GridHeaderState({required List fields}) = _GridHeaderState; + const factory GridHeaderState({required List fields}) = + _GridHeaderState; factory GridHeaderState.initial(List fields) { // final List newFields = List.from(fields); diff --git a/frontend/app_flowy/lib/workspace/application/grid/grid_service.dart b/frontend/app_flowy/lib/plugins/grid/application/grid_service.dart similarity index 86% rename from frontend/app_flowy/lib/workspace/application/grid/grid_service.dart rename to frontend/app_flowy/lib/plugins/grid/application/grid_service.dart index 1f8b4336fc..dff03f636e 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/grid_service.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/grid_service.dart @@ -1,6 +1,6 @@ import 'dart:collection'; -import 'package:app_flowy/workspace/application/grid/field/grid_listenr.dart'; +import 'package:app_flowy/plugins/grid/application/field/grid_listener.dart'; import 'package:dartz/dartz.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart'; import 'package:flowy_sdk/log.dart'; @@ -26,13 +26,15 @@ class GridService { return GridEventGetGrid(payload).send(); } - Future> createRow({Option? startRowId}) { + Future> createRow( + {Option? startRowId}) { CreateRowPayloadPB payload = CreateRowPayloadPB.create()..gridId = gridId; startRowId?.fold(() => null, (id) => payload.startRowId = id); return GridEventCreateRow(payload).send(); } - Future> getFields({required List fieldIds}) { + Future> getFields( + {required List fieldIds}) { final payload = QueryFieldPayloadPB.create() ..gridId = gridId ..fieldIds = RepeatedGridFieldIdPB(items: fieldIds); @@ -64,9 +66,11 @@ class GridFieldCache { final GridFieldsListener _fieldListener; FieldsNotifier? _fieldNotifier = FieldsNotifier(); final Map _fieldsCallbackMap = {}; - final Map _changesetCallbackMap = {}; + final Map + _changesetCallbackMap = {}; - GridFieldCache({required this.gridId}) : _fieldListener = GridFieldsListener(gridId: gridId) { + GridFieldCache({required this.gridId}) + : _fieldListener = GridFieldsListener(gridId: gridId) { _fieldListener.start(onFieldsChanged: (result) { result.fold( (changeset) { @@ -88,7 +92,8 @@ class GridFieldCache { _fieldNotifier = null; } - UnmodifiableListView get unmodifiableFields => UnmodifiableListView(_fieldNotifier?.fields ?? []); + UnmodifiableListView get unmodifiableFields => + UnmodifiableListView(_fieldNotifier?.fields ?? []); List get fields => [..._fieldNotifier?.fields ?? []]; @@ -127,7 +132,7 @@ class GridFieldCache { void removeListener({ FieldsCallback? onFieldsListener, - FieldChangesetCallback? onChangsetListener, + FieldChangesetCallback? onChangesetListener, }) { if (onFieldsListener != null) { final fn = _fieldsCallbackMap.remove(onFieldsListener); @@ -136,8 +141,8 @@ class GridFieldCache { } } - if (onChangsetListener != null) { - _changesetCallbackMap.remove(onChangsetListener); + if (onChangesetListener != null) { + _changesetCallbackMap.remove(onChangesetListener); } } @@ -175,7 +180,8 @@ class GridFieldCache { } final List newFields = fields; for (final updatedField in updatedFields) { - final index = newFields.indexWhere((field) => field.id == updatedField.id); + final index = + newFields.indexWhere((field) => field.id == updatedField.id); if (index != -1) { newFields.removeAt(index); newFields.insert(index, updatedField); @@ -219,7 +225,7 @@ class GridRowCacheFieldNotifierImpl extends GridRowCacheFieldNotifier { } if (_onChangesetFn != null) { - _cache.removeListener(onChangsetListener: _onChangesetFn!); + _cache.removeListener(onChangesetListener: _onChangesetFn!); _onChangesetFn = null; } } diff --git a/frontend/app_flowy/lib/workspace/application/grid/prelude.dart b/frontend/app_flowy/lib/plugins/grid/application/prelude.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/prelude.dart rename to frontend/app_flowy/lib/plugins/grid/application/prelude.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/row/row_action_sheet_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/row/row_action_sheet_bloc.dart similarity index 86% rename from frontend/app_flowy/lib/workspace/application/grid/row/row_action_sheet_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/row/row_action_sheet_bloc.dart index 9fe12f3ff5..7881e485cb 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/row/row_action_sheet_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/row/row_action_sheet_bloc.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/row/row_service.dart'; +import 'package:app_flowy/plugins/grid/application/row/row_service.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -8,7 +8,8 @@ import 'package:dartz/dartz.dart'; part 'row_action_sheet_bloc.freezed.dart'; -class RowActionSheetBloc extends Bloc { +class RowActionSheetBloc + extends Bloc { final RowService _rowService; RowActionSheetBloc({required GridRowInfo rowData}) @@ -56,7 +57,8 @@ class RowActionSheetState with _$RowActionSheetState { required GridRowInfo rowData, }) = _RowActionSheetState; - factory RowActionSheetState.initial(GridRowInfo rowData) => RowActionSheetState( + factory RowActionSheetState.initial(GridRowInfo rowData) => + RowActionSheetState( rowData: rowData, ); } diff --git a/frontend/app_flowy/lib/workspace/application/grid/row/row_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/row/row_bloc.dart similarity index 81% rename from frontend/app_flowy/lib/workspace/application/grid/row/row_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/row/row_bloc.dart index 1d7224383d..3b755d1524 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/row/row_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/row/row_bloc.dart @@ -1,5 +1,5 @@ import 'dart:collection'; -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; import 'package:equatable/equatable.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -34,7 +34,9 @@ class RowBloc extends Bloc { _rowService.createRow(); }, didReceiveCellDatas: (_DidReceiveCellDatas value) async { - final fields = value.gridCellMap.values.map((e) => GridCellEquatable(e.field)).toList(); + final fields = value.gridCellMap.values + .map((e) => GridCellEquatable(e.field)) + .toList(); final snapshots = UnmodifiableListView(fields); emit(state.copyWith( gridCellMap: value.gridCellMap, @@ -59,7 +61,8 @@ class RowBloc extends Bloc { Future _startListening() async { _rowListenFn = _rowCache.addListener( rowId: state.rowInfo.id, - onCellUpdated: (cellDatas, reason) => add(RowEvent.didReceiveCellDatas(cellDatas, reason)), + onCellUpdated: (cellDatas, reason) => + add(RowEvent.didReceiveCellDatas(cellDatas, reason)), listenWhen: () => !isClosed, ); } @@ -69,7 +72,8 @@ class RowBloc extends Bloc { class RowEvent with _$RowEvent { const factory RowEvent.initial() = _InitialRow; const factory RowEvent.createRow() = _CreateRow; - const factory RowEvent.didReceiveCellDatas(GridCellMap gridCellMap, GridRowChangeReason reason) = + const factory RowEvent.didReceiveCellDatas( + GridCellMap gridCellMap, GridRowChangeReason reason) = _DidReceiveCellDatas; } @@ -82,10 +86,12 @@ class RowState with _$RowState { GridRowChangeReason? changeReason, }) = _RowState; - factory RowState.initial(GridRowInfo rowInfo, GridCellMap cellDataMap) => RowState( + factory RowState.initial(GridRowInfo rowInfo, GridCellMap cellDataMap) => + RowState( rowInfo: rowInfo, gridCellMap: cellDataMap, - snapshots: UnmodifiableListView(cellDataMap.values.map((e) => GridCellEquatable(e.field)).toList()), + snapshots: UnmodifiableListView( + cellDataMap.values.map((e) => GridCellEquatable(e.field)).toList()), ); } diff --git a/frontend/app_flowy/lib/workspace/application/grid/row/row_detail_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/row/row_detail_bloc.dart similarity index 84% rename from frontend/app_flowy/lib/workspace/application/grid/row/row_detail_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/row/row_detail_bloc.dart index 966310fe8c..900b56f9a5 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/row/row_detail_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/row/row_detail_bloc.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'dart:async'; @@ -42,7 +42,8 @@ class RowDetailBloc extends Bloc { Future _startListening() async { _rowListenFn = _rowCache.addListener( rowId: rowInfo.id, - onCellUpdated: (cellDatas, reason) => add(RowDetailEvent.didReceiveCellDatas(cellDatas.values.toList())), + onCellUpdated: (cellDatas, reason) => + add(RowDetailEvent.didReceiveCellDatas(cellDatas.values.toList())), listenWhen: () => !isClosed, ); } @@ -58,7 +59,8 @@ class RowDetailBloc extends Bloc { @freezed class RowDetailEvent with _$RowDetailEvent { const factory RowDetailEvent.initial() = _Initial; - const factory RowDetailEvent.didReceiveCellDatas(List gridCells) = _DidReceiveCellDatas; + const factory RowDetailEvent.didReceiveCellDatas( + List gridCells) = _DidReceiveCellDatas; } @freezed diff --git a/frontend/app_flowy/lib/workspace/application/grid/row/row_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/row/row_listener.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/row/row_listener.dart rename to frontend/app_flowy/lib/plugins/grid/application/row/row_listener.dart diff --git a/frontend/app_flowy/lib/workspace/application/grid/row/row_service.dart b/frontend/app_flowy/lib/plugins/grid/application/row/row_service.dart similarity index 90% rename from frontend/app_flowy/lib/workspace/application/grid/row/row_service.dart rename to frontend/app_flowy/lib/plugins/grid/application/row/row_service.dart index 893ebb719b..4fd18a1fdd 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/row/row_service.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/row/row_service.dart @@ -1,5 +1,5 @@ import 'dart:collection'; -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; import 'package:dartz/dartz.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart'; import 'package:flowy_sdk/log.dart'; @@ -53,9 +53,12 @@ class GridRowCache { _rowChangeReasonNotifier = _GridRowChangesetNotifier(), _fieldNotifier = notifier { // - notifier.onFieldsChanged(() => _rowChangeReasonNotifier.receive(const GridRowChangeReason.fieldDidChange())); + notifier.onFieldsChanged(() => _rowChangeReasonNotifier + .receive(const GridRowChangeReason.fieldDidChange())); notifier.onFieldChanged((field) => _cellCache.remove(field.id)); - _rowInfos = block.rows.map((rowInfo) => buildGridRow(rowInfo.id, rowInfo.height.toDouble())).toList(); + _rowInfos = block.rows + .map((rowInfo) => buildGridRow(rowInfo.id, rowInfo.height.toDouble())) + .toList(); } Future dispose() async { @@ -81,7 +84,9 @@ class GridRowCache { final List newRows = []; final DeletedIndexs deletedIndex = []; - final Map deletedRowByRowId = {for (var rowId in deletedRows) rowId: rowId}; + final Map deletedRowByRowId = { + for (var rowId in deletedRows) rowId: rowId + }; _rowInfos.asMap().forEach((index, row) { if (deletedRowByRowId[row.id] == null) { @@ -107,7 +112,8 @@ class GridRowCache { rowId: insertRow.rowId, ); insertIndexs.add(insertIndex); - _rowInfos.insert(insertRow.index, (buildGridRow(insertRow.rowId, insertRow.height.toDouble()))); + _rowInfos.insert(insertRow.index, + (buildGridRow(insertRow.rowId, insertRow.height.toDouble()))); } _rowChangeReasonNotifier.receive(GridRowChangeReason.insert(insertIndexs)); @@ -126,7 +132,8 @@ class GridRowCache { _rowByRowId[rowId] = updatedRow.row; _rowInfos.removeAt(index); - _rowInfos.insert(index, buildGridRow(rowId, updatedRow.row.height.toDouble())); + _rowInfos.insert( + index, buildGridRow(rowId, updatedRow.row.height.toDouble())); updatedIndexs[rowId] = UpdatedIndex(index: index, rowId: rowId); } } @@ -225,7 +232,8 @@ class GridRowCache { updatedRow.freeze(); _rowByRowId[updatedRow.id] = updatedRow; - final index = _rowInfos.indexWhere((gridRow) => gridRow.id == updatedRow.id); + final index = + _rowInfos.indexWhere((gridRow) => gridRow.id == updatedRow.id); if (index != -1) { // update the corresponding row in _rows if they are not the same if (_rowInfos[index].rawRow != updatedRow) { @@ -237,7 +245,8 @@ class GridRowCache { updatedIndexs[row.id] = UpdatedIndex(index: index, rowId: row.id); // - _rowChangeReasonNotifier.receive(GridRowChangeReason.update(updatedIndexs)); + _rowChangeReasonNotifier + .receive(GridRowChangeReason.update(updatedIndexs)); } } } @@ -275,7 +284,8 @@ class RowService { final String blockId; final String rowId; - RowService({required this.gridId, required this.blockId, required this.rowId}); + RowService( + {required this.gridId, required this.blockId, required this.rowId}); Future> createRow() { CreateRowPayloadPB payload = CreateRowPayloadPB.create() @@ -285,7 +295,8 @@ class RowService { return GridEventCreateRow(payload).send(); } - Future> moveRow(String rowId, int fromIndex, int toIndex) { + Future> moveRow( + String rowId, int fromIndex, int toIndex) { final payload = MoveItemPayloadPB.create() ..gridId = gridId ..itemId = rowId diff --git a/frontend/app_flowy/lib/workspace/application/grid/setting/property_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/setting/property_bloc.dart similarity index 73% rename from frontend/app_flowy/lib/workspace/application/grid/setting/property_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/setting/property_bloc.dart index ee16eb0455..7c185279ae 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/setting/property_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/setting/property_bloc.dart @@ -1,5 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; -import 'package:app_flowy/workspace/application/grid/grid_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/grid_service.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -22,8 +22,10 @@ class GridPropertyBloc extends Bloc { _startListening(); }, setFieldVisibility: (_SetFieldVisibility value) async { - final fieldService = FieldService(gridId: gridId, fieldId: value.fieldId); - final result = await fieldService.updateField(visibility: value.visibility); + final fieldService = + FieldService(gridId: gridId, fieldId: value.fieldId); + final result = + await fieldService.updateField(visibility: value.visibility); result.fold( (l) => null, (err) => Log.error(err), @@ -50,7 +52,8 @@ class GridPropertyBloc extends Bloc { } void _startListening() { - _onFieldsFn = (fields) => add(GridPropertyEvent.didReceiveFieldUpdate(fields)); + _onFieldsFn = + (fields) => add(GridPropertyEvent.didReceiveFieldUpdate(fields)); _fieldCache.addListener( onFields: _onFieldsFn, listenWhen: () => !isClosed, @@ -61,9 +64,12 @@ class GridPropertyBloc extends Bloc { @freezed class GridPropertyEvent with _$GridPropertyEvent { const factory GridPropertyEvent.initial() = _Initial; - const factory GridPropertyEvent.setFieldVisibility(String fieldId, bool visibility) = _SetFieldVisibility; - const factory GridPropertyEvent.didReceiveFieldUpdate(List fields) = _DidReceiveFieldUpdate; - const factory GridPropertyEvent.moveField(int fromIndex, int toIndex) = _MoveField; + const factory GridPropertyEvent.setFieldVisibility( + String fieldId, bool visibility) = _SetFieldVisibility; + const factory GridPropertyEvent.didReceiveFieldUpdate( + List fields) = _DidReceiveFieldUpdate; + const factory GridPropertyEvent.moveField(int fromIndex, int toIndex) = + _MoveField; } @freezed @@ -73,7 +79,8 @@ class GridPropertyState with _$GridPropertyState { required List fields, }) = _GridPropertyState; - factory GridPropertyState.initial(String gridId, List fields) => GridPropertyState( + factory GridPropertyState.initial(String gridId, List fields) => + GridPropertyState( gridId: gridId, fields: fields, ); diff --git a/frontend/app_flowy/lib/workspace/application/grid/setting/setting_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/setting/setting_bloc.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/grid/setting/setting_bloc.dart rename to frontend/app_flowy/lib/plugins/grid/application/setting/setting_bloc.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/grid.dart b/frontend/app_flowy/lib/plugins/grid/grid.dart similarity index 90% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/grid.dart rename to frontend/app_flowy/lib/plugins/grid/grid.dart index 776dd833ea..c0c6d78642 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/grid.dart +++ b/frontend/app_flowy/lib/plugins/grid/grid.dart @@ -1,12 +1,12 @@ import 'package:app_flowy/generated/locale_keys.g.dart'; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; -import 'package:app_flowy/workspace/presentation/plugins/widgets/left_bar_item.dart'; +import 'package:app_flowy/workspace/presentation/widgets/left_bar_item.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter/material.dart'; -import 'src/grid_page.dart'; +import 'presentation/grid_page.dart'; class GridPluginBuilder implements PluginBuilder { @override diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/controller/flowy_table_selection.dart b/frontend/app_flowy/lib/plugins/grid/presentation/controller/flowy_table_selection.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/controller/flowy_table_selection.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/controller/flowy_table_selection.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/controller/grid_scroll.dart b/frontend/app_flowy/lib/plugins/grid/presentation/controller/grid_scroll.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/controller/grid_scroll.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/controller/grid_scroll.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/grid_page.dart b/frontend/app_flowy/lib/plugins/grid/presentation/grid_page.dart similarity index 87% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/grid_page.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/grid_page.dart index 4aae99acbe..ed6306a972 100755 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/grid_page.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/grid_page.dart @@ -1,6 +1,6 @@ import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/grid_bloc.dart'; -import 'package:app_flowy/workspace/application/grid/row/row_service.dart'; +import 'package:app_flowy/plugins/grid/application/grid_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/row/row_service.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart'; import 'package:flowy_infra_ui/style_widget/scrolling/styled_scroll_bar.dart'; @@ -35,13 +35,15 @@ class _GridPageState extends State { return MultiBlocProvider( providers: [ BlocProvider( - create: (context) => getIt(param1: widget.view)..add(const GridEvent.initial()), + create: (context) => getIt(param1: widget.view) + ..add(const GridEvent.initial()), ), ], child: BlocBuilder( builder: (context, state) { return state.loadingState.map( - loading: (_) => const Center(child: CircularProgressIndicator.adaptive()), + loading: (_) => + const Center(child: CircularProgressIndicator.adaptive()), finish: (result) => result.successOrFail.fold( (_) => const GridShortcuts(child: FlowyGrid()), (err) => FlowyErrorPage(err.toString()), @@ -76,7 +78,8 @@ class FlowyGrid extends StatefulWidget { } class _FlowyGridState extends State { - final _scrollController = GridScrollController(scrollGroupContorller: LinkedScrollControllerGroup()); + final _scrollController = GridScrollController( + scrollGroupContorller: LinkedScrollControllerGroup()); late ScrollController headerScrollController; @override @@ -204,7 +207,8 @@ class _GridRowsState extends State<_GridRows> { for (final item in value.items) { _key.currentState?.removeItem( item.index, - (context, animation) => _renderRow(context, item.row, animation), + (context, animation) => + _renderRow(context, item.row, animation), ); } }, @@ -215,8 +219,10 @@ class _GridRowsState extends State<_GridRows> { return SliverAnimatedList( key: _key, initialItemCount: context.read().state.rowInfos.length, - itemBuilder: (BuildContext context, int index, Animation animation) { - final GridRowInfo rowInfo = context.read().state.rowInfos[index]; + itemBuilder: + (BuildContext context, int index, Animation animation) { + final GridRowInfo rowInfo = + context.read().state.rowInfos[index]; return _renderRow(context, rowInfo, animation); }, ); @@ -229,7 +235,8 @@ class _GridRowsState extends State<_GridRows> { GridRowInfo rowInfo, Animation animation, ) { - final rowCache = context.read().getRowCache(rowInfo.blockId, rowInfo.id); + final rowCache = + context.read().getRowCache(rowInfo.blockId, rowInfo.id); final fieldCache = context.read().fieldCache; if (rowCache != null) { return SizeTransition( @@ -266,10 +273,10 @@ class _GridFooter extends StatelessWidget { SizedBox(width: GridSize.leadingHeaderPadding), Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ const SizedBox(width: 120, child: GridAddRowButton()), const SizedBox(height: 30), - _rowCountTextWidget(theme: theme,count: rowCount) + _rowCountTextWidget(theme: theme, count: rowCount) ], ), ], @@ -280,16 +287,18 @@ class _GridFooter extends StatelessWidget { ); } - Widget _rowCountTextWidget({required AppTheme theme, required int count}){ + Widget _rowCountTextWidget({required AppTheme theme, required int count}) { return Row( mainAxisAlignment: MainAxisAlignment.start, children: [ - FlowyText.regular('Count : ', - fontSize: 13, - color: theme.shader3, + FlowyText.regular( + 'Count : ', + fontSize: 13, + color: theme.shader3, ), - FlowyText.regular(count.toString(), - fontSize: 13, + FlowyText.regular( + count.toString(), + fontSize: 13, ), ], ); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/layout/layout.dart b/frontend/app_flowy/lib/plugins/grid/presentation/layout/layout.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/layout/layout.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/layout/layout.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/layout/sizes.dart b/frontend/app_flowy/lib/plugins/grid/presentation/layout/sizes.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/layout/sizes.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/layout/sizes.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_accessory.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_accessory.dart similarity index 85% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_accessory.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_accessory.dart index 88eadb39c4..e41f9bc9ac 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_accessory.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_accessory.dart @@ -1,11 +1,12 @@ import 'package:flowy_infra/image.dart'; import 'package:flowy_infra_ui/style_widget/hover.dart'; -import 'package:flutter/widgets.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:flowy_infra/size.dart'; import 'package:styled_widget/styled_widget.dart'; +import 'package:app_flowy/generated/locale_keys.g.dart'; +import 'package:easy_localization/easy_localization.dart'; class GridCellAccessoryBuildContext { final BuildContext anchorContext; @@ -39,7 +40,13 @@ class PrimaryCellAccessory extends StatelessWidget with GridCellAccessory { return const SizedBox(); } else { final theme = context.watch(); - return svgWidget("grid/expander", color: theme.main1); + return Tooltip( + message: LocaleKeys.tooltip_openAsPage.tr(), + child: svgWidget( + "grid/expander", + color: theme.main1, + ), + ); } } @@ -50,7 +57,8 @@ class PrimaryCellAccessory extends StatelessWidget with GridCellAccessory { bool enable() => !isCellEditing; } -typedef AccessoryBuilder = List Function(GridCellAccessoryBuildContext buildContext); +typedef AccessoryBuilder = List Function( + GridCellAccessoryBuildContext buildContext); abstract class CellAccessory extends Widget { const CellAccessory({Key? key}) : super(key: key); @@ -81,7 +89,8 @@ class _AccessoryHoverState extends State { @override void initState() { _hoverState = AccessoryHoverState(); - _listenerFn = () => _hoverState.onHover = widget.child.onAccessoryHover?.value ?? false; + _listenerFn = () => + _hoverState.onHover = widget.child.onAccessoryHover?.value ?? false; widget.child.onAccessoryHover?.addListener(_listenerFn!); super.initState(); @@ -159,7 +168,8 @@ class _Background extends StatelessWidget { builder: (context, state, child) { if (state.onHover) { return FlowyHoverContainer( - style: HoverStyle(borderRadius: Corners.s6Border, hoverColor: theme.shader6), + style: HoverStyle( + borderRadius: Corners.s6Border, hoverColor: theme.shader6), ); } else { return const SizedBox(); @@ -171,14 +181,17 @@ class _Background extends StatelessWidget { class CellAccessoryContainer extends StatelessWidget { final List accessories; - const CellAccessoryContainer({required this.accessories, Key? key}) : super(key: key); + const CellAccessoryContainer({required this.accessories, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { final theme = context.watch(); - final children = accessories.where((accessory) => accessory.enable()).map((accessory) { + final children = + accessories.where((accessory) => accessory.enable()).map((accessory) { final hover = FlowyHover( - style: HoverStyle(hoverColor: theme.bg3, backgroundColor: theme.surface), + style: + HoverStyle(hoverColor: theme.bg3, backgroundColor: theme.surface), builder: (_, onHover) => Container( width: 26, height: 26, diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_builder.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_builder.dart similarity index 77% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_builder.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_builder.dart index f785672f71..1913aac786 100755 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_builder.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_builder.dart @@ -1,5 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; -import 'package:app_flowy/workspace/application/grid/grid_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/grid_service.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; @@ -30,19 +30,36 @@ class GridCellBuilder { final key = cell.key(); switch (cell.fieldType) { case FieldType.Checkbox: - return GridCheckboxCell(cellControllerBuilder: cellControllerBuilder, key: key); + return GridCheckboxCell( + cellControllerBuilder: cellControllerBuilder, key: key); case FieldType.DateTime: - return GridDateCell(cellControllerBuilder: cellControllerBuilder, key: key, style: style); + return GridDateCell( + cellControllerBuilder: cellControllerBuilder, + key: key, + style: style); case FieldType.SingleSelect: - return GridSingleSelectCell(cellContorllerBuilder: cellControllerBuilder, style: style, key: key); + return GridSingleSelectCell( + cellContorllerBuilder: cellControllerBuilder, + style: style, + key: key); case FieldType.MultiSelect: - return GridMultiSelectCell(cellContorllerBuilder: cellControllerBuilder, style: style, key: key); + return GridMultiSelectCell( + cellContorllerBuilder: cellControllerBuilder, + style: style, + key: key); case FieldType.Number: - return GridNumberCell(cellContorllerBuilder: cellControllerBuilder, key: key); + return GridNumberCell( + cellContorllerBuilder: cellControllerBuilder, key: key); case FieldType.RichText: - return GridTextCell(cellContorllerBuilder: cellControllerBuilder, style: style, key: key); + return GridTextCell( + cellContorllerBuilder: cellControllerBuilder, + style: style, + key: key); case FieldType.URL: - return GridURLCell(cellContorllerBuilder: cellControllerBuilder, style: style, key: key); + return GridURLCell( + cellContorllerBuilder: cellControllerBuilder, + style: style, + key: key); } throw UnimplementedError; } @@ -65,7 +82,8 @@ abstract class CellEditable { ValueNotifier get onCellEditing; } -abstract class GridCellWidget extends StatefulWidget implements CellAccessory, CellEditable, CellShortcuts { +abstract class GridCellWidget extends StatefulWidget + implements CellAccessory, CellEditable, CellShortcuts { GridCellWidget({Key? key}) : super(key: key) { onCellEditing.addListener(() { onCellFocus.value = onCellEditing.value; @@ -83,7 +101,8 @@ abstract class GridCellWidget extends StatefulWidget implements CellAccessory, C final ValueNotifier onCellEditing = ValueNotifier(false); @override - List Function(GridCellAccessoryBuildContext buildContext)? get accessoryBuilder => null; + List Function(GridCellAccessoryBuildContext buildContext)? + get accessoryBuilder => null; @override final GridCellFocusListener beginFocus = GridCellFocusListener(); @@ -129,12 +148,14 @@ abstract class GridCellState extends State { void onInsert(String value) {} } -abstract class GridFocusNodeCellState extends GridCellState { +abstract class GridFocusNodeCellState + extends GridCellState { SingleListenrFocusNode focusNode = SingleListenrFocusNode(); @override void initState() { - widget.shortcutHandlers[CellKeyboardKey.onEnter] = () => focusNode.unfocus(); + widget.shortcutHandlers[CellKeyboardKey.onEnter] = + () => focusNode.unfocus(); _listenOnFocusNodeChanged(); super.initState(); } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_cotainer.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_cotainer.dart similarity index 79% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_cotainer.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_cotainer.dart index fbb343dd6c..b2d174e3e2 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_cotainer.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_cotainer.dart @@ -1,10 +1,10 @@ -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/row/grid_row.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flutter/widgets.dart'; import 'package:provider/provider.dart'; import 'package:styled_widget/styled_widget.dart'; +import '../../layout/sizes.dart'; +import '../row/grid_row.dart'; import 'cell_accessory.dart'; import 'cell_builder.dart'; import 'cell_shortcuts.dart'; @@ -24,9 +24,11 @@ class CellContainer extends StatelessWidget { @override Widget build(BuildContext context) { - return ChangeNotifierProxyProvider( + return ChangeNotifierProxyProvider( create: (_) => CellContainerNotifier(child), - update: (_, rowStateNotifier, cellStateNotifier) => cellStateNotifier!..onEnter = rowStateNotifier.onEnter, + update: (_, rowStateNotifier, cellStateNotifier) => + cellStateNotifier!..onEnter = rowStateNotifier.onEnter, child: Selector( selector: (context, notifier) => notifier.isFocus, builder: (context, isFocus, _) { @@ -39,7 +41,8 @@ class CellContainer extends StatelessWidget { )); if (accessories.isNotEmpty) { - container = CellEnterRegion(child: container, accessories: accessories); + container = + CellEnterRegion(child: container, accessories: accessories); } } @@ -65,7 +68,8 @@ class CellContainer extends StatelessWidget { return BoxDecoration(border: Border.fromBorderSide(borderSide)); } else { final borderSide = BorderSide(color: theme.shader5, width: 1.0); - return BoxDecoration(border: Border(right: borderSide, bottom: borderSide)); + return BoxDecoration( + border: Border(right: borderSide, bottom: borderSide)); } } } @@ -73,7 +77,9 @@ class CellContainer extends StatelessWidget { class CellEnterRegion extends StatelessWidget { final Widget child; final List accessories; - const CellEnterRegion({required this.child, required this.accessories, Key? key}) : super(key: key); + const CellEnterRegion( + {required this.child, required this.accessories, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -82,13 +88,18 @@ class CellEnterRegion extends StatelessWidget { builder: (context, onEnter, _) { List children = [child]; if (onEnter) { - children.add(CellAccessoryContainer(accessories: accessories).positioned(right: 0)); + children.add(CellAccessoryContainer(accessories: accessories) + .positioned(right: 0)); } return MouseRegion( cursor: SystemMouseCursors.click, - onEnter: (p) => Provider.of(context, listen: false).onEnter = true, - onExit: (p) => Provider.of(context, listen: false).onEnter = false, + onEnter: (p) => + Provider.of(context, listen: false) + .onEnter = true, + onExit: (p) => + Provider.of(context, listen: false) + .onEnter = false, child: Stack( alignment: AlignmentDirectional.center, fit: StackFit.expand, @@ -102,7 +113,6 @@ class CellEnterRegion extends StatelessWidget { class CellContainerNotifier extends ChangeNotifier { final CellEditable cellEditable; - bool mouted = false; VoidCallback? _onCellFocusListener; bool _isFocus = false; bool _onEnter = false; diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_decoration.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_decoration.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_decoration.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_decoration.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_shortcuts.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_shortcuts.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_shortcuts.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_shortcuts.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/checkbox_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/checkbox_cell.dart similarity index 77% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/checkbox_cell.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/checkbox_cell.dart index 9fcbaf751f..d334cc38af 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/checkbox_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/checkbox_cell.dart @@ -1,5 +1,5 @@ import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra_ui/style_widget/icon_button.dart'; import 'package:flutter/widgets.dart'; @@ -23,7 +23,8 @@ class _CheckboxCellState extends GridCellState { @override void initState() { final cellContext = widget.cellControllerBuilder.build(); - _cellBloc = getIt(param1: cellContext)..add(const CheckboxCellEvent.initial()); + _cellBloc = getIt(param1: cellContext) + ..add(const CheckboxCellEvent.initial()); super.initState(); } @@ -33,11 +34,15 @@ class _CheckboxCellState extends GridCellState { value: _cellBloc, child: BlocBuilder( builder: (context, state) { - final icon = state.isSelected ? svgWidget('editor/editor_check') : svgWidget('editor/editor_uncheck'); + final icon = state.isSelected + ? svgWidget('editor/editor_check') + : svgWidget('editor/editor_uncheck'); return Align( alignment: Alignment.centerLeft, child: FlowyIconButton( - onPressed: () => context.read().add(const CheckboxCellEvent.select()), + onPressed: () => context + .read() + .add(const CheckboxCellEvent.select()), iconPadding: EdgeInsets.zero, icon: icon, width: 20, diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell/date_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_cell.dart similarity index 85% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell/date_cell.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_cell.dart index 78d18a50e8..3254f58e6c 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell/date_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_cell.dart @@ -2,7 +2,7 @@ import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import '../cell_builder.dart'; import 'date_editor.dart'; @@ -44,13 +44,16 @@ class _DateCellState extends GridCellState { @override void initState() { final cellContext = widget.cellControllerBuilder.build(); - _cellBloc = getIt(param1: cellContext)..add(const DateCellEvent.initial()); + _cellBloc = getIt(param1: cellContext) + ..add(const DateCellEvent.initial()); super.initState(); } @override Widget build(BuildContext context) { - final alignment = widget.cellStyle != null ? widget.cellStyle!.alignment : Alignment.center; + final alignment = widget.cellStyle != null + ? widget.cellStyle!.alignment + : Alignment.center; return BlocProvider.value( value: _cellBloc, child: BlocBuilder( @@ -77,7 +80,8 @@ class _DateCellState extends GridCellState { void _showCalendar(BuildContext context) { final bloc = context.read(); widget.onCellEditing.value = true; - final calendar = DateCellEditor(onDismissed: () => widget.onCellEditing.value = false); + final calendar = + DateCellEditor(onDismissed: () => widget.onCellEditing.value = false); calendar.show( context, cellController: bloc.cellContext.clone(), diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell/date_editor.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_editor.dart similarity index 90% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell/date_editor.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_editor.dart index 36ad22ec53..a439506815 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell/date_editor.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_editor.dart @@ -1,7 +1,5 @@ import 'package:app_flowy/generated/locale_keys.g.dart'; -import 'package:app_flowy/workspace/application/grid/cell/date_cal_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/type_option/date.dart'; +import 'package:app_flowy/plugins/grid/application/cell/date_cal_bloc.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; @@ -15,7 +13,10 @@ import 'package:flowy_sdk/protobuf/flowy-grid/date_type_option.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:table_calendar/table_calendar.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; + +import '../../../layout/sizes.dart'; +import '../../header/type_option/date.dart'; final kToday = DateTime.now(); final kFirstDay = DateTime(kToday.year, kToday.month - 3, kToday.day); @@ -35,7 +36,8 @@ class DateCellEditor with FlowyOverlayDelegate { }) async { DateCellEditor.remove(context); - final result = await cellController.getFieldTypeOption(DateTypeOptionDataParser()); + final result = + await cellController.getFieldTypeOption(DateTypeOptionDataParser()); result.fold( (dateTypeOption) { final calendar = _CellCalendarWidget( @@ -167,7 +169,9 @@ class _CellCalendarWidget extends StatelessWidget { }, onDaySelected: (selectedDay, focusedDay) { _CalDateTimeSetting.hide(context); - context.read().add(DateCalEvent.selectDay(selectedDay)); + context + .read() + .add(DateCalEvent.selectDay(selectedDay)); }, onFormatChanged: (format) { _CalDateTimeSetting.hide(context); @@ -175,7 +179,9 @@ class _CellCalendarWidget extends StatelessWidget { }, onPageChanged: (focusedDay) { _CalDateTimeSetting.hide(context); - context.read().add(DateCalEvent.setFocusedDay(focusedDay)); + context + .read() + .add(DateCalEvent.setFocusedDay(focusedDay)); }, ); }, @@ -200,11 +206,14 @@ class _IncludeTimeButton extends StatelessWidget { children: [ svgWidget("grid/clock", color: theme.iconColor), const HSpace(4), - FlowyText.medium(LocaleKeys.grid_field_includeTime.tr(), fontSize: 14), + FlowyText.medium(LocaleKeys.grid_field_includeTime.tr(), + fontSize: 14), const Spacer(), Switch( value: includeTime, - onChanged: (newValue) => context.read().add(DateCalEvent.setIncludeTime(newValue)), + onChanged: (newValue) => context + .read() + .add(DateCalEvent.setIncludeTime(newValue)), ), ], ), @@ -294,7 +303,9 @@ class _DateTypeOptionButton extends StatelessWidget { @override Widget build(BuildContext context) { final theme = context.watch(); - final title = LocaleKeys.grid_field_dateFormat.tr() + " &" + LocaleKeys.grid_field_timeFormat.tr(); + final title = LocaleKeys.grid_field_dateFormat.tr() + + " &" + + LocaleKeys.grid_field_timeFormat.tr(); return BlocSelector( selector: (state) => state.dateTypeOption, builder: (context, dateTypeOption) { @@ -321,7 +332,9 @@ class _DateTypeOptionButton extends StatelessWidget { class _CalDateTimeSetting extends StatefulWidget { final DateTypeOption dateTypeOption; final Function(DateCalEvent) onEvent; - const _CalDateTimeSetting({required this.dateTypeOption, required this.onEvent, Key? key}) : super(key: key); + const _CalDateTimeSetting( + {required this.dateTypeOption, required this.onEvent, Key? key}) + : super(key: key); @override State<_CalDateTimeSetting> createState() => _CalDateTimeSettingState(); @@ -358,7 +371,8 @@ class _CalDateTimeSettingState extends State<_CalDateTimeSetting> { DateFormatButton(onTap: () { final list = DateFormatList( selectedFormat: widget.dateTypeOption.dateFormat, - onSelected: (format) => widget.onEvent(DateCalEvent.setDateFormat(format)), + onSelected: (format) => + widget.onEvent(DateCalEvent.setDateFormat(format)), ); _showOverlay(context, list); }), @@ -367,7 +381,8 @@ class _CalDateTimeSettingState extends State<_CalDateTimeSetting> { onTap: () { final list = TimeFormatList( selectedFormat: widget.dateTypeOption.timeFormat, - onSelected: (format) => widget.onEvent(DateCalEvent.setTimeFormat(format)), + onSelected: (format) => + widget.onEvent(DateCalEvent.setTimeFormat(format)), ); _showOverlay(context, list); }, diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/number_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/number_cell.dart similarity index 82% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/number_cell.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/number_cell.dart index 573a4168c9..8c6db0afe9 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/number_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/number_cell.dart @@ -1,6 +1,6 @@ import 'dart:async'; import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -26,8 +26,10 @@ class _NumberCellState extends GridFocusNodeCellState { @override void initState() { final cellContext = widget.cellContorllerBuilder.build(); - _cellBloc = getIt(param1: cellContext)..add(const NumberCellEvent.initial()); - _controller = TextEditingController(text: contentFromState(_cellBloc.state)); + _cellBloc = getIt(param1: cellContext) + ..add(const NumberCellEvent.initial()); + _controller = + TextEditingController(text: contentFromState(_cellBloc.state)); super.initState(); } @@ -39,7 +41,8 @@ class _NumberCellState extends GridFocusNodeCellState { listeners: [ BlocListener( listenWhen: (p, c) => p.content != c.content, - listener: (context, state) => _controller.text = contentFromState(state), + listener: (context, state) => + _controller.text = contentFromState(state), ), ], child: TextField( @@ -70,7 +73,8 @@ class _NumberCellState extends GridFocusNodeCellState { if (mounted) { _delayOperation?.cancel(); _delayOperation = Timer(const Duration(milliseconds: 300), () { - if (_cellBloc.isClosed == false && _controller.text != contentFromState(_cellBloc.state)) { + if (_cellBloc.isClosed == false && + _controller.text != contentFromState(_cellBloc.state)) { _cellBloc.add(NumberCellEvent.updateCell(_controller.text)); } }); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/prelude.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/prelude.dart similarity index 85% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/prelude.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/prelude.dart index 792e58810f..7b34d8fcdf 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/prelude.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/prelude.dart @@ -4,3 +4,4 @@ export 'number_cell.dart'; export 'date_cell/date_cell.dart'; export 'checkbox_cell.dart'; export 'select_option_cell/select_option_cell.dart'; +export 'url_cell/url_cell.dart'; diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/extension.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/extension.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/extension.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/extension.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/select_option_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_cell.dart similarity index 86% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/select_option_cell.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_cell.dart index f822e503d2..53c77c6016 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/select_option_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_cell.dart @@ -1,6 +1,6 @@ import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/cell_builder.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; + import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/text.dart'; // ignore: unused_import @@ -9,6 +9,7 @@ import 'package:flowy_sdk/protobuf/flowy-grid/select_option.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import '../cell_builder.dart'; import 'extension.dart'; import 'select_option_editor.dart'; @@ -45,8 +46,10 @@ class _SingleSelectCellState extends State { @override void initState() { - final cellContext = widget.cellContorllerBuilder.build() as GridSelectOptionCellController; - _cellBloc = getIt(param1: cellContext)..add(const SelectOptionCellEvent.initial()); + final cellContext = + widget.cellContorllerBuilder.build() as GridSelectOptionCellController; + _cellBloc = getIt(param1: cellContext) + ..add(const SelectOptionCellEvent.initial()); super.initState(); } @@ -99,8 +102,10 @@ class _MultiSelectCellState extends State { @override void initState() { - final cellContext = widget.cellContorllerBuilder.build() as GridSelectOptionCellController; - _cellBloc = getIt(param1: cellContext)..add(const SelectOptionCellEvent.initial()); + final cellContext = + widget.cellContorllerBuilder.build() as GridSelectOptionCellController; + _cellBloc = getIt(param1: cellContext) + ..add(const SelectOptionCellEvent.initial()); super.initState(); } @@ -147,7 +152,8 @@ class _SelectOptionCell extends StatelessWidget { if (selectOptions.isEmpty && cellStyle != null) { child = Align( alignment: Alignment.centerLeft, - child: FlowyText.medium(cellStyle!.placeholder, fontSize: 14, color: theme.shader3), + child: FlowyText.medium(cellStyle!.placeholder, + fontSize: 14, color: theme.shader3), ); } else { final tags = selectOptions @@ -172,8 +178,10 @@ class _SelectOptionCell extends StatelessWidget { InkWell( onTap: () { onFocus(true); - final cellContext = cellContorllerBuilder.build() as GridSelectOptionCellController; - SelectOptionCellEditor.show(context, cellContext, () => onFocus(false)); + final cellContext = + cellContorllerBuilder.build() as GridSelectOptionCellController; + SelectOptionCellEditor.show( + context, cellContext, () => onFocus(false)); }, ), ], diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/select_option_editor.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_editor.dart similarity index 82% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/select_option_editor.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_editor.dart index 95f2bf1e03..c07eef5617 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/select_option_editor.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_editor.dart @@ -1,9 +1,7 @@ import 'dart:collection'; -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; -import 'package:app_flowy/workspace/application/grid/cell/select_option_editor_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/type_option/select_option_editor.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/common/text_field.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/select_option_editor_bloc.dart'; + import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; @@ -18,6 +16,9 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; import 'package:textfield_tags/textfield_tags.dart'; +import '../../../layout/sizes.dart'; +import '../../common/text_field.dart'; +import '../../header/type_option/select_option_editor.dart'; import 'extension.dart'; import 'text_field.dart'; @@ -105,7 +106,8 @@ class _OptionList extends StatelessWidget { builder: (context, state) { List cells = []; cells.addAll(state.options.map((option) { - return _SelectOptionCell(option, state.selectedOptions.contains(option)); + return _SelectOptionCell( + option, state.selectedOptions.contains(option)); }).toList()); state.createOption.fold( @@ -146,8 +148,10 @@ class _TextField extends StatelessWidget { Widget build(BuildContext context) { return BlocBuilder( builder: (context, state) { - final optionMap = LinkedHashMap.fromIterable(state.selectedOptions, - key: (option) => option.name, value: (option) => option); + final optionMap = LinkedHashMap.fromIterable( + state.selectedOptions, + key: (option) => option.name, + value: (option) => option); return SizedBox( height: 42, @@ -156,12 +160,17 @@ class _TextField extends StatelessWidget { selectedOptionMap: optionMap, distanceToText: _editorPannelWidth * 0.7, tagController: _tagController, - onClick: () => FlowyOverlay.of(context).remove(SelectOptionTypeOptionEditor.identifier), + onClick: () => FlowyOverlay.of(context) + .remove(SelectOptionTypeOptionEditor.identifier), newText: (text) { - context.read().add(SelectOptionEditorEvent.filterOption(text)); + context + .read() + .add(SelectOptionEditorEvent.filterOption(text)); }, onNewTag: (tagName) { - context.read().add(SelectOptionEditorEvent.newOption(tagName)); + context + .read() + .add(SelectOptionEditorEvent.newOption(tagName)); }, ), ); @@ -208,7 +217,9 @@ class _CreateOptionCell extends StatelessWidget { SelectOptionTag( name: name, color: theme.shader6, - onSelected: () => context.read().add(SelectOptionEditorEvent.newOption(name)), + onSelected: () => context + .read() + .add(SelectOptionEditorEvent.newOption(name)), ), ], ); @@ -218,7 +229,8 @@ class _CreateOptionCell extends StatelessWidget { class _SelectOptionCell extends StatelessWidget { final SelectOptionPB option; final bool isSelected; - const _SelectOptionCell(this.option, this.isSelected, {Key? key}) : super(key: key); + const _SelectOptionCell(this.option, this.isSelected, {Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -232,7 +244,9 @@ class _SelectOptionCell extends StatelessWidget { child: SelectOptionTagCell( option: option, onSelected: (option) { - context.read().add(SelectOptionEditorEvent.selectOption(option.id)); + context + .read() + .add(SelectOptionEditorEvent.selectOption(option.id)); }, children: [ if (isSelected) @@ -258,12 +272,17 @@ class _SelectOptionCell extends StatelessWidget { final pannel = SelectOptionTypeOptionEditor( option: option, onDeleted: () { - context.read().add(SelectOptionEditorEvent.deleteOption(option)); + context + .read() + .add(SelectOptionEditorEvent.deleteOption(option)); }, onUpdated: (updatedOption) { - context.read().add(SelectOptionEditorEvent.updateOption(updatedOption)); + context + .read() + .add(SelectOptionEditorEvent.updateOption(updatedOption)); }, - key: ValueKey(option.id), // Use ValueKey to refresh the UI, otherwise, it will remain the old value. + key: ValueKey(option + .id), // Use ValueKey to refresh the UI, otherwise, it will remain the old value. ); final overlayIdentifier = (SelectOptionTypeOptionEditor).toString(); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/text_field.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/text_field.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/text_field.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/text_field.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/text_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/text_cell.dart similarity index 94% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/text_cell.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/text_cell.dart index 55bf757ba4..29471c13b6 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/text_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/text_cell.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'cell_builder.dart'; class GridTextCellStyle extends GridCellStyle { @@ -86,7 +86,8 @@ class _GridTextCellState extends GridFocusNodeCellState { if (mounted) { _delayOperation?.cancel(); _delayOperation = Timer(const Duration(milliseconds: 300), () { - if (_cellBloc.isClosed == false && _controller.text != _cellBloc.state.content) { + if (_cellBloc.isClosed == false && + _controller.text != _cellBloc.state.content) { _cellBloc.add(TextCellEvent.updateText(_controller.text)); } }); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/url_cell/cell_editor.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/cell_editor.dart similarity index 87% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/url_cell/cell_editor.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/cell_editor.dart index b6bc8daa21..9095d73fa6 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/url_cell/cell_editor.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/cell_editor.dart @@ -1,5 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; -import 'package:app_flowy/workspace/application/grid/cell/url_cell_editor_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/cell/url_cell_editor_bloc.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flutter/material.dart'; import 'dart:async'; @@ -9,7 +9,9 @@ import 'package:flutter_bloc/flutter_bloc.dart'; class URLCellEditor extends StatefulWidget with FlowyOverlayDelegate { final GridURLCellController cellController; final VoidCallback completed; - const URLCellEditor({required this.cellController, required this.completed, Key? key}) : super(key: key); + const URLCellEditor( + {required this.cellController, required this.completed, Key? key}) + : super(key: key); @override State createState() => _URLCellEditorState(); @@ -105,7 +107,8 @@ class _URLCellEditorState extends State { Future focusChanged() async { if (mounted) { - if (_cellBloc.isClosed == false && _controller.text != _cellBloc.state.content) { + if (_cellBloc.isClosed == false && + _controller.text != _cellBloc.state.content) { _cellBloc.add(URLCellEditorEvent.updateText(_controller.text)); } } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/url_cell/url_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/url_cell.dart similarity index 73% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/url_cell/url_cell.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/url_cell.dart index 9cc14fbbda..bb39b8f276 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/url_cell/url_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/url_cell.dart @@ -1,16 +1,16 @@ import 'dart:async'; import 'package:app_flowy/generated/locale_keys.g.dart'; -import 'package:app_flowy/workspace/application/grid/cell/url_cell_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/cell/url_cell_bloc.dart'; import 'package:app_flowy/workspace/presentation/home/toast.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/cell_accessory.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:url_launcher/url_launcher.dart'; +import '../cell_accessory.dart'; import '../cell_builder.dart'; import 'cell_editor.dart'; @@ -48,34 +48,41 @@ class GridURLCell extends GridCellWidget { @override GridCellState createState() => _GridURLCellState(); - GridCellAccessory accessoryFromType(GridURLCellAccessoryType ty, GridCellAccessoryBuildContext buildContext) { + GridCellAccessory accessoryFromType( + GridURLCellAccessoryType ty, GridCellAccessoryBuildContext buildContext) { switch (ty) { case GridURLCellAccessoryType.edit: - final cellContext = cellContorllerBuilder.build() as GridURLCellController; - return _EditURLAccessory(cellContext: cellContext, anchorContext: buildContext.anchorContext); + final cellContext = + cellContorllerBuilder.build() as GridURLCellController; + return _EditURLAccessory( + cellContext: cellContext, + anchorContext: buildContext.anchorContext); case GridURLCellAccessoryType.copyURL: - final cellContext = cellContorllerBuilder.build() as GridURLCellController; + final cellContext = + cellContorllerBuilder.build() as GridURLCellController; return _CopyURLAccessory(cellContext: cellContext); } } @override - List Function(GridCellAccessoryBuildContext buildContext) get accessoryBuilder => (buildContext) { - final List accessories = []; - if (cellStyle != null) { - accessories.addAll(cellStyle!.accessoryTypes.map((ty) { - return accessoryFromType(ty, buildContext); - })); - } + List Function(GridCellAccessoryBuildContext buildContext) + get accessoryBuilder => (buildContext) { + final List accessories = []; + if (cellStyle != null) { + accessories.addAll(cellStyle!.accessoryTypes.map((ty) { + return accessoryFromType(ty, buildContext); + })); + } - // If the accessories is empty then the default accessory will be GridURLCellAccessoryType.edit - if (accessories.isEmpty) { - accessories.add(accessoryFromType(GridURLCellAccessoryType.edit, buildContext)); - } + // If the accessories is empty then the default accessory will be GridURLCellAccessoryType.edit + if (accessories.isEmpty) { + accessories.add(accessoryFromType( + GridURLCellAccessoryType.edit, buildContext)); + } - return accessories; - }; + return accessories; + }; } class _GridURLCellState extends GridCellState { @@ -83,7 +90,8 @@ class _GridURLCellState extends GridCellState { @override void initState() { - final cellContext = widget.cellContorllerBuilder.build() as GridURLCellController; + final cellContext = + widget.cellContorllerBuilder.build() as GridURLCellController; _cellBloc = URLCellBloc(cellContext: cellContext); _cellBloc.add(const URLCellEvent.initial()); super.initState(); @@ -132,7 +140,8 @@ class _GridURLCellState extends GridCellState { if (url.isNotEmpty && await canLaunchUrl(uri)) { await launchUrl(uri); } else { - final cellContext = widget.cellContorllerBuilder.build() as GridURLCellController; + final cellContext = + widget.cellContorllerBuilder.build() as GridURLCellController; widget.onCellEditing.value = true; URLCellEditor.show(context, cellContext, () { widget.onCellEditing.value = false; @@ -177,7 +186,8 @@ class _EditURLAccessory extends StatelessWidget with GridCellAccessory { class _CopyURLAccessory extends StatelessWidget with GridCellAccessory { final GridURLCellController cellContext; - const _CopyURLAccessory({required this.cellContext, Key? key}) : super(key: key); + const _CopyURLAccessory({required this.cellContext, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -187,7 +197,8 @@ class _CopyURLAccessory extends StatelessWidget with GridCellAccessory { @override void onTap() { - final content = cellContext.getCellData(loadIfNotExist: false)?.content ?? ""; + final content = + cellContext.getCellData(loadIfNotExist: false)?.content ?? ""; Clipboard.setData(ClipboardData(text: content)); showMessageToast(LocaleKeys.grid_row_copyProperty.tr()); } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/common/text_field.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/common/text_field.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/common/text_field.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/common/text_field.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/footer/grid_footer.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/footer/grid_footer.dart similarity index 91% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/footer/grid_footer.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/footer/grid_footer.dart index 6ed8700cfc..f7b5ab350a 100755 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/footer/grid_footer.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/footer/grid_footer.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/grid_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/grid_bloc.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/button.dart'; diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/constants.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/constants.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/constants.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/constants.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell.dart similarity index 84% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_cell.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell.dart index 8202a3537f..aec88f5eaf 100755 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell.dart @@ -1,6 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/field/field_cell_bloc.dart'; -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_cell_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/button.dart'; @@ -9,6 +8,7 @@ import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import '../../layout/sizes.dart'; import 'field_type_extension.dart'; import 'field_cell_action_sheet.dart'; @@ -21,7 +21,8 @@ class GridFieldCell extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => FieldCellBloc(cellContext: cellContext)..add(const FieldCellEvent.initial()), + create: (context) => FieldCellBloc(cellContext: cellContext) + ..add(const FieldCellEvent.initial()), child: BlocBuilder( // buildWhen: (p, c) => p.field != c.field, builder: (context, state) { @@ -53,7 +54,8 @@ class GridFieldCell extends StatelessWidget { void _showActionSheet(BuildContext context) { final state = context.read().state; GridFieldCellActionSheet( - cellContext: GridFieldCellContext(gridId: state.gridId, field: state.field), + cellContext: + GridFieldCellContext(gridId: state.gridId, field: state.field), onEdited: () => _showFieldEditor(context), ).show(context); } @@ -96,7 +98,8 @@ class _GridHeaderCellContainer extends StatelessWidget { return Container( width: width, decoration: decoration, - child: ConstrainedBox(constraints: const BoxConstraints.expand(), child: child), + child: ConstrainedBox( + constraints: const BoxConstraints.expand(), child: child), ); } } @@ -115,12 +118,17 @@ class _DragToExpandLine extends StatelessWidget { child: GestureDetector( behavior: HitTestBehavior.opaque, onHorizontalDragUpdate: (value) { - context.read().add(FieldCellEvent.startUpdateWidth(value.delta.dx)); + context + .read() + .add(FieldCellEvent.startUpdateWidth(value.delta.dx)); }, onHorizontalDragEnd: (end) { - context.read().add(const FieldCellEvent.endUpdateWidth()); + context + .read() + .add(const FieldCellEvent.endUpdateWidth()); }, child: FlowyHover( + cursor: SystemMouseCursors.resizeLeftRight, style: HoverStyle( hoverColor: theme.main1, borderRadius: BorderRadius.zero, diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_cell_action_sheet.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dart similarity index 83% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_cell_action_sheet.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dart index 3e7f0c9271..cd884cd557 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_cell_action_sheet.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dart @@ -1,6 +1,5 @@ import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; @@ -12,10 +11,15 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; -class GridFieldCellActionSheet extends StatelessWidget with FlowyOverlayDelegate { +import '../../layout/sizes.dart'; + +class GridFieldCellActionSheet extends StatelessWidget + with FlowyOverlayDelegate { final GridFieldCellContext cellContext; final VoidCallback onEdited; - const GridFieldCellActionSheet({required this.cellContext, required this.onEdited, Key? key}) : super(key: key); + const GridFieldCellActionSheet( + {required this.cellContext, required this.onEdited, Key? key}) + : super(key: key); void show(BuildContext overlayContext) { FlowyOverlay.of(overlayContext).insertWithAnchor( @@ -44,7 +48,8 @@ class GridFieldCellActionSheet extends StatelessWidget with FlowyOverlayDelegate }, ), const VSpace(6), - _FieldOperationList(cellContext, () => FlowyOverlay.of(context).remove(identifier())), + _FieldOperationList(cellContext, + () => FlowyOverlay.of(context).remove(identifier())), ], ), ), @@ -73,7 +78,8 @@ class _EditFieldButton extends StatelessWidget { return SizedBox( height: GridSize.typeOptionItemHeight, child: FlowyButton( - text: FlowyText.medium(LocaleKeys.grid_field_editProperty.tr(), fontSize: 12), + text: FlowyText.medium(LocaleKeys.grid_field_editProperty.tr(), + fontSize: 12), hoverColor: theme.hover, onTap: onEdited, ), @@ -86,7 +92,8 @@ class _EditFieldButton extends StatelessWidget { class _FieldOperationList extends StatelessWidget { final GridFieldCellContext fieldData; final VoidCallback onDismissed; - const _FieldOperationList(this.fieldData, this.onDismissed, {Key? key}) : super(key: key); + const _FieldOperationList(this.fieldData, this.onDismissed, {Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -143,7 +150,8 @@ class FieldActionCell extends StatelessWidget { Widget build(BuildContext context) { final theme = context.watch(); return FlowyButton( - text: FlowyText.medium(action.title(), fontSize: 12, color: enable ? null : theme.shader4), + text: FlowyText.medium(action.title(), + fontSize: 12, color: enable ? null : theme.shader4), hoverColor: theme.hover, onTap: () { if (enable) { @@ -188,13 +196,19 @@ extension _FieldActionExtension on FieldAction { void run(BuildContext context) { switch (this) { case FieldAction.hide: - context.read().add(const FieldActionSheetEvent.hideField()); + context + .read() + .add(const FieldActionSheetEvent.hideField()); break; case FieldAction.duplicate: - context.read().add(const FieldActionSheetEvent.duplicateField()); + context + .read() + .add(const FieldActionSheetEvent.duplicateField()); break; case FieldAction.delete: - context.read().add(const FieldActionSheetEvent.deleteField()); + context + .read() + .add(const FieldActionSheetEvent.deleteField()); break; } } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_editor.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_editor.dart similarity index 88% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_editor.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_editor.dart index 3a857a9fb4..30a76a34bb 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_editor.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_editor.dart @@ -1,5 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/field/field_editor_bloc.dart'; -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_editor_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flowy_infra_ui/style_widget/text.dart'; @@ -36,7 +36,8 @@ class FieldEditor extends StatelessWidget with FlowyOverlayDelegate { return ListView( shrinkWrap: true, children: [ - FlowyText.medium(LocaleKeys.grid_field_editProperty.tr(), fontSize: 12), + FlowyText.medium(LocaleKeys.grid_field_editProperty.tr(), + fontSize: 12), const VSpace(10), const _FieldNameCell(), const VSpace(10), @@ -85,7 +86,8 @@ class _FieldTypeOptionCell extends StatelessWidget { return state.field.fold( () => const SizedBox(), (fieldContext) { - final dataController = context.read().dataController; + final dataController = + context.read().dataController; return FieldTypeOptionEditor(dataController: dataController); }, ); @@ -105,7 +107,9 @@ class _FieldNameCell extends StatelessWidget { name: state.name, errorText: context.read().state.errorText, onNameChanged: (newName) { - context.read().add(FieldEditorEvent.updateName(newName)); + context + .read() + .add(FieldEditorEvent.updateName(newName)); }, ); }, diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_name_input.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_name_input.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_name_input.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_name_input.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_type_extension.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_extension.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_type_extension.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_extension.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_type_list.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_list.dart similarity index 93% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_type_list.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_list.dart index 0ea53fb547..de9b3a809f 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_type_list.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_list.dart @@ -1,4 +1,3 @@ -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; @@ -8,6 +7,7 @@ import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter/material.dart'; +import '../../layout/sizes.dart'; import 'field_type_extension.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -15,7 +15,8 @@ typedef SelectFieldCallback = void Function(FieldType); class FieldTypeList extends StatelessWidget with FlowyOverlayDelegate { final SelectFieldCallback onSelectField; - const FieldTypeList({required this.onSelectField, Key? key}) : super(key: key); + const FieldTypeList({required this.onSelectField, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_type_option_editor.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_option_editor.dart similarity index 82% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_type_option_editor.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_option_editor.dart index 95dd39bae9..c2a12bb7ad 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_type_option_editor.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_option_editor.dart @@ -9,14 +9,15 @@ import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_type_list.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; +import '../../layout/sizes.dart'; import 'field_type_extension.dart'; +import 'field_type_list.dart'; import 'type_option/builder.dart'; typedef UpdateFieldCallback = void Function(GridFieldPB, Uint8List); -typedef SwitchToFieldCallback = Future> Function( +typedef SwitchToFieldCallback + = Future> Function( String fieldId, FieldType fieldType, ); @@ -39,12 +40,15 @@ class _FieldTypeOptionEditorState extends State { @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => - FieldTypeOptionEditBloc(widget.dataController)..add(const FieldTypeOptionEditEvent.initial()), + create: (context) => FieldTypeOptionEditBloc(widget.dataController) + ..add(const FieldTypeOptionEditEvent.initial()), child: BlocBuilder( builder: (context, state) { - List children = [_switchFieldTypeButton(context, widget.dataController.field)]; - final typeOptionWidget = _typeOptionWidget(context: context, state: state); + List children = [ + _switchFieldTypeButton(context, widget.dataController.field) + ]; + final typeOptionWidget = + _typeOptionWidget(context: context, state: state); if (typeOptionWidget != null) { children.add(typeOptionWidget); @@ -95,7 +99,8 @@ class _FieldTypeOptionEditorState extends State { ); } - void _showOverlay(BuildContext context, Widget child, {VoidCallback? onRemoved}) { + void _showOverlay(BuildContext context, Widget child, + {VoidCallback? onRemoved}) { final identifier = child.toString(); if (currentOverlayIdentifier != null) { FlowyOverlay.of(context).remove(currentOverlayIdentifier!); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/grid_header.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/grid_header.dart similarity index 84% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/grid_header.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/grid_header.dart index 5a888129b5..df7be4ee2b 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/grid_header.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/grid_header.dart @@ -1,6 +1,5 @@ import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/button.dart'; @@ -9,6 +8,7 @@ import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:reorderables/reorderables.dart'; +import '../../layout/sizes.dart'; import 'field_editor.dart'; import 'field_cell.dart'; @@ -24,7 +24,8 @@ class GridHeaderSliverAdaptor extends StatefulWidget { }) : super(key: key); @override - State createState() => _GridHeaderSliverAdaptorState(); + State createState() => + _GridHeaderSliverAdaptorState(); } class _GridHeaderSliverAdaptorState extends State { @@ -32,12 +33,14 @@ class _GridHeaderSliverAdaptorState extends State { Widget build(BuildContext context) { return BlocProvider( create: (context) { - final bloc = getIt(param1: widget.gridId, param2: widget.fieldCache); + final bloc = getIt( + param1: widget.gridId, param2: widget.fieldCache); bloc.add(const GridHeaderEvent.initial()); return bloc; }, child: BlocBuilder( - buildWhen: (previous, current) => previous.fields.length != current.fields.length, + buildWhen: (previous, current) => + previous.fields.length != current.fields.length, builder: (context, state) { return SingleChildScrollView( scrollDirection: Axis.horizontal, @@ -76,7 +79,8 @@ class _GridHeaderState extends State<_GridHeader> { builder: (context, state) { final cells = state.fields .where((field) => field.visibility) - .map((field) => GridFieldCellContext(gridId: widget.gridId, field: field)) + .map((field) => + GridFieldCellContext(gridId: widget.gridId, field: field)) .map((ctx) => GridFieldCell(ctx, key: ValueKey(ctx.field.id))) .toList(); @@ -99,10 +103,13 @@ class _GridHeaderState extends State<_GridHeader> { ); } - void _onReorder(List cells, int oldIndex, BuildContext context, int newIndex) { + void _onReorder(List cells, int oldIndex, BuildContext context, + int newIndex) { if (cells.length > oldIndex) { final field = cells[oldIndex].cellContext.field; - context.read().add(GridHeaderEvent.moveField(field, oldIndex, newIndex)); + context + .read() + .add(GridHeaderEvent.moveField(field, oldIndex, newIndex)); } } } @@ -158,14 +165,17 @@ class CreateFieldButton extends StatelessWidget { } } -class SliverHeaderDelegateImplementation extends SliverPersistentHeaderDelegate { +class SliverHeaderDelegateImplementation + extends SliverPersistentHeaderDelegate { final String gridId; final List fields; - SliverHeaderDelegateImplementation({required this.gridId, required this.fields}); + SliverHeaderDelegateImplementation( + {required this.gridId, required this.fields}); @override - Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) { + Widget build( + BuildContext context, double shrinkOffset, bool overlapsContent) { return _GridHeader(gridId: gridId); } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/builder.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/builder.dart similarity index 92% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/builder.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/builder.dart index 63fa761d98..4471e672a3 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/builder.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/builder.dart @@ -1,10 +1,10 @@ import 'dart:typed_data'; -import 'package:app_flowy/workspace/application/grid/field/type_option/multi_select_type_option.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/type_option/checkbox.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/multi_select_type_option.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter/material.dart'; +import 'checkbox.dart'; import 'date.dart'; import 'multi_select.dart'; import 'number.dart'; diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/checkbox.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/checkbox.dart similarity index 74% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/checkbox.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/checkbox.dart index beca8acd09..fdc5719181 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/checkbox.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/checkbox.dart @@ -1,11 +1,12 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/type_option_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_service.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/checkbox_type_option.pb.dart'; import 'package:flutter/material.dart'; import 'builder.dart'; typedef CheckboxTypeOptionContext = TypeOptionWidgetContext; -class CheckboxTypeOptionWidgetDataParser extends TypeOptionDataParser { +class CheckboxTypeOptionWidgetDataParser + extends TypeOptionDataParser { @override CheckboxTypeOption fromBuffer(List buffer) { return CheckboxTypeOption.fromBuffer(buffer); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/date.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/date.dart similarity index 88% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/date.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/date.dart index 39408c9ee3..c162595b88 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/date.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/date.dart @@ -1,6 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/date_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_type_option_editor.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/date_bloc.dart'; import 'package:easy_localization/easy_localization.dart' hide DateFormat; import 'package:app_flowy/generated/locale_keys.g.dart'; import 'package:flowy_infra/image.dart'; @@ -12,6 +10,8 @@ import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/date_type_option_entities.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import '../../../layout/sizes.dart'; +import '../field_type_option_editor.dart'; import 'builder.dart'; class DateTypeOptionWidgetBuilder extends TypeOptionWidgetBuilder { @@ -44,9 +44,11 @@ class DateTypeOptionWidget extends TypeOptionWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => DateTypeOptionBloc(typeOptionContext: typeOptionContext), + create: (context) => + DateTypeOptionBloc(typeOptionContext: typeOptionContext), child: BlocConsumer( - listener: (context, state) => typeOptionContext.typeOption = state.typeOption, + listener: (context, state) => + typeOptionContext.typeOption = state.typeOption, builder: (context, state) { return Column(children: [ _renderDateFormatButton(context, state.typeOption.dateFormat), @@ -63,7 +65,9 @@ class DateTypeOptionWidget extends TypeOptionWidget { final list = DateFormatList( selectedFormat: dataFormat, onSelected: (format) { - context.read().add(DateTypeOptionEvent.didSelectDateFormat(format)); + context + .read() + .add(DateTypeOptionEvent.didSelectDateFormat(format)); }, ); overlayDelegate.showOverlay(context, list); @@ -77,7 +81,9 @@ class DateTypeOptionWidget extends TypeOptionWidget { final list = TimeFormatList( selectedFormat: timeFormat, onSelected: (format) { - context.read().add(DateTypeOptionEvent.didSelectTimeFormat(format)); + context + .read() + .add(DateTypeOptionEvent.didSelectTimeFormat(format)); }); overlayDelegate.showOverlay(context, list); }, @@ -95,7 +101,8 @@ class DateFormatButton extends StatelessWidget { return SizedBox( height: GridSize.typeOptionItemHeight, child: FlowyButton( - text: FlowyText.medium(LocaleKeys.grid_field_dateFormat.tr(), fontSize: 12), + text: FlowyText.medium(LocaleKeys.grid_field_dateFormat.tr(), + fontSize: 12), margin: GridSize.typeOptionContentInsets, hoverColor: theme.hover, onTap: onTap, @@ -108,7 +115,9 @@ class DateFormatButton extends StatelessWidget { class TimeFormatButton extends StatelessWidget { final TimeFormat timeFormat; final VoidCallback onTap; - const TimeFormatButton({required this.timeFormat, required this.onTap, Key? key}) : super(key: key); + const TimeFormatButton( + {required this.timeFormat, required this.onTap, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -116,7 +125,8 @@ class TimeFormatButton extends StatelessWidget { return SizedBox( height: GridSize.typeOptionItemHeight, child: FlowyButton( - text: FlowyText.medium(LocaleKeys.grid_field_timeFormat.tr(), fontSize: 12), + text: FlowyText.medium(LocaleKeys.grid_field_timeFormat.tr(), + fontSize: 12), margin: GridSize.typeOptionContentInsets, hoverColor: theme.hover, onTap: onTap, @@ -140,12 +150,15 @@ class _IncludeTimeButton extends StatelessWidget { padding: GridSize.typeOptionContentInsets, child: Row( children: [ - FlowyText.medium(LocaleKeys.grid_field_includeTime.tr(), fontSize: 12), + FlowyText.medium(LocaleKeys.grid_field_includeTime.tr(), + fontSize: 12), const Spacer(), Switch( value: includeTime, onChanged: (newValue) { - context.read().add(DateTypeOptionEvent.includeTime(newValue)); + context + .read() + .add(DateTypeOptionEvent.includeTime(newValue)); }, ), ], @@ -160,7 +173,9 @@ class _IncludeTimeButton extends StatelessWidget { class DateFormatList extends StatelessWidget { final DateFormat selectedFormat; final Function(DateFormat format) onSelected; - const DateFormatList({required this.selectedFormat, required this.onSelected, Key? key}) : super(key: key); + const DateFormatList( + {required this.selectedFormat, required this.onSelected, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/multi_select.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart similarity index 85% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/multi_select.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart index 8c7ab40a6f..e1b97fe087 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/multi_select.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart @@ -1,7 +1,7 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/multi_select_type_option.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_type_option_editor.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/multi_select_type_option.dart'; import 'package:flutter/material.dart'; +import '../field_type_option_editor.dart'; import 'builder.dart'; import 'select_option.dart'; diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/number.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart similarity index 83% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/number.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart index e15abb1728..8e4e53b40c 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/number.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart @@ -1,8 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/number_bloc.dart'; -import 'package:app_flowy/workspace/application/grid/field/type_option/number_format_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/common/text_field.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_type_option_editor.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/number_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/number_format_bloc.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; @@ -15,6 +12,9 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:easy_localization/easy_localization.dart' hide NumberFormat; import 'package:app_flowy/generated/locale_keys.g.dart'; +import '../../../layout/sizes.dart'; +import '../../common/text_field.dart'; +import '../field_type_option_editor.dart'; import 'builder.dart'; class NumberTypeOptionWidgetBuilder extends TypeOptionWidgetBuilder { @@ -45,19 +45,23 @@ class NumberTypeOptionWidget extends TypeOptionWidget { Widget build(BuildContext context) { final theme = context.watch(); return BlocProvider( - create: (context) => NumberTypeOptionBloc(typeOptionContext: typeOptionContext), + create: (context) => + NumberTypeOptionBloc(typeOptionContext: typeOptionContext), child: SizedBox( height: GridSize.typeOptionItemHeight, child: BlocConsumer( - listener: (context, state) => typeOptionContext.typeOption = state.typeOption, + listener: (context, state) => + typeOptionContext.typeOption = state.typeOption, builder: (context, state) { return FlowyButton( text: Row( children: [ - FlowyText.medium(LocaleKeys.grid_field_numberFormat.tr(), fontSize: 12), + FlowyText.medium(LocaleKeys.grid_field_numberFormat.tr(), + fontSize: 12), // const HSpace(6), const Spacer(), - FlowyText.regular(state.typeOption.format.title(), fontSize: 12), + FlowyText.regular(state.typeOption.format.title(), + fontSize: 12), ], ), margin: GridSize.typeOptionContentInsets, @@ -65,7 +69,9 @@ class NumberTypeOptionWidget extends TypeOptionWidget { onTap: () { final list = NumberFormatList( onSelected: (format) { - context.read().add(NumberTypeOptionEvent.didSelectFormat(format)); + context + .read() + .add(NumberTypeOptionEvent.didSelectFormat(format)); }, selectedFormat: state.typeOption.format, ); @@ -88,7 +94,9 @@ typedef _SelectNumberFormatCallback = Function(NumberFormat format); class NumberFormatList extends StatelessWidget { final _SelectNumberFormatCallback onSelected; final NumberFormat selectedFormat; - const NumberFormatList({required this.selectedFormat, required this.onSelected, Key? key}) : super(key: key); + const NumberFormatList( + {required this.selectedFormat, required this.onSelected, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -108,7 +116,8 @@ class NumberFormatList extends StatelessWidget { format: format, onSelected: (format) { onSelected(format); - FlowyOverlay.of(context).remove(NumberFormatList.identifier()); + FlowyOverlay.of(context) + .remove(NumberFormatList.identifier()); }); }).toList(); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/rich_text.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/rich_text.dart similarity index 74% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/rich_text.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/rich_text.dart index 2375918f11..a4291f91ce 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/rich_text.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/rich_text.dart @@ -1,11 +1,12 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/type_option_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_service.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/text_type_option.pb.dart'; import 'package:flutter/material.dart'; import 'builder.dart'; typedef RichTextTypeOptionContext = TypeOptionWidgetContext; -class RichTextTypeOptionWidgetDataParser extends TypeOptionDataParser { +class RichTextTypeOptionWidgetDataParser + extends TypeOptionDataParser { @override RichTextTypeOption fromBuffer(List buffer) { return RichTextTypeOption.fromBuffer(buffer); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/select_option.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option.dart similarity index 79% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/select_option.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option.dart index c0d54159e8..5d6304ea7a 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/select_option.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option.dart @@ -1,7 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/select_option_type_option_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/extension.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/common/text_field.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/select_option_type_option_bloc.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/button.dart'; @@ -13,6 +10,9 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; +import '../../../layout/sizes.dart'; +import '../../cell/select_option_cell/extension.dart'; +import '../../common/text_field.dart'; import 'builder.dart'; import 'select_option_editor.dart'; @@ -33,8 +33,10 @@ class SelectOptionTypeOptionWidget extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => SelectOptionTypeOptionBloc(options: options, typeOptionAction: typeOptionAction), - child: BlocBuilder( + create: (context) => SelectOptionTypeOptionBloc( + options: options, typeOptionAction: typeOptionAction), + child: + BlocBuilder( builder: (context, state) { List children = [ const TypeOptionSeparator(), @@ -44,7 +46,8 @@ class SelectOptionTypeOptionWidget extends StatelessWidget { padding: EdgeInsets.only(bottom: 10), child: _CreateOptionTextField(), ), - if (state.options.isEmpty && !state.isEditingOption) const _AddOptionButton(), + if (state.options.isEmpty && !state.isEditingOption) + const _AddOptionButton(), _OptionList(overlayDelegate) ]; @@ -62,7 +65,9 @@ class OptionTitle extends StatelessWidget { Widget build(BuildContext context) { return BlocBuilder( builder: (context, state) { - List children = [FlowyText.medium(LocaleKeys.grid_field_optionTitle.tr(), fontSize: 12)]; + List children = [ + FlowyText.medium(LocaleKeys.grid_field_optionTitle.tr(), fontSize: 12) + ]; if (state.options.isNotEmpty) { children.add(const Spacer()); children.add(const _OptionTitleButton()); @@ -94,7 +99,9 @@ class _OptionTitleButton extends StatelessWidget { ), hoverColor: theme.hover, onTap: () { - context.read().add(const SelectOptionTypeOptionEvent.addingOption()); + context + .read() + .add(const SelectOptionTypeOptionEvent.addingOption()); }, ), ); @@ -139,11 +146,15 @@ class _OptionList extends StatelessWidget { option: option, onDeleted: () { delegate.hideOverlay(context); - context.read().add(SelectOptionTypeOptionEvent.deleteOption(option)); + context + .read() + .add(SelectOptionTypeOptionEvent.deleteOption(option)); }, onUpdated: (updatedOption) { delegate.hideOverlay(context); - context.read().add(SelectOptionTypeOptionEvent.updateOption(updatedOption)); + context + .read() + .add(SelectOptionTypeOptionEvent.updateOption(updatedOption)); }, key: ValueKey(option.id), ); @@ -191,10 +202,13 @@ class _AddOptionButton extends StatelessWidget { return SizedBox( height: GridSize.typeOptionItemHeight, child: FlowyButton( - text: FlowyText.medium(LocaleKeys.grid_field_addSelectOption.tr(), fontSize: 12), + text: FlowyText.medium(LocaleKeys.grid_field_addSelectOption.tr(), + fontSize: 12), hoverColor: theme.hover, onTap: () { - context.read().add(const SelectOptionTypeOptionEvent.addingOption()); + context + .read() + .add(const SelectOptionTypeOptionEvent.addingOption()); }, leftIcon: svgWidget("home/add", color: theme.iconColor), ), @@ -214,10 +228,14 @@ class _CreateOptionTextField extends StatelessWidget { autoClearWhenDone: true, text: text, onCanceled: () { - context.read().add(const SelectOptionTypeOptionEvent.endAddingOption()); + context + .read() + .add(const SelectOptionTypeOptionEvent.endAddingOption()); }, onDone: (optionName) { - context.read().add(SelectOptionTypeOptionEvent.createOption(optionName)); + context + .read() + .add(SelectOptionTypeOptionEvent.createOption(optionName)); }, ); }, diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/select_option_editor.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option_editor.dart similarity index 81% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/select_option_editor.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option_editor.dart index 5381342d20..fbb42b5784 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/select_option_editor.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option_editor.dart @@ -1,7 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/edit_select_option_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/select_option_cell/extension.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/common/text_field.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/edit_select_option_bloc.dart'; +import 'package:app_flowy/plugins/grid/presentation/widgets/cell/select_option_cell/extension.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/button.dart'; @@ -14,6 +12,9 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; +import '../../../layout/sizes.dart'; +import '../../common/text_field.dart'; + class SelectOptionTypeOptionEditor extends StatelessWidget { final SelectOptionPB option; final VoidCallback onDeleted; @@ -49,11 +50,14 @@ class SelectOptionTypeOptionEditor extends StatelessWidget { child: BlocBuilder( builder: (context, state) { List slivers = [ - SliverToBoxAdapter(child: _OptionNameTextField(state.option.name)), + SliverToBoxAdapter( + child: _OptionNameTextField(state.option.name)), const SliverToBoxAdapter(child: VSpace(10)), const SliverToBoxAdapter(child: _DeleteTag()), const SliverToBoxAdapter(child: TypeOptionSeparator()), - SliverToBoxAdapter(child: SelectOptionColorList(selectedColor: state.option.color)), + SliverToBoxAdapter( + child: + SelectOptionColorList(selectedColor: state.option.color)), ]; return SizedBox( @@ -80,11 +84,14 @@ class _DeleteTag extends StatelessWidget { return SizedBox( height: GridSize.typeOptionItemHeight, child: FlowyButton( - text: FlowyText.medium(LocaleKeys.grid_selectOption_deleteTag.tr(), fontSize: 12), + text: FlowyText.medium(LocaleKeys.grid_selectOption_deleteTag.tr(), + fontSize: 12), hoverColor: theme.hover, leftIcon: svgWidget("grid/delete", color: theme.iconColor), onTap: () { - context.read().add(const EditSelectOptionEvent.delete()); + context + .read() + .add(const EditSelectOptionEvent.delete()); }, ), ); @@ -102,7 +109,9 @@ class _OptionNameTextField extends StatelessWidget { onCanceled: () {}, onDone: (optionName) { if (name != optionName) { - context.read().add(EditSelectOptionEvent.updateName(optionName)); + context + .read() + .add(EditSelectOptionEvent.updateName(optionName)); } }, ); @@ -111,12 +120,14 @@ class _OptionNameTextField extends StatelessWidget { class SelectOptionColorList extends StatelessWidget { final SelectOptionColorPB selectedColor; - const SelectOptionColorList({required this.selectedColor, Key? key}) : super(key: key); + const SelectOptionColorList({required this.selectedColor, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { final cells = SelectOptionColorPB.values.map((color) { - return _SelectOptionColorCell(color: color, isSelected: selectedColor == color); + return _SelectOptionColorCell( + color: color, isSelected: selectedColor == color); }).toList(); return Column( @@ -154,7 +165,9 @@ class SelectOptionColorList extends StatelessWidget { class _SelectOptionColorCell extends StatelessWidget { final SelectOptionColorPB color; final bool isSelected; - const _SelectOptionColorCell({required this.color, required this.isSelected, Key? key}) : super(key: key); + const _SelectOptionColorCell( + {required this.color, required this.isSelected, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -182,7 +195,9 @@ class _SelectOptionColorCell extends StatelessWidget { leftIcon: colorIcon, rightIcon: checkmark, onTap: () { - context.read().add(EditSelectOptionEvent.updateColor(color)); + context + .read() + .add(EditSelectOptionEvent.updateColor(color)); }, ), ); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/single_select.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/single_select.dart similarity index 85% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/single_select.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/single_select.dart index a1ed4e857a..57940ecbee 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/single_select.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/single_select.dart @@ -1,6 +1,6 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/single_select_type_option.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_type_option_editor.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/single_select_type_option.dart'; import 'package:flutter/material.dart'; +import '../field_type_option_editor.dart'; import 'builder.dart'; import 'select_option.dart'; diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/url.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/url.dart similarity index 74% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/url.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/url.dart index 97c0db0814..894a1b1e5c 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/type_option/url.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/url.dart @@ -1,11 +1,12 @@ -import 'package:app_flowy/workspace/application/grid/field/type_option/type_option_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_service.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/url_type_option.pb.dart'; import 'package:flutter/material.dart'; import 'builder.dart'; typedef URLTypeOptionContext = TypeOptionWidgetContext; -class URLTypeOptionWidgetDataParser extends TypeOptionDataParser { +class URLTypeOptionWidgetDataParser + extends TypeOptionDataParser { @override URLTypeOption fromBuffer(List buffer) { return URLTypeOption.fromBuffer(buffer); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/grid_row.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/grid_row.dart similarity index 89% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/grid_row.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/grid_row.dart index c3e2e17b7e..effc1b188c 100755 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/grid_row.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/grid_row.dart @@ -1,8 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/prelude.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/cell_accessory.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/cell_cotainer.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/icon_button.dart'; @@ -11,6 +7,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:provider/provider.dart'; +import '../../layout/sizes.dart'; +import '../cell/cell_accessory.dart'; +import '../cell/cell_cotainer.dart'; +import '../cell/prelude.dart'; import 'row_action_sheet.dart'; import 'row_detail.dart'; @@ -95,7 +95,9 @@ class _RowLeading extends StatelessWidget { Widget build(BuildContext context) { return Consumer( builder: (context, state, _) { - return SizedBox(width: GridSize.leadingHeaderPadding, child: state.onEnter ? _activeWidget() : null); + return SizedBox( + width: GridSize.leadingHeaderPadding, + child: state.onEnter ? _activeWidget() : null); }, ); } @@ -168,7 +170,8 @@ class _RowCells extends StatelessWidget { @override Widget build(BuildContext context) { return BlocBuilder( - buildWhen: (previous, current) => !listEquals(previous.snapshots, current.snapshots), + buildWhen: (previous, current) => + !listEquals(previous.snapshots, current.snapshots), builder: (context, state) { return IntrinsicHeight( child: Row( @@ -204,7 +207,8 @@ class _RowCells extends StatelessWidget { return CellContainer( width: cellId.field.width.toDouble(), child: child, - rowStateNotifier: Provider.of(context, listen: false), + rowStateNotifier: + Provider.of(context, listen: false), accessoryBuilder: accessoryBuilder, ); }, diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_action_sheet.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_action_sheet.dart similarity index 87% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_action_sheet.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_action_sheet.dart index 06e9c68d19..67c7b4893b 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_action_sheet.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_action_sheet.dart @@ -1,6 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/row/row_action_sheet_bloc.dart'; -import 'package:app_flowy/workspace/application/grid/row/row_service.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; +import 'package:app_flowy/plugins/grid/application/row/row_action_sheet_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/row/row_service.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; import 'package:flowy_infra/image.dart'; @@ -13,6 +12,8 @@ import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import '../../layout/sizes.dart'; + class GridRowActionSheet extends StatelessWidget { final GridRowInfo rowData; const GridRowActionSheet({required this.rowData, Key? key}) : super(key: key); @@ -76,7 +77,9 @@ class GridRowActionSheet extends StatelessWidget { class _RowActionCell extends StatelessWidget { final _RowAction action; final VoidCallback onDismissed; - const _RowActionCell({required this.action, required this.onDismissed, Key? key}) : super(key: key); + const _RowActionCell( + {required this.action, required this.onDismissed, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -139,10 +142,14 @@ extension _RowActionExtension on _RowAction { void performAction(BuildContext context) { switch (this) { case _RowAction.duplicate: - context.read().add(const RowActionSheetEvent.duplicateRow()); + context + .read() + .add(const RowActionSheetEvent.duplicateRow()); break; case _RowAction.delete: - context.read().add(const RowActionSheetEvent.deleteRow()); + context + .read() + .add(const RowActionSheetEvent.deleteRow()); break; } } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_detail.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_detail.dart similarity index 83% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_detail.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_detail.dart index a01f97b847..e7e00ead68 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_detail.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_detail.dart @@ -1,13 +1,7 @@ -import 'package:app_flowy/workspace/application/grid/cell/cell_service/cell_service.dart'; -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; -import 'package:app_flowy/workspace/application/grid/row/row_detail_bloc.dart'; -import 'package:app_flowy/workspace/application/grid/row/row_service.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/cell_accessory.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/prelude.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/url_cell/url_cell.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_cell.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_editor.dart'; +import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/row/row_detail_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/row/row_service.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; @@ -20,6 +14,12 @@ import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import '../../layout/sizes.dart'; +import '../cell/cell_accessory.dart'; +import '../cell/prelude.dart'; +import '../header/field_cell.dart'; +import '../header/field_editor.dart'; + class RowDetailPage extends StatefulWidget with FlowyOverlayDelegate { final GridRowInfo rowInfo; final GridRowCache rowCache; @@ -62,7 +62,8 @@ class _RowDetailPageState extends State { Widget build(BuildContext context) { return BlocProvider( create: (context) { - final bloc = RowDetailBloc(rowInfo: widget.rowInfo, rowCache: widget.rowCache); + final bloc = + RowDetailBloc(rowInfo: widget.rowInfo, rowCache: widget.rowCache); bloc.add(const RowDetailEvent.initial()); return bloc; }, @@ -92,7 +93,8 @@ class _CloseButton extends StatelessWidget { final theme = context.watch(); return FlowyIconButton( width: 24, - onPressed: () => FlowyOverlay.of(context).remove(RowDetailPage.identifier()), + onPressed: () => + FlowyOverlay.of(context).remove(RowDetailPage.identifier()), iconPadding: const EdgeInsets.fromLTRB(2, 2, 2, 2), icon: svgWidget("home/close", color: theme.iconColor), ); @@ -156,7 +158,8 @@ class _RowDetailCell extends StatelessWidget { onTap: () => cell.beginFocus.notify(), child: AccessoryHover( child: cell, - contentPadding: const EdgeInsets.symmetric(horizontal: 10, vertical: 12), + contentPadding: + const EdgeInsets.symmetric(horizontal: 10, vertical: 12), ), ); @@ -169,7 +172,8 @@ class _RowDetailCell extends StatelessWidget { children: [ SizedBox( width: 150, - child: FieldCellButton(field: cellId.field, onTap: () => _showFieldEditor(context)), + child: FieldCellButton( + field: cellId.field, onTap: () => _showFieldEditor(context)), ), const HSpace(10), Expanded(child: gesture), diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/shortcuts.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/shortcuts.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/shortcuts.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/shortcuts.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_property.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_property.dart similarity index 81% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_property.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_property.dart index b34007493b..df4eb2115c 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_property.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_property.dart @@ -1,10 +1,8 @@ import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/grid/field/field_service.dart'; -import 'package:app_flowy/workspace/application/grid/grid_service.dart'; -import 'package:app_flowy/workspace/application/grid/setting/property_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_editor.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_type_extension.dart'; +import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; +import 'package:app_flowy/plugins/grid/application/grid_service.dart'; +import 'package:app_flowy/plugins/grid/application/setting/property_bloc.dart'; +import 'package:app_flowy/plugins/grid/presentation/widgets/header/field_type_extension.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; @@ -17,6 +15,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:styled_widget/styled_widget.dart'; +import '../../layout/sizes.dart'; +import '../header/field_editor.dart'; + class GridPropertyList extends StatelessWidget with FlowyOverlayDelegate { final String gridId; final GridFieldCache fieldCache; @@ -44,11 +45,13 @@ class GridPropertyList extends StatelessWidget with FlowyOverlayDelegate { Widget build(BuildContext context) { return BlocProvider( create: (context) => - getIt(param1: gridId, param2: fieldCache)..add(const GridPropertyEvent.initial()), + getIt(param1: gridId, param2: fieldCache) + ..add(const GridPropertyEvent.initial()), child: BlocBuilder( builder: (context, state) { final cells = state.fields.map((field) { - return _GridPropertyCell(gridId: gridId, field: field, key: ValueKey(field.id)); + return _GridPropertyCell( + gridId: gridId, field: field, key: ValueKey(field.id)); }).toList(); return ListView.separated( @@ -77,7 +80,8 @@ class GridPropertyList extends StatelessWidget with FlowyOverlayDelegate { class _GridPropertyCell extends StatelessWidget { final GridFieldPB field; final String gridId; - const _GridPropertyCell({required this.gridId, required this.field, Key? key}) : super(key: key); + const _GridPropertyCell({required this.gridId, required this.field, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -99,7 +103,9 @@ class _GridPropertyCell extends StatelessWidget { hoverColor: theme.hover, width: GridSize.typeOptionItemHeight, onPressed: () { - context.read().add(GridPropertyEvent.setFieldVisibility(field.id, !field.visibility)); + context.read().add( + GridPropertyEvent.setFieldVisibility( + field.id, !field.visibility)); }, icon: checkmark.padding(all: 6), ) diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_setting.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_setting.dart similarity index 82% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_setting.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_setting.dart index 7e3c14e021..d7c084fe2d 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_setting.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_setting.dart @@ -1,5 +1,5 @@ -import 'package:app_flowy/workspace/application/grid/grid_service.dart'; -import 'package:app_flowy/workspace/application/grid/setting/setting_bloc.dart'; +import 'package:app_flowy/plugins/grid/application/grid_service.dart'; +import 'package:app_flowy/plugins/grid/application/setting/setting_bloc.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; @@ -12,8 +12,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; - +import '../../layout/sizes.dart'; import 'grid_property.dart'; class GridSettingContext { @@ -29,7 +28,9 @@ class GridSettingContext { class GridSettingList extends StatelessWidget { final GridSettingContext settingContext; final Function(GridSettingAction, GridSettingContext) onAction; - const GridSettingList({required this.settingContext, required this.onAction, Key? key}) : super(key: key); + const GridSettingList( + {required this.settingContext, required this.onAction, Key? key}) + : super(key: key); static void show(BuildContext context, GridSettingContext settingContext) { final list = GridSettingList( @@ -41,7 +42,10 @@ class GridSettingList extends StatelessWidget { case GridSettingAction.sortBy: break; case GridSettingAction.properties: - GridPropertyList(gridId: settingContext.gridId, fieldCache: settingContext.fieldCache).show(context); + GridPropertyList( + gridId: settingContext.gridId, + fieldCache: settingContext.fieldCache) + .show(context); break; } }, @@ -64,7 +68,8 @@ class GridSettingList extends StatelessWidget { return BlocProvider( create: (context) => GridSettingBloc(gridId: settingContext.gridId), child: BlocListener( - listenWhen: (previous, current) => previous.selectedAction != current.selectedAction, + listenWhen: (previous, current) => + previous.selectedAction != current.selectedAction, listener: (context, state) { state.selectedAction.foldLeft(null, (_, action) { FlowyOverlay.of(context).remove(identifier()); @@ -85,7 +90,8 @@ class GridSettingList extends StatelessWidget { } Widget _renderList() { - final cells = GridSettingAction.values.where((value) => value.enable()).map((action) { + final cells = + GridSettingAction.values.where((value) => value.enable()).map((action) { return _SettingItem(action: action); }).toList(); @@ -128,10 +134,13 @@ class _SettingItem extends StatelessWidget { height: GridSize.typeOptionItemHeight, child: FlowyButton( isSelected: isSelected, - text: FlowyText.medium(action.title(), fontSize: 12, color: action.enable() ? null : theme.shader4), + text: FlowyText.medium(action.title(), + fontSize: 12, color: action.enable() ? null : theme.shader4), hoverColor: theme.hover, onTap: () { - context.read().add(GridSettingEvent.performAction(action)); + context + .read() + .add(GridSettingEvent.performAction(action)); }, leftIcon: svgWidget(action.iconName(), color: theme.iconColor), ), diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_toolbar.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_toolbar.dart similarity index 85% rename from frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_toolbar.dart rename to frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_toolbar.dart index 8d25189163..2f332ffe2f 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/toolbar/grid_toolbar.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_toolbar.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/application/grid/grid_service.dart'; +import 'package:app_flowy/plugins/grid/application/grid_service.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/extension.dart'; @@ -6,8 +6,7 @@ import 'package:flowy_infra_ui/style_widget/icon_button.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; - +import '../../layout/sizes.dart'; import 'grid_setting.dart'; class GridToolbarContext { @@ -44,7 +43,8 @@ class GridToolbar extends StatelessWidget { class _SettingButton extends StatelessWidget { final GridSettingContext settingContext; - const _SettingButton({required this.settingContext, Key? key}) : super(key: key); + const _SettingButton({required this.settingContext, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -53,7 +53,8 @@ class _SettingButton extends StatelessWidget { hoverColor: theme.hover, width: 22, onPressed: () => GridSettingList.show(context, settingContext), - icon: svgWidget("grid/setting/setting").padding(horizontal: 3, vertical: 3), + icon: + svgWidget("grid/setting/setting").padding(horizontal: 3, vertical: 3), ); } } diff --git a/frontend/app_flowy/lib/workspace/application/trash/prelude.dart b/frontend/app_flowy/lib/plugins/trash/application/prelude.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/trash/prelude.dart rename to frontend/app_flowy/lib/plugins/trash/application/prelude.dart diff --git a/frontend/app_flowy/lib/workspace/application/trash/trash_bloc.dart b/frontend/app_flowy/lib/plugins/trash/application/trash_bloc.dart similarity index 82% rename from frontend/app_flowy/lib/workspace/application/trash/trash_bloc.dart rename to frontend/app_flowy/lib/plugins/trash/application/trash_bloc.dart index a7bcf0588c..0286747fd5 100644 --- a/frontend/app_flowy/lib/workspace/application/trash/trash_bloc.dart +++ b/frontend/app_flowy/lib/plugins/trash/application/trash_bloc.dart @@ -4,20 +4,23 @@ import 'package:flowy_sdk/protobuf/flowy-folder/trash.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:app_flowy/workspace/application/trash/trash_service.dart'; -import 'package:app_flowy/workspace/application/trash/trash_listener.dart'; +import 'package:app_flowy/plugins/trash/application/trash_service.dart'; +import 'package:app_flowy/plugins/trash/application/trash_listener.dart'; + part 'trash_bloc.freezed.dart'; class TrashBloc extends Bloc { final TrashService service; final TrashListener listener; - TrashBloc({required this.service, required this.listener}) : super(TrashState.init()) { + TrashBloc({required this.service, required this.listener}) + : super(TrashState.init()) { on((event, emit) async { await event.map(initial: (e) async { listener.start(trashUpdated: _listenTrashUpdated); final result = await service.readTrash(); emit(result.fold( - (object) => state.copyWith(objects: object.items, successOrFailure: left(unit)), + (object) => state.copyWith( + objects: object.items, successOrFailure: left(unit)), (error) => state.copyWith(successOrFailure: right(error)), )); }, didReceiveTrash: (e) async { @@ -26,7 +29,8 @@ class TrashBloc extends Bloc { final result = await service.putback(e.trashId); await _handleResult(result, emit); }, delete: (e) async { - final result = await service.deleteViews([Tuple2(e.trash.id, e.trash.ty)]); + final result = + await service.deleteViews([Tuple2(e.trash.id, e.trash.ty)]); await _handleResult(result, emit); }, deleteAll: (e) async { final result = await service.deleteAll(); @@ -38,7 +42,8 @@ class TrashBloc extends Bloc { }); } - Future _handleResult(Either result, Emitter emit) async { + Future _handleResult( + Either result, Emitter emit) async { emit(result.fold( (l) => state.copyWith(successOrFailure: left(unit)), (error) => state.copyWith(successOrFailure: right(error)), diff --git a/frontend/app_flowy/lib/workspace/application/trash/trash_listener.dart b/frontend/app_flowy/lib/plugins/trash/application/trash_listener.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/trash/trash_listener.dart rename to frontend/app_flowy/lib/plugins/trash/application/trash_listener.dart diff --git a/frontend/app_flowy/lib/workspace/application/trash/trash_service.dart b/frontend/app_flowy/lib/plugins/trash/application/trash_service.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/application/trash/trash_service.dart rename to frontend/app_flowy/lib/plugins/trash/application/trash_service.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/menu.dart b/frontend/app_flowy/lib/plugins/trash/menu.dart similarity index 77% rename from frontend/app_flowy/lib/workspace/presentation/plugins/trash/menu.dart rename to frontend/app_flowy/lib/plugins/trash/menu.dart index ec782db205..e0a6c5ce49 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/menu.dart +++ b/frontend/app_flowy/lib/plugins/trash/menu.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/application/appearance.dart'; import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; @@ -22,7 +22,8 @@ class MenuTrash extends StatelessWidget { child: InkWell( onTap: () { getIt().latestOpenView = null; - getIt().setPlugin(makePlugin(pluginType: DefaultPlugin.trash.type())); + getIt() + .setPlugin(makePlugin(pluginType: DefaultPlugin.trash.type())); }, child: _render(context), ), @@ -35,8 +36,10 @@ class MenuTrash extends StatelessWidget { value: Provider.of(context, listen: true), child: Selector( selector: (ctx, notifier) => notifier.theme, - builder: (ctx, theme, child) => - SizedBox(width: 16, height: 16, child: svgWidget("home/trash", color: theme.iconColor)), + builder: (ctx, theme, child) => SizedBox( + width: 16, + height: 16, + child: svgWidget("home/trash", color: theme.iconColor)), ), ), const HSpace(6), @@ -44,7 +47,8 @@ class MenuTrash extends StatelessWidget { value: Provider.of(context, listen: true), child: Selector( selector: (ctx, notifier) => notifier.locale, - builder: (ctx, _, child) => FlowyText.medium(LocaleKeys.trash_text.tr(), fontSize: 12), + builder: (ctx, _, child) => + FlowyText.medium(LocaleKeys.trash_text.tr(), fontSize: 12), ), ), ]); diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/src/sizes.dart b/frontend/app_flowy/lib/plugins/trash/src/sizes.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/trash/src/sizes.dart rename to frontend/app_flowy/lib/plugins/trash/src/sizes.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/src/trash_cell.dart b/frontend/app_flowy/lib/plugins/trash/src/trash_cell.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/trash/src/trash_cell.dart rename to frontend/app_flowy/lib/plugins/trash/src/trash_cell.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/src/trash_header.dart b/frontend/app_flowy/lib/plugins/trash/src/trash_header.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/trash/src/trash_header.dart rename to frontend/app_flowy/lib/plugins/trash/src/trash_header.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/trash.dart b/frontend/app_flowy/lib/plugins/trash/trash.dart similarity index 90% rename from frontend/app_flowy/lib/workspace/presentation/plugins/trash/trash.dart rename to frontend/app_flowy/lib/plugins/trash/trash.dart index e098eddf96..18a2c4aa8e 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/trash/trash.dart +++ b/frontend/app_flowy/lib/plugins/trash/trash.dart @@ -2,9 +2,9 @@ export "./src/sizes.dart"; export "./src/trash_cell.dart"; export "./src/trash_header.dart"; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/trash/trash_bloc.dart'; +import 'package:app_flowy/plugins/trash/application/trash_bloc.dart'; import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra/image.dart'; @@ -59,7 +59,8 @@ class TrashPlugin extends Plugin { class TrashPluginDisplay extends PluginDisplay { @override - Widget get leftBarItem => FlowyText.medium(LocaleKeys.trash_text.tr(), fontSize: 12); + Widget get leftBarItem => + FlowyText.medium(LocaleKeys.trash_text.tr(), fontSize: 12); @override Widget? get rightBarItem => null; @@ -145,20 +146,24 @@ class _TrashPageState extends State { SizedBox.fromSize( size: const Size(102, 30), child: FlowyButton( - text: FlowyText.medium(LocaleKeys.trash_restoreAll.tr(), fontSize: 12), + text: FlowyText.medium(LocaleKeys.trash_restoreAll.tr(), + fontSize: 12), leftIcon: svgWidget('editor/restore', color: theme.iconColor), hoverColor: theme.hover, - onTap: () => context.read().add(const TrashEvent.restoreAll()), + onTap: () => + context.read().add(const TrashEvent.restoreAll()), ), ), const HSpace(6), SizedBox.fromSize( size: const Size(102, 30), child: FlowyButton( - text: FlowyText.medium(LocaleKeys.trash_deleteAll.tr(), fontSize: 12), + text: FlowyText.medium(LocaleKeys.trash_deleteAll.tr(), + fontSize: 12), leftIcon: svgWidget('editor/delete', color: theme.iconColor), hoverColor: theme.hover, - onTap: () => context.read().add(const TrashEvent.deleteAll()), + onTap: () => + context.read().add(const TrashEvent.deleteAll()), ), ) ], @@ -186,7 +191,8 @@ class _TrashPageState extends State { onRestore: () { context.read().add(TrashEvent.putback(object.id)); }, - onDelete: () => context.read().add(TrashEvent.delete(object)), + onDelete: () => + context.read().add(TrashEvent.delete(object)), ), ); }, diff --git a/frontend/app_flowy/lib/startup/deps_resolver.dart b/frontend/app_flowy/lib/startup/deps_resolver.dart index e0ab40eea7..8b173a4002 100644 --- a/frontend/app_flowy/lib/startup/deps_resolver.dart +++ b/frontend/app_flowy/lib/startup/deps_resolver.dart @@ -2,17 +2,17 @@ import 'package:app_flowy/core/network_monitor.dart'; import 'package:app_flowy/user/application/user_listener.dart'; import 'package:app_flowy/user/application/user_service.dart'; import 'package:app_flowy/workspace/application/app/prelude.dart'; -import 'package:app_flowy/workspace/application/doc/prelude.dart'; -import 'package:app_flowy/workspace/application/grid/prelude.dart'; -import 'package:app_flowy/workspace/application/trash/prelude.dart'; +import 'package:app_flowy/plugins/doc/application/prelude.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:app_flowy/workspace/application/user/prelude.dart'; import 'package:app_flowy/workspace/application/workspace/prelude.dart'; -import 'package:app_flowy/workspace/application/edit_pannel/edit_pannel_bloc.dart'; +import 'package:app_flowy/workspace/application/edit_panel/edit_panel_bloc.dart'; import 'package:app_flowy/workspace/application/view/prelude.dart'; import 'package:app_flowy/workspace/application/menu/prelude.dart'; import 'package:app_flowy/workspace/application/settings/prelude.dart'; import 'package:app_flowy/user/application/prelude.dart'; import 'package:app_flowy/user/presentation/router.dart'; +import 'package:app_flowy/plugins/trash/application/prelude.dart'; import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; import 'package:app_flowy/workspace/presentation/home/menu/menu.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart'; @@ -43,7 +43,7 @@ void _resolveUserDeps(GetIt getIt) { getIt.registerFactory(() => SignUpBloc(getIt())); getIt.registerFactory(() => SplashRoute()); - getIt.registerFactory(() => EditPannelBloc()); + getIt.registerFactory(() => EditPanelBloc()); getIt.registerFactory(() => SplashBloc()); getIt.registerLazySingleton(() => NetworkListener()); } @@ -76,7 +76,8 @@ void _resolveHomeDeps(GetIt getIt) { void _resolveFolderDeps(GetIt getIt) { //workspace getIt.registerFactoryParam( - (user, workspaceId) => WorkspaceListener(user: user, workspaceId: workspaceId)); + (user, workspaceId) => + WorkspaceListener(user: user, workspaceId: workspaceId)); // ViewPB getIt.registerFactoryParam( @@ -171,7 +172,8 @@ void _resolveGridDeps(GetIt getIt) { ), ); - getIt.registerFactoryParam( + getIt.registerFactoryParam( (context, _) => SelectOptionCellBloc( cellContext: context, ), diff --git a/frontend/app_flowy/lib/plugin/plugin.dart b/frontend/app_flowy/lib/startup/plugin/plugin.dart similarity index 93% rename from frontend/app_flowy/lib/plugin/plugin.dart rename to frontend/app_flowy/lib/startup/plugin/plugin.dart index e05a3ad862..a02a8cfb83 100644 --- a/frontend/app_flowy/lib/plugin/plugin.dart +++ b/frontend/app_flowy/lib/startup/plugin/plugin.dart @@ -1,6 +1,6 @@ library flowy_plugin; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; import 'package:flowy_infra/notifier.dart'; @@ -72,7 +72,8 @@ abstract class PluginDisplay with NavigationItem { } void registerPlugin({required PluginBuilder builder, PluginConfig? config}) { - getIt().registerPlugin(builder.pluginType, builder, config: config); + getIt() + .registerPlugin(builder.pluginType, builder, config: config); } Plugin makePlugin({required PluginType pluginType, dynamic data}) { diff --git a/frontend/app_flowy/lib/plugin/src/runner.dart b/frontend/app_flowy/lib/startup/plugin/src/runner.dart similarity index 100% rename from frontend/app_flowy/lib/plugin/src/runner.dart rename to frontend/app_flowy/lib/startup/plugin/src/runner.dart diff --git a/frontend/app_flowy/lib/plugin/src/sandbox.dart b/frontend/app_flowy/lib/startup/plugin/src/sandbox.dart similarity index 100% rename from frontend/app_flowy/lib/plugin/src/sandbox.dart rename to frontend/app_flowy/lib/startup/plugin/src/sandbox.dart diff --git a/frontend/app_flowy/lib/startup/startup.dart b/frontend/app_flowy/lib/startup/startup.dart index 38243afa56..f71df96f23 100644 --- a/frontend/app_flowy/lib/startup/startup.dart +++ b/frontend/app_flowy/lib/startup/startup.dart @@ -1,6 +1,6 @@ import 'dart:io'; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/startup/tasks/prelude.dart'; import 'package:app_flowy/startup/deps_resolver.dart'; import 'package:flutter/foundation.dart'; diff --git a/frontend/app_flowy/lib/startup/tasks/load_plugin.dart b/frontend/app_flowy/lib/startup/tasks/load_plugin.dart index d89bc83b37..5eabc18064 100644 --- a/frontend/app_flowy/lib/startup/tasks/load_plugin.dart +++ b/frontend/app_flowy/lib/startup/tasks/load_plugin.dart @@ -1,10 +1,10 @@ -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/presentation/plugins/blank/blank.dart'; -import 'package:app_flowy/workspace/presentation/plugins/board/board.dart'; -import 'package:app_flowy/workspace/presentation/plugins/doc/document.dart'; -import 'package:app_flowy/workspace/presentation/plugins/grid/grid.dart'; -import 'package:app_flowy/workspace/presentation/plugins/trash/trash.dart'; +import 'package:app_flowy/plugins/blank/blank.dart'; +import 'package:app_flowy/plugins/board/board.dart'; +import 'package:app_flowy/plugins/doc/document.dart'; +import 'package:app_flowy/plugins/grid/grid.dart'; +import 'package:app_flowy/plugins/trash/trash.dart'; class PluginLoadTask extends LaunchTask { @override diff --git a/frontend/app_flowy/lib/workspace/application/app/app_bloc.dart b/frontend/app_flowy/lib/workspace/application/app/app_bloc.dart index e8d2335168..f86bb5855b 100644 --- a/frontend/app_flowy/lib/workspace/application/app/app_bloc.dart +++ b/frontend/app_flowy/lib/workspace/application/app/app_bloc.dart @@ -1,6 +1,6 @@ import 'dart:collection'; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/application/app/app_listener.dart'; import 'package:app_flowy/workspace/application/app/app_service.dart'; @@ -22,7 +22,9 @@ class AppBloc extends Bloc { final AppService appService; final AppListener appListener; - AppBloc({required this.app, required this.appService, required this.appListener}) : super(AppState.initial(app)) { + AppBloc( + {required this.app, required this.appService, required this.appListener}) + : super(AppState.initial(app)) { on((event, emit) async { await event.map(initial: (e) async { _startListening(); @@ -103,11 +105,13 @@ class AppBloc extends Bloc { return super.close(); } - Future _didReceiveViewUpdated(List views, Emitter emit) async { + Future _didReceiveViewUpdated( + List views, Emitter emit) async { final latestCreatedView = state.latestCreatedView; AppState newState = state.copyWith(views: views); if (latestCreatedView != null) { - final index = views.indexWhere((element) => element.id == latestCreatedView.id); + final index = + views.indexWhere((element) => element.id == latestCreatedView.id); if (index == -1) { newState = newState.copyWith(latestCreatedView: null); } @@ -139,7 +143,8 @@ class AppEvent with _$AppEvent { ) = CreateView; const factory AppEvent.delete() = Delete; const factory AppEvent.rename(String newName) = Rename; - const factory AppEvent.didReceiveViewUpdated(List views) = ReceiveViews; + const factory AppEvent.didReceiveViewUpdated(List views) = + ReceiveViews; const factory AppEvent.appDidUpdate(AppPB app) = AppDidUpdate; } @@ -164,11 +169,13 @@ class AppViewDataContext extends ChangeNotifier { final ValueNotifier> _viewsNotifier = ValueNotifier([]); final ValueNotifier _selectedViewNotifier = ValueNotifier(null); VoidCallback? _menuSharedStateListener; - ExpandableController expandController = ExpandableController(initialExpanded: false); + ExpandableController expandController = + ExpandableController(initialExpanded: false); AppViewDataContext({required this.appId}) { _setLatestView(getIt().latestOpenView); - _menuSharedStateListener = getIt().addLatestViewListener((view) { + _menuSharedStateListener = + getIt().addLatestViewListener((view) { _setLatestView(view); }); } @@ -206,9 +213,11 @@ class AppViewDataContext extends ChangeNotifier { } } - UnmodifiableListView get views => UnmodifiableListView(_viewsNotifier.value); + UnmodifiableListView get views => + UnmodifiableListView(_viewsNotifier.value); - VoidCallback addViewsChangeListener(void Function(UnmodifiableListView) callback) { + VoidCallback addViewsChangeListener( + void Function(UnmodifiableListView) callback) { listener() { callback(views); } @@ -241,7 +250,8 @@ class AppViewDataContext extends ChangeNotifier { @override void dispose() { if (_menuSharedStateListener != null) { - getIt().removeLatestViewListener(_menuSharedStateListener!); + getIt() + .removeLatestViewListener(_menuSharedStateListener!); } super.dispose(); } diff --git a/frontend/app_flowy/lib/workspace/application/app/app_service.dart b/frontend/app_flowy/lib/workspace/application/app/app_service.dart index cc75751e49..695f2f4b6b 100644 --- a/frontend/app_flowy/lib/workspace/application/app/app_service.dart +++ b/frontend/app_flowy/lib/workspace/application/app/app_service.dart @@ -6,7 +6,7 @@ import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; class AppService { final String appId; @@ -53,7 +53,8 @@ class AppService { return FolderEventDeleteApp(request).send(); } - Future> updateApp({required String appId, String? name}) { + Future> updateApp( + {required String appId, String? name}) { UpdateAppPayloadPB payload = UpdateAppPayloadPB.create()..appId = appId; if (name != null) { diff --git a/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_context.dart b/frontend/app_flowy/lib/workspace/application/edit_panel/edit_context.dart similarity index 57% rename from frontend/app_flowy/lib/workspace/application/edit_pannel/edit_context.dart rename to frontend/app_flowy/lib/workspace/application/edit_panel/edit_context.dart index 571461b365..6234858f60 100644 --- a/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_context.dart +++ b/frontend/app_flowy/lib/workspace/application/edit_panel/edit_context.dart @@ -1,11 +1,12 @@ import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; -abstract class EditPannelContext extends Equatable { +abstract class EditPanelContext extends Equatable { final String identifier; final String title; final Widget child; - const EditPannelContext({required this.child, required this.identifier, required this.title}); + const EditPanelContext( + {required this.child, required this.identifier, required this.title}); @override List get props => [identifier]; diff --git a/frontend/app_flowy/lib/workspace/application/edit_panel/edit_panel_bloc.dart b/frontend/app_flowy/lib/workspace/application/edit_panel/edit_panel_bloc.dart new file mode 100644 index 0000000000..d739c25559 --- /dev/null +++ b/frontend/app_flowy/lib/workspace/application/edit_panel/edit_panel_bloc.dart @@ -0,0 +1,41 @@ +import 'package:app_flowy/workspace/application/edit_panel/edit_context.dart'; +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +part 'edit_panel_bloc.freezed.dart'; + +class EditPanelBloc extends Bloc { + EditPanelBloc() : super(EditPanelState.initial()) { + on((event, emit) async { + await event.map( + startEdit: (e) async { + emit(state.copyWith(isEditing: true, editContext: some(e.context))); + }, + endEdit: (value) async { + emit(state.copyWith(isEditing: false, editContext: none())); + }, + ); + }); + } +} + +@freezed +class EditPanelEvent with _$EditPanelEvent { + const factory EditPanelEvent.startEdit(EditPanelContext context) = _StartEdit; + + const factory EditPanelEvent.endEdit(EditPanelContext context) = _EndEdit; +} + +@freezed +class EditPanelState with _$EditPanelState { + const factory EditPanelState({ + required bool isEditing, + required Option editContext, + }) = _EditPanelState; + + factory EditPanelState.initial() => EditPanelState( + isEditing: false, + editContext: none(), + ); +} diff --git a/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart b/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart deleted file mode 100644 index e1f2f5835d..0000000000 --- a/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart +++ /dev/null @@ -1,41 +0,0 @@ -import 'package:app_flowy/workspace/application/edit_pannel/edit_context.dart'; -import 'package:dartz/dartz.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; - -part 'edit_pannel_bloc.freezed.dart'; - -class EditPannelBloc extends Bloc { - EditPannelBloc() : super(EditPannelState.initial()) { - on((event, emit) async { - await event.map( - startEdit: (e) async { - emit(state.copyWith(isEditing: true, editContext: some(e.context))); - }, - endEdit: (value) async { - emit(state.copyWith(isEditing: false, editContext: none())); - }, - ); - }); - } -} - -@freezed -class EditPannelEvent with _$EditPannelEvent { - const factory EditPannelEvent.startEdit(EditPannelContext context) = _StartEdit; - - const factory EditPannelEvent.endEdit(EditPannelContext context) = _EndEdit; -} - -@freezed -class EditPannelState with _$EditPannelState { - const factory EditPannelState({ - required bool isEditing, - required Option editContext, - }) = _EditPannelState; - - factory EditPannelState.initial() => EditPannelState( - isEditing: false, - editContext: none(), - ); -} diff --git a/frontend/app_flowy/lib/workspace/application/home/home_bloc.dart b/frontend/app_flowy/lib/workspace/application/home/home_bloc.dart index af637ea1c7..87bac230da 100644 --- a/frontend/app_flowy/lib/workspace/application/home/home_bloc.dart +++ b/frontend/app_flowy/lib/workspace/application/home/home_bloc.dart @@ -1,9 +1,10 @@ import 'package:app_flowy/user/application/user_listener.dart'; -import 'package:app_flowy/workspace/application/edit_pannel/edit_context.dart'; +import 'package:app_flowy/workspace/application/edit_panel/edit_context.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-error-code/code.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; -import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart' show CurrentWorkspaceSettingPB; +import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart' + show CurrentWorkspaceSettingPB; import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; @@ -24,7 +25,8 @@ class HomeBloc extends Bloc { onAuthChanged: (result) => _authDidChanged(result), onSettingUpdated: (result) { result.fold( - (setting) => add(HomeEvent.didReceiveWorkspaceSetting(setting)), + (setting) => + add(HomeEvent.didReceiveWorkspaceSetting(setting)), (r) => Log.error(r), ); }, @@ -33,11 +35,11 @@ class HomeBloc extends Bloc { showLoading: (e) async { emit(state.copyWith(isLoading: e.isLoading)); }, - setEditPannel: (e) async { - emit(state.copyWith(pannelContext: some(e.editContext))); + setEditPanel: (e) async { + emit(state.copyWith(panelContext: some(e.editContext))); }, - dismissEditPannel: (value) async { - emit(state.copyWith(pannelContext: none())); + dismissEditPanel: (value) async { + emit(state.copyWith(panelContext: none())); }, forceCollapse: (e) async { emit(state.copyWith(forceCollapse: e.forceCollapse)); @@ -51,8 +53,9 @@ class HomeBloc extends Bloc { collapseMenu: (e) { emit(state.copyWith(isMenuCollapsed: !state.isMenuCollapsed)); }, - editPannelResized: (e) { - final newOffset = (state.resizeOffset + e.offset).clamp(-50, 200).toDouble(); + editPanelResized: (e) { + final newOffset = + (state.resizeOffset + e.offset).clamp(-50, 200).toDouble(); emit(state.copyWith(resizeOffset: newOffset)); }, ); @@ -80,12 +83,14 @@ class HomeEvent with _$HomeEvent { const factory HomeEvent.initial() = _Initial; const factory HomeEvent.showLoading(bool isLoading) = _ShowLoading; const factory HomeEvent.forceCollapse(bool forceCollapse) = _ForceCollapse; - const factory HomeEvent.setEditPannel(EditPannelContext editContext) = _ShowEditPannel; - const factory HomeEvent.dismissEditPannel() = _DismissEditPannel; - const factory HomeEvent.didReceiveWorkspaceSetting(CurrentWorkspaceSettingPB setting) = _DidReceiveWorkspaceSetting; + const factory HomeEvent.setEditPanel(EditPanelContext editContext) = + _ShowEditPanel; + const factory HomeEvent.dismissEditPanel() = _DismissEditPanel; + const factory HomeEvent.didReceiveWorkspaceSetting( + CurrentWorkspaceSettingPB setting) = _DidReceiveWorkspaceSetting; const factory HomeEvent.unauthorized(String msg) = _Unauthorized; const factory HomeEvent.collapseMenu() = _CollapseMenu; - const factory HomeEvent.editPannelResized(double offset) = _EditPannelResized; + const factory HomeEvent.editPanelResized(double offset) = _EditPanelResized; } @freezed @@ -93,17 +98,18 @@ class HomeState with _$HomeState { const factory HomeState({ required bool isLoading, required bool forceCollapse, - required Option pannelContext, + required Option panelContext, required CurrentWorkspaceSettingPB workspaceSetting, required bool unauthorized, required bool isMenuCollapsed, required double resizeOffset, }) = _HomeState; - factory HomeState.initial(CurrentWorkspaceSettingPB workspaceSetting) => HomeState( + factory HomeState.initial(CurrentWorkspaceSettingPB workspaceSetting) => + HomeState( isLoading: false, forceCollapse: false, - pannelContext: none(), + panelContext: none(), workspaceSetting: workspaceSetting, unauthorized: false, isMenuCollapsed: false, diff --git a/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart b/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart index 21d51f5a93..4b699570e6 100644 --- a/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart +++ b/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart @@ -1,5 +1,5 @@ import 'dart:async'; -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/workspace/application/workspace/workspace_listener.dart'; import 'package:app_flowy/workspace/application/workspace/workspace_service.dart'; import 'package:dartz/dartz.dart'; @@ -40,7 +40,10 @@ class MenuBloc extends Bloc { moveApp: (_MoveApp value) { if (state.apps.length > value.fromIndex) { final app = state.apps[value.fromIndex]; - _workspaceService.moveApp(appId: app.id, fromIndex: value.fromIndex, toIndex: value.toIndex); + _workspaceService.moveApp( + appId: app.id, + fromIndex: value.fromIndex, + toIndex: value.toIndex); final apps = List.from(state.apps); apps.insert(value.toIndex, apps.removeAt(value.fromIndex)); emit(state.copyWith(apps: apps)); @@ -56,8 +59,10 @@ class MenuBloc extends Bloc { return super.close(); } - Future _performActionOnCreateApp(_CreateApp event, Emitter emit) async { - final result = await _workspaceService.createApp(name: event.name, desc: event.desc ?? ""); + Future _performActionOnCreateApp( + _CreateApp event, Emitter emit) async { + final result = await _workspaceService.createApp( + name: event.name, desc: event.desc ?? ""); result.fold( (app) => {}, (error) { @@ -93,7 +98,8 @@ class MenuEvent with _$MenuEvent { const factory MenuEvent.openPage(Plugin plugin) = _OpenPage; const factory MenuEvent.createApp(String name, {String? desc}) = _CreateApp; const factory MenuEvent.moveApp(int fromIndex, int toIndex) = _MoveApp; - const factory MenuEvent.didReceiveApps(Either, FlowyError> appsOrFail) = _ReceiveApps; + const factory MenuEvent.didReceiveApps( + Either, FlowyError> appsOrFail) = _ReceiveApps; } @freezed diff --git a/frontend/app_flowy/lib/workspace/application/view/view_ext.dart b/frontend/app_flowy/lib/workspace/application/view/view_ext.dart index a54d5ecf40..79a27b64ce 100644 --- a/frontend/app_flowy/lib/workspace/application/view/view_ext.dart +++ b/frontend/app_flowy/lib/workspace/application/view/view_ext.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter/material.dart'; diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart index e7e02b9767..dde5091d44 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart @@ -11,16 +11,17 @@ import 'home_sizes.dart'; class HomeLayout { late double menuWidth; late bool showMenu; - late bool showEditPannel; - late double editPannelWidth; + late bool showEditPanel; + late double editPanelWidth; late double homePageLOffset; late double homePageROffset; late Duration animDuration; - HomeLayout(BuildContext context, BoxConstraints homeScreenConstraint, bool forceCollapse) { + HomeLayout(BuildContext context, BoxConstraints homeScreenConstraint, + bool forceCollapse) { final homeBlocState = context.read().state; - showEditPannel = homeBlocState.pannelContext.isSome(); + showEditPanel = homeBlocState.panelContext.isSome(); menuWidth = Sizes.sideBarMed; if (context.widthPx >= PageBreaks.desktop) { @@ -38,7 +39,7 @@ class HomeLayout { homePageLOffset = showMenu ? menuWidth : 0.0; animDuration = .35.seconds; - editPannelWidth = HomeSizes.editPannelWidth; - homePageROffset = showEditPannel ? editPannelWidth : 0; + editPanelWidth = HomeSizes.editPanelWidth; + homePageROffset = showEditPanel ? editPanelWidth : 0; } } diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart index bdb6088f61..508fbd1759 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart @@ -1,7 +1,7 @@ -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/workspace/application/home/home_bloc.dart'; import 'package:app_flowy/workspace/presentation/home/hotkeys.dart'; -import 'package:app_flowy/workspace/presentation/widgets/edit_pannel/pannel_animation.dart'; +import 'package:app_flowy/workspace/presentation/widgets/edit_panel/panel_animation.dart'; import 'package:app_flowy/workspace/presentation/widgets/float_bubble/question_bubble.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:flowy_sdk/log.dart'; @@ -13,7 +13,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:styled_widget/styled_widget.dart'; -import '../widgets/edit_pannel/edit_pannel.dart'; +import '../widgets/edit_panel/edit_panel.dart'; import 'home_layout.dart'; import 'home_stack.dart'; @@ -66,9 +66,9 @@ class _HomeScreenState extends State { child: BlocBuilder( buildWhen: (previous, current) => previous != current, builder: (context, state) { - final collapasedNotifier = + final collapsedNotifier = getIt().collapsedNotifier; - collapasedNotifier.addPublishListener((isCollapsed) { + collapsedNotifier.addPublishListener((isCollapsed) { context .read() .add(HomeEvent.forceCollapse(isCollapsed)); @@ -96,7 +96,7 @@ class _HomeScreenState extends State { state: state, ); final homeMenuResizer = _buildHomeMenuResizer(context: context); - final editPannel = _buildEditPannel( + final editPanel = _buildEditPanel( homeState: state, layout: layout, context: context, @@ -106,7 +106,7 @@ class _HomeScreenState extends State { layout: layout, homeStack: homeStack, homeMenu: menu, - editPannel: editPannel, + editPanel: editPanel, bubble: bubble, homeMenuResizer: homeMenuResizer, ); @@ -144,23 +144,24 @@ class _HomeScreenState extends State { return FocusTraversalGroup(child: RepaintBoundary(child: homeMenu)); } - Widget _buildEditPannel( + + Widget _buildEditPanel( {required HomeState homeState, required BuildContext context, required HomeLayout layout}) { final homeBloc = context.read(); return BlocBuilder( buildWhen: (previous, current) => - previous.pannelContext != current.pannelContext, + previous.panelContext != current.panelContext, builder: (context, state) { - return state.pannelContext.fold( + return state.panelContext.fold( () => const SizedBox(), - (pannelContext) => FocusTraversalGroup( + (panelContext) => FocusTraversalGroup( child: RepaintBoundary( - child: EditPannel( - pannelContext: pannelContext, + child: EditPanel( + panelContext: panelContext, onEndEdit: () => - homeBloc.add(const HomeEvent.dismissEditPannel()), + homeBloc.add(const HomeEvent.dismissEditPanel()), ), ), ), @@ -179,7 +180,7 @@ class _HomeScreenState extends State { onPanUpdate: ((details) { context .read() - .add(HomeEvent.editPannelResized(details.delta.dx)); + .add(HomeEvent.editPanelResized(details.delta.dx)); }), behavior: HitTestBehavior.translucent, child: SizedBox( @@ -193,7 +194,7 @@ class _HomeScreenState extends State { required HomeLayout layout, required Widget homeMenu, required Widget homeStack, - required Widget editPannel, + required Widget editPanel, required Widget bubble, required Widget homeMenuResizer, }) { @@ -228,14 +229,14 @@ class _HomeScreenState extends State { animate: true, ) .animate(layout.animDuration, Curves.easeOut), - editPannel + editPanel .animatedPanelX( duration: layout.animDuration.inMilliseconds * 0.001, - closeX: layout.editPannelWidth, - isClosed: !layout.showEditPannel, + closeX: layout.editPanelWidth, + isClosed: !layout.showEditPanel, ) .positioned( - right: 0, top: 0, bottom: 0, width: layout.editPannelWidth), + right: 0, top: 0, bottom: 0, width: layout.editPanelWidth), ], ); } diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_sizes.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_sizes.dart index 350a1e49be..299d3fe03c 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_sizes.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_sizes.dart @@ -1,8 +1,8 @@ class HomeSizes { static double get menuAddButtonHeight => 60; static double get topBarHeight => 60; - static double get editPannelTopBarHeight => 60; - static double get editPannelWidth => 400; + static double get editPanelTopBarHeight => 60; + static double get editPanelWidth => 400; } class HomeInsets { diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart index 07bd99deb1..d58f849cd7 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart @@ -2,6 +2,7 @@ import 'dart:io' show Platform; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/application/home/home_bloc.dart'; +import 'package:app_flowy/plugins/blank/blank.dart'; import 'package:app_flowy/workspace/presentation/home/toast.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_sdk/log.dart'; @@ -9,8 +10,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:provider/provider.dart'; import 'package:time/time.dart'; -import 'package:app_flowy/plugin/plugin.dart'; -import 'package:app_flowy/workspace/presentation/plugins/blank/blank.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:app_flowy/workspace/presentation/home/home_sizes.dart'; import 'package:app_flowy/workspace/presentation/home/navigation.dart'; import 'package:app_flowy/core/frameless_window.dart'; @@ -107,7 +107,8 @@ class HomeStackNotifier extends ChangeNotifier { Widget get titleWidget => _plugin.display.leftBarItem; - HomeStackNotifier({Plugin? plugin}) : _plugin = plugin ?? makePlugin(pluginType: DefaultPlugin.blank.type()); + HomeStackNotifier({Plugin? plugin}) + : _plugin = plugin ?? makePlugin(pluginType: DefaultPlugin.blank.type()); set plugin(Plugin newPlugin) { if (newPlugin.id == _plugin.id) { @@ -166,7 +167,9 @@ class HomeStackManager { index: getIt().indexOf(notifier.plugin.ty), children: getIt().supportPluginTypes.map((pluginType) { if (pluginType == notifier.plugin.ty) { - return notifier.plugin.display.buildWidget().padding(horizontal: 40, vertical: 28); + return notifier.plugin.display + .buildWidget() + .padding(horizontal: 40, vertical: 28); } else { return const BlankPage(); } @@ -190,7 +193,8 @@ class HomeTopBar extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, children: [ BlocBuilder( - buildWhen: ((previous, current) => previous.isMenuCollapsed != current.isMenuCollapsed), + buildWhen: ((previous, current) => + previous.isMenuCollapsed != current.isMenuCollapsed), builder: (context, state) { if (state.isMenuCollapsed && Platform.isMacOS) { return const HSpace(80); @@ -202,7 +206,8 @@ class HomeTopBar extends StatelessWidget { ChangeNotifierProvider.value( value: Provider.of(context, listen: false), child: Consumer( - builder: (BuildContext context, HomeStackNotifier notifier, Widget? child) { + builder: (BuildContext context, HomeStackNotifier notifier, + Widget? child) { return notifier.plugin.display.rightBarItem ?? const SizedBox(); }, ), diff --git a/frontend/app_flowy/lib/workspace/presentation/home/menu/app/header/add_button.dart b/frontend/app_flowy/lib/workspace/presentation/home/menu/app/header/add_button.dart index 5b15fecc52..5b06d2c3a2 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/menu/app/header/add_button.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/menu/app/header/add_button.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/plugin/plugin.dart'; +import 'package:app_flowy/startup/plugin/plugin.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; @@ -28,7 +28,8 @@ class AddButton extends StatelessWidget { onSelected: onSelected, ).show(context); }, - icon: svgWidget("home/add", color: theme.iconColor).padding(horizontal: 3, vertical: 3), + icon: svgWidget("home/add", color: theme.iconColor) + .padding(horizontal: 3, vertical: 3), ); } } diff --git a/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart b/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart index 09370176bb..5f08225919 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/menu/menu.dart @@ -2,9 +2,9 @@ export './app/header/header.dart'; export './app/menu_app.dart'; import 'dart:io' show Platform; +import 'package:app_flowy/plugins/trash/menu.dart'; import 'package:app_flowy/workspace/presentation/home/home_sizes.dart'; import 'package:app_flowy/workspace/presentation/home/home_stack.dart'; -import 'package:app_flowy/workspace/presentation/plugins/trash/menu.dart'; import 'package:flowy_infra/notifier.dart'; import 'package:flowy_infra/size.dart'; import 'package:flowy_infra/theme.dart'; diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/edit_pannel/edit_pannel.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/edit_panel/edit_panel.dart similarity index 66% rename from frontend/app_flowy/lib/workspace/presentation/widgets/edit_pannel/edit_pannel.dart rename to frontend/app_flowy/lib/workspace/presentation/widgets/edit_panel/edit_panel.dart index f9e5e0e6b5..ef0b61865e 100644 --- a/frontend/app_flowy/lib/workspace/presentation/widgets/edit_pannel/edit_pannel.dart +++ b/frontend/app_flowy/lib/workspace/presentation/widgets/edit_panel/edit_panel.dart @@ -1,5 +1,5 @@ -import 'package:app_flowy/workspace/application/edit_pannel/edit_pannel_bloc.dart'; -import 'package:app_flowy/workspace/application/edit_pannel/edit_context.dart'; +import 'package:app_flowy/workspace/application/edit_panel/edit_panel_bloc.dart'; +import 'package:app_flowy/workspace/application/edit_panel/edit_context.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/presentation/home/home_sizes.dart'; import 'package:easy_localization/easy_localization.dart'; @@ -9,12 +9,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; -class EditPannel extends StatelessWidget { - final EditPannelContext pannelContext; +class EditPanel extends StatelessWidget { + final EditPanelContext panelContext; final VoidCallback onEndEdit; - const EditPannel({ + const EditPanel({ Key? key, - required this.pannelContext, + required this.panelContext, required this.onEndEdit, }) : super(key: key); @@ -23,15 +23,15 @@ class EditPannel extends StatelessWidget { return Container( color: Theme.of(context).colorScheme.secondary, child: BlocProvider( - create: (context) => getIt(), - child: BlocBuilder( + create: (context) => getIt(), + child: BlocBuilder( builder: (context, state) { return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - EditPannelTopBar(onClose: () => onEndEdit()), + EditPanelTopBar(onClose: () => onEndEdit()), Expanded( - child: pannelContext.child, + child: panelContext.child, ), ], ); @@ -42,13 +42,13 @@ class EditPannel extends StatelessWidget { } } -class EditPannelTopBar extends StatelessWidget { +class EditPanelTopBar extends StatelessWidget { final VoidCallback onClose; - const EditPannelTopBar({Key? key, required this.onClose}) : super(key: key); + const EditPanelTopBar({Key? key, required this.onClose}) : super(key: key); @override Widget build(BuildContext context) { return SizedBox( - height: HomeSizes.editPannelTopBarHeight, + height: HomeSizes.editPanelTopBarHeight, child: Padding( padding: const EdgeInsets.all(8.0), child: Row( diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/edit_pannel/pannel_animation.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/edit_panel/panel_animation.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/widgets/edit_pannel/pannel_animation.dart rename to frontend/app_flowy/lib/workspace/presentation/widgets/edit_panel/panel_animation.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/emoji_button.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/emoji_button.dart index de8434a1dd..37ce933618 100644 --- a/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/emoji_button.dart +++ b/frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/emoji_button.dart @@ -1,4 +1,4 @@ -import 'package:app_flowy/workspace/presentation/plugins/doc/document.dart'; +import 'package:app_flowy/plugins/doc/presentation/toolbar/toolbar_icon_button.dart'; import 'package:flutter/material.dart'; import 'package:flutter_quill/flutter_quill.dart'; import 'package:app_flowy/workspace/presentation/widgets/emoji_picker/emoji_picker.dart'; @@ -88,7 +88,8 @@ class _EmojiStyleButtonState extends State { _entry = null; setState(() => _isToggled = false); } else { - RenderBox box = emojiButtonKey.currentContext?.findRenderObject() as RenderBox; + RenderBox box = + emojiButtonKey.currentContext?.findRenderObject() as RenderBox; Offset position = box.localToGlobal(Offset.zero); // final window = await getWindowInfo(); @@ -118,7 +119,8 @@ class _EmojiStyleButtonState extends State { } class BuildEmojiPickerView extends StatefulWidget { - const BuildEmojiPickerView({Key? key, required this.controller, this.offset}) : super(key: key); + const BuildEmojiPickerView({Key? key, required this.controller, this.offset}) + : super(key: key); final QuillController controller; final Offset? offset; @@ -134,8 +136,11 @@ class _BuildEmojiPickerViewState extends State { children: [ Positioned( //TODO @gaganyadav80: Not sure about the calculated position. - top: widget.offset!.dy - MediaQuery.of(context).size.height / 2.83 - 30, - left: widget.offset!.dx - MediaQuery.of(context).size.width / 3.92 + 40, + top: widget.offset!.dy - + MediaQuery.of(context).size.height / 2.83 - + 30, + left: + widget.offset!.dx - MediaQuery.of(context).size.width / 3.92 + 40, child: Material( borderRadius: BorderRadius.circular(8.0), child: SizedBox( @@ -175,6 +180,7 @@ class _BuildEmojiPickerViewState extends State { extentOffset: baseOffset + emoji.emoji.length, ); - widget.controller.replaceText(baseOffset, replaceLen, emoji.emoji, selection); + widget.controller + .replaceText(baseOffset, replaceLen, emoji.emoji, selection); } } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/widgets/left_bar_item.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/left_bar_item.dart similarity index 100% rename from frontend/app_flowy/lib/workspace/presentation/plugins/widgets/left_bar_item.dart rename to frontend/app_flowy/lib/workspace/presentation/widgets/left_bar_item.dart diff --git a/frontend/app_flowy/packages/appflowy_board/.gitignore b/frontend/app_flowy/packages/appflowy_board/.gitignore new file mode 100644 index 0000000000..96486fd930 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/frontend/app_flowy/packages/appflowy_board/.metadata b/frontend/app_flowy/packages/appflowy_board/.metadata new file mode 100644 index 0000000000..e7011f64f3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + channel: stable + +project_type: package diff --git a/frontend/app_flowy/packages/appflowy_board/CHANGELOG.md b/frontend/app_flowy/packages/appflowy_board/CHANGELOG.md new file mode 100644 index 0000000000..76f33711b1 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/CHANGELOG.md @@ -0,0 +1,17 @@ +# 0.0.4 +* fix some bugs + +# 0.0.3 +* Support customize UI +* Update example +* Add AppFlowy style widget + +## 0.0.2 + +* Update documentation + +## 0.0.1 + +* Support drag and drop column +* Support drag and drop column items from one to another + diff --git a/frontend/app_flowy/packages/appflowy_board/LICENSE b/frontend/app_flowy/packages/appflowy_board/LICENSE new file mode 100644 index 0000000000..0ad25db4bd --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/frontend/app_flowy/packages/appflowy_board/README.md b/frontend/app_flowy/packages/appflowy_board/README.md new file mode 100644 index 0000000000..b33c4d7883 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/README.md @@ -0,0 +1,86 @@ +# appflowy_board + +The **appflowy_board** is a package that is used in [AppFlowy](https://github.com/AppFlowy-IO/AppFlowy). For the moment, this package is iterated very fast. + + +**appflowy_board** will be a standard git repository when it becomes stable. +## Getting Started + +

+ +

+ +```dart +@override + void initState() { + final column1 = BoardColumnData(id: "To Do", items: [ + TextItem("Card 1"), + TextItem("Card 2"), + TextItem("Card 3"), + TextItem("Card 4"), + ]); + final column2 = BoardColumnData(id: "In Progress", items: [ + TextItem("Card 5"), + TextItem("Card 6"), + ]); + + final column3 = BoardColumnData(id: "Done", items: []); + + boardDataController.addColumn(column1); + boardDataController.addColumn(column2); + boardDataController.addColumn(column3); + + super.initState(); + } + + @override + Widget build(BuildContext context) { + final config = BoardConfig( + columnBackgroundColor: HexColor.fromHex('#F7F8FC'), + ); + return Container( + color: Colors.white, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 30, horizontal: 20), + child: Board( + dataController: boardDataController, + footBuilder: (context, columnData) { + return AppFlowyColumnFooter( + icon: const Icon(Icons.add, size: 20), + title: const Text('New'), + height: 50, + margin: config.columnItemPadding, + ); + }, + headerBuilder: (context, columnData) { + return AppFlowyColumnHeader( + icon: const Icon(Icons.lightbulb_circle), + title: Text(columnData.id), + addIcon: const Icon(Icons.add, size: 20), + moreIcon: const Icon(Icons.more_horiz, size: 20), + height: 50, + margin: config.columnItemPadding, + ); + }, + cardBuilder: (context, item) { + final textItem = item as TextItem; + return AppFlowyColumnItemCard( + key: ObjectKey(item), + child: Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), + child: Text(textItem.s), + ), + ), + ); + }, + columnConstraints: const BoxConstraints.tightFor(width: 240), + config: BoardConfig( + columnBackgroundColor: HexColor.fromHex('#F7F8FC'), + ), + ), + ), + ); + } +``` \ No newline at end of file diff --git a/frontend/app_flowy/packages/appflowy_board/analysis_options.yaml b/frontend/app_flowy/packages/appflowy_board/analysis_options.yaml new file mode 100644 index 0000000000..a5744c1cfb --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/frontend/app_flowy/packages/appflowy_board/example/.gitignore b/frontend/app_flowy/packages/appflowy_board/example/.gitignore new file mode 100644 index 0000000000..34802023f3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/.gitignore @@ -0,0 +1,49 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release + +.metadata \ No newline at end of file diff --git a/frontend/app_flowy/packages/appflowy_board/example/README.md b/frontend/app_flowy/packages/appflowy_board/example/README.md new file mode 100644 index 0000000000..2b3fce4c86 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/README.md @@ -0,0 +1,16 @@ +# example + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/frontend/app_flowy/packages/appflowy_board/example/analysis_options.yaml b/frontend/app_flowy/packages/appflowy_board/example/analysis_options.yaml new file mode 100644 index 0000000000..61b6c4de17 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +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` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// 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 + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/.gitignore b/frontend/app_flowy/packages/appflowy_board/example/android/.gitignore new file mode 100644 index 0000000000..6f568019d3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/build.gradle b/frontend/app_flowy/packages/appflowy_board/example/android/app/build.gradle new file mode 100644 index 0000000000..4466eba652 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/build.gradle @@ -0,0 +1,71 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.appflowy.board.example" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/debug/AndroidManifest.xml b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000000..95bcce0ae3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/AndroidManifest.xml b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..07ba21884a --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/kotlin/com/appflowy/board/example/MainActivity.kt b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/kotlin/com/appflowy/board/example/MainActivity.kt new file mode 100644 index 0000000000..4cd6f28560 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/kotlin/com/appflowy/board/example/MainActivity.kt @@ -0,0 +1,6 @@ +package com.appflowy.board.example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/drawable-v21/launch_background.xml b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000000..f74085f3f6 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/drawable/launch_background.xml b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000000..304732f884 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000..db77bb4b7b Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000..17987b79bb Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000..09d4391482 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000..d5f1c8d34e Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000..4d6372eebd Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/values-night/styles.xml b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000000..06952be745 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/values/styles.xml b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000000..cb1ef88056 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/app/src/profile/AndroidManifest.xml b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000000..95bcce0ae3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/build.gradle b/frontend/app_flowy/packages/appflowy_board/example/android/build.gradle new file mode 100644 index 0000000000..83ae220041 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.1.2' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/gradle.properties b/frontend/app_flowy/packages/appflowy_board/example/android/gradle.properties new file mode 100644 index 0000000000..94adc3a3f9 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/gradle/wrapper/gradle-wrapper.properties b/frontend/app_flowy/packages/appflowy_board/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000..cc5527d781 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/frontend/app_flowy/packages/appflowy_board/example/android/settings.gradle b/frontend/app_flowy/packages/appflowy_board/example/android/settings.gradle new file mode 100644 index 0000000000..44e62bcf06 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/frontend/app_flowy/packages/appflowy_board/example/gifs/appflowy_board_video_1.gif b/frontend/app_flowy/packages/appflowy_board/example/gifs/appflowy_board_video_1.gif new file mode 100644 index 0000000000..bf1345608e Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/gifs/appflowy_board_video_1.gif differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/.gitignore b/frontend/app_flowy/packages/appflowy_board/example/ios/.gitignore new file mode 100644 index 0000000000..7a7f9873ad --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/AppFrameworkInfo.plist b/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000000..8d4492f977 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 9.0 + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/Debug.xcconfig b/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000000..592ceee85b --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/Release.xcconfig b/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000000..592ceee85b --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.pbxproj b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..74374c8530 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,481 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1300; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.appflowy.board.example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.appflowy.board.example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.appflowy.board.example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..919434a625 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000000..f9b0d7c5ea --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000000..c87d15a335 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..1d526a16ed --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000000..f9b0d7c5ea --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/AppDelegate.swift b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000000..70693e4a8c --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..d36b1fab2d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000000..dc9ada4725 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000000..28c6bf0301 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000000..2ccbfd967d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000000..f091b6b0bc Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000000..4cde12118d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000000..d0ef06e7ed Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000000..dcdc2306c2 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000000..2ccbfd967d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000000..c8f9ed8f5c Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000000..a6d6b8609d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000000..a6d6b8609d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000000..75b2d164a5 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000000..c4df70d39d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000000..6a84f41e14 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000000..d0e1f58536 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000000..0bedcf2fd4 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000000..9da19eacad Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000000..9da19eacad Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000000..9da19eacad Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000000..89c2725b70 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000000..f2e259c7c9 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Base.lproj/Main.storyboard b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000000..f3c28516fb --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Info.plist b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Info.plist new file mode 100644 index 0000000000..907f329fe0 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Example + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + example + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + CADisableMinimumFrameDurationOnPhone + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Runner-Bridging-Header.h b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000000..308a2a560b --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/frontend/app_flowy/packages/appflowy_board/example/lib/main.dart b/frontend/app_flowy/packages/appflowy_board/example/lib/main.dart new file mode 100644 index 0000000000..c881370e03 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/lib/main.dart @@ -0,0 +1,59 @@ +import 'package:flutter/material.dart'; +import 'single_board_list_example.dart'; +import 'multi_board_list_example.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatefulWidget { + const MyApp({Key? key}) : super(key: key); + + @override + State createState() => _MyAppState(); +} + +class _MyAppState extends State { + int _currentIndex = 0; + final _bottomNavigationColor = Colors.blue; + + final List _examples = [ + const MultiBoardListExample(), + const SingleBoardListExample(), + ]; + + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('AppFlowy Board'), + ), + body: _examples[_currentIndex], + bottomNavigationBar: BottomNavigationBar( + fixedColor: _bottomNavigationColor, + showSelectedLabels: true, + showUnselectedLabels: false, + currentIndex: _currentIndex, + items: [ + BottomNavigationBarItem( + icon: Icon(Icons.grid_on, color: _bottomNavigationColor), + label: "MultiColumn"), + BottomNavigationBarItem( + icon: Icon(Icons.grid_on, color: _bottomNavigationColor), + label: "SingleColumn"), + ], + onTap: (int index) { + setState(() { + _currentIndex = index; + }); + }, + )), + ); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart b/frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart new file mode 100644 index 0000000000..d692a6fe20 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart @@ -0,0 +1,155 @@ +import 'package:appflowy_board/appflowy_board.dart'; +import 'package:flutter/material.dart'; + +class MultiBoardListExample extends StatefulWidget { + const MultiBoardListExample({Key? key}) : super(key: key); + + @override + State createState() => _MultiBoardListExampleState(); +} + +class _MultiBoardListExampleState extends State { + final BoardDataController boardDataController = BoardDataController( + onMoveColumn: (fromIndex, toIndex) { + debugPrint('Move column from $fromIndex to $toIndex'); + }, + onMoveColumnItem: (columnId, fromIndex, toIndex) { + debugPrint('Move $columnId:$fromIndex to $columnId:$toIndex'); + }, + onMoveColumnItemToColumn: (fromColumnId, fromIndex, toColumnId, toIndex) { + debugPrint('Move $fromColumnId:$fromIndex to $toColumnId:$toIndex'); + }, + ); + + @override + void initState() { + final column1 = BoardColumnData(id: "To Do", items: [ + TextItem("Card 1"), + TextItem("Card 2"), + RichTextItem(title: "Card 3", subtitle: 'Aug 1, 2020 4:05 PM'), + TextItem("Card 4"), + ]); + final column2 = BoardColumnData(id: "In Progress", items: [ + RichTextItem(title: "Card 5", subtitle: 'Aug 1, 2020 4:05 PM'), + TextItem("Card 6"), + ]); + + final column3 = BoardColumnData(id: "Done", items: []); + + boardDataController.addColumn(column1); + boardDataController.addColumn(column2); + boardDataController.addColumn(column3); + + super.initState(); + } + + @override + Widget build(BuildContext context) { + final config = BoardConfig( + columnBackgroundColor: HexColor.fromHex('#F7F8FC'), + ); + return Container( + color: Colors.white, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 30, horizontal: 20), + child: Board( + dataController: boardDataController, + footBuilder: (context, columnData) { + return AppFlowyColumnFooter( + icon: const Icon(Icons.add, size: 20), + title: const Text('New'), + height: 50, + margin: config.columnItemPadding, + ); + }, + headerBuilder: (context, columnData) { + return AppFlowyColumnHeader( + icon: const Icon(Icons.lightbulb_circle), + title: Text(columnData.id), + addIcon: const Icon(Icons.add, size: 20), + moreIcon: const Icon(Icons.more_horiz, size: 20), + height: 50, + margin: config.columnItemPadding, + ); + }, + cardBuilder: (context, item) { + return AppFlowyColumnItemCard( + key: ObjectKey(item), + child: _buildCard(item), + ); + }, + columnConstraints: const BoxConstraints.tightFor(width: 240), + config: BoardConfig( + columnBackgroundColor: HexColor.fromHex('#F7F8FC'), + ), + ), + ), + ); + } + + Widget _buildCard(ColumnItem item) { + if (item is TextItem) { + return Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), + child: Text(item.s), + ), + ); + } + + if (item is RichTextItem) { + return Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + item.title, + style: const TextStyle(fontSize: 14), + textAlign: TextAlign.left, + ), + const SizedBox(height: 10), + Text( + item.subtitle, + style: const TextStyle(fontSize: 12, color: Colors.grey), + ) + ], + ), + ), + ); + } + + throw UnimplementedError(); + } +} + +class TextItem extends ColumnItem { + final String s; + + TextItem(this.s); + + @override + String get id => s; +} + +class RichTextItem extends ColumnItem { + final String title; + final String subtitle; + + RichTextItem({required this.title, required this.subtitle}); + + @override + String get id => title; +} + +extension HexColor on Color { + static Color fromHex(String hexString) { + final buffer = StringBuffer(); + if (hexString.length == 6 || hexString.length == 7) buffer.write('ff'); + buffer.write(hexString.replaceFirst('#', '')); + return Color(int.parse(buffer.toString(), radix: 16)); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/lib/single_board_list_example.dart b/frontend/app_flowy/packages/appflowy_board/example/lib/single_board_list_example.dart new file mode 100644 index 0000000000..655f1439c1 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/lib/single_board_list_example.dart @@ -0,0 +1,60 @@ +import 'package:flutter/material.dart'; +import 'package:appflowy_board/appflowy_board.dart'; + +class SingleBoardListExample extends StatefulWidget { + const SingleBoardListExample({Key? key}) : super(key: key); + + @override + State createState() => _SingleBoardListExampleState(); +} + +class _SingleBoardListExampleState extends State { + final BoardDataController boardData = BoardDataController(); + + @override + void initState() { + final column = BoardColumnData(id: "1", items: [ + TextItem("a"), + TextItem("b"), + TextItem("c"), + TextItem("d"), + ]); + + boardData.addColumn(column); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Board( + dataController: boardData, + cardBuilder: (context, item) { + return _RowWidget(item: item as TextItem, key: ObjectKey(item)); + }, + ); + } +} + +class _RowWidget extends StatelessWidget { + final TextItem item; + const _RowWidget({Key? key, required this.item}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + key: ObjectKey(item), + height: 60, + color: Colors.green, + child: Center(child: Text(item.s)), + ); + } +} + +class TextItem extends ColumnItem { + final String s; + + TextItem(this.s); + + @override + String get id => s; +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/.gitignore b/frontend/app_flowy/packages/appflowy_board/example/linux/.gitignore new file mode 100644 index 0000000000..d3896c9844 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/CMakeLists.txt b/frontend/app_flowy/packages/appflowy_board/example/linux/CMakeLists.txt new file mode 100644 index 0000000000..697a9f905a --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/CMakeLists.txt @@ -0,0 +1,138 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.10) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "example") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "com.appflowy.board.example") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Define the application target. To change its name, change BINARY_NAME above, +# not the value here, or `flutter run` will no longer work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/CMakeLists.txt b/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/CMakeLists.txt new file mode 100644 index 0000000000..d5bd01648a --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugin_registrant.cc b/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000000..e71a16d23d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void fl_register_plugins(FlPluginRegistry* registry) { +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugin_registrant.h b/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000000..e0f0a47bc0 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugins.cmake b/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugins.cmake new file mode 100644 index 0000000000..2e1de87a7e --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/main.cc b/frontend/app_flowy/packages/appflowy_board/example/linux/main.cc new file mode 100644 index 0000000000..e7c5c54370 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/my_application.cc b/frontend/app_flowy/packages/appflowy_board/example/linux/my_application.cc new file mode 100644 index 0000000000..0ba8f43096 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/my_application.cc @@ -0,0 +1,104 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "example"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "example"); + } + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/linux/my_application.h b/frontend/app_flowy/packages/appflowy_board/example/linux/my_application.h new file mode 100644 index 0000000000..72271d5e41 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/linux/my_application.h @@ -0,0 +1,18 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/.gitignore b/frontend/app_flowy/packages/appflowy_board/example/macos/.gitignore new file mode 100644 index 0000000000..746adbb6b9 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/Flutter-Debug.xcconfig b/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 0000000000..c2efd0b608 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/Flutter-Release.xcconfig b/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 0000000000..c2efd0b608 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/GeneratedPluginRegistrant.swift b/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 0000000000..cccf817a52 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,10 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/project.pbxproj b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..c84862c675 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,572 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* example.app */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* example.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1300; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000000..fb7259e177 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcworkspace/contents.xcworkspacedata b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..1d526a16ed --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/AppDelegate.swift b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/AppDelegate.swift new file mode 100644 index 0000000000..d53ef64377 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/AppDelegate.swift @@ -0,0 +1,9 @@ +import Cocoa +import FlutterMacOS + +@NSApplicationMain +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..a2ec33f19f --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 0000000000..3c4935a7ca Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 0000000000..ed4cc16421 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 0000000000..483be61389 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 0000000000..bcbf36df2f Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 0000000000..9c0a652864 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 0000000000..e71a726136 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 0000000000..8a31fe2dd3 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Base.lproj/MainMenu.xib b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 0000000000..80e867a4e0 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/AppInfo.xcconfig b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 0000000000..e379d4a333 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = example + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.appflowy.board.example + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2022 com.appflowy.board. All rights reserved. diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Debug.xcconfig b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 0000000000..36b0fd9464 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Release.xcconfig b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 0000000000..dff4f49561 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Warnings.xcconfig b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 0000000000..42bcbf4780 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/DebugProfile.entitlements b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/DebugProfile.entitlements new file mode 100644 index 0000000000..dddb8a30c8 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Info.plist b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Info.plist new file mode 100644 index 0000000000..4789daa6a4 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/MainFlutterWindow.swift b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 0000000000..2722837ec9 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController.init() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Release.entitlements b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Release.entitlements new file mode 100644 index 0000000000..852fa1a472 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/pubspec.yaml b/frontend/app_flowy/packages/appflowy_board/example/pubspec.yaml new file mode 100644 index 0000000000..1a90f3b84a --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/pubspec.yaml @@ -0,0 +1,91 @@ +name: example +description: A new Flutter project. + +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +version: 1.0.0+1 + +environment: + sdk: ">=2.17.6 <3.0.0" + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + appflowy_board: + path: ../ + + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/frontend/app_flowy/packages/appflowy_board/example/test/widget_test.dart b/frontend/app_flowy/packages/appflowy_board/example/test/widget_test.dart new file mode 100644 index 0000000000..29cad86982 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/test/widget_test.dart @@ -0,0 +1,7 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. +void main() {} diff --git a/frontend/app_flowy/packages/appflowy_board/example/web/favicon.png b/frontend/app_flowy/packages/appflowy_board/example/web/favicon.png new file mode 100644 index 0000000000..8aaa46ac1a Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/web/favicon.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-192.png b/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-192.png new file mode 100644 index 0000000000..b749bfef07 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-192.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-512.png b/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-512.png new file mode 100644 index 0000000000..88cfd48dff Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-512.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-maskable-192.png b/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000000..eb9b4d76e5 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-maskable-192.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-maskable-512.png b/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000000..d69c56691f Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/web/icons/Icon-maskable-512.png differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/web/index.html b/frontend/app_flowy/packages/appflowy_board/example/web/index.html new file mode 100644 index 0000000000..41b3bc336f --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/web/index.html @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + example + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/web/manifest.json b/frontend/app_flowy/packages/appflowy_board/example/web/manifest.json new file mode 100644 index 0000000000..096edf8fe4 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "example", + "short_name": "example", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/.gitignore b/frontend/app_flowy/packages/appflowy_board/example/windows/.gitignore new file mode 100644 index 0000000000..d492d0d98c --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/CMakeLists.txt b/frontend/app_flowy/packages/appflowy_board/example/windows/CMakeLists.txt new file mode 100644 index 0000000000..c0270746b1 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/CMakeLists.txt @@ -0,0 +1,101 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(example LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "example") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/CMakeLists.txt b/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/CMakeLists.txt new file mode 100644 index 0000000000..930d2071a3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/CMakeLists.txt @@ -0,0 +1,104 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + windows-x64 $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugin_registrant.cc b/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000000..8b6d4680af --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void RegisterPlugins(flutter::PluginRegistry* registry) { +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugin_registrant.h b/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000000..dc139d85a9 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugins.cmake b/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugins.cmake new file mode 100644 index 0000000000..b93c4c30c1 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/CMakeLists.txt b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/CMakeLists.txt new file mode 100644 index 0000000000..b9e550fba8 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/Runner.rc b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/Runner.rc new file mode 100644 index 0000000000..8949260514 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#ifdef FLUTTER_BUILD_NUMBER +#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER +#else +#define VERSION_AS_NUMBER 1,0,0 +#endif + +#ifdef FLUTTER_BUILD_NAME +#define VERSION_AS_STRING #FLUTTER_BUILD_NAME +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "com.appflowy.board" "\0" + VALUE "FileDescription", "example" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "example" "\0" + VALUE "LegalCopyright", "Copyright (C) 2022 com.appflowy.board. All rights reserved." "\0" + VALUE "OriginalFilename", "example.exe" "\0" + VALUE "ProductName", "example" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/flutter_window.cpp b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/flutter_window.cpp new file mode 100644 index 0000000000..b43b9095ea --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/flutter_window.cpp @@ -0,0 +1,61 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/flutter_window.h b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/flutter_window.h new file mode 100644 index 0000000000..6da0652f05 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/main.cpp b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/main.cpp new file mode 100644 index 0000000000..bcb57b0e2a --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.CreateAndShow(L"example", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/resource.h b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/resource.h new file mode 100644 index 0000000000..66a65d1e4a --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/resources/app_icon.ico b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/resources/app_icon.ico new file mode 100644 index 0000000000..c04e20caf6 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/resources/app_icon.ico differ diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/runner.exe.manifest b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/runner.exe.manifest new file mode 100644 index 0000000000..c977c4a425 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/runner.exe.manifest @@ -0,0 +1,20 @@ + + + + + PerMonitorV2 + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/utils.cpp b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/utils.cpp new file mode 100644 index 0000000000..f5bf9fa0f5 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/utils.cpp @@ -0,0 +1,64 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr); + std::string utf8_string; + if (target_length == 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, utf8_string.data(), + target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/utils.h b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/utils.h new file mode 100644 index 0000000000..3879d54755 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/win32_window.cpp b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/win32_window.cpp new file mode 100644 index 0000000000..c10f08dc7d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/win32_window.cpp @@ -0,0 +1,245 @@ +#include "win32_window.h" + +#include + +#include "resource.h" + +namespace { + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + FreeLibrary(user32_module); + } +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::CreateAndShow(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + return OnCreate(); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} diff --git a/frontend/app_flowy/packages/appflowy_board/example/windows/runner/win32_window.h b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/win32_window.h new file mode 100644 index 0000000000..17ba431125 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/example/windows/runner/win32_window.h @@ -0,0 +1,98 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates and shows a win32 window with |title| and position and size using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size to will treat the width height passed in to this function + // as logical pixels and scale to appropriate for the default monitor. Returns + // true if the window was created successfully. + bool CreateAndShow(const std::wstring& title, + const Point& origin, + const Size& size); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responsponds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_ diff --git a/frontend/app_flowy/packages/appflowy_board/lib/appflowy_board.dart b/frontend/app_flowy/packages/appflowy_board/lib/appflowy_board.dart new file mode 100644 index 0000000000..fc8f3c662f --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/appflowy_board.dart @@ -0,0 +1,6 @@ +library appflowy_board; + +export 'src/widgets/board_column/board_column_data.dart'; +export 'src/widgets/board_data.dart'; +export 'src/widgets/styled_widgets/appflowy_styled_widgets.dart'; +export 'src/widgets/board.dart'; diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/rendering/board_overlay.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/rendering/board_overlay.dart new file mode 100644 index 0000000000..f2c99e057b --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/rendering/board_overlay.dart @@ -0,0 +1,409 @@ +import 'dart:collection'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter/scheduler.dart'; + +class BoardOverlayEntry { + /// This entry will include the widget built by this builder in the overlay at + /// the entry's position. + /// The builder will be called again after calling [markNeedsBuild] on this entry. + final WidgetBuilder builder; + + /// Whether this entry occludes the entire overlay. + /// + /// If an entry claims to be opaque, then, for efficiency, the overlay will + /// skip building entries below that entry. + bool get opaque => _opaque; + bool _opaque; + + BoardOverlayState? _overlay; + final GlobalKey<_OverlayEntryWidgetState> _key = + GlobalKey<_OverlayEntryWidgetState>(); + + set opaque(bool value) { + if (_opaque == value) return; + + _opaque = value; + assert(_overlay != null); + _overlay!._didChangeEntryOpacity(); + } + + BoardOverlayEntry({ + required this.builder, + bool opaque = false, + }) : _opaque = opaque; + + /// If this method is called while the [SchedulerBinding.schedulerPhase] is + /// [SchedulerPhase.persistentCallbacks], i.e. during the build, layout, or + /// paint phases (see [WidgetsBinding.drawFrame]), then the removal is + /// delayed until the post-frame callbacks phase. Otherwise the removal is done synchronously. + void remove() { + assert(_overlay != null, 'Should only call once'); + final BoardOverlayState overlay = _overlay!; + _overlay = null; + if (SchedulerBinding.instance.schedulerPhase == + SchedulerPhase.persistentCallbacks) { + SchedulerBinding.instance.addPostFrameCallback((Duration duration) { + overlay._remove(this); + }); + } else { + overlay._remove(this); + } + } + + /// Cause this entry to rebuild during the next pipeline flush. + /// You need to call this function if the output of [builder] has changed. + void markNeedsBuild() { + _key.currentState?._markNeedsBuild(); + } +} + +/// A [Stack] of entries that can be managed independently. +/// +/// Overlays let independent child widgets "float" visual elements on top of +/// other widgets by inserting them into the overlay's [Stack]. The overlay lets +/// each of these widgets manage their participation in the overlay using +/// [OverlayEntry] objects. +class BoardOverlay extends StatefulWidget { + final List initialEntries; + + const BoardOverlay({ + this.initialEntries = const [], + Key? key, + }) : super(key: key); + + static BoardOverlayState of(BuildContext context, + {Widget? debugRequiredFor}) { + final BoardOverlayState? result = + context.findAncestorStateOfType(); + assert(() { + if (debugRequiredFor != null && result == null) { + final String additional = context.widget != debugRequiredFor + ? '\nThe context from which that widget was searching for an overlay was:\n $context' + : ''; + throw FlutterError('No Overlay widget found.\n' + '${debugRequiredFor.runtimeType} widgets require an Overlay widget ancestor for correct operation.\n' + 'The most common way to add an Overlay to an application is to include a MaterialApp or Navigator widget in the runApp() call.\n' + 'The specific widget that failed to find an overlay was:\n' + ' $debugRequiredFor' + '$additional'); + } + return true; + }()); + return result!; + } + + @override + BoardOverlayState createState() => BoardOverlayState(); +} + +class BoardOverlayState extends State + with TickerProviderStateMixin { + final List _entries = []; + + @override + void initState() { + super.initState(); + insertAll(widget.initialEntries); + } + + /// Insert the given entry into the overlay. + /// + /// If [above] is non-null, the entry is inserted just above [above]. + /// Otherwise, the entry is inserted on top. + void insert(BoardOverlayEntry entry, {BoardOverlayEntry? above}) { + assert(entry._overlay == null); + assert( + above == null || (above._overlay == this && _entries.contains(above))); + entry._overlay = this; + setState(() { + final int index = + above == null ? _entries.length : _entries.indexOf(above) + 1; + _entries.insert(index, entry); + }); + } + + /// Insert all the entries in the given iterable. + /// + /// If [above] is non-null, the entries are inserted just above [above]. + /// Otherwise, the entries are inserted on top. + void insertAll(Iterable entries, + {BoardOverlayEntry? above}) { + assert( + above == null || (above._overlay == this && _entries.contains(above))); + if (entries.isEmpty) return; + for (BoardOverlayEntry entry in entries) { + assert(entry._overlay == null); + entry._overlay = this; + } + setState(() { + final int index = + above == null ? _entries.length : _entries.indexOf(above) + 1; + _entries.insertAll(index, entries); + }); + } + + void _remove(BoardOverlayEntry entry) { + if (mounted) { + _entries.remove(entry); + setState(() { + /* entry was removed */ + }); + } + } + + void _didChangeEntryOpacity() { + setState(() { + // We use the opacity of the entry in our build function, which means we + // our state has changed. + }); + } + + @override + Widget build(BuildContext context) { + // These lists are filled backwards. For the offstage children that + // does not matter since they aren't rendered, but for the onstage + // children we reverse the list below before adding it to the tree. + final List onstageChildren = []; + final List offstageChildren = []; + bool onstage = true; + for (int i = _entries.length - 1; i >= 0; i -= 1) { + final BoardOverlayEntry entry = _entries[i]; + if (onstage) { + onstageChildren.add(_OverlayEntryWidget(entry)); + if (entry.opaque) onstage = false; + } + } + return _BoardStack( + onstage: Stack( + fit: StackFit.passthrough, + //HanSheng changed it to passthrough so that this widget doesn't change layout constraints + children: onstageChildren.reversed.toList(growable: false), + ), + offstage: offstageChildren, + ); + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + .add(DiagnosticsProperty>('entries', _entries)); + } +} + +class _OverlayEntryWidget extends StatefulWidget { + _OverlayEntryWidget(this.entry) : super(key: entry._key); + + final BoardOverlayEntry entry; + + @override + _OverlayEntryWidgetState createState() => _OverlayEntryWidgetState(); +} + +class _OverlayEntryWidgetState extends State<_OverlayEntryWidget> { + @override + Widget build(BuildContext context) { + return widget.entry.builder(context); + } + + void _markNeedsBuild() { + setState(() {}); + } +} + +/// A widget that has one [onstage] child which is visible, and one or more +/// [offstage] widgets which are kept alive, and are built, but are not laid out +/// or painted. +/// +/// The onstage widget must be a Stack. +/// +/// For convenience, it is legal to use [Positioned] widgets around the offstage +/// widgets. +class _BoardStack extends RenderObjectWidget { + final Stack? onstage; + final List offstage; + + const _BoardStack({ + required this.offstage, + this.onstage, + }); + + @override + _BoardStackElement createElement() => _BoardStackElement(this); + + @override + _RenderBoardObject createRenderObject(BuildContext context) => + _RenderBoardObject(); +} + +class _BoardStackElement extends RenderObjectElement { + Element? _onstage; + static final Object _onstageSlot = Object(); + late List _offstage; + final Set _forgottenOffstageChildren = HashSet(); + + _BoardStackElement(_BoardStack widget) + : assert(!debugChildrenHaveDuplicateKeys(widget, widget.offstage)), + super(widget); + + @override + _BoardStack get widget => super.widget as _BoardStack; + + @override + _RenderBoardObject get renderObject => + super.renderObject as _RenderBoardObject; + + @override + void insertRenderObjectChild(RenderBox child, dynamic slot) { + assert(renderObject.debugValidateChild(child)); + if (slot == _onstageSlot) { + assert(child is RenderStack); + renderObject.child = child as RenderStack?; + } else { + assert(slot == null || slot is Element); + renderObject.insert(child, after: slot?.renderObject); + } + } + + @override + void moveRenderObjectChild(RenderBox child, dynamic oldSlot, dynamic slot) { + if (slot == _onstageSlot) { + renderObject.remove(child); + assert(child is RenderStack); + renderObject.child = child as RenderStack?; + } else { + assert(slot == null || slot is Element); + if (renderObject.child == child) { + renderObject.child = null; + renderObject.insert(child, after: slot?.renderObject); + } else { + renderObject.move(child, after: slot?.renderObject); + } + } + } + + @override + void removeRenderObjectChild(RenderBox child, dynamic slot) { + if (renderObject.child == child) { + renderObject.child = null; + } else { + renderObject.remove(child); + } + } + + @override + void visitChildren(ElementVisitor visitor) { + if (_onstage != null) visitor(_onstage!); + for (Element child in _offstage) { + if (!_forgottenOffstageChildren.contains(child)) visitor(child); + } + } + + @override + void debugVisitOnstageChildren(ElementVisitor visitor) { + if (_onstage != null) visitor(_onstage!); + } + + @override + void forgetChild(Element child) { + if (child == _onstage) { + _onstage = null; + } else { + assert(_offstage.contains(child)); + assert(!_forgottenOffstageChildren.contains(child)); + _forgottenOffstageChildren.add(child); + } + super.forgetChild(child); + } + + @override + void mount(Element? parent, dynamic newSlot) { + super.mount(parent, newSlot); + _onstage = updateChild(_onstage, widget.onstage, _onstageSlot); + _offstage = []; + } + + @override + void update(_BoardStack newWidget) { + super.update(newWidget); + assert(widget == newWidget); + _onstage = updateChild(_onstage, widget.onstage, _onstageSlot); + _offstage = updateChildren(_offstage, widget.offstage, + forgottenChildren: _forgottenOffstageChildren); + _forgottenOffstageChildren.clear(); + } +} + +// A render object which lays out and paints one subtree while keeping a list +// of other subtrees alive but not laid out or painted. +// +// The subtree that is laid out and painted must be a [RenderStack]. +// +// This class uses [StackParentData] objects for its parent data so that the +// children of its primary subtree's stack can be moved to this object's list +// of zombie children without changing their parent data objects. +class _RenderBoardObject extends RenderBox + with + RenderObjectWithChildMixin, + RenderProxyBoxMixin, + ContainerRenderObjectMixin { + @override + void setupParentData(RenderObject child) { + if (child.parentData is! StackParentData) { + child.parentData = StackParentData(); + } + } + + @override + void redepthChildren() { + if (child != null) redepthChild(child!); + super.redepthChildren(); + } + + @override + void visitChildren(RenderObjectVisitor visitor) { + if (child != null) visitor(child!); + super.visitChildren(visitor); + } + + @override + List debugDescribeChildren() { + final List children = []; + + if (child != null) children.add(child!.toDiagnosticsNode(name: 'onstage')); + + if (firstChild != null) { + RenderBox child = firstChild!; + + int count = 1; + while (true) { + children.add( + child.toDiagnosticsNode( + name: 'offstage $count', + style: DiagnosticsTreeStyle.offstage, + ), + ); + if (child == lastChild) break; + final StackParentData childParentData = + child.parentData! as StackParentData; + child = childParentData.nextSibling!; + count += 1; + } + } else { + children.add( + DiagnosticsNode.message( + 'no offstage children', + style: DiagnosticsTreeStyle.offstage, + ), + ); + } + return children; + } + + @override + void visitChildrenForSemantics(RenderObjectVisitor visitor) { + if (child != null) visitor(child!); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/utils/log.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/utils/log.dart new file mode 100644 index 0000000000..b9f766f961 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/utils/log.dart @@ -0,0 +1,28 @@ +import 'package:flutter/material.dart'; + +// ignore: constant_identifier_names +const DART_LOG = "Dart_LOG"; + +class Log { + // static const enableLog = bool.hasEnvironment(DART_LOG); + // static final shared = Log(); + static const enableLog = true; + + static void info(String? message) { + if (enableLog) { + debugPrint('ℹ️[Info]=> $message'); + } + } + + static void debug(String? message) { + if (enableLog) { + debugPrint('🐛[Debug]=> $message'); + } + } + + static void trace(String? message) { + if (enableLog) { + // debugPrint('❗️[Trace]=> $message'); + } + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board.dart new file mode 100644 index 0000000000..3cd2a331f1 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board.dart @@ -0,0 +1,264 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'board_column/board_column.dart'; +import 'board_column/board_column_data.dart'; +import 'board_data.dart'; +import 'reorder_flex/drag_target_inteceptor.dart'; +import 'reorder_flex/reorder_flex.dart'; +import 'reorder_phantom/phantom_controller.dart'; +import '../rendering/board_overlay.dart'; + +class BoardConfig { + final double cornerRadius; + final EdgeInsets columnPadding; + final EdgeInsets columnItemPadding; + final Color columnBackgroundColor; + + const BoardConfig({ + this.cornerRadius = 6.0, + this.columnPadding = const EdgeInsets.symmetric(horizontal: 8), + this.columnItemPadding = const EdgeInsets.symmetric(horizontal: 10), + this.columnBackgroundColor = Colors.transparent, + }); +} + +class Board extends StatelessWidget { + /// The direction to use as the main axis. + final Axis direction = Axis.vertical; + + /// + final Widget? background; + + /// + final BoardColumnCardBuilder cardBuilder; + + /// + final BoardColumnHeaderBuilder? headerBuilder; + + /// + final BoardColumnFooterBuilder? footBuilder; + + /// + final BoardDataController dataController; + + final BoxConstraints columnConstraints; + + /// + final BoardPhantomController phantomController; + + final BoardConfig config; + + Board({ + required this.dataController, + required this.cardBuilder, + this.background, + this.footBuilder, + this.headerBuilder, + this.columnConstraints = const BoxConstraints(maxWidth: 200), + this.config = const BoardConfig(), + Key? key, + }) : phantomController = BoardPhantomController(delegate: dataController), + super(key: key); + + @override + Widget build(BuildContext context) { + return ChangeNotifierProvider.value( + value: dataController, + child: Consumer( + builder: (context, notifier, child) { + return BoardContent( + config: config, + dataController: dataController, + background: background, + delegate: phantomController, + columnConstraints: columnConstraints, + cardBuilder: cardBuilder, + footBuilder: footBuilder, + headerBuilder: headerBuilder, + phantomController: phantomController, + onReorder: dataController.moveColumn, + ); + }, + ), + ); + } +} + +class BoardContent extends StatefulWidget { + final ScrollController? scrollController; + final OnDragStarted? onDragStarted; + final OnReorder onReorder; + final OnDragEnded? onDragEnded; + final BoardDataController dataController; + final Widget? background; + final BoardConfig config; + final ReorderFlexConfig reorderFlexConfig; + final BoxConstraints columnConstraints; + + /// + final BoardColumnCardBuilder cardBuilder; + + /// + final BoardColumnHeaderBuilder? headerBuilder; + + /// + final BoardColumnFooterBuilder? footBuilder; + + final OverlapDragTargetDelegate delegate; + + final BoardPhantomController phantomController; + + const BoardContent({ + required this.config, + required this.onReorder, + required this.delegate, + required this.dataController, + this.onDragStarted, + this.onDragEnded, + this.scrollController, + this.background, + required this.columnConstraints, + required this.cardBuilder, + this.footBuilder, + this.headerBuilder, + required this.phantomController, + Key? key, + }) : reorderFlexConfig = const ReorderFlexConfig(), + super(key: key); + + @override + State createState() => _BoardContentState(); +} + +class _BoardContentState extends State { + final GlobalKey _columnContainerOverlayKey = + GlobalKey(debugLabel: '$BoardContent overlay key'); + late BoardOverlayEntry _overlayEntry; + + @override + void initState() { + _overlayEntry = BoardOverlayEntry( + builder: (BuildContext context) { + final interceptor = OverlappingDragTargetInteceptor( + reorderFlexId: widget.dataController.identifier, + acceptedReorderFlexId: widget.dataController.columnIds, + delegate: widget.delegate, + ); + + final reorderFlex = ReorderFlex( + key: widget.key, + config: widget.reorderFlexConfig, + scrollController: widget.scrollController, + onDragStarted: widget.onDragStarted, + onReorder: widget.onReorder, + onDragEnded: widget.onDragEnded, + dataSource: widget.dataController, + direction: Axis.horizontal, + interceptor: interceptor, + children: _buildColumns(), + ); + + return Stack( + alignment: AlignmentDirectional.topStart, + children: [ + if (widget.background != null) + Container( + clipBehavior: Clip.hardEdge, + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(widget.config.cornerRadius), + ), + child: widget.background, + ), + reorderFlex, + ], + ); + }, + opaque: false, + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return BoardOverlay( + key: _columnContainerOverlayKey, + initialEntries: [_overlayEntry], + ); + } + + List _buildColumns() { + final List children = + widget.dataController.columnDatas.asMap().entries.map( + (item) { + final columnData = item.value; + final columnIndex = item.key; + + final dataSource = _BoardColumnDataSourceImpl( + columnId: columnData.id, + dataController: widget.dataController, + ); + + return ChangeNotifierProvider.value( + key: ValueKey(columnData.id), + value: widget.dataController.columnController(columnData.id), + child: Consumer( + builder: (context, value, child) { + return ConstrainedBox( + constraints: widget.columnConstraints, + child: BoardColumnWidget( + margin: _marginFromIndex(columnIndex), + itemMargin: widget.config.columnItemPadding, + headerBuilder: widget.headerBuilder, + footBuilder: widget.footBuilder, + cardBuilder: widget.cardBuilder, + dataSource: dataSource, + scrollController: ScrollController(), + phantomController: widget.phantomController, + onReorder: widget.dataController.moveColumnItem, + cornerRadius: widget.config.cornerRadius, + backgroundColor: widget.config.columnBackgroundColor, + ), + ); + }, + ), + ); + }, + ).toList(); + + return children; + } + + EdgeInsets _marginFromIndex(int index) { + if (widget.dataController.columnDatas.isEmpty) { + return widget.config.columnPadding; + } + + if (index == 0) { + return EdgeInsets.only(right: widget.config.columnPadding.right); + } + + if (index == widget.dataController.columnDatas.length - 1) { + return EdgeInsets.only(left: widget.config.columnPadding.left); + } + + return widget.config.columnPadding; + } +} + +class _BoardColumnDataSourceImpl extends BoardColumnDataDataSource { + String columnId; + final BoardDataController dataController; + + _BoardColumnDataSourceImpl({ + required this.columnId, + required this.dataController, + }); + + @override + BoardColumnData get columnData => + dataController.columnController(columnId).columnData; + + @override + List get acceptedColumnIds => dataController.columnIds; +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dart new file mode 100644 index 0000000000..d8981096e3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dart @@ -0,0 +1,208 @@ +import 'dart:collection'; + +import 'package:flutter/material.dart'; +import '../../rendering/board_overlay.dart'; +import '../../utils/log.dart'; +import '../reorder_phantom/phantom_controller.dart'; +import '../reorder_flex/reorder_flex.dart'; +import '../reorder_flex/drag_target_inteceptor.dart'; +import 'board_column_data.dart'; + +typedef OnColumnDragStarted = void Function(int index); + +typedef OnColumnDragEnded = void Function(String listId); + +typedef OnColumnReorder = void Function( + String listId, + int fromIndex, + int toIndex, +); + +typedef OnColumnDeleted = void Function(String listId, int deletedIndex); + +typedef OnColumnInserted = void Function(String listId, int insertedIndex); + +typedef BoardColumnCardBuilder = Widget Function( + BuildContext context, + ColumnItem item, +); + +typedef BoardColumnHeaderBuilder = Widget Function( + BuildContext context, + BoardColumnData columnData, +); + +typedef BoardColumnFooterBuilder = Widget Function( + BuildContext context, + BoardColumnData columnData, +); + +abstract class BoardColumnDataDataSource extends ReoderFlextDataSource { + BoardColumnData get columnData; + + List get acceptedColumnIds; + + @override + String get identifier => columnData.id; + + @override + UnmodifiableListView get items => columnData.items; + + void debugPrint() { + String msg = '[$BoardColumnDataDataSource] $columnData data: '; + for (var element in items) { + msg = '$msg$element,'; + } + + Log.debug(msg); + } +} + +/// [BoardColumnWidget] represents the column of the Board. +/// +class BoardColumnWidget extends StatefulWidget { + final BoardColumnDataDataSource dataSource; + final ScrollController? scrollController; + final ReorderFlexConfig config; + + final OnColumnDragStarted? onDragStarted; + final OnColumnReorder onReorder; + final OnColumnDragEnded? onDragEnded; + + final BoardPhantomController phantomController; + + String get columnId => dataSource.columnData.id; + + final BoardColumnCardBuilder cardBuilder; + + final BoardColumnHeaderBuilder? headerBuilder; + + final BoardColumnFooterBuilder? footBuilder; + + final EdgeInsets margin; + + final EdgeInsets itemMargin; + + final double cornerRadius; + + final Color backgroundColor; + + const BoardColumnWidget({ + Key? key, + this.headerBuilder, + this.footBuilder, + required this.cardBuilder, + required this.onReorder, + required this.dataSource, + required this.phantomController, + this.onDragStarted, + this.scrollController, + this.onDragEnded, + this.margin = EdgeInsets.zero, + this.itemMargin = EdgeInsets.zero, + this.cornerRadius = 0.0, + this.backgroundColor = Colors.transparent, + }) : config = const ReorderFlexConfig(), + super(key: key); + + @override + State createState() => _BoardColumnWidgetState(); +} + +class _BoardColumnWidgetState extends State { + final GlobalKey _columnOverlayKey = + GlobalKey(debugLabel: '$BoardColumnWidget overlay key'); + + late BoardOverlayEntry _overlayEntry; + + @override + void initState() { + _overlayEntry = BoardOverlayEntry( + builder: (BuildContext context) { + final children = widget.dataSource.columnData.items + .map((item) => _buildWidget(context, item)) + .toList(); + + final header = + widget.headerBuilder?.call(context, widget.dataSource.columnData); + + final footer = + widget.footBuilder?.call(context, widget.dataSource.columnData); + + final interceptor = CrossReorderFlexDragTargetInterceptor( + reorderFlexId: widget.columnId, + delegate: widget.phantomController, + acceptedReorderFlexIds: widget.dataSource.acceptedColumnIds, + draggableTargetBuilder: PhantomDraggableBuilder(), + ); + + final reorderFlex = ReorderFlex( + key: widget.key, + scrollController: widget.scrollController, + config: widget.config, + onDragStarted: (index) { + widget.phantomController.columnStartDragging(widget.columnId); + widget.onDragStarted?.call(index); + }, + onReorder: ((fromIndex, toIndex) { + if (widget.phantomController.isFromColumn(widget.columnId)) { + widget.onReorder(widget.columnId, fromIndex, toIndex); + widget.phantomController.transformIndex(fromIndex, toIndex); + } + }), + onDragEnded: () { + widget.phantomController.columnEndDragging(widget.columnId); + widget.onDragEnded?.call(widget.columnId); + widget.dataSource.debugPrint(); + }, + dataSource: widget.dataSource, + interceptor: interceptor, + children: children, + ); + + return Container( + margin: widget.margin, + clipBehavior: Clip.hardEdge, + decoration: BoxDecoration( + color: widget.backgroundColor, + borderRadius: BorderRadius.circular(widget.cornerRadius), + ), + child: Column( + children: [ + if (header != null) header, + Expanded( + child: Padding( + padding: widget.itemMargin, + child: reorderFlex, + ), + ), + if (footer != null) footer, + ], + ), + ); + }, + opaque: false, + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return BoardOverlay( + key: _columnOverlayKey, + initialEntries: [_overlayEntry], + ); + } + + Widget _buildWidget(BuildContext context, ColumnItem item) { + if (item is PhantomColumnItem) { + return PassthroughPhantomWidget( + key: UniqueKey(), + opacity: widget.config.draggingWidgetOpacity, + passthroughPhantomContext: item.phantomContext, + ); + } else { + return widget.cardBuilder(context, item); + } + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column_data.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column_data.dart new file mode 100644 index 0000000000..2ce739220e --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column_data.dart @@ -0,0 +1,130 @@ +import 'dart:collection'; + +import 'package:equatable/equatable.dart'; +import 'package:flutter/material.dart'; +import '../../utils/log.dart'; +import '../reorder_flex/reorder_flex.dart'; + +abstract class ColumnItem extends ReoderFlexItem { + bool get isPhantom => false; + + @override + String toString() => id; +} + +/// [BoardColumnDataController] is used to handle the [BoardColumnData]. +/// * Remove an item by calling [removeAt] method. +/// * Move item to another position by calling [move] method. +/// * Insert item to index by calling [insert] method +/// * Replace item at index by calling [replace] method. +/// +/// All there operations will notify listeners by default. +/// +class BoardColumnDataController extends ChangeNotifier with EquatableMixin { + final BoardColumnData columnData; + + BoardColumnDataController({ + required this.columnData, + }); + + @override + List get props => columnData.props; + + /// Returns the readonly List + UnmodifiableListView get items => + UnmodifiableListView(columnData.items); + + /// Remove the item at [index]. + /// * [index] the index of the item you want to remove + /// * [notify] the default value of [notify] is true, it will notify the + /// listener. Set to [false] if you do not want to notify the listeners. + /// + ColumnItem removeAt(int index, {bool notify = true}) { + assert(index >= 0); + + Log.debug('[$BoardColumnDataController] $columnData remove item at $index'); + final item = columnData._items.removeAt(index); + if (notify) { + notifyListeners(); + } + return item; + } + + int removeWhere(bool Function(ColumnItem) condition) { + return items.indexWhere(condition); + } + + /// Move the item from [fromIndex] to [toIndex]. It will do nothing if the + /// [fromIndex] equal to the [toIndex]. + void move(int fromIndex, int toIndex) { + assert(fromIndex >= 0); + assert(toIndex >= 0); + + if (fromIndex == toIndex) { + return; + } + Log.debug( + '[$BoardColumnDataController] $columnData move item from $fromIndex to $toIndex'); + final item = columnData._items.removeAt(fromIndex); + columnData._items.insert(toIndex, item); + notifyListeners(); + } + + /// Insert an item to [index] and notify the listen if the value of [notify] + /// is true. + /// + /// The default value of [notify] is true. + void insert(int index, ColumnItem item, {bool notify = true}) { + assert(index >= 0); + Log.debug( + '[$BoardColumnDataController] $columnData insert $item at $index'); + + if (columnData._items.length > index) { + columnData._items.insert(index, item); + } else { + columnData._items.add(item); + } + + if (notify) { + notifyListeners(); + } + } + + /// Replace the item at index with the [newItem]. + void replace(int index, ColumnItem newItem) { + if (columnData._items.isEmpty) { + columnData._items.add(newItem); + Log.debug('[$BoardColumnDataController] $columnData add $newItem'); + } else { + final removedItem = columnData._items.removeAt(index); + columnData._items.insert(index, newItem); + Log.debug( + '[$BoardColumnDataController] $columnData replace $removedItem with $newItem at $index'); + } + + notifyListeners(); + } +} + +/// [BoardColumnData] represents the data of each Column of the Board. +class BoardColumnData extends ReoderFlexItem with EquatableMixin { + @override + final String id; + final List _items; + + BoardColumnData({ + required this.id, + required List items, + }) : _items = items; + + /// Returns the readonly List + UnmodifiableListView get items => UnmodifiableListView(_items); + + @override + List get props => [id, ..._items]; + + @override + String toString() { + return 'Column:[$id]'; + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_data.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_data.dart new file mode 100644 index 0000000000..06e8ff1a57 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_data.dart @@ -0,0 +1,153 @@ +import 'dart:collection'; + +import 'package:equatable/equatable.dart'; + +import '../utils/log.dart'; +import 'board_column/board_column_data.dart'; +import 'reorder_flex/reorder_flex.dart'; +import 'package:flutter/material.dart'; +import 'reorder_phantom/phantom_controller.dart'; + +typedef OnMoveColumn = void Function(int fromIndex, int toIndex); + +typedef OnMoveColumnItem = void Function( + String columnId, + int fromIndex, + int toIndex, +); + +typedef OnMoveColumnItemToColumn = void Function( + String fromColumnId, + int fromIndex, + String toColumnId, + int toIndex, +); + +class BoardDataController extends ChangeNotifier + with EquatableMixin, BoardPhantomControllerDelegate, ReoderFlextDataSource { + final List _columnDatas = []; + final OnMoveColumn? onMoveColumn; + final OnMoveColumnItem? onMoveColumnItem; + final OnMoveColumnItemToColumn? onMoveColumnItemToColumn; + + List get columnDatas => _columnDatas; + + List get columnIds => + _columnDatas.map((columnData) => columnData.id).toList(); + + final LinkedHashMap _columnControllers = + LinkedHashMap(); + + BoardDataController({ + this.onMoveColumn, + this.onMoveColumnItem, + this.onMoveColumnItemToColumn, + }); + + void addColumn(BoardColumnData columnData) { + final controller = BoardColumnDataController(columnData: columnData); + _columnDatas.add(columnData); + _columnControllers[columnData.id] = controller; + } + + BoardColumnDataController columnController(String columnId) { + return _columnControllers[columnId]!; + } + + void moveColumn(int fromIndex, int toIndex) { + final columnData = _columnDatas.removeAt(fromIndex); + _columnDatas.insert(toIndex, columnData); + onMoveColumn?.call(fromIndex, toIndex); + notifyListeners(); + } + + void moveColumnItem(String columnId, int fromIndex, int toIndex) { + final columnController = _columnControllers[columnId]; + assert(columnController != null); + if (columnController != null) { + columnController.move(fromIndex, toIndex); + onMoveColumnItem?.call(columnId, fromIndex, toIndex); + } + } + + @override + @protected + void swapColumnItem( + String fromColumnId, + int fromColumnIndex, + String toColumnId, + int toColumnIndex, + ) { + final item = columnController(fromColumnId).removeAt(fromColumnIndex); + + if (columnController(toColumnId).items.length > toColumnIndex) { + assert(columnController(toColumnId).items[toColumnIndex] + is PhantomColumnItem); + } + + columnController(toColumnId).replace(toColumnIndex, item); + + onMoveColumnItemToColumn?.call( + fromColumnId, + fromColumnIndex, + toColumnId, + toColumnIndex, + ); + } + + @override + List get props { + return [_columnDatas]; + } + + @override + BoardColumnDataController? controller(String columnId) { + return _columnControllers[columnId]; + } + + @override + String get identifier => '$BoardDataController'; + + @override + UnmodifiableListView get items => + UnmodifiableListView(_columnDatas); + + @override + @protected + bool removePhantom(String columnId) { + final columnController = this.columnController(columnId); + final index = columnController.items.indexWhere((item) => item.isPhantom); + + final isExist = index != -1; + if (isExist) { + columnController.removeAt(index); + + Log.debug( + '[$BoardDataController] Column:[$columnId] remove phantom, current count: ${columnController.items.length}'); + } + return isExist; + } + + @override + @protected + void updatePhantom(String columnId, int newIndex) { + final columnDataController = columnController(columnId); + final index = + columnDataController.items.indexWhere((item) => item.isPhantom); + + assert(index != -1); + if (index != -1) { + if (index != newIndex) { + // Log.debug('[$BoardPhantomController] update $toColumnId:$index to $toColumnId:$phantomIndex'); + final item = columnDataController.removeAt(index, notify: false); + columnDataController.insert(newIndex, item, notify: false); + } + } + } + + @override + @protected + void insertPhantom(String columnId, int index, PhantomColumnItem item) { + columnController(columnId).insert(index, item); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_state.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_state.dart new file mode 100644 index 0000000000..f5f7250834 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_state.dart @@ -0,0 +1,172 @@ +import 'package:flutter/material.dart'; + +import '../../utils/log.dart'; +import 'drag_target.dart'; +import 'reorder_flex.dart'; + +/// [FlexDragTargetData] is used to store the custom dragging data. +/// +/// * [draggingIndex] the index of the dragTarget that is being dragged. +/// * [draggingWidget] the widget of the dragTarget that is being dragged. +/// * [reorderFlexId] the id of the [ReorderFlex] +/// * [reorderFlexItem] the item of the [ReorderFlex] +/// +class FlexDragTargetData extends DragTargetData { + /// The index of the dragging target in the boardList. + @override + final int draggingIndex; + + final DraggingState _state; + + Widget? get draggingWidget => _state.draggingWidget; + + Size? get feedbackSize => _state.feedbackSize; + + final String dragTargetId; + + final String reorderFlexId; + + final ReoderFlexItem reorderFlexItem; + + FlexDragTargetData({ + required this.dragTargetId, + required this.draggingIndex, + required this.reorderFlexId, + required this.reorderFlexItem, + required DraggingState state, + }) : _state = state; + + @override + String toString() { + return 'ReorderFlexId: $reorderFlexId, dragTargetId: $dragTargetId'; + } +} + +class DraggingState { + final String id; + + /// The member of widget.children currently being dragged. + Widget? _draggingWidget; + + Widget? get draggingWidget => _draggingWidget; + + /// The last computed size of the feedback widget being dragged. + Size? feedbackSize = Size.zero; + + /// The location that the dragging widget occupied before it started to drag. + int dragStartIndex = -1; + + /// The index that the dragging widget most recently left. + /// This is used to show an animation of the widget's position. + int phantomIndex = -1; + + /// The index that the dragging widget currently occupies. + int currentIndex = -1; + + /// The widget to move the dragging widget too after the current index. + int nextIndex = 0; + + /// Whether or not we are currently scrolling this view to show a widget. + bool scrolling = false; + + /// The additional margin to place around a computed drop area. + static const double _dropAreaMargin = 0.0; + + DraggingState(this.id); + + Size get dropAreaSize { + if (feedbackSize == null) { + return Size.zero; + } + return feedbackSize! + const Offset(_dropAreaMargin, _dropAreaMargin); + } + + void startDragging( + Widget draggingWidget, + int draggingWidgetIndex, + Size? draggingWidgetSize, + ) { + /// + assert(draggingWidgetIndex >= 0); + + _draggingWidget = draggingWidget; + phantomIndex = draggingWidgetIndex; + dragStartIndex = draggingWidgetIndex; + currentIndex = draggingWidgetIndex; + feedbackSize = draggingWidgetSize; + } + + void endDragging() { + dragStartIndex = -1; + phantomIndex = -1; + currentIndex = -1; + _draggingWidget = null; + } + + /// When the phantomIndex and currentIndex are the same, it means the dragging + /// widget did move to the destination location. + void removePhantom() { + phantomIndex = currentIndex; + } + + /// The dragging widget overlaps with the phantom widget. + bool isOverlapWithPhantom() { + return currentIndex != phantomIndex; + } + + bool isPhantomAboveDragTarget() { + return currentIndex > phantomIndex; + } + + bool isPhantomBelowDragTarget() { + return currentIndex < phantomIndex; + } + + bool didDragTargetMoveToNext() { + return currentIndex == nextIndex; + } + + /// Set the currentIndex to nextIndex + void moveDragTargetToNext() { + currentIndex = nextIndex; + } + + void updateNextIndex(int index) { + Log.trace('updateNextIndex: $index'); + nextIndex = index; + } + + bool isNotDragging() { + return dragStartIndex == -1; + } + + bool isDragging() { + return !isNotDragging(); + } + + /// When the _dragStartIndex less than the _currentIndex, it means the + /// dragTarget is going down to the end of the list. + bool isDragTargetMovingDown() { + return dragStartIndex < currentIndex; + } + + /// The index represents the widget original index of the list. + int calculateShiftedIndex(int index) { + int shiftedIndex = index; + if (index == dragStartIndex) { + shiftedIndex = phantomIndex; + } else if (index > dragStartIndex && index <= phantomIndex) { + /// phantom move up + shiftedIndex--; + } else if (index < dragStartIndex && index >= phantomIndex) { + /// phantom move down + shiftedIndex++; + } + return shiftedIndex; + } + + @override + String toString() { + return 'DragStartIndex: $dragStartIndex, PhantomIndex: $phantomIndex, CurrentIndex: $currentIndex, NextIndex: $nextIndex'; + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target.dart new file mode 100644 index 0000000000..a6a09a9770 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target.dart @@ -0,0 +1,471 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; +import 'package:provider/provider.dart'; +import '../transitions.dart'; + +abstract class DragTargetData { + int get draggingIndex; +} + +abstract class ReorderFlexDraggableTargetBuilder { + Widget? build( + BuildContext context, + Widget child, + DragTargetOnStarted onDragStarted, + DragTargetOnEnded onDragEnded, + DragTargetWillAccpet onWillAccept, + AnimationController insertAnimationController, + AnimationController deleteAnimationController, + ); +} + +/// +typedef DragTargetWillAccpet = bool Function( + T dragTargetData); + +/// +typedef DragTargetOnStarted = void Function(Widget, int, Size?); + +/// +typedef DragTargetOnEnded = void Function( + T dragTargetData); + +/// [ReorderDragTarget] is a [DragTarget] that carries the index information of +/// the child. You could check out this link for more information. +/// +/// The size of the [ReorderDragTarget] will become zero when it start dragging. +/// +class ReorderDragTarget extends StatefulWidget { + final Widget child; + final T dragTargetData; + + final GlobalObjectKey _indexGlobalKey; + + /// Called when dragTarget is being dragging. + final DragTargetOnStarted onDragStarted; + + final DragTargetOnEnded onDragEnded; + + /// Called to determine whether this widget is interested in receiving a given + /// piece of data being dragged over this drag target. + /// + /// [toAccept] represents the dragTarget index, which is the value passed in + /// when creating the [ReorderDragTarget]. + final DragTargetWillAccpet onWillAccept; + + /// Called when an acceptable piece of data was dropped over this drag target. + /// + /// Equivalent to [onAcceptWithDetails], but only includes the data. + final void Function(T dragTargetData)? onAccept; + + /// Called when a given piece of data being dragged over this target leaves + /// the target. + final void Function(T dragTargetData)? onLeave; + + final ReorderFlexDraggableTargetBuilder? draggableTargetBuilder; + + final AnimationController insertAnimationController; + final AnimationController deleteAnimationController; + + final bool useMoveAnimation; + + ReorderDragTarget({ + Key? key, + required this.child, + required this.dragTargetData, + required this.onDragStarted, + required this.onDragEnded, + required this.onWillAccept, + required this.insertAnimationController, + required this.deleteAnimationController, + required this.useMoveAnimation, + this.onAccept, + this.onLeave, + this.draggableTargetBuilder, + }) : _indexGlobalKey = GlobalObjectKey(child.key!), + super(key: key); + + @override + State> createState() => _ReorderDragTargetState(); +} + +class _ReorderDragTargetState + extends State> { + /// Returns the dragTarget's size + Size? _draggingFeedbackSize = Size.zero; + + @override + Widget build(BuildContext context) { + Widget dragTarget = DragTarget( + builder: _buildDraggableWidget, + onWillAccept: (dragTargetData) { + assert(dragTargetData != null); + if (dragTargetData == null) return false; + return widget.onWillAccept(dragTargetData); + }, + onAccept: widget.onAccept, + onLeave: (dragTargetData) { + assert(dragTargetData != null); + if (dragTargetData != null) { + widget.onLeave?.call(dragTargetData); + } + }, + ); + + dragTarget = KeyedSubtree(key: widget._indexGlobalKey, child: dragTarget); + return dragTarget; + } + + Widget _buildDraggableWidget( + BuildContext context, + List acceptedCandidates, + List rejectedCandidates, + ) { + Widget feedbackBuilder = Builder(builder: (BuildContext context) { + BoxConstraints contentSizeConstraints = + BoxConstraints.loose(_draggingFeedbackSize!); + return _buildDraggableFeedback( + context, + contentSizeConstraints, + widget.child, + ); + }); + + final draggableWidget = widget.draggableTargetBuilder?.build( + context, + widget.child, + widget.onDragStarted, + widget.onDragEnded, + widget.onWillAccept, + widget.insertAnimationController, + widget.deleteAnimationController, + ) ?? + LongPressDraggable( + maxSimultaneousDrags: 1, + data: widget.dragTargetData, + ignoringFeedbackSemantics: false, + feedback: feedbackBuilder, + childWhenDragging: IgnorePointerWidget( + useIntrinsicSize: !widget.useMoveAnimation, + child: widget.child, + ), + onDragStarted: () { + _draggingFeedbackSize = widget._indexGlobalKey.currentContext?.size; + widget.onDragStarted( + widget.child, + widget.dragTargetData.draggingIndex, + _draggingFeedbackSize, + ); + }, + dragAnchorStrategy: childDragAnchorStrategy, + + /// When the drag ends inside a DragTarget widget, the drag + /// succeeds, and we reorder the widget into position appropriately. + onDragCompleted: () { + widget.onDragEnded(widget.dragTargetData); + }, + + /// When the drag does not end inside a DragTarget widget, the + /// drag fails, but we still reorder the widget to the last position it + /// had been dragged to. + onDraggableCanceled: (Velocity velocity, Offset offset) => + widget.onDragEnded(widget.dragTargetData), + child: widget.child, + ); + + return draggableWidget; + } + + Widget _buildDraggableFeedback( + BuildContext context, BoxConstraints constraints, Widget child) { + return Transform( + transform: Matrix4.rotationZ(0), + alignment: FractionalOffset.topLeft, + child: Material( + color: Colors.transparent, + borderRadius: BorderRadius.zero, + clipBehavior: Clip.hardEdge, + child: ConstrainedBox( + constraints: constraints, + child: Opacity(opacity: 0.3, child: child), + ), + ), + ); + } +} + +class DragTargetAnimation { + // How long an animation to reorder an element in the list takes. + final Duration reorderAnimationDuration; + + // This controls the entrance of the dragging widget into a new place. + late AnimationController entranceController; + + // This controls the 'phantom' of the dragging widget, which is left behind + // where the widget used to be. + late AnimationController phantomController; + + late AnimationController insertController; + + late AnimationController deleteController; + + DragTargetAnimation({ + required this.reorderAnimationDuration, + required TickerProvider vsync, + required void Function(AnimationStatus) entranceAnimateStatusChanged, + }) { + entranceController = AnimationController( + value: 1.0, vsync: vsync, duration: reorderAnimationDuration); + entranceController.addStatusListener(entranceAnimateStatusChanged); + + phantomController = AnimationController( + value: 0, vsync: vsync, duration: reorderAnimationDuration); + + insertController = AnimationController( + value: 0.0, vsync: vsync, duration: const Duration(milliseconds: 100)); + + deleteController = AnimationController( + value: 0.0, vsync: vsync, duration: const Duration(milliseconds: 10)); + } + + void startDargging() { + entranceController.value = 1.0; + } + + void animateToNext() { + phantomController.reverse(from: 1.0); + entranceController.forward(from: 0.0); + } + + void reverseAnimation() { + phantomController.reverse(from: 0.1); + entranceController.reverse(from: 0.0); + } + + void dispose() { + entranceController.dispose(); + phantomController.dispose(); + insertController.dispose(); + deleteController.dispose(); + } +} + +class IgnorePointerWidget extends StatelessWidget { + final Widget? child; + final bool useIntrinsicSize; + const IgnorePointerWidget({ + required this.child, + this.useIntrinsicSize = false, + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + final sizedChild = useIntrinsicSize + ? child + : SizedBox(width: 0.0, height: 0.0, child: child); + + final opacity = useIntrinsicSize ? 0.3 : 0.0; + return IgnorePointer( + ignoring: true, + child: Opacity( + opacity: opacity, + child: sizedChild, + ), + ); + } +} + +class PhantomWidget extends StatelessWidget { + final Widget? child; + final double opacity; + const PhantomWidget({ + this.child, + this.opacity = 1.0, + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Opacity( + opacity: opacity, + child: child, + ); + } +} + +abstract class DragTargetMovePlaceholderDelegate { + void registerPlaceholder( + int dragTargetIndex, + void Function(int currentDragTargetIndex) callback, + ); + + void unregisterPlaceholder(int dragTargetIndex); +} + +class DragTargeMovePlaceholder extends StatefulWidget { + final double height; + final Color color; + final Color highlightColor; + final int dragTargetIndex; + final DragTargetMovePlaceholderDelegate delegate; + + const DragTargeMovePlaceholder({ + required this.delegate, + required this.dragTargetIndex, + this.height = 4, + this.color = Colors.transparent, + this.highlightColor = Colors.lightBlue, + Key? key, + }) : super(key: key); + + @override + State createState() => + _DragTargeMovePlaceholderState(); +} + +class _DragTargeMovePlaceholderState extends State { + ValueNotifier isHighlight = ValueNotifier(false); + + @override + void initState() { + widget.delegate.registerPlaceholder( + widget.dragTargetIndex, + (currentDragTargetIndex) { + if (!mounted) return; + + SchedulerBinding.instance.addPostFrameCallback((Duration duration) { + if (currentDragTargetIndex == -1) { + isHighlight.value = false; + } else { + isHighlight.value = + widget.dragTargetIndex == currentDragTargetIndex; + } + }); + }, + ); + super.initState(); + } + + @override + void dispose() { + isHighlight.dispose(); + widget.delegate.unregisterPlaceholder(widget.dragTargetIndex); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return ChangeNotifierProvider.value( + value: isHighlight, + child: Consumer>( + builder: (context, notifier, child) { + return Container( + height: widget.height, + color: notifier.value ? widget.highlightColor : widget.color, + ); + }, + ), + ); + } +} + +abstract class FakeDragTargetEventTrigger { + void fakeOnDragEnded(VoidCallback callback); +} + +abstract class FakeDragTargetEventData { + Size? get feedbackSize; + int get index; + DragTargetData get dragTargetData; +} + +class FakeDragTarget extends StatefulWidget { + final Duration animationDuration; + final FakeDragTargetEventTrigger eventTrigger; + final FakeDragTargetEventData eventData; + final DragTargetOnStarted onDragStarted; + final DragTargetOnEnded onDragEnded; + final DragTargetWillAccpet onWillAccept; + final Widget child; + final AnimationController insertAnimationController; + final AnimationController deleteAnimationController; + const FakeDragTarget({ + Key? key, + required this.eventTrigger, + required this.eventData, + required this.onDragStarted, + required this.onDragEnded, + required this.onWillAccept, + required this.insertAnimationController, + required this.deleteAnimationController, + required this.child, + this.animationDuration = const Duration(milliseconds: 250), + }) : super(key: key); + + @override + State> createState() => _FakeDragTargetState(); +} + +class _FakeDragTargetState + extends State> + with TickerProviderStateMixin> { + bool simulateDragging = false; + + @override + void initState() { + widget.insertAnimationController.addStatusListener( + _onInsertedAnimationStatusChanged, + ); + + /// Start insert animation + widget.insertAnimationController.forward(from: 0.0); + + widget.eventTrigger.fakeOnDragEnded(() { + WidgetsBinding.instance.addPostFrameCallback((_) { + widget.onDragEnded(widget.eventData.dragTargetData as T); + }); + }); + + super.initState(); + } + + @override + Widget build(BuildContext context) { + if (simulateDragging) { + return SizeTransitionWithIntrinsicSize( + sizeFactor: widget.deleteAnimationController, + axis: Axis.vertical, + child: IgnorePointerWidget( + child: widget.child, + ), + ); + } else { + return SizeTransitionWithIntrinsicSize( + sizeFactor: widget.insertAnimationController, + axis: Axis.vertical, + child: IgnorePointerWidget( + useIntrinsicSize: true, + child: widget.child, + ), + ); + } + } + + void _onInsertedAnimationStatusChanged(AnimationStatus status) { + if (status != AnimationStatus.completed) return; + WidgetsBinding.instance.addPostFrameCallback((_) { + if (!mounted) return; + setState(() { + simulateDragging = true; + widget.deleteAnimationController.reverse(from: 1.0); + widget.onWillAccept(widget.eventData.dragTargetData as T); + widget.onDragStarted( + widget.child, + widget.eventData.index, + widget.eventData.feedbackSize, + ); + }); + }); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target_inteceptor.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target_inteceptor.dart new file mode 100644 index 0000000000..da529819dd --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target_inteceptor.dart @@ -0,0 +1,161 @@ +import 'package:flutter/material.dart'; + +import '../../utils/log.dart'; +import 'drag_state.dart'; +import 'drag_target.dart'; +import 'reorder_flex.dart'; + +/// [DragTargetInterceptor] is used to intercept the [DragTarget]'s +/// [onWillAccept], [OnAccept], and [onLeave] event. +abstract class DragTargetInterceptor { + /// Returns [yes] to receive the [DragTarget]'s event. + bool canHandler(FlexDragTargetData dragTargetData); + + /// Handle the [DragTarget]'s [onWillAccept] event. + bool onWillAccept({ + required BuildContext context, + required ReorderFlexState reorderFlexState, + required FlexDragTargetData dragTargetData, + required String dragTargetId, + required int dragTargetIndex, + }); + + /// Handle the [DragTarget]'s [onAccept] event. + void onAccept(FlexDragTargetData dragTargetData) {} + + /// Handle the [DragTarget]'s [onLeave] event. + void onLeave(FlexDragTargetData dragTargetData) {} + + ReorderFlexDraggableTargetBuilder? get draggableTargetBuilder => null; +} + +abstract class OverlapDragTargetDelegate { + void cancel(); + void moveTo( + String reorderFlexId, + FlexDragTargetData dragTargetData, + int dragTargetIndex, + ); + + bool canMoveTo(String dragTargetId); +} + +/// [OverlappingDragTargetInteceptor] is used to receive the overlapping +/// [DragTarget] event. If a [DragTarget] child is [DragTarget], it will +/// receive the [DragTarget] event when being dragged. +/// +/// Receive the [DragTarget] event if the [acceptedReorderFlexId] contains +/// the passed in dragTarget' reorderFlexId. +class OverlappingDragTargetInteceptor extends DragTargetInterceptor { + final String reorderFlexId; + final List acceptedReorderFlexId; + final OverlapDragTargetDelegate delegate; + + OverlappingDragTargetInteceptor({ + required this.delegate, + required this.reorderFlexId, + required this.acceptedReorderFlexId, + }); + + @override + bool canHandler(FlexDragTargetData dragTargetData) { + return acceptedReorderFlexId.contains(dragTargetData.reorderFlexId); + } + + @override + bool onWillAccept( + {required BuildContext context, + required ReorderFlexState reorderFlexState, + required FlexDragTargetData dragTargetData, + required String dragTargetId, + required int dragTargetIndex}) { + if (dragTargetId == dragTargetData.reorderFlexId) { + delegate.cancel(); + } else { + if (delegate.canMoveTo(dragTargetId)) { + delegate.moveTo(dragTargetId, dragTargetData, 0); + } + } + + return true; + } +} + +abstract class CrossReorderFlexDragTargetDelegate { + /// * [reorderFlexId] is the id that the [ReorderFlex] passed in. + bool acceptNewDragTargetData( + String reorderFlexId, + FlexDragTargetData dragTargetData, + int dragTargetIndex, + ); + + void updateDragTargetData( + String reorderFlexId, + int dragTargetIndex, + ); +} + +class CrossReorderFlexDragTargetInterceptor extends DragTargetInterceptor { + final String reorderFlexId; + final List acceptedReorderFlexIds; + final CrossReorderFlexDragTargetDelegate delegate; + @override + final ReorderFlexDraggableTargetBuilder? draggableTargetBuilder; + + CrossReorderFlexDragTargetInterceptor({ + required this.reorderFlexId, + required this.delegate, + required this.acceptedReorderFlexIds, + this.draggableTargetBuilder, + }); + + @override + bool canHandler(FlexDragTargetData dragTargetData) { + if (acceptedReorderFlexIds.isEmpty) { + return false; + } + + if (acceptedReorderFlexIds.contains(dragTargetData.reorderFlexId)) { + /// If the columnId equal to the dragTargetData's columnId, + /// it means the dragTarget is dragging on the top of its own list. + /// Otherwise, it means the dargTarget was moved to another list. + return reorderFlexId != dragTargetData.reorderFlexId; + } else { + return false; + } + } + + @override + void onAccept(FlexDragTargetData dragTargetData) { + Log.trace( + '[$CrossReorderFlexDragTargetInterceptor] Column:[$reorderFlexId] on onAccept'); + } + + @override + void onLeave(FlexDragTargetData dragTargetData) { + Log.trace( + '[$CrossReorderFlexDragTargetInterceptor] Column:[$reorderFlexId] on leave'); + } + + @override + bool onWillAccept({ + required BuildContext context, + required ReorderFlexState reorderFlexState, + required FlexDragTargetData dragTargetData, + required String dragTargetId, + required int dragTargetIndex, + }) { + final isNewDragTarget = delegate.acceptNewDragTargetData( + reorderFlexId, + dragTargetData, + dragTargetIndex, + ); + + if (isNewDragTarget == false) { + delegate.updateDragTargetData(reorderFlexId, dragTargetIndex); + reorderFlexState.handleOnWillAccept(context, dragTargetIndex); + } + + return true; + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_flex.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_flex.dart new file mode 100644 index 0000000000..27af28d778 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_flex.dart @@ -0,0 +1,556 @@ +import 'dart:collection'; +import 'dart:math'; + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import '../../utils/log.dart'; +import 'reorder_mixin.dart'; +import 'drag_target.dart'; +import 'drag_state.dart'; +import 'drag_target_inteceptor.dart'; + +typedef OnDragStarted = void Function(int index); +typedef OnDragEnded = void Function(); +typedef OnReorder = void Function(int fromIndex, int toIndex); +typedef OnDeleted = void Function(int deletedIndex); +typedef OnInserted = void Function(int insertedIndex); +typedef OnReveivePassedInPhantom = void Function( + FlexDragTargetData dragTargetData, int phantomIndex); + +abstract class ReoderFlextDataSource { + /// [identifier] represents the id the [ReorderFlex]. It must be unique. + String get identifier; + + /// The number of [ReoderFlexItem]s will be displaied in the [ReorderFlex]. + UnmodifiableListView get items; +} + +/// Each item displaied in the [ReorderFlex] required to implement the [ReoderFlexItem]. +abstract class ReoderFlexItem { + /// [id] is used to identify the item. It must be unique. + String get id; +} + +class ReorderFlexConfig { + /// The opacity of the dragging widget + final double draggingWidgetOpacity = 0.3; + + // How long an animation to reorder an element + final Duration reorderAnimationDuration = const Duration(milliseconds: 250); + + // How long an animation to scroll to an off-screen element + final Duration scrollAnimationDuration = const Duration(milliseconds: 250); + + final bool useMoveAnimation; + + final bool useMovePlaceholder; + + const ReorderFlexConfig({ + this.useMoveAnimation = true, + }) : useMovePlaceholder = !useMoveAnimation; +} + +class ReorderFlex extends StatefulWidget { + final ReorderFlexConfig config; + + final List children; + + /// [direction] How to place the children, default is Axis.vertical + final Axis direction; + final MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start; + + final ScrollController? scrollController; + + /// [onDragStarted] is called when start dragging + final OnDragStarted? onDragStarted; + + /// [onReorder] is called when dragTarget did end dragging + final OnReorder onReorder; + + /// [onDragEnded] is called when dragTarget did end dragging + final OnDragEnded? onDragEnded; + + final ReoderFlextDataSource dataSource; + + final DragTargetInterceptor? interceptor; + + const ReorderFlex({ + Key? key, + this.scrollController, + required this.dataSource, + required this.children, + required this.config, + required this.onReorder, + this.onDragStarted, + this.onDragEnded, + this.interceptor, + this.direction = Axis.vertical, + }) : super(key: key); + + @override + State createState() => ReorderFlexState(); + + String get reorderFlexId => dataSource.identifier; +} + +class ReorderFlexState extends State + with ReorderFlexMinxi, TickerProviderStateMixin { + /// Controls scrolls and measures scroll progress. + late ScrollController _scrollController; + + /// Records the position of the [Scrollable] + ScrollPosition? _attachedScrollPosition; + + /// Whether or not we are currently scrolling this view to show a widget. + bool _scrolling = false; + + /// [dragState] records the dragging state including dragStartIndex, and phantomIndex, etc. + late DraggingState dragState; + + /// [_animation] controls the dragging animations + late DragTargetAnimation _animation; + + late ReorderFlexNotifier _notifier; + + @override + void initState() { + _notifier = ReorderFlexNotifier(); + dragState = DraggingState(widget.reorderFlexId); + + _animation = DragTargetAnimation( + reorderAnimationDuration: widget.config.reorderAnimationDuration, + entranceAnimateStatusChanged: (status) { + if (status == AnimationStatus.completed) { + setState(() => _requestAnimationToNextIndex()); + } + }, + vsync: this, + ); + + super.initState(); + } + + @override + void didChangeDependencies() { + if (_attachedScrollPosition != null) { + _scrollController.detach(_attachedScrollPosition!); + _attachedScrollPosition = null; + } + + _scrollController = widget.scrollController ?? + PrimaryScrollController.of(context) ?? + ScrollController(); + + if (_scrollController.hasClients) { + _attachedScrollPosition = Scrollable.of(context)?.position; + } else { + _attachedScrollPosition = null; + } + + if (_attachedScrollPosition != null) { + _scrollController.attach(_attachedScrollPosition!); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final List children = []; + + for (int i = 0; i < widget.children.length; i += 1) { + Widget child = widget.children[i]; + children.add(_wrap(child, i)); + + // if (widget.config.useMovePlaceholder) { + // children.add(DragTargeMovePlaceholder( + // dragTargetIndex: i, + // delegate: _notifier, + // )); + // } + } + + final child = _wrapContainer(children); + return _wrapScrollView(child: child); + } + + @override + void dispose() { + if (_attachedScrollPosition != null) { + _scrollController.detach(_attachedScrollPosition!); + _attachedScrollPosition = null; + } + + _animation.dispose(); + super.dispose(); + } + + void _requestAnimationToNextIndex({bool isAcceptingNewTarget = false}) { + /// Update the dragState and animate to the next index if the current + /// dragging animation is completed. Otherwise, it will get called again + /// when the animation finishs. + + if (_animation.entranceController.isCompleted) { + dragState.removePhantom(); + + if (!isAcceptingNewTarget && dragState.didDragTargetMoveToNext()) { + return; + } + + dragState.moveDragTargetToNext(); + _animation.animateToNext(); + } + } + + /// [child]: the child will be wrapped with dartTarget + /// [childIndex]: the index of the child in a list + Widget _wrap(Widget child, int childIndex) { + return Builder(builder: (context) { + final ReorderDragTarget dragTarget = + _buildDragTarget(context, child, childIndex); + int shiftedIndex = childIndex; + + if (dragState.isOverlapWithPhantom()) { + shiftedIndex = dragState.calculateShiftedIndex(childIndex); + } + + Log.trace( + 'Rebuild: Column:[${dragState.id}] ${dragState.toString()}, childIndex: $childIndex shiftedIndex: $shiftedIndex'); + final currentIndex = dragState.currentIndex; + final dragPhantomIndex = dragState.phantomIndex; + + if (shiftedIndex == currentIndex || childIndex == dragPhantomIndex) { + Widget dragSpace; + if (dragState.draggingWidget != null) { + if (dragState.draggingWidget is PhantomWidget) { + dragSpace = dragState.draggingWidget!; + } else { + dragSpace = PhantomWidget( + opacity: widget.config.draggingWidgetOpacity, + child: dragState.draggingWidget, + ); + } + } else { + dragSpace = SizedBox.fromSize(size: dragState.dropAreaSize); + } + + /// Returns the dragTarget it is not start dragging. The size of the + /// dragTarget is the same as the the passed in child. + /// + if (dragState.isNotDragging()) { + return _buildDraggingContainer(children: [dragTarget]); + } + + /// Determine the size of the drop area to show under the dragging widget. + Size? feedbackSize = Size.zero; + if (widget.config.useMoveAnimation) { + feedbackSize = dragState.feedbackSize; + } + + Widget appearSpace = _makeAppearSpace(dragSpace, feedbackSize); + Widget disappearSpace = _makeDisappearSpace(dragSpace, feedbackSize); + + /// When start dragging, the dragTarget, [ReorderDragTarget], will + /// return a [IgnorePointerWidget] which size is zero. + if (dragState.isPhantomAboveDragTarget()) { + _notifier.updateDragTargetIndex(currentIndex); + if (shiftedIndex == currentIndex && childIndex == dragPhantomIndex) { + return _buildDraggingContainer(children: [ + disappearSpace, + dragTarget, + appearSpace, + ]); + } else if (shiftedIndex == currentIndex) { + return _buildDraggingContainer(children: [ + dragTarget, + appearSpace, + ]); + } else if (childIndex == dragPhantomIndex) { + return _buildDraggingContainer( + children: shiftedIndex <= childIndex + ? [dragTarget, disappearSpace] + : [disappearSpace, dragTarget]); + } + } + + /// + if (dragState.isPhantomBelowDragTarget()) { + _notifier.updateDragTargetIndex(currentIndex); + if (shiftedIndex == currentIndex && childIndex == dragPhantomIndex) { + return _buildDraggingContainer(children: [ + appearSpace, + dragTarget, + disappearSpace, + ]); + } else if (shiftedIndex == currentIndex) { + return _buildDraggingContainer(children: [ + appearSpace, + dragTarget, + ]); + } else if (childIndex == dragPhantomIndex) { + return _buildDraggingContainer( + children: shiftedIndex >= childIndex + ? [disappearSpace, dragTarget] + : [dragTarget, disappearSpace]); + } + } + + assert(!dragState.isOverlapWithPhantom()); + + List children = []; + if (dragState.isDragTargetMovingDown()) { + children.addAll([dragTarget, appearSpace]); + } else { + children.addAll([appearSpace, dragTarget]); + } + return _buildDraggingContainer(children: children); + } + + /// We still wrap dragTarget with a container so that widget's depths are + /// the same and it prevent's layout alignment issue + return _buildDraggingContainer(children: [dragTarget]); + }); + } + + ReorderDragTarget _buildDragTarget( + BuildContext builderContext, Widget child, int dragTargetIndex) { + final ReoderFlexItem reorderFlexItem = + widget.dataSource.items[dragTargetIndex]; + return ReorderDragTarget( + dragTargetData: FlexDragTargetData( + draggingIndex: dragTargetIndex, + reorderFlexId: widget.reorderFlexId, + reorderFlexItem: reorderFlexItem, + state: dragState, + dragTargetId: reorderFlexItem.id, + ), + onDragStarted: (draggingWidget, draggingIndex, size) { + Log.debug( + "[DragTarget] Column:[${widget.dataSource.identifier}] start dragging item at $draggingIndex"); + _startDragging(draggingWidget, draggingIndex, size); + widget.onDragStarted?.call(draggingIndex); + }, + onDragEnded: (dragTargetData) { + Log.debug( + "[DragTarget]: Column:[${widget.dataSource.identifier}] end dragging"); + _notifier.updateDragTargetIndex(-1); + setState(() { + if (dragTargetData.reorderFlexId == widget.reorderFlexId) { + _onReordered( + dragState.dragStartIndex, + dragState.currentIndex, + ); + } + + dragState.endDragging(); + widget.onDragEnded?.call(); + }); + }, + onWillAccept: (FlexDragTargetData dragTargetData) { + if (_animation.deleteController.isAnimating) { + return false; + } + + assert(widget.dataSource.items.length > dragTargetIndex); + if (_interceptDragTarget( + dragTargetData, + (interceptor) => interceptor.onWillAccept( + context: builderContext, + reorderFlexState: this, + dragTargetData: dragTargetData, + dragTargetId: reorderFlexItem.id, + dragTargetIndex: dragTargetIndex, + ), + )) { + return true; + } else { + return handleOnWillAccept(builderContext, dragTargetIndex); + } + }, + onAccept: (dragTargetData) { + _interceptDragTarget( + dragTargetData, + (interceptor) => interceptor.onAccept(dragTargetData), + ); + }, + onLeave: (dragTargetData) { + _notifier.updateDragTargetIndex(-1); + _interceptDragTarget( + dragTargetData, + (interceptor) => interceptor.onLeave(dragTargetData), + ); + }, + insertAnimationController: _animation.insertController, + deleteAnimationController: _animation.deleteController, + draggableTargetBuilder: widget.interceptor?.draggableTargetBuilder, + useMoveAnimation: widget.config.useMoveAnimation, + child: child, + ); + } + + bool _interceptDragTarget( + FlexDragTargetData dragTargetData, + void Function(DragTargetInterceptor) callback, + ) { + final interceptor = widget.interceptor; + if (interceptor != null && interceptor.canHandler(dragTargetData)) { + callback(interceptor); + return true; + } else { + return false; + } + } + + Widget _makeAppearSpace(Widget child, Size? feedbackSize) { + return makeAppearingWidget( + child, + _animation.entranceController, + feedbackSize, + widget.direction, + ); + } + + Widget _makeDisappearSpace(Widget child, Size? feedbackSize) { + return makeDisappearingWidget( + child, + _animation.phantomController, + feedbackSize, + widget.direction, + ); + } + + void _startDragging( + Widget draggingWidget, + int dragIndex, + Size? feedbackSize, + ) { + setState(() { + dragState.startDragging(draggingWidget, dragIndex, feedbackSize); + _animation.startDargging(); + }); + } + + bool handleOnWillAccept(BuildContext context, int dragTargetIndex) { + final dragIndex = dragState.dragStartIndex; + + /// The [willAccept] will be true if the dargTarget is the widget that gets + /// dragged and it is dragged on top of the other dragTargets. + /// + Log.debug( + '[$ReorderDragTarget] ${widget.dataSource.identifier} on will accept, dragIndex:$dragIndex, dragTargetIndex:$dragTargetIndex, count: ${widget.dataSource.items.length}'); + + bool willAccept = + dragState.dragStartIndex == dragIndex && dragIndex != dragTargetIndex; + setState(() { + if (willAccept) { + int shiftedIndex = dragState.calculateShiftedIndex(dragTargetIndex); + dragState.updateNextIndex(shiftedIndex); + } else { + dragState.updateNextIndex(dragTargetIndex); + } + _requestAnimationToNextIndex(isAcceptingNewTarget: true); + }); + + _scrollTo(context); + + /// If the target is not the original starting point, then we will accept the drop. + return willAccept; + } + + void _onReordered(int fromIndex, int toIndex) { + if (fromIndex != toIndex) { + widget.onReorder.call(fromIndex, toIndex); + } + + _animation.reverseAnimation(); + } + + Widget _wrapScrollView({required Widget child}) { + if (widget.scrollController != null && + PrimaryScrollController.of(context) == null) { + return child; + } else { + return SingleChildScrollView( + scrollDirection: widget.direction, + controller: _scrollController, + child: child, + ); + } + } + + Widget _wrapContainer(List children) { + switch (widget.direction) { + case Axis.horizontal: + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: widget.mainAxisAlignment, + children: children, + ); + case Axis.vertical: + default: + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: widget.mainAxisAlignment, + children: children, + ); + } + } + + Widget _buildDraggingContainer({required List children}) { + switch (widget.direction) { + case Axis.horizontal: + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: widget.mainAxisAlignment, + children: children, + ); + case Axis.vertical: + default: + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: widget.mainAxisAlignment, + children: children, + ); + } + } + +// Scrolls to a target context if that context is not on the screen. + void _scrollTo(BuildContext context) { + if (_scrolling) return; + final RenderObject contextObject = context.findRenderObject()!; + final RenderAbstractViewport viewport = + RenderAbstractViewport.of(contextObject)!; + // If and only if the current scroll offset falls in-between the offsets + // necessary to reveal the selected context at the top or bottom of the + // screen, then it is already on-screen. + final double margin = widget.direction == Axis.horizontal + ? dragState.dropAreaSize.width + : dragState.dropAreaSize.height; + if (_scrollController.hasClients) { + final double scrollOffset = _scrollController.offset; + final double topOffset = max( + _scrollController.position.minScrollExtent, + viewport.getOffsetToReveal(contextObject, 0.0).offset - margin, + ); + final double bottomOffset = min( + _scrollController.position.maxScrollExtent, + viewport.getOffsetToReveal(contextObject, 1.0).offset + margin, + ); + final bool onScreen = + scrollOffset <= topOffset && scrollOffset >= bottomOffset; + + // If the context is off screen, then we request a scroll to make it visible. + if (!onScreen) { + _scrolling = true; + _scrollController.position + .animateTo( + scrollOffset < bottomOffset ? bottomOffset : topOffset, + duration: widget.config.scrollAnimationDuration, + curve: Curves.easeInOut, + ) + .then((void value) { + setState(() => _scrolling = false); + }); + } + } + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_mixin.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_mixin.dart new file mode 100644 index 0000000000..accdaa866b --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_mixin.dart @@ -0,0 +1,142 @@ +import 'package:flutter/widgets.dart'; + +import '../transitions.dart'; +import 'drag_target.dart'; + +mixin ReorderFlexMinxi { + @protected + Widget makeAppearingWidget( + Widget child, + AnimationController animationController, + Size? draggingFeedbackSize, + Axis direction, + ) { + final sizeFactor = animationController.withLinearCurve(); + if (null == draggingFeedbackSize) { + return SizeTransitionWithIntrinsicSize( + sizeFactor: sizeFactor, + axis: direction, + child: FadeTransition( + opacity: sizeFactor, + child: child, + ), + ); + } else { + var transition = SizeTransition( + sizeFactor: sizeFactor, + axis: direction, + child: FadeTransition(opacity: animationController, child: child), + ); + + BoxConstraints contentSizeConstraints = + BoxConstraints.loose(draggingFeedbackSize); + return ConstrainedBox( + constraints: contentSizeConstraints, child: transition); + } + } + + @protected + Widget makeDisappearingWidget( + Widget child, + AnimationController animationController, + Size? draggingFeedbackSize, + Axis direction, + ) { + final sizeFactor = animationController.withLinearCurve(); + if (null == draggingFeedbackSize) { + return SizeTransitionWithIntrinsicSize( + sizeFactor: sizeFactor, + axis: direction, + child: FadeTransition( + opacity: sizeFactor, + child: child, + ), + ); + } else { + var transition = SizeTransition( + sizeFactor: sizeFactor, + axis: direction, + child: FadeTransition(opacity: animationController, child: child), + ); + + BoxConstraints contentSizeConstraints = + BoxConstraints.loose(draggingFeedbackSize); + return ConstrainedBox( + constraints: contentSizeConstraints, child: transition); + } + } +} + +Animation withCurve( + AnimationController animationController, Cubic curve) { + return CurvedAnimation( + parent: animationController, + curve: curve, + ); +} + +extension CurveAnimationController on AnimationController { + Animation withLinearCurve() { + return withCurve(Curves.linear); + } + + Animation withCurve(Curve curve) { + return CurvedAnimation( + parent: this, + curve: curve, + ); + } +} + +class ReorderFlexNotifier extends DragTargetMovePlaceholderDelegate { + Map dragTargeEventNotifier = {}; + + void updateDragTargetIndex(int index) { + for (var notifier in dragTargeEventNotifier.values) { + notifier.setDragTargetIndex(index); + } + } + + DragTargetEventNotifier _notifierFromIndex(int dragTargetIndex) { + DragTargetEventNotifier? notifier = dragTargeEventNotifier[dragTargetIndex]; + if (notifier == null) { + final newNotifier = DragTargetEventNotifier(); + dragTargeEventNotifier[dragTargetIndex] = newNotifier; + notifier = newNotifier; + } + + return notifier; + } + + void dispose() { + for (var notifier in dragTargeEventNotifier.values) { + notifier.dispose(); + } + } + + @override + void registerPlaceholder( + int dragTargetIndex, + void Function(int dragTargetIndex) callback, + ) { + _notifierFromIndex(dragTargetIndex).addListener(() { + callback.call(_notifierFromIndex(dragTargetIndex).currentDragTargetIndex); + }); + } + + @override + void unregisterPlaceholder(int dragTargetIndex) { + dragTargeEventNotifier.remove(dragTargetIndex); + } +} + +class DragTargetEventNotifier extends ChangeNotifier { + int currentDragTargetIndex = -1; + + void setDragTargetIndex(int index) { + if (currentDragTargetIndex != index) { + currentDragTargetIndex = index; + notifyListeners(); + } + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_phantom/phantom_controller.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_phantom/phantom_controller.dart new file mode 100644 index 0000000000..ccff83b502 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_phantom/phantom_controller.dart @@ -0,0 +1,353 @@ +import 'package:flutter/material.dart'; +import '../../utils/log.dart'; +import '../board_column/board_column_data.dart'; +import '../reorder_flex/drag_state.dart'; +import '../reorder_flex/drag_target.dart'; +import '../reorder_flex/drag_target_inteceptor.dart'; +import 'phantom_state.dart'; + +abstract class BoardPhantomControllerDelegate { + BoardColumnDataController? controller(String columnId); + + bool removePhantom(String columnId); + + /// Insert the phantom into column + /// + /// * [toColumnId] id of the column + /// * [phantomIndex] the phantom occupies index + void insertPhantom( + String columnId, + int index, + PhantomColumnItem item, + ); + + /// Update the column's phantom index if it exists. + /// [toColumnId] the id of the column + /// [dragTargetIndex] the index of the dragTarget + void updatePhantom(String columnId, int newIndex); + + void swapColumnItem( + String fromColumnId, + int fromColumnIndex, + String toColumnId, + int toColumnIndex, + ); +} + +class BoardPhantomController extends OverlapDragTargetDelegate + with CrossReorderFlexDragTargetDelegate { + PhantomRecord? phantomRecord; + final BoardPhantomControllerDelegate delegate; + final columnsState = ColumnPhantomStateController(); + BoardPhantomController({required this.delegate}); + + bool isFromColumn(String columnId) { + if (phantomRecord != null) { + return phantomRecord!.fromColumnId == columnId; + } else { + return true; + } + } + + void transformIndex(int fromIndex, int toIndex) { + if (phantomRecord == null) { + return; + } + assert(phantomRecord!.fromColumnIndex == fromIndex); + phantomRecord?.updateFromColumnIndex(toIndex); + } + + void columnStartDragging(String columnId) { + columnsState.setColumnIsDragging(columnId, false); + } + + /// Remove the phanton in the column when the column is end dragging. + void columnEndDragging(String columnId) { + columnsState.setColumnIsDragging(columnId, true); + if (phantomRecord == null) return; + + final fromColumnId = phantomRecord!.fromColumnId; + final toColumnId = phantomRecord!.toColumnId; + if (fromColumnId == columnId) { + columnsState.notifyDidRemovePhantom(toColumnId); + } + + if (columnsState.isDragging(fromColumnId) == false) { + return; + } + + delegate.swapColumnItem( + fromColumnId, + phantomRecord!.fromColumnIndex, + toColumnId, + phantomRecord!.toColumnIndex, + ); + + Log.debug("[$BoardPhantomController] did move ${phantomRecord.toString()}"); + phantomRecord = null; + } + + /// Remove the phantom in the column if it contains phantom + void _removePhantom(String columnId) { + if (delegate.removePhantom(columnId)) { + columnsState.notifyDidRemovePhantom(columnId); + columnsState.removeColumnListener(columnId); + } + } + + void _insertPhantom( + String toColumnId, + FlexDragTargetData dragTargetData, + int phantomIndex, + ) { + final phantomContext = PassthroughPhantomContext( + index: phantomIndex, + dragTargetData: dragTargetData, + ); + columnsState.addColumnListener(toColumnId, phantomContext); + + delegate.insertPhantom( + toColumnId, + phantomIndex, + PhantomColumnItem(phantomContext), + ); + + columnsState.notifyDidInsertPhantom(toColumnId); + } + + /// Reset or initial the [PhantomRecord] + /// + /// + /// * [columnId] the id of the column + /// * [dragTargetData] + /// * [dragTargetIndex] + /// + void _resetPhantomRecord( + String columnId, + FlexDragTargetData dragTargetData, + int dragTargetIndex, + ) { + // Log.debug('[$BoardPhantomController] move Column:[${dragTargetData.reorderFlexId}]:${dragTargetData.draggingIndex} ' + // 'to Column:[$columnId]:$index'); + + phantomRecord = PhantomRecord( + toColumnId: columnId, + toColumnIndex: dragTargetIndex, + fromColumnId: dragTargetData.reorderFlexId, + fromColumnIndex: dragTargetData.draggingIndex, + ); + Log.debug('[$BoardPhantomController] will move: $phantomRecord'); + } + + @override + bool acceptNewDragTargetData( + String reorderFlexId, + FlexDragTargetData dragTargetData, + int dragTargetIndex, + ) { + if (phantomRecord == null) { + _resetPhantomRecord(reorderFlexId, dragTargetData, dragTargetIndex); + _insertPhantom(reorderFlexId, dragTargetData, dragTargetIndex); + return false; + } + + final isNewDragTarget = phantomRecord!.toColumnId != reorderFlexId; + if (isNewDragTarget) { + /// Remove the phantom when the dragTarget is moved from one column to another column. + _removePhantom(phantomRecord!.toColumnId); + _resetPhantomRecord(reorderFlexId, dragTargetData, dragTargetIndex); + _insertPhantom(reorderFlexId, dragTargetData, dragTargetIndex); + } + + return isNewDragTarget; + } + + @override + void updateDragTargetData( + String reorderFlexId, + int dragTargetIndex, + ) { + phantomRecord?.updateInsertedIndex(dragTargetIndex); + + assert(phantomRecord != null); + if (phantomRecord!.toColumnId == reorderFlexId) { + /// Update the existing phantom index + delegate.updatePhantom(phantomRecord!.toColumnId, dragTargetIndex); + } + } + + @override + void cancel() { + if (phantomRecord == null) { + return; + } + + /// Remove the phantom when the dragTarge is go back to the original column. + _removePhantom(phantomRecord!.toColumnId); + phantomRecord = null; + } + + @override + void moveTo( + String reorderFlexId, + FlexDragTargetData dragTargetData, + int dragTargetIndex, + ) { + acceptNewDragTargetData( + reorderFlexId, + dragTargetData, + dragTargetIndex, + ); + } + + @override + bool canMoveTo(String dragTargetId) { + return delegate.controller(dragTargetId)?.columnData.items.isEmpty ?? false; + } +} + +/// Use [PhantomRecord] to record where to remove the column item and where to +/// insert the column item. +/// +/// [fromColumnId] the column that phantom comes from +/// [fromColumnIndex] the index of the phantom from the original column +/// [toColumnId] the column that the phantom moves into +/// [toColumnIndex] the index of the phantom moves into the column +/// +class PhantomRecord { + final String fromColumnId; + int fromColumnIndex; + + final String toColumnId; + int toColumnIndex; + + PhantomRecord({ + required this.toColumnId, + required this.toColumnIndex, + required this.fromColumnId, + required this.fromColumnIndex, + }); + + void updateFromColumnIndex(int index) { + if (fromColumnIndex == index) { + return; + } + Log.debug( + '[$PhantomRecord] Update Column:[$fromColumnId] remove position to $index'); + fromColumnIndex = index; + } + + void updateInsertedIndex(int index) { + if (toColumnIndex == index) { + return; + } + + Log.debug( + '[$PhantomRecord] Column:[$toColumnId] update position $toColumnIndex -> $index'); + toColumnIndex = index; + } + + @override + String toString() { + return 'Column:[$fromColumnId]:$fromColumnIndex to Column:[$toColumnId]:$toColumnIndex'; + } +} + +class PhantomColumnItem extends ColumnItem { + final PassthroughPhantomContext phantomContext; + + PhantomColumnItem(PassthroughPhantomContext insertedPhantom) + : phantomContext = insertedPhantom; + + @override + bool get isPhantom => true; + + @override + String get id => phantomContext.itemData.id; + + Size? get feedbackSize => phantomContext.feedbackSize; + + Widget get draggingWidget => phantomContext.draggingWidget == null + ? const SizedBox() + : phantomContext.draggingWidget!; + + @override + String toString() { + return 'phantom:$id'; + } +} + +class PassthroughPhantomContext extends FakeDragTargetEventTrigger + with FakeDragTargetEventData, PassthroughPhantomListener { + @override + int index; + + @override + final FlexDragTargetData dragTargetData; + + @override + Size? get feedbackSize => dragTargetData.feedbackSize; + + Widget? get draggingWidget => dragTargetData.draggingWidget; + + ColumnItem get itemData => dragTargetData.reorderFlexItem as ColumnItem; + + @override + VoidCallback? onInserted; + + @override + VoidCallback? onDragEnded; + + PassthroughPhantomContext({ + required this.index, + required this.dragTargetData, + }); + + @override + void fakeOnDragEnded(VoidCallback callback) { + onDragEnded = callback; + } +} + +class PassthroughPhantomWidget extends PhantomWidget { + final PassthroughPhantomContext passthroughPhantomContext; + + PassthroughPhantomWidget({ + required double opacity, + required this.passthroughPhantomContext, + Key? key, + }) : super( + child: passthroughPhantomContext.draggingWidget, + opacity: opacity, + key: key, + ); +} + +class PhantomDraggableBuilder extends ReorderFlexDraggableTargetBuilder { + PhantomDraggableBuilder(); + @override + Widget? build( + BuildContext context, + Widget child, + DragTargetOnStarted onDragStarted, + DragTargetOnEnded onDragEnded, + DragTargetWillAccpet onWillAccept, + AnimationController insertAnimationController, + AnimationController deleteAnimationController, + ) { + if (child is PassthroughPhantomWidget) { + return FakeDragTarget( + eventTrigger: child.passthroughPhantomContext, + eventData: child.passthroughPhantomContext, + onDragStarted: onDragStarted, + onDragEnded: onDragEnded, + onWillAccept: onWillAccept, + insertAnimationController: insertAnimationController, + deleteAnimationController: deleteAnimationController, + child: child, + ); + } else { + return null; + } + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_phantom/phantom_state.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_phantom/phantom_state.dart new file mode 100644 index 0000000000..d33b53500d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_phantom/phantom_state.dart @@ -0,0 +1,103 @@ +import 'phantom_controller.dart'; +import 'package:flutter/material.dart'; + +class ColumnPhantomStateController { + final _states = {}; + + void setColumnIsDragging(String columnId, bool isDragging) { + _stateWithId(columnId).isDragging = isDragging; + } + + bool isDragging(String columnId) { + return _stateWithId(columnId).isDragging; + } + + void addColumnListener(String columnId, PassthroughPhantomListener listener) { + _stateWithId(columnId).notifier.addListener( + onInserted: (c) => listener.onInserted?.call(), + onDeleted: () => listener.onDragEnded?.call(), + ); + } + + void removeColumnListener(String columnId) { + _stateWithId(columnId).notifier.dispose(); + _states.remove(columnId); + } + + void notifyDidInsertPhantom(String columnId) { + _stateWithId(columnId).notifier.insert(); + } + + void notifyDidRemovePhantom(String columnId) { + _stateWithId(columnId).notifier.remove(); + } + + ColumnState _stateWithId(String columnId) { + var state = _states[columnId]; + if (state == null) { + state = ColumnState(); + _states[columnId] = state; + } + return state; + } +} + +class ColumnState { + bool isDragging = false; + final notifier = PassthroughPhantomNotifier(); +} + +abstract class PassthroughPhantomListener { + VoidCallback? get onInserted; + VoidCallback? get onDragEnded; +} + +class PassthroughPhantomNotifier { + final insertNotifier = PhantomInsertNotifier(); + + final removeNotifier = PhantomDeleteNotifier(); + + void insert() { + insertNotifier.insert(); + } + + void remove() { + removeNotifier.remove(); + } + + void addListener({ + void Function(PassthroughPhantomContext? insertedPhantom)? onInserted, + void Function()? onDeleted, + }) { + if (onInserted != null) { + insertNotifier.addListener(() { + onInserted(insertNotifier.insertedPhantom); + }); + } + + if (onDeleted != null) { + removeNotifier.addListener(() { + onDeleted(); + }); + } + } + + void dispose() { + insertNotifier.dispose(); + removeNotifier.dispose(); + } +} + +class PhantomInsertNotifier extends ChangeNotifier { + PassthroughPhantomContext? insertedPhantom; + + void insert() { + notifyListeners(); + } +} + +class PhantomDeleteNotifier extends ChangeNotifier { + void remove() { + notifyListeners(); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/appflowy_styled_widgets.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/appflowy_styled_widgets.dart new file mode 100644 index 0000000000..b802d15dae --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/appflowy_styled_widgets.dart @@ -0,0 +1,3 @@ +export 'card.dart'; +export 'footer.dart'; +export 'header.dart'; diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/card.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/card.dart new file mode 100644 index 0000000000..323964c75f --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/card.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; + +class AppFlowyColumnItemCard extends StatefulWidget { + final Widget? child; + final Color backgroundColor; + final double cornerRadius; + final EdgeInsets margin; + final BoxConstraints boxConstraints; + + const AppFlowyColumnItemCard({ + this.child, + this.cornerRadius = 0.0, + this.margin = const EdgeInsets.all(4), + this.backgroundColor = Colors.white, + this.boxConstraints = const BoxConstraints(minHeight: 40), + Key? key, + }) : super(key: key); + + @override + State createState() => _AppFlowyColumnItemCardState(); +} + +class _AppFlowyColumnItemCardState extends State { + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(4), + child: Container( + clipBehavior: Clip.hardEdge, + constraints: widget.boxConstraints, + decoration: BoxDecoration( + color: widget.backgroundColor, + borderRadius: BorderRadius.circular(widget.cornerRadius), + ), + child: widget.child, + ), + ); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/footer.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/footer.dart new file mode 100644 index 0000000000..7f5655fe60 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/footer.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; + +typedef OnFooterAddButtonClick = void Function(); + +class AppFlowyColumnFooter extends StatefulWidget { + final double height; + final Widget? icon; + final Widget? title; + final EdgeInsets margin; + final OnFooterAddButtonClick? onAddButtonClick; + + const AppFlowyColumnFooter({ + this.icon, + this.title, + this.margin = EdgeInsets.zero, + required this.height, + this.onAddButtonClick, + Key? key, + }) : super(key: key); + + @override + State createState() => _AppFlowyColumnFooterState(); +} + +class _AppFlowyColumnFooterState extends State { + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: widget.onAddButtonClick, + child: SizedBox( + height: widget.height, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + if (widget.icon != null) widget.icon!, + if (widget.title != null) widget.title!, + ], + ), + ), + ), + ); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/header.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/header.dart new file mode 100644 index 0000000000..fdebc7ef21 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/styled_widgets/header.dart @@ -0,0 +1,74 @@ +import 'package:flutter/material.dart'; + +typedef OnHeaderAddButtonClick = void Function(); +typedef OnHeaderMoreButtonClick = void Function(); + +class AppFlowyColumnHeader extends StatefulWidget { + final double height; + final Widget? icon; + final Widget? title; + final Widget? addIcon; + final Widget? moreIcon; + final EdgeInsets margin; + final OnHeaderAddButtonClick? onAddButtonClick; + final OnHeaderMoreButtonClick? onMoreButtonClick; + + const AppFlowyColumnHeader({ + required this.height, + this.icon, + this.title, + this.addIcon, + this.moreIcon, + this.margin = EdgeInsets.zero, + this.onAddButtonClick, + this.onMoreButtonClick, + Key? key, + }) : super(key: key); + + @override + State createState() => _AppFlowyColumnHeaderState(); +} + +class _AppFlowyColumnHeaderState extends State { + @override + Widget build(BuildContext context) { + List children = []; + + if (widget.icon != null) { + children.add(widget.icon!); + children.add(_hSpace()); + } + + if (widget.title != null) { + children.add(widget.title!); + children.add(_hSpace()); + } + + if (widget.moreIcon != null) { + children.add(const Spacer()); + children.add( + IconButton(onPressed: widget.onMoreButtonClick, icon: widget.moreIcon!), + ); + } + + if (widget.addIcon != null) { + children.add( + IconButton(onPressed: widget.onAddButtonClick, icon: widget.addIcon!), + ); + } + + return SizedBox( + height: widget.height, + child: Padding( + padding: widget.margin, + child: Row( + children: children, + ), + ), + ); + } + + Widget _hSpace() { + return const SizedBox(width: 6); + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/transitions.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/transitions.dart new file mode 100644 index 0000000000..525006af9c --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/transitions.dart @@ -0,0 +1,113 @@ +import 'package:flutter/widgets.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/rendering.dart'; + +class SizeTransitionWithIntrinsicSize extends SingleChildRenderObjectWidget { + /// Creates a size transition with its intrinsic width/height taking [sizeFactor] + /// into account. + /// + /// The [axis] argument defaults to [Axis.vertical]. + /// The [axisAlignment] defaults to 0.0, which centers the child along the + /// main axis during the transition. + SizeTransitionWithIntrinsicSize({ + this.axis = Axis.vertical, + required this.sizeFactor, + double axisAlignment = 0.0, + Widget? child, + Key? key, + }) : super( + key: key, + child: SizeTransition( + axis: axis, + sizeFactor: sizeFactor, + axisAlignment: axisAlignment, + child: child, + )); + + final Axis axis; + final Animation sizeFactor; + + @override + RenderSizeTransitionWithIntrinsicSize createRenderObject( + BuildContext context) { + return RenderSizeTransitionWithIntrinsicSize( + axis: axis, + sizeFactor: sizeFactor, + ); + } + + @override + void updateRenderObject(BuildContext context, + RenderSizeTransitionWithIntrinsicSize renderObject) { + renderObject + ..axis = axis + ..sizeFactor = sizeFactor; + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(DiagnosticsProperty('axis', axis)); + properties + .add(DiagnosticsProperty>('sizeFactor', sizeFactor)); + } +} + +class RenderSizeTransitionWithIntrinsicSize extends RenderProxyBox { + Axis axis; + Animation sizeFactor; + + RenderSizeTransitionWithIntrinsicSize({ + this.axis = Axis.vertical, + required this.sizeFactor, + RenderBox? child, + }) : super(child); + + @override + double computeMinIntrinsicWidth(double height) { + final child = this.child; + if (child != null) { + double childWidth = child.getMinIntrinsicWidth(height); + return axis == Axis.horizontal + ? childWidth * sizeFactor.value + : childWidth; + } + return 0.0; + } + + @override + double computeMaxIntrinsicWidth(double height) { + final child = this.child; + if (child != null) { + double childWidth = child.getMaxIntrinsicWidth(height); + return axis == Axis.horizontal + ? childWidth * sizeFactor.value + : childWidth; + } + return 0.0; + } + + @override + double computeMinIntrinsicHeight(double width) { + final child = this.child; + if (child != null) { + double childHeight = child.getMinIntrinsicHeight(width); + return axis == Axis.vertical + ? childHeight * sizeFactor.value + : childHeight; + } + return 0.0; + } + + @override + double computeMaxIntrinsicHeight(double width) { + final child = this.child; + if (child != null) { + double childHeight = child.getMaxIntrinsicHeight(width); + return axis == Axis.vertical + ? childHeight * sizeFactor.value + : childHeight; + } + return 0.0; + } +} diff --git a/frontend/app_flowy/packages/appflowy_board/pubspec.yaml b/frontend/app_flowy/packages/appflowy_board/pubspec.yaml new file mode 100644 index 0000000000..962fc8be80 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/pubspec.yaml @@ -0,0 +1,57 @@ +name: appflowy_board +description: AppFlowy board implementation. +version: 0.0.4 +homepage: https://github.com/AppFlowy-IO/AppFlowy +repository: https://github.com/AppFlowy-IO/AppFlowy/tree/main/frontend/app_flowy/packages/appflowy_board + +environment: + sdk: ">=2.17.0 <3.0.0" + flutter: ">=1.17.0" + +dependencies: + flutter: + sdk: flutter + equatable: ^2.0.3 + provider: ^6.0.1 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # To add assets to your package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/assets-and-images/#from-packages + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # To add custom fonts to your package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/custom-fonts/#from-packages diff --git a/frontend/app_flowy/packages/appflowy_board/test/appflowy_board_test.dart b/frontend/app_flowy/packages/appflowy_board/test/appflowy_board_test.dart new file mode 100644 index 0000000000..ab73b3a234 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_board/test/appflowy_board_test.dart @@ -0,0 +1 @@ +void main() {} diff --git a/frontend/app_flowy/packages/flowy_editor/example/lib/plugin/image_node_widget.dart b/frontend/app_flowy/packages/flowy_editor/example/lib/plugin/image_node_widget.dart index 417d1ce11c..7a47802163 100644 --- a/frontend/app_flowy/packages/flowy_editor/example/lib/plugin/image_node_widget.dart +++ b/frontend/app_flowy/packages/flowy_editor/example/lib/plugin/image_node_widget.dart @@ -55,26 +55,22 @@ class _ImageNodeWidgetState extends State with Selectable { @override Position end() { - // TODO: implement end - throw UnimplementedError(); + return Position(path: node.path, offset: 0); } @override Position start() { - // TODO: implement start - throw UnimplementedError(); + return Position(path: node.path, offset: 0); } @override List getRectsInSelection(Selection selection) { - // TODO: implement getRectsInSelection - throw UnimplementedError(); + return []; } @override Selection getSelectionInRange(Offset start, Offset end) { - // TODO: implement getSelectionInRange - throw UnimplementedError(); + return Selection.collapsed(Position(path: node.path, offset: 0)); } @override @@ -82,12 +78,6 @@ class _ImageNodeWidgetState extends State with Selectable { throw UnimplementedError(); } - @override - Rect getCursorRectInPosition(Position position) { - // TODO: implement getCursorRectInPosition - throw UnimplementedError(); - } - @override Position getPositionInOffset(Offset start) { return Position(path: node.path, offset: 0); diff --git a/frontend/app_flowy/packages/flowy_editor/example/lib/plugin/youtube_link_node_widget.dart b/frontend/app_flowy/packages/flowy_editor/example/lib/plugin/youtube_link_node_widget.dart index 10787db2a7..fd79077912 100644 --- a/frontend/app_flowy/packages/flowy_editor/example/lib/plugin/youtube_link_node_widget.dart +++ b/frontend/app_flowy/packages/flowy_editor/example/lib/plugin/youtube_link_node_widget.dart @@ -32,7 +32,8 @@ class LinkNodeWidget extends StatefulWidget { State createState() => _YouTubeLinkNodeWidgetState(); } -class _YouTubeLinkNodeWidgetState extends State with Selectable { +class _YouTubeLinkNodeWidgetState extends State + with Selectable { Node get node => widget.node; EditorState get editorState => widget.editorState; String get src => widget.node.attributes['youtube_link'] as String; @@ -66,12 +67,6 @@ class _YouTubeLinkNodeWidgetState extends State with Selectable throw UnimplementedError(); } - @override - Rect getCursorRectInPosition(Position position) { - // TODO: implement getCursorRectInPosition - throw UnimplementedError(); - } - @override Position getPositionInOffset(Offset start) { // TODO: implement getPositionInOffset @@ -85,16 +80,16 @@ class _YouTubeLinkNodeWidgetState extends State with Selectable late final PodPlayerController controller; -@override + @override void initState() { controller = PodPlayerController( playVideoFrom: PlayVideoFrom.network( - src, + src, ), )..initialise(); - super.initState(); + super.initState(); } - + Widget _build(BuildContext context) { return Column( children: [ diff --git a/frontend/app_flowy/packages/flowy_editor/lib/document/node.dart b/frontend/app_flowy/packages/flowy_editor/lib/document/node.dart index c3f75c5c9c..21883362b1 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/document/node.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/document/node.dart @@ -183,7 +183,7 @@ class TextNode extends Node { super(children: children ?? LinkedList(), attributes: attributes ?? {}); TextNode.empty() - : _delta = Delta([TextInsert(' ')]), + : _delta = Delta([TextInsert('')]), super( type: 'text', children: LinkedList(), diff --git a/frontend/app_flowy/packages/flowy_editor/lib/document/node_iterator.dart b/frontend/app_flowy/packages/flowy_editor/lib/document/node_iterator.dart index 1f321e937a..bafe106f27 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/document/node_iterator.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/document/node_iterator.dart @@ -43,7 +43,7 @@ class NodeIterator implements Iterator { if (nextOfParent == null) { _currentNode = null; } else { - _currentNode = _findLeadingChild(node); + _currentNode = _findLeadingChild(nextOfParent); } } diff --git a/frontend/app_flowy/packages/flowy_editor/lib/infra/html_converter.dart b/frontend/app_flowy/packages/flowy_editor/lib/infra/html_converter.dart index 5a1a7912da..708e47cb85 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/infra/html_converter.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/infra/html_converter.dart @@ -4,6 +4,7 @@ import 'package:flowy_editor/document/attributes.dart'; import 'package:flowy_editor/document/node.dart'; import 'package:flowy_editor/document/text_delta.dart'; import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; import 'package:html/parser.dart' show parse; import 'package:html/dom.dart' as html; @@ -205,20 +206,58 @@ class HTMLConverter { } } -String deltaToHtml(Delta delta) { - var result = "

"; +html.Element deltaToHtml(Delta delta, [String? subType]) { + final childNodes = []; + String tagName = tagParagraph; + + if (subType == "bulleted-list") { + tagName = tagList; + } for (final op in delta.operations) { if (op is TextInsert) { final attributes = op.attributes; if (attributes != null && attributes["bold"] == true) { - result += '${op.content}'; + final strong = html.Element.tag("strong"); + strong.append(html.Text(op.content)); + childNodes.add(strong); } else { - result += op.content; + childNodes.add(html.Text(op.content)); } } } - result += "

"; - return result; + if (tagName != tagParagraph) { + final p = html.Element.tag(tagParagraph); + for (final node in childNodes) { + p.append(node); + } + final result = html.Element.tag("li"); + result.append(p); + return result; + } else { + final p = html.Element.tag(tagName); + for (final node in childNodes) { + p.append(node); + } + return p; + } +} + +String stringify(html.Node node) { + if (node is html.Element) { + String result = '<${node.localName}>'; + + for (final node in node.nodes) { + result += stringify(node); + } + + return result += ''; + } + + if (node is html.Text) { + return node.text; + } + + return ""; } diff --git a/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/checkbox_text.dart b/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/checkbox_text.dart index 065ae8b595..317d1a6bdf 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/checkbox_text.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/checkbox_text.dart @@ -77,7 +77,7 @@ class _CheckboxNodeWidgetState extends State debugPrint('[Checkbox] onTap...'); TransactionBuilder(widget.editorState) ..updateNode(widget.textNode, { - 'checkbox': !check, + StyleKey.checkbox: !check, }) ..commit(); }, @@ -110,11 +110,17 @@ class _CheckboxNodeWidgetState extends State .map( (child) => widget.editorState.service.renderPluginService .buildPluginWidget( - NodeWidgetContext( - context: context, - node: child, - editorState: widget.editorState, - ), + child is TextNode + ? NodeWidgetContext( + context: context, + node: child, + editorState: widget.editorState, + ) + : NodeWidgetContext( + context: context, + node: child, + editorState: widget.editorState, + ), ), ) .toList(), diff --git a/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/default_selectable.dart b/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/default_selectable.dart index 21cc5108f3..e218fdcaf6 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/default_selectable.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/default_selectable.dart @@ -11,8 +11,8 @@ mixin DefaultSelectable { Position getPositionInOffset(Offset start) => forward.getPositionInOffset(start); - Rect getCursorRectInPosition(Position position) => - forward.getCursorRectInPosition(position).shift(baseOffset); + Rect? getCursorRectInPosition(Position position) => + forward.getCursorRectInPosition(position)?.shift(baseOffset); List getRectsInSelection(Selection selection) => forward .getRectsInSelection(selection) diff --git a/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/flowy_rich_text.dart b/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/flowy_rich_text.dart index dbf4e5f63c..32715d8556 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/flowy_rich_text.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/flowy_rich_text.dart @@ -76,7 +76,7 @@ class _FlowyRichTextState extends State with Selectable { path: widget.textNode.path, offset: widget.textNode.toRawString().length); @override - Rect getCursorRectInPosition(Position position) { + Rect? getCursorRectInPosition(Position position) { final textPosition = TextPosition(offset: position.offset); final cursorOffset = _renderParagraph.getOffsetForCaret(textPosition, Rect.zero); @@ -138,11 +138,16 @@ class _FlowyRichTextState extends State with Selectable { } Widget _buildRichText(BuildContext context) { - return Stack( - children: [ - _buildPlaceholderText(context), - _buildSingleRichText(context), - ], + return MouseRegion( + cursor: SystemMouseCursors.text, + child: widget.textNode.toRawString().isEmpty + ? Stack( + children: [ + _buildPlaceholderText(context), + _buildSingleRichText(context), + ], + ) + : _buildSingleRichText(context), ); } diff --git a/frontend/app_flowy/packages/flowy_editor/lib/render/selection/selectable.dart b/frontend/app_flowy/packages/flowy_editor/lib/render/selection/selectable.dart index bc32706aa0..58377dcc02 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/render/selection/selectable.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/render/selection/selectable.dart @@ -25,7 +25,9 @@ mixin Selectable on State { return null; } - Rect getCursorRectInPosition(Position position); + Rect? getCursorRectInPosition(Position position) { + return null; + } Offset localToGlobal(Offset offset); diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/editor_service.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/editor_service.dart index 5c088b46d6..78f7bb76fa 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/editor_service.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/editor_service.dart @@ -13,9 +13,10 @@ import 'package:flowy_editor/service/internal_key_event_handlers/arrow_keys_hand import 'package:flowy_editor/service/internal_key_event_handlers/copy_paste_handler.dart'; import 'package:flowy_editor/service/internal_key_event_handlers/delete_nodes_handler.dart'; import 'package:flowy_editor/service/internal_key_event_handlers/delete_text_handler.dart'; -import 'package:flowy_editor/service/internal_key_event_handlers/enter_in_edge_of_text_node_handler.dart'; +import 'package:flowy_editor/service/internal_key_event_handlers/enter_without_shift_in_text_node_handler.dart'; import 'package:flowy_editor/service/internal_key_event_handlers/slash_handler.dart'; import 'package:flowy_editor/service/internal_key_event_handlers/update_text_style_by_command_x_handler.dart'; +import 'package:flowy_editor/service/internal_key_event_handlers/whitespace_handler.dart'; import 'package:flowy_editor/service/keyboard_service.dart'; import 'package:flowy_editor/service/render_plugin_service.dart'; import 'package:flowy_editor/service/scroll_service.dart'; @@ -38,8 +39,9 @@ List defaultKeyEventHandler = [ flowyDeleteNodesHandler, arrowKeysHandler, copyPasteKeysHandler, - enterInEdgeOfTextNodeHandler, + enterWithoutShiftInTextNodesHandler, updateTextStyleByCommandXHandler, + whiteSpaceHandler, ]; class FlowyEditor extends StatefulWidget { diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/input_service.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/input_service.dart index 9d6e0f7470..824fc07230 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/input_service.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/input_service.dart @@ -2,8 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flowy_editor/document/node.dart'; -import 'package:flowy_editor/document/path.dart'; -import 'package:flowy_editor/document/position.dart'; import 'package:flowy_editor/document/selection.dart'; import 'package:flowy_editor/editor_state.dart'; import 'package:flowy_editor/extensions/node_extensions.dart'; @@ -83,22 +81,29 @@ class _FlowyInputState extends State void apply(List deltas) { // TODO: implement the detail for (final delta in deltas) { - if (delta is TextEditingDeltaInsertion) { - if (_composingTextRange != null) { - _composingTextRange = TextRange( - start: _composingTextRange!.start, - end: delta.composing.end, - ); - } else { - _composingTextRange = delta.composing; - } + _updateComposing(delta); + if (delta is TextEditingDeltaInsertion) { _applyInsert(delta); } else if (delta is TextEditingDeltaDeletion) { + _applyDelete(delta); } else if (delta is TextEditingDeltaReplacement) { _applyReplacement(delta); - } else if (delta is TextEditingDeltaNonTextUpdate) { - _composingTextRange = null; + } else if (delta is TextEditingDeltaNonTextUpdate) {} + } + } + + void _updateComposing(TextEditingDelta delta) { + if (delta is! TextEditingDeltaNonTextUpdate) { + if (_composingTextRange != null && + delta.composing.end != -1 && + _composingTextRange!.start != -1) { + _composingTextRange = TextRange( + start: _composingTextRange!.start, + end: delta.composing.end, + ); + } else { + _composingTextRange = delta.composing; } } } @@ -123,6 +128,23 @@ class _FlowyInputState extends State } } + void _applyDelete(TextEditingDeltaDeletion delta) { + final selectionService = _editorState.service.selectionService; + final currentSelection = selectionService.currentSelection.value; + if (currentSelection == null) { + return; + } + if (currentSelection.isSingle) { + final textNode = selectionService.currentSelectedNodes.first as TextNode; + final length = delta.deletedRange.end - delta.deletedRange.start; + TransactionBuilder(_editorState) + ..deleteText(textNode, delta.deletedRange.start, length) + ..commit(); + } else { + // TODO: implement + } + } + void _applyReplacement(TextEditingDeltaReplacement delta) { final selectionService = _editorState.service.selectionService; final currentSelection = selectionService.currentSelection.value; @@ -246,9 +268,11 @@ class _FlowyInputState extends State final size = renderBox.size; final transform = renderBox.getTransformTo(null); final rect = selectable.getCursorRectInPosition(selection.end); - _textInputConnection - ?..setEditableSizeAndTransform(size, transform) - ..setCaretRect(rect); + if (rect != null) { + _textInputConnection + ?..setEditableSizeAndTransform(size, transform) + ..setCaretRect(rect); + } } } } diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/copy_paste_handler.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/copy_paste_handler.dart index 8cab09b293..d3eeb073b9 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/copy_paste_handler.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/copy_paste_handler.dart @@ -1,3 +1,4 @@ +import 'package:html/dom.dart' as html; import 'package:flowy_editor/flowy_editor.dart'; import 'package:flowy_editor/service/keyboard_service.dart'; import 'package:flowy_editor/infra/html_converter.dart'; @@ -6,6 +7,50 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:rich_clipboard/rich_clipboard.dart'; +class _HTMLNormalizer { + final List nodes; + html.Element? _pendingList; + + _HTMLNormalizer(this.nodes); + + List normalize() { + final result = []; + + for (final item in nodes) { + if (item is Text) { + result.add(item); + continue; + } + + if (item is html.Element) { + if (item.localName == "li") { + if (_pendingList != null) { + _pendingList!.append(item); + } else { + final ulItem = html.Element.tag("ul"); + ulItem.append(item); + + _pendingList = ulItem; + } + } else { + _pushList(result); + result.add(item); + } + } + } + + return result; + } + + _pushList(List result) { + if (_pendingList == null) { + return; + } + result.add(_pendingList!); + _pendingList = null; + } +} + _handleCopy(EditorState editorState) async { final selection = editorState.cursorSelection; if (selection == null || selection.isCollapsed) { @@ -18,7 +63,7 @@ _handleCopy(EditorState editorState) async { final delta = textNode.delta.slice(selection.start.offset, selection.end.offset); - final htmlString = deltaToHtml(delta); + final htmlString = stringify(deltaToHtml(delta)); debugPrint('copy html: $htmlString'); RichClipboard.setData(RichClipboardData(html: htmlString)); } else { @@ -31,27 +76,30 @@ _handleCopy(EditorState editorState) async { final endNode = editorState.document.nodeAtPath(selection.end.path)!; final traverser = NodeIterator(editorState.document, beginNode, endNode); - var copyString = ""; + final nodes = []; while (traverser.moveNext()) { final node = traverser.current; if (node.type == "text") { final textNode = node as TextNode; + String? subType = textNode.attributes["subtype"]; if (node == beginNode) { - final htmlString = - deltaToHtml(textNode.delta.slice(selection.start.offset)); - copyString += htmlString; + final htmlElement = + deltaToHtml(textNode.delta.slice(selection.start.offset), subType); + nodes.add(htmlElement); } else if (node == endNode) { - final htmlString = - deltaToHtml(textNode.delta.slice(0, selection.end.offset)); - copyString += htmlString; + final htmlElement = + deltaToHtml(textNode.delta.slice(0, selection.end.offset), subType); + nodes.add(htmlElement); } else { - final htmlString = deltaToHtml(textNode.delta); - copyString += htmlString; + final htmlElement = deltaToHtml(textNode.delta, subType); + nodes.add(htmlElement); } } // TODO: handle image and other blocks - } + + final copyString = _HTMLNormalizer(nodes).normalize().fold( + "", ((previousValue, element) => previousValue + stringify(element))); debugPrint('copy html: $copyString'); RichClipboard.setData(RichClipboardData(html: copyString)); } diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/delete_text_handler.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/delete_text_handler.dart index 5f59f4266d..e44f0002a0 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/delete_text_handler.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/delete_text_handler.dart @@ -1,8 +1,9 @@ -import 'package:flowy_editor/flowy_editor.dart'; -import 'package:flowy_editor/service/keyboard_service.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flowy_editor/flowy_editor.dart'; +import 'package:flowy_editor/service/keyboard_service.dart'; + // Handle delete text. FlowyKeyEventHandler deleteTextHandler = (editorState, event) { if (event.logicalKey != LogicalKeyboardKey.backspace) { @@ -28,9 +29,16 @@ FlowyKeyEventHandler deleteTextHandler = (editorState, event) { if (index < 0) { // 1. style if (textNode.subtype != null) { - transactionBuilder.updateNode(textNode, { - 'subtype': null, - }); + transactionBuilder + ..updateNode(textNode, { + 'subtype': null, + }) + ..afterSelection = Selection.collapsed( + Position( + path: textNode.path, + offset: 0, + ), + ); } else { // 2. non-style // find previous text node. @@ -38,8 +46,14 @@ FlowyKeyEventHandler deleteTextHandler = (editorState, event) { if (textNode.previous is TextNode) { final previous = textNode.previous as TextNode; transactionBuilder + ..mergeText(previous, textNode) ..deleteNode(textNode) - ..mergeText(previous, textNode); + ..afterSelection = Selection.collapsed( + Position( + path: previous.path, + offset: previous.toRawString().length, + ), + ); break; } } diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/enter_in_edge_of_text_node_handler.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/enter_in_edge_of_text_node_handler.dart deleted file mode 100644 index 9ea754e162..0000000000 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/enter_in_edge_of_text_node_handler.dart +++ /dev/null @@ -1,94 +0,0 @@ -import 'dart:collection'; - -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; - -import 'package:flowy_editor/document/node.dart'; -import 'package:flowy_editor/document/position.dart'; -import 'package:flowy_editor/document/selection.dart'; -import 'package:flowy_editor/document/text_delta.dart'; -import 'package:flowy_editor/extensions/node_extensions.dart'; -import 'package:flowy_editor/extensions/path_extensions.dart'; -import 'package:flowy_editor/operation/transaction_builder.dart'; -import 'package:flowy_editor/render/rich_text/rich_text_style.dart'; -import 'package:flowy_editor/service/keyboard_service.dart'; - -FlowyKeyEventHandler enterInEdgeOfTextNodeHandler = (editorState, event) { - if (event.logicalKey != LogicalKeyboardKey.enter) { - return KeyEventResult.ignored; - } - - final nodes = editorState.service.selectionService.currentSelectedNodes; - final selection = editorState.service.selectionService.currentSelection.value; - if (selection == null || - nodes.length != 1 || - nodes.first is! TextNode || - !selection.isCollapsed) { - return KeyEventResult.ignored; - } - - final textNode = nodes.first as TextNode; - if (textNode.selectable!.end() == selection.end) { - if (textNode.subtype != null && textNode.delta.length == 0) { - TransactionBuilder(editorState) - ..deleteNode(textNode) - ..insertNode( - textNode.path, - textNode.copyWith( - children: LinkedList(), - delta: Delta([TextInsert('')]), - attributes: {}, - ), - ) - ..afterSelection = Selection.collapsed( - Position( - path: textNode.path, - offset: 0, - ), - ) - ..commit(); - } else { - final needCopyAttributes = StyleKey.globalStyleKeys - .where((key) => key != StyleKey.heading) - .contains(textNode.subtype); - TransactionBuilder(editorState) - ..insertNode( - textNode.path.next, - textNode.copyWith( - children: LinkedList(), - delta: Delta([TextInsert('')]), - attributes: needCopyAttributes ? textNode.attributes : {}, - ), - ) - ..afterSelection = Selection.collapsed( - Position( - path: textNode.path.next, - offset: 0, - ), - ) - ..commit(); - } - - return KeyEventResult.handled; - } else if (textNode.selectable!.start() == selection.start) { - TransactionBuilder(editorState) - ..insertNode( - textNode.path, - textNode.copyWith( - children: LinkedList(), - delta: Delta([TextInsert('')]), - attributes: {}, - ), - ) - ..afterSelection = Selection.collapsed( - Position( - path: textNode.path.next, - offset: 0, - ), - ) - ..commit(); - return KeyEventResult.handled; - } - - return KeyEventResult.ignored; -}; diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/enter_without_shift_in_text_node_handler.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/enter_without_shift_in_text_node_handler.dart new file mode 100644 index 0000000000..cf71830386 --- /dev/null +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/enter_without_shift_in_text_node_handler.dart @@ -0,0 +1,106 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +import 'package:flowy_editor/document/node.dart'; +import 'package:flowy_editor/document/position.dart'; +import 'package:flowy_editor/document/selection.dart'; +import 'package:flowy_editor/extensions/path_extensions.dart'; +import 'package:flowy_editor/operation/transaction_builder.dart'; +import 'package:flowy_editor/render/rich_text/rich_text_style.dart'; +import 'package:flowy_editor/service/keyboard_service.dart'; + +/// Handle some cases where enter is pressed and shift is not pressed. +/// +/// 1. Multiple selection and the selected nodes are [TextNode] +/// 1.1 delete the nodes expect for the first and the last, +/// and delete the text in the first and the last node by case. +/// 2. Single selection and the selected node is [TextNode] +/// 2.1 split the node into two nodes with style +/// 2.2 or insert a empty text node before. +FlowyKeyEventHandler enterWithoutShiftInTextNodesHandler = + (editorState, event) { + if (event.logicalKey != LogicalKeyboardKey.enter || event.isShiftPressed) { + return KeyEventResult.ignored; + } + + final nodes = editorState.service.selectionService.currentSelectedNodes; + final textNodes = nodes.whereType().toList(growable: false); + final selection = editorState.service.selectionService.currentSelection.value; + + if (selection == null || nodes.length != textNodes.length) { + return KeyEventResult.ignored; + } + + // Multiple selection + if (!selection.isSingle) { + final length = textNodes.length; + final List subTextNodes = + length >= 3 ? textNodes.sublist(1, textNodes.length - 2) : []; + final afterSelection = Selection.collapsed( + Position(path: textNodes.first.path.next, offset: 0), + ); + TransactionBuilder(editorState) + ..deleteText( + textNodes.first, + selection.start.offset, + textNodes.first.toRawString().length, + ) + ..deleteNodes(subTextNodes) + ..deleteText( + textNodes.last, + 0, + selection.end.offset, + ) + ..afterSelection = afterSelection + ..commit(); + return KeyEventResult.handled; + } + + // Single selection and the selected node is [TextNode] + if (textNodes.length != 1) { + return KeyEventResult.ignored; + } + + final textNode = textNodes.first; + + // If selection is collapsed and position.start.offset == 0, + // insert a empty text node before. + if (selection.isCollapsed && selection.start.offset == 0) { + final afterSelection = Selection.collapsed( + Position(path: textNode.path.next, offset: 0), + ); + TransactionBuilder(editorState) + ..insertNode( + textNode.path, + TextNode.empty(), + ) + ..afterSelection = afterSelection + ..commit(); + return KeyEventResult.handled; + } + + // Otherwise, + // split the node into two nodes with style + final needCopyAttributes = StyleKey.globalStyleKeys + .where((key) => key != StyleKey.heading) + .contains(textNode.subtype); + final afterSelection = Selection.collapsed( + Position(path: textNode.path.next, offset: 0), + ); + TransactionBuilder(editorState) + ..insertNode( + textNode.path.next, + textNode.copyWith( + attributes: needCopyAttributes ? textNode.attributes : {}, + delta: textNode.delta.slice(selection.end.offset), + ), + ) + ..deleteText( + textNode, + selection.start.offset, + textNode.toRawString().length - selection.start.offset, + ) + ..afterSelection = afterSelection + ..commit(); + return KeyEventResult.handled; +}; diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/slash_handler.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/slash_handler.dart index 68bcdca7a6..4d77ef1ebc 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/slash_handler.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/slash_handler.dart @@ -71,17 +71,26 @@ FlowyKeyEventHandler slashShortcutHandler = (editorState, event) { } final rect = selectable.getCursorRectInPosition(selection.start); - final offset = selectable.localToGlobal(rect.topLeft); - if (!selection.isCollapsed) { - TransactionBuilder(editorState) - ..deleteText( - textNode, - selection.start.offset, - selection.end.offset - selection.start.offset, - ) - ..commit(); + if (rect == null) { + return KeyEventResult.ignored; } + final offset = selectable.localToGlobal(rect.topLeft); + TransactionBuilder(editorState) + ..replaceText(textNode, selection.start.offset, + selection.end.offset - selection.start.offset, '/') + ..commit(); + + _editorState = editorState; + WidgetsBinding.instance.addPostFrameCallback((_) { + showPopupList(context, editorState, offset); + }); + + return KeyEventResult.handled; +}; + +void showPopupList( + BuildContext context, EditorState editorState, Offset offset) { _popupListOverlay?.remove(); _popupListOverlay = OverlayEntry( builder: (context) => Positioned( @@ -97,20 +106,22 @@ FlowyKeyEventHandler slashShortcutHandler = (editorState, event) { Overlay.of(context)?.insert(_popupListOverlay!); editorState.service.selectionService.currentSelection - .removeListener(clearPopupListOverlay); + .removeListener(clearPopupList); editorState.service.selectionService.currentSelection - .addListener(clearPopupListOverlay); - // editorState.service.keyboardService?.disable(); - _editorState = editorState; + .addListener(clearPopupList); - return KeyEventResult.handled; -}; + editorState.service.scrollService?.disable(); +} -void clearPopupListOverlay() { +void clearPopupList() { + if (_popupListOverlay == null || _editorState == null) { + return; + } _popupListOverlay?.remove(); _popupListOverlay = null; _editorState?.service.keyboardService?.enable(); + _editorState?.service.scrollService?.enable(); _editorState = null; } @@ -209,13 +220,16 @@ class _PopupListWidgetState extends State { if (event.logicalKey == LogicalKeyboardKey.enter) { if (0 <= selectedIndex && selectedIndex < widget.items.length) { + _deleteSlash(); widget.items[selectedIndex].handler(widget.editorState); return KeyEventResult.handled; } - } - - if (event.logicalKey == LogicalKeyboardKey.escape) { - clearPopupListOverlay(); + } else if (event.logicalKey == LogicalKeyboardKey.escape) { + clearPopupList(); + return KeyEventResult.handled; + } else if (event.logicalKey == LogicalKeyboardKey.backspace) { + clearPopupList(); + _deleteSlash(); return KeyEventResult.handled; } @@ -237,6 +251,22 @@ class _PopupListWidgetState extends State { } return KeyEventResult.ignored; } + + void _deleteSlash() { + final selection = + widget.editorState.service.selectionService.currentSelection.value; + final nodes = + widget.editorState.service.selectionService.currentSelectedNodes; + if (selection != null && nodes.length == 1) { + TransactionBuilder(widget.editorState) + ..deleteText( + nodes.first as TextNode, + selection.start.offset - 1, + 1, + ) + ..commit(); + } + } } class _PopupListItemWidget extends StatelessWidget { diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/whitespace_handler.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/whitespace_handler.dart new file mode 100644 index 0000000000..b3642cc1a1 --- /dev/null +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/whitespace_handler.dart @@ -0,0 +1,131 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +import 'package:flowy_editor/document/node.dart'; +import 'package:flowy_editor/document/position.dart'; +import 'package:flowy_editor/document/selection.dart'; +import 'package:flowy_editor/editor_state.dart'; +import 'package:flowy_editor/operation/transaction_builder.dart'; +import 'package:flowy_editor/render/rich_text/rich_text_style.dart'; +import 'package:flowy_editor/service/keyboard_service.dart'; + +const _bulletedListSymbols = ['*', '-']; +const _checkboxListSymbols = ['[x]', '-[x]']; +const _unCheckboxListSymbols = ['[]', '-[]']; + +FlowyKeyEventHandler whiteSpaceHandler = (editorState, event) { + if (event.logicalKey != LogicalKeyboardKey.space) { + return KeyEventResult.ignored; + } + + /// Process markdown input style. + /// + /// like, #, *, -, 1., -[], + + final selection = editorState.service.selectionService.currentSelection.value; + if (selection == null || !selection.isCollapsed) { + return KeyEventResult.ignored; + } + + final textNodes = editorState.service.selectionService.currentSelectedNodes + .whereType(); + if (textNodes.length != 1) { + return KeyEventResult.ignored; + } + + final textNode = textNodes.first; + final text = textNode.toRawString(); + if ((_checkboxListSymbols + _unCheckboxListSymbols).any(text.startsWith)) { + return _toCheckboxList(editorState, textNode); + } else if (_bulletedListSymbols.any(text.startsWith)) { + return _toBulletedList(editorState, textNode); + } else if (_countOfSign(text) != 0) { + return _toHeadingStyle(editorState, textNode); + } + + return KeyEventResult.ignored; +}; + +KeyEventResult _toBulletedList(EditorState editorState, TextNode textNode) { + if (textNode.subtype == StyleKey.bulletedList) { + return KeyEventResult.ignored; + } + TransactionBuilder(editorState) + ..deleteText(textNode, 0, 1) + ..updateNode(textNode, { + StyleKey.subtype: StyleKey.bulletedList, + }) + ..afterSelection = Selection.collapsed( + Position( + path: textNode.path, + offset: 0, + ), + ) + ..commit(); + return KeyEventResult.handled; +} + +KeyEventResult _toCheckboxList(EditorState editorState, TextNode textNode) { + if (textNode.subtype == StyleKey.checkbox) { + return KeyEventResult.ignored; + } + final String symbol; + bool check = false; + final symbols = List.from(_checkboxListSymbols) + ..retainWhere(textNode.toRawString().startsWith); + if (symbols.isNotEmpty) { + symbol = symbols.first; + check = true; + } else { + symbol = (List.from(_unCheckboxListSymbols) + ..retainWhere(textNode.toRawString().startsWith)) + .first; + check = false; + } + + TransactionBuilder(editorState) + ..deleteText(textNode, 0, symbol.length) + ..updateNode(textNode, { + StyleKey.subtype: StyleKey.checkbox, + StyleKey.checkbox: check, + }) + ..afterSelection = Selection.collapsed( + Position( + path: textNode.path, + offset: 0, + ), + ) + ..commit(); + return KeyEventResult.handled; +} + +KeyEventResult _toHeadingStyle(EditorState editorState, TextNode textNode) { + final x = _countOfSign(textNode.toRawString()); + final hX = 'h$x'; + if (textNode.attributes.heading == hX) { + return KeyEventResult.ignored; + } + TransactionBuilder(editorState) + ..deleteText(textNode, 0, x) + ..updateNode(textNode, { + StyleKey.subtype: StyleKey.heading, + StyleKey.heading: hX, + }) + ..afterSelection = Selection.collapsed( + Position( + path: textNode.path, + offset: 0, + ), + ) + ..commit(); + return KeyEventResult.handled; +} + +int _countOfSign(String text) { + for (var i = 6; i >= 0; i--) { + if (text.startsWith('#' * i)) { + return i; + } + } + return 0; +} diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/scroll_service.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/scroll_service.dart index c3a0a6fedc..af48a78c49 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/scroll_service.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/scroll_service.dart @@ -6,7 +6,8 @@ mixin FlowyScrollService on State { void scrollTo(double dy); - RenderObject? scrollRenderObject(); + void enable(); + void disable(); } class FlowyScroll extends StatefulWidget { @@ -25,6 +26,8 @@ class _FlowyScrollState extends State with FlowyScrollService { final _scrollController = ScrollController(); final _scrollViewKey = GlobalKey(); + bool _scrollEnabled = true; + @override double get dy => _scrollController.position.pixels; @@ -51,15 +54,22 @@ class _FlowyScrollState extends State with FlowyScrollService { ); } + @override + void disable() { + _scrollEnabled = false; + debugPrint('[scroll] $_scrollEnabled'); + } + + @override + void enable() { + _scrollEnabled = true; + debugPrint('[scroll] $_scrollEnabled'); + } + void _onPointerSignal(PointerSignalEvent event) { - if (event is PointerScrollEvent) { + if (event is PointerScrollEvent && _scrollEnabled) { final dy = (_scrollController.position.pixels + event.scrollDelta.dy); scrollTo(dy); } } - - @override - RenderObject? scrollRenderObject() { - return _scrollViewKey.currentContext?.findRenderObject(); - } } diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart index 8baa54c26f..82088561cb 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart @@ -160,6 +160,7 @@ class _FlowySelectionState extends State onPanEnd: _onPanEnd, onTapDown: _onTapDown, onDoubleTapDown: _onDoubleTapDown, + onTripleTapDown: _onTripleTapDown, child: widget.child, ); } @@ -252,6 +253,25 @@ class _FlowySelectionState extends State .updateCursorSelection(selectable.getWorldBoundaryInOffset(offset)); } + void _onTripleTapDown(TapDownDetails details) { + final offset = details.globalPosition; + final node = getNodeInOffset(offset); + if (node == null) { + editorState.updateCursorSelection(null); + return; + } + Selection selection; + if (node is TextNode) { + final textLen = node.delta.length; + selection = Selection( + start: Position(path: node.path, offset: 0), + end: Position(path: node.path, offset: textLen)); + } else { + selection = Selection.collapsed(Position(path: node.path, offset: 0)); + } + editorState.updateCursorSelection(selection); + } + void _onTapDown(TapDownDetails details) { // clear old state. panStartOffset = null; @@ -267,6 +287,7 @@ class _FlowySelectionState extends State editorState.updateCursorSelection(selection); editorState.service.keyboardService?.enable(); + editorState.service.scrollService?.enable(); } @override @@ -313,13 +334,9 @@ class _FlowySelectionState extends State panStartOffsetWithScrollDyGap.translate(0, panStartScrollDy! - dy); } - final sortedNodes = - editorState.document.root.children.toList(growable: false); - final first = _lowerBound( - sortedNodes, panStartOffsetWithScrollDyGap, 0, sortedNodes.length) - .selectable; - final last = _upperBound(sortedNodes, panEndOffset!, 0, sortedNodes.length) - .selectable; + final first = + _lowerBoundInDocument(panStartOffsetWithScrollDyGap).selectable; + final last = _upperBoundInDocument(panEndOffset!).selectable; // compute the selection in range. if (first != null && last != null) { @@ -518,19 +535,20 @@ class _FlowySelectionState extends State Node _lowerBoundInDocument(Offset offset) { final sortedNodes = editorState.document.root.children.toList(growable: false); - return _lowerBound(sortedNodes, offset, 0, sortedNodes.length); + return _lowerBound(sortedNodes, offset, 0, sortedNodes.length - 1); } Node _upperBoundInDocument(Offset offset) { final sortedNodes = editorState.document.root.children.toList(growable: false); - return _upperBound(sortedNodes, offset, 0, sortedNodes.length); + return _upperBound(sortedNodes, offset, 0, sortedNodes.length - 1); } /// TODO: Supports multi-level nesting, /// currently only single-level nesting is supported // find the first node's rect.bottom <= offset.dy Node _lowerBound(List sortedNodes, Offset offset, int start, int end) { + assert(start >= 0 && end < sortedNodes.length); var min = start; var max = end; while (min <= max) { @@ -541,7 +559,12 @@ class _FlowySelectionState extends State max = mid - 1; } } - return sortedNodes[min]; + final node = sortedNodes[min]; + if (node.children.isNotEmpty && node.children.first.rect.top <= offset.dy) { + final children = node.children.toList(growable: false); + return _lowerBound(children, offset, 0, children.length - 1); + } + return node; } /// TODO: Supports multi-level nesting, @@ -553,6 +576,7 @@ class _FlowySelectionState extends State int start, int end, ) { + assert(start >= 0 && end < sortedNodes.length); var min = start; var max = end; while (min <= max) { @@ -563,7 +587,12 @@ class _FlowySelectionState extends State max = mid - 1; } } - return sortedNodes[max]; + final node = sortedNodes[max]; + if (node.children.isNotEmpty && node.children.first.rect.top <= offset.dy) { + final children = node.children.toList(growable: false); + return _lowerBound(children, offset, 0, children.length - 1); + } + return node; } } @@ -576,6 +605,7 @@ class _SelectionGestureDetector extends StatefulWidget { this.child, this.onTapDown, this.onDoubleTapDown, + this.onTripleTapDown, this.onPanStart, this.onPanUpdate, this.onPanEnd}) @@ -589,14 +619,19 @@ class _SelectionGestureDetector extends StatefulWidget { final GestureTapDownCallback? onTapDown; final GestureTapDownCallback? onDoubleTapDown; + final GestureTapDownCallback? onTripleTapDown; final GestureDragStartCallback? onPanStart; final GestureDragUpdateCallback? onPanUpdate; final GestureDragEndCallback? onPanEnd; } +const Duration kTripleTapTimeout = Duration(milliseconds: 500); + class _SelectionGestureDetectorState extends State<_SelectionGestureDetector> { bool _isDoubleTap = false; Timer? _doubleTapTimer; + int _tripleTabCount = 0; + Timer? _tripleTabTimer; @override Widget build(BuildContext context) { return RawGestureDetector( @@ -625,13 +660,21 @@ class _SelectionGestureDetectorState extends State<_SelectionGestureDetector> { } _tapDownDelegate(TapDownDetails tapDownDetails) { - if (_isDoubleTap) { + if (_tripleTabCount == 2) { + _tripleTabCount = 0; + _tripleTabTimer?.cancel(); + _tripleTabTimer = null; + if (widget.onTripleTapDown != null) { + widget.onTripleTapDown!(tapDownDetails); + } + } else if (_isDoubleTap) { _isDoubleTap = false; _doubleTapTimer?.cancel(); _doubleTapTimer = null; if (widget.onDoubleTapDown != null) { widget.onDoubleTapDown!(tapDownDetails); } + _tripleTabCount++; } else { if (widget.onTapDown != null) { widget.onTapDown!(tapDownDetails); @@ -643,12 +686,20 @@ class _SelectionGestureDetectorState extends State<_SelectionGestureDetector> { _isDoubleTap = false; _doubleTapTimer = null; }); + + _tripleTabCount = 1; + _tripleTabTimer?.cancel(); + _tripleTabTimer = Timer(kTripleTapTimeout, () { + _tripleTabCount = 0; + _tripleTabTimer = null; + }); } } @override void dispose() { _doubleTapTimer?.cancel(); + _tripleTabTimer?.cancel(); super.dispose(); } } diff --git a/frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/hover.dart b/frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/hover.dart index 42ee43cabc..b9440bf1f1 100644 --- a/frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/hover.dart +++ b/frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/hover.dart @@ -9,14 +9,16 @@ class FlowyHover extends StatefulWidget { final HoverBuilder? builder; final Widget? child; final bool Function()? setSelected; + final MouseCursor? cursor; - const FlowyHover({ - Key? key, - this.builder, - this.child, - required this.style, - this.setSelected, - }) : super(key: key); + const FlowyHover( + {Key? key, + this.builder, + this.child, + required this.style, + this.setSelected, + this.cursor}) + : super(key: key); @override State createState() => _FlowyHoverState(); @@ -28,7 +30,7 @@ class _FlowyHoverState extends State { @override Widget build(BuildContext context) { return MouseRegion( - cursor: SystemMouseCursors.click, + cursor: widget.cursor != null ? widget.cursor! : SystemMouseCursors.click, opaque: false, onEnter: (p) => setState(() => _onHover = true), onExit: (p) => setState(() => _onHover = false), diff --git a/frontend/app_flowy/pubspec.lock b/frontend/app_flowy/pubspec.lock index e0d5e46770..05f245a8cc 100644 --- a/frontend/app_flowy/pubspec.lock +++ b/frontend/app_flowy/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "42.0.0" + version: "44.0.0" analyzer: dependency: "direct overridden" description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "4.3.0" + version: "4.4.0" animations: dependency: transitive description: @@ -22,6 +22,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.3" + appflowy_board: + dependency: "direct main" + description: + path: "packages/appflowy_board" + relative: true + source: path + version: "0.0.4" args: dependency: transitive description: diff --git a/frontend/app_flowy/pubspec.yaml b/frontend/app_flowy/pubspec.yaml index 623d5df900..a73f86359f 100644 --- a/frontend/app_flowy/pubspec.yaml +++ b/frontend/app_flowy/pubspec.yaml @@ -37,6 +37,8 @@ dependencies: path: packages/flowy_infra_ui flowy_infra: path: packages/flowy_infra + appflowy_board: + path: packages/appflowy_board flutter_quill: git: url: https://github.com/appflowy/flutter-quill.git @@ -87,7 +89,7 @@ dev_dependencies: bloc_test: ^9.0.2 dependency_overrides: - analyzer: ">=4.2.0 <5.0.0" + analyzer: ">=4.4.0 <5.0.0" # The "flutter_lints" package below contains a set of recommended lints to # encourage good coding practices. The lint set provided by the package is