From 0ba26e0a8496de8d8ceba8b299ceab55e3b472d2 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Mon, 28 Nov 2022 10:37:37 +0800 Subject: [PATCH 1/9] feat: Customize Font Size In AppFlowy #1479 --- .../app_flowy/assets/translations/en.json | 6 + .../lib/plugins/document/document.dart | 190 +++++------------- .../lib/plugins/document/editor_styles.dart | 25 ++- .../presentation/more/font_size_switcher.dart | 54 +++++ .../presentation/more/more_button.dart | 30 +++ .../presentation/share/share_button.dart | 133 ++++++++++++ 6 files changed, 291 insertions(+), 147 deletions(-) create mode 100644 frontend/app_flowy/lib/plugins/document/presentation/more/font_size_switcher.dart create mode 100644 frontend/app_flowy/lib/plugins/document/presentation/more/more_button.dart create mode 100644 frontend/app_flowy/lib/plugins/document/presentation/share/share_button.dart diff --git a/frontend/app_flowy/assets/translations/en.json b/frontend/app_flowy/assets/translations/en.json index 70ebe3245f..790ce87631 100644 --- a/frontend/app_flowy/assets/translations/en.json +++ b/frontend/app_flowy/assets/translations/en.json @@ -40,6 +40,12 @@ "markdown": "Markdown", "copyLink": "Copy Link" }, + "moreAction": { + "small": "small", + "medium": "medium", + "large": "large", + "fontSize": "Font Size" + }, "disclosureAction": { "rename": "Rename", "delete": "Delete", diff --git a/frontend/app_flowy/lib/plugins/document/document.dart b/frontend/app_flowy/lib/plugins/document/document.dart index 2808b032d8..7f38db17b7 100644 --- a/frontend/app_flowy/lib/plugins/document/document.dart +++ b/frontend/app_flowy/lib/plugins/document/document.dart @@ -1,28 +1,17 @@ library document_plugin; import 'package:app_flowy/generated/locale_keys.g.dart'; +import 'package:app_flowy/plugins/document/document_page.dart'; +import 'package:app_flowy/plugins/document/presentation/more/more_button.dart'; +import 'package:app_flowy/plugins/document/presentation/share/share_button.dart'; import 'package:app_flowy/plugins/util.dart'; import 'package:app_flowy/startup/plugin/plugin.dart'; -import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/plugins/document/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/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:appflowy_popover/appflowy_popover.dart'; -import 'package:clipboard/clipboard.dart'; import 'package:easy_localization/easy_localization.dart'; -import 'package:file_picker/file_picker.dart'; -import 'package:flowy_infra_ui/widget/rounded_button.dart'; -import 'package:flowy_sdk/log.dart'; -import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; -import 'package:flowy_sdk/protobuf/flowy-document/entities.pb.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; - -import 'document_page.dart'; +import 'package:provider/provider.dart'; class DocumentPluginBuilder extends PluginBuilder { @override @@ -47,8 +36,20 @@ class DocumentPluginBuilder extends PluginBuilder { ViewDataFormatPB get dataFormatType => ViewDataFormatPB.TreeFormat; } +class DocumentStyle with ChangeNotifier { + DocumentStyle(); + + double _fontSize = 14.0; + double get fontSize => _fontSize; + set fontSize(double fontSize) { + _fontSize = fontSize; + notifyListeners(); + } +} + class DocumentPlugin extends Plugin { late PluginType _pluginType; + late final DocumentStyle _documentStyle; @override final ViewPluginNotifier notifier; @@ -59,10 +60,22 @@ class DocumentPlugin extends Plugin { Key? key, }) : notifier = ViewPluginNotifier(view: view) { _pluginType = pluginType; + _documentStyle = DocumentStyle(); } @override - PluginDisplay get display => DocumentPluginDisplay(notifier: notifier); + void dispose() { + _documentStyle.dispose(); + super.dispose(); + } + + @override + PluginDisplay get display { + return DocumentPluginDisplay( + notifier: notifier, + documentStyle: _documentStyle, + ); + } @override PluginType get ty => _pluginType; @@ -75,8 +88,13 @@ class DocumentPluginDisplay extends PluginDisplay with NavigationItem { final ViewPluginNotifier notifier; ViewPB get view => notifier.view; int? deletedViewIndex; + DocumentStyle documentStyle; - DocumentPluginDisplay({required this.notifier, Key? key}); + DocumentPluginDisplay({ + required this.notifier, + required this.documentStyle, + Key? key, + }); @override Widget buildWidget(PluginContext context) { @@ -88,10 +106,13 @@ class DocumentPluginDisplay extends PluginDisplay with NavigationItem { }); }); - return DocumentPage( - view: view, - onDeleted: () => context.onDeleted(view, deletedViewIndex), - key: ValueKey(view.id), + return ChangeNotifierProvider.value( + value: documentStyle, + child: DocumentPage( + view: view, + onDeleted: () => context.onDeleted(view, deletedViewIndex), + key: ValueKey(view.id), + ), ); } @@ -99,126 +120,23 @@ class DocumentPluginDisplay extends PluginDisplay with NavigationItem { Widget get leftBarItem => ViewLeftBarItem(view: view); @override - Widget? get rightBarItem => DocumentShareButton(view: view); + Widget? get rightBarItem { + return Row( + children: [ + DocumentShareButton(view: view), + const SizedBox(width: 10), + ChangeNotifierProvider.value( + value: documentStyle, + child: const DocumentMoreButton(), + ), + ], + ); + } @override List get navigationItems => [this]; } -class DocumentShareButton extends StatelessWidget { - final ViewPB view; - DocumentShareButton({Key? key, required this.view}) - : super(key: ValueKey(view.hashCode)); - - @override - Widget build(BuildContext context) { - return BlocProvider( - create: (context) => getIt(param1: view), - child: BlocListener( - listener: (context, state) { - state.map( - initial: (_) {}, - loading: (_) {}, - finish: (state) { - state.successOrFail.fold( - _handleExportData, - _handleExportError, - ); - }, - ); - }, - child: BlocBuilder( - builder: (context, state) => ConstrainedBox( - constraints: const BoxConstraints.expand( - height: 30, - width: 100, - ), - child: ShareActionList(view: view), - ), - ), - ), - ); - } - - void _handleExportData(ExportDataPB exportData) { - switch (exportData.exportType) { - case ExportType.Link: - break; - case ExportType.Markdown: - FlutterClipboard.copy(exportData.data) - .then((value) => Log.info('copied to clipboard')); - break; - case ExportType.Text: - break; - } - } - - void _handleExportError(FlowyError error) {} -} - -class ShareActionList extends StatelessWidget { - const ShareActionList({ - Key? key, - required this.view, - }) : super(key: key); - - final ViewPB view; - - @override - Widget build(BuildContext context) { - final docShareBloc = context.read(); - return PopoverActionList( - direction: PopoverDirection.bottomWithCenterAligned, - actions: ShareAction.values - .map((action) => ShareActionWrapper(action)) - .toList(), - buildChild: (controller) { - return RoundedTextButton( - title: LocaleKeys.shareAction_buttonText.tr(), - onPressed: () => controller.show(), - ); - }, - onSelected: (action, controller) async { - switch (action.inner) { - case ShareAction.markdown: - final exportPath = await FilePicker.platform.saveFile( - dialogTitle: '', - fileName: '${view.name}.md', - ); - if (exportPath != null) { - docShareBloc.add(DocShareEvent.shareMarkdown(exportPath)); - showMessageToast('Exported to: $exportPath'); - } - break; - case ShareAction.copyLink: - NavigatorAlertDialog( - title: LocaleKeys.shareAction_workInProgress.tr()) - .show(context); - break; - } - controller.close(); - }, - ); - } -} - -enum ShareAction { - markdown, - copyLink, -} - -class ShareActionWrapper extends ActionCell { - final ShareAction inner; - - ShareActionWrapper(this.inner); - - @override - Widget? icon(Color iconColor) => null; - - @override - String get name => inner.name; -} - extension QuestionBubbleExtension on ShareAction { String get name { switch (this) { diff --git a/frontend/app_flowy/lib/plugins/document/editor_styles.dart b/frontend/app_flowy/lib/plugins/document/editor_styles.dart index 0468542a51..ecd75838e2 100644 --- a/frontend/app_flowy/lib/plugins/document/editor_styles.dart +++ b/frontend/app_flowy/lib/plugins/document/editor_styles.dart @@ -1,9 +1,10 @@ +import 'package:app_flowy/plugins/document/document.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flutter/material.dart'; - -const _baseFontSize = 14.0; +import 'package:provider/provider.dart'; EditorStyle customEditorTheme(BuildContext context) { + final documentStyle = context.watch(); var editorStyle = Theme.of(context).brightness == Brightness.dark ? EditorStyle.dark : EditorStyle.light; @@ -11,11 +12,11 @@ EditorStyle customEditorTheme(BuildContext context) { padding: const EdgeInsets.all(0), textStyle: editorStyle.textStyle?.copyWith( fontFamily: 'poppins', - fontSize: _baseFontSize, + fontSize: documentStyle.fontSize, ), placeholderTextStyle: editorStyle.placeholderTextStyle?.copyWith( fontFamily: 'poppins', - fontSize: _baseFontSize, + fontSize: documentStyle.fontSize, ), bold: editorStyle.bold?.copyWith( fontWeight: FontWeight.w500, @@ -26,22 +27,24 @@ EditorStyle customEditorTheme(BuildContext context) { } Iterable> customPluginTheme(BuildContext context) { + final documentStyle = context.watch(); const basePadding = 12.0; var headingPluginStyle = Theme.of(context).brightness == Brightness.dark ? HeadingPluginStyle.dark : HeadingPluginStyle.light; headingPluginStyle = headingPluginStyle.copyWith( textStyle: (EditorState editorState, Node node) { + final baseFontSize = documentStyle.fontSize; final headingToFontSize = { - 'h1': _baseFontSize + 12, - 'h2': _baseFontSize + 8, - 'h3': _baseFontSize + 4, - 'h4': _baseFontSize, - 'h5': _baseFontSize, - 'h6': _baseFontSize, + 'h1': baseFontSize + 12, + 'h2': baseFontSize + 8, + 'h3': baseFontSize + 4, + 'h4': baseFontSize, + 'h5': baseFontSize, + 'h6': baseFontSize, }; final fontSize = - headingToFontSize[node.attributes.heading] ?? _baseFontSize; + headingToFontSize[node.attributes.heading] ?? baseFontSize; return TextStyle(fontSize: fontSize, fontWeight: FontWeight.w600); }, padding: (EditorState editorState, Node node) { diff --git a/frontend/app_flowy/lib/plugins/document/presentation/more/font_size_switcher.dart b/frontend/app_flowy/lib/plugins/document/presentation/more/font_size_switcher.dart new file mode 100644 index 0000000000..c0da6ddc5c --- /dev/null +++ b/frontend/app_flowy/lib/plugins/document/presentation/more/font_size_switcher.dart @@ -0,0 +1,54 @@ +import 'package:app_flowy/plugins/document/document.dart'; +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:provider/provider.dart'; + +class FontSizeSwitcher extends StatefulWidget { + const FontSizeSwitcher({ + super.key, + // required this.documentStyle, + }); + + // final DocumentStyle documentStyle; + + @override + State createState() => _FontSizeSwitcherState(); +} + +class _FontSizeSwitcherState extends State { + @override + Widget build(BuildContext context) { + return Column( + children: [ + const FlowyText.semibold(LocaleKeys.moreAction_fontSize), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + _buildFontSizeSwitchButton(LocaleKeys.moreAction_small, 12.0), + _buildFontSizeSwitchButton(LocaleKeys.moreAction_medium, 14.0), + _buildFontSizeSwitchButton(LocaleKeys.moreAction_large, 18.0), + ], + ) + ], + ); + } + + Widget _buildFontSizeSwitchButton(String name, double fontSize) { + return Center( + child: TextButton( + onPressed: () { + final x = Provider.of(context, listen: false); + x; + Provider.of(context, listen: false).fontSize = + fontSize; + }, + child: Text( + name, + style: TextStyle(fontSize: fontSize), + ), + ), + ); + } +} diff --git a/frontend/app_flowy/lib/plugins/document/presentation/more/more_button.dart b/frontend/app_flowy/lib/plugins/document/presentation/more/more_button.dart new file mode 100644 index 0000000000..fc70f78b5c --- /dev/null +++ b/frontend/app_flowy/lib/plugins/document/presentation/more/more_button.dart @@ -0,0 +1,30 @@ +import 'package:app_flowy/plugins/document/presentation/more/font_size_switcher.dart'; +import 'package:flowy_infra/image.dart'; +import 'package:flutter/material.dart'; + +class DocumentMoreButton extends StatelessWidget { + const DocumentMoreButton({ + Key? key, + // required this.documentStyle, + }) : super(key: key); + + // final DocumentStyle documentStyle; + + @override + Widget build(BuildContext context) { + return PopupMenuButton( + itemBuilder: (context) { + return [ + const PopupMenuItem( + value: 1, + enabled: false, + child: FontSizeSwitcher( + // documentStyle: documentStyle, + ), + ) + ]; + }, + child: svgWithSize('editor/details', const Size(18, 18)), + ); + } +} diff --git a/frontend/app_flowy/lib/plugins/document/presentation/share/share_button.dart b/frontend/app_flowy/lib/plugins/document/presentation/share/share_button.dart new file mode 100644 index 0000000000..6a96ed9bff --- /dev/null +++ b/frontend/app_flowy/lib/plugins/document/presentation/share/share_button.dart @@ -0,0 +1,133 @@ +library document_plugin; + +import 'package:app_flowy/generated/locale_keys.g.dart'; +import 'package:app_flowy/startup/startup.dart'; +import 'package:app_flowy/plugins/document/application/share_bloc.dart'; +import 'package:app_flowy/workspace/presentation/home/toast.dart'; +import 'package:app_flowy/workspace/presentation/widgets/dialogs.dart'; +import 'package:app_flowy/workspace/presentation/widgets/pop_up_action.dart'; +import 'package:appflowy_popover/appflowy_popover.dart'; +import 'package:clipboard/clipboard.dart'; +import 'package:easy_localization/easy_localization.dart'; +import 'package:file_picker/file_picker.dart'; +import 'package:flowy_infra_ui/widget/rounded_button.dart'; +import 'package:flowy_sdk/log.dart'; +import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; +import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; +import 'package:flowy_sdk/protobuf/flowy-document/entities.pb.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class DocumentShareButton extends StatelessWidget { + final ViewPB view; + DocumentShareButton({Key? key, required this.view}) + : super(key: ValueKey(view.hashCode)); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (context) => getIt(param1: view), + child: BlocListener( + listener: (context, state) { + state.map( + initial: (_) {}, + loading: (_) {}, + finish: (state) { + state.successOrFail.fold( + _handleExportData, + _handleExportError, + ); + }, + ); + }, + child: BlocBuilder( + builder: (context, state) => ConstrainedBox( + constraints: const BoxConstraints.expand( + height: 30, + width: 100, + ), + child: ShareActionList(view: view), + ), + ), + ), + ); + } + + void _handleExportData(ExportDataPB exportData) { + switch (exportData.exportType) { + case ExportType.Link: + break; + case ExportType.Markdown: + FlutterClipboard.copy(exportData.data) + .then((value) => Log.info('copied to clipboard')); + break; + case ExportType.Text: + break; + } + } + + void _handleExportError(FlowyError error) {} +} + +class ShareActionList extends StatelessWidget { + const ShareActionList({ + Key? key, + required this.view, + }) : super(key: key); + + final ViewPB view; + + @override + Widget build(BuildContext context) { + final docShareBloc = context.read(); + return PopoverActionList( + direction: PopoverDirection.bottomWithCenterAligned, + actions: ShareAction.values + .map((action) => ShareActionWrapper(action)) + .toList(), + buildChild: (controller) { + return RoundedTextButton( + title: LocaleKeys.shareAction_buttonText.tr(), + onPressed: () => controller.show(), + ); + }, + onSelected: (action, controller) async { + switch (action.inner) { + case ShareAction.markdown: + final exportPath = await FilePicker.platform.saveFile( + dialogTitle: '', + fileName: '${view.name}.md', + ); + if (exportPath != null) { + docShareBloc.add(DocShareEvent.shareMarkdown(exportPath)); + showMessageToast('Exported to: $exportPath'); + } + break; + case ShareAction.copyLink: + NavigatorAlertDialog( + title: LocaleKeys.shareAction_workInProgress.tr()) + .show(context); + break; + } + controller.close(); + }, + ); + } +} + +enum ShareAction { + markdown, + copyLink, +} + +class ShareActionWrapper extends ActionCell { + final ShareAction inner; + + ShareActionWrapper(this.inner); + + @override + Widget? icon(Color iconColor) => null; + + @override + String get name => inner.name; +} From 37b119172bb2a25c90ad59b0fec464d27aa004e2 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Mon, 28 Nov 2022 13:26:43 +0800 Subject: [PATCH 2/9] feat: Customize Font Size In AppFlowy #1479 --- .../lib/plugins/doc/.document.dart.icloud | Bin 0 -> 161 bytes .../plugins/doc/.document_page.dart.icloud | Bin 0 -> 168 bytes .../plugins/doc/.editor_styles.dart.icloud | Bin 0 -> 168 bytes .../lib/plugins/doc/.styles.dart.icloud | Bin 0 -> 159 bytes .../presentation/more/font_size_switcher.dart | 77 +++++++++++------- .../presentation/more/more_button.dart | 12 ++- 6 files changed, 57 insertions(+), 32 deletions(-) create mode 100644 frontend/app_flowy/lib/plugins/doc/.document.dart.icloud create mode 100644 frontend/app_flowy/lib/plugins/doc/.document_page.dart.icloud create mode 100644 frontend/app_flowy/lib/plugins/doc/.editor_styles.dart.icloud create mode 100644 frontend/app_flowy/lib/plugins/doc/.styles.dart.icloud diff --git a/frontend/app_flowy/lib/plugins/doc/.document.dart.icloud b/frontend/app_flowy/lib/plugins/doc/.document.dart.icloud new file mode 100644 index 0000000000000000000000000000000000000000..3dfd2ddd1aca4e3f372c6ee9a1099c917ec6f651 GIT binary patch literal 161 zcmYc)$jK}&F)+By$i&RT$`<1n92(@~mzbOComv?$AOPmNW#*&?XI4RkB;Z0psm1xF zMaiill?5QF*p&R_(%jU%61|kfq7p%=XYm3uSk(rlrkCa<7IE;)=zB#(Gk^gjBZOvP Jhte>r3II()ELi{m literal 0 HcmV?d00001 diff --git a/frontend/app_flowy/lib/plugins/doc/.document_page.dart.icloud b/frontend/app_flowy/lib/plugins/doc/.document_page.dart.icloud new file mode 100644 index 0000000000000000000000000000000000000000..373f78aca282714771d6fbff98eaabc4b0a75c44 GIT binary patch literal 168 zcmYc)$jK}&F)+By$i&RT$`<1n92(@~mzbOComv?$AOPmNW#*&?XI4RkB;Z0psm1xF zMaiill?4zfp_KgO(%jU%lK6te^i;i+#G(>Go=fopGFY_)rKXqWBo=Y-%jkQ>CozBl OBO`=nV29E$su2LP4lZl} literal 0 HcmV?d00001 diff --git a/frontend/app_flowy/lib/plugins/doc/.editor_styles.dart.icloud b/frontend/app_flowy/lib/plugins/doc/.editor_styles.dart.icloud new file mode 100644 index 0000000000000000000000000000000000000000..31095f5c0acadc7c7db54e6706d4c0ef0d42ede8 GIT binary patch literal 168 zcmYc)$jK}&F)+By$i&RT$`<1n92(@~mzbOComv?$AOPmNW#*&?XI4RkB;Z0psm1xF zMaiill?4zfq12SjlKi6h;*!do)MCAq#G(>G_6zX>GFY_)rKXqWBo=Y-%jkQ>CozBl OBO`=nV29E$su2Lb?k createState() => _FontSizeSwitcherState(); } class _FontSizeSwitcherState extends State { + final _selectedFontSizes = [false, true, false]; + final List> _fontSizes = [ + Tuple2(LocaleKeys.moreAction_small.tr(), 12.0), + Tuple2(LocaleKeys.moreAction_medium.tr(), 14.0), + Tuple2(LocaleKeys.moreAction_large.tr(), 18.0), + ]; + @override Widget build(BuildContext context) { return Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - const FlowyText.semibold(LocaleKeys.moreAction_fontSize), - Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - _buildFontSizeSwitchButton(LocaleKeys.moreAction_small, 12.0), - _buildFontSizeSwitchButton(LocaleKeys.moreAction_medium, 14.0), - _buildFontSizeSwitchButton(LocaleKeys.moreAction_large, 18.0), + FlowyText.semibold( + LocaleKeys.moreAction_fontSize.tr(), + fontSize: 12, + ), + const SizedBox( + height: 5, + ), + ToggleButtons( + isSelected: _selectedFontSizes, + onPressed: (int index) { + setState(() { + for (int i = 0; i < _selectedFontSizes.length; i++) { + _selectedFontSizes[i] = i == index; + } + context.read().fontSize = _fontSizes[index].item2; + }); + }, + borderRadius: const BorderRadius.all(Radius.circular(5)), + selectedBorderColor: Theme.of(context).colorScheme.primaryContainer, + selectedColor: Theme.of(context).colorScheme.onSurface, + fillColor: Theme.of(context).colorScheme.primaryContainer, + color: Theme.of(context).hintColor, + constraints: const BoxConstraints( + minHeight: 40.0, + minWidth: 80.0, + ), + children: const [ + Text( + 'small', + style: TextStyle(fontSize: 12), + ), + Text( + 'medium', + style: TextStyle(fontSize: 14), + ), + Text( + 'large', + style: TextStyle(fontSize: 18), + ) ], ) ], ); } - - Widget _buildFontSizeSwitchButton(String name, double fontSize) { - return Center( - child: TextButton( - onPressed: () { - final x = Provider.of(context, listen: false); - x; - Provider.of(context, listen: false).fontSize = - fontSize; - }, - child: Text( - name, - style: TextStyle(fontSize: fontSize), - ), - ), - ); - } } diff --git a/frontend/app_flowy/lib/plugins/document/presentation/more/more_button.dart b/frontend/app_flowy/lib/plugins/document/presentation/more/more_button.dart index fc70f78b5c..3ee0a867e0 100644 --- a/frontend/app_flowy/lib/plugins/document/presentation/more/more_button.dart +++ b/frontend/app_flowy/lib/plugins/document/presentation/more/more_button.dart @@ -1,6 +1,8 @@ +import 'package:app_flowy/plugins/document/document.dart'; import 'package:app_flowy/plugins/document/presentation/more/font_size_switcher.dart'; import 'package:flowy_infra/image.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; class DocumentMoreButton extends StatelessWidget { const DocumentMoreButton({ @@ -13,14 +15,16 @@ class DocumentMoreButton extends StatelessWidget { @override Widget build(BuildContext context) { return PopupMenuButton( + offset: const Offset(0, 30), itemBuilder: (context) { return [ - const PopupMenuItem( + PopupMenuItem( value: 1, enabled: false, - child: FontSizeSwitcher( - // documentStyle: documentStyle, - ), + child: ChangeNotifierProvider.value( + value: context.read(), + child: const FontSizeSwitcher(), + ), ) ]; }, From 6d6e61956a5412d08a627e19ebc76a888f028fcb Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Mon, 28 Nov 2022 15:34:55 +0800 Subject: [PATCH 3/9] feat: Customize Font Size In AppFlowy #1479 --- .../lib/plugins/document/document.dart | 10 ++- .../lib/plugins/document/editor_styles.dart | 24 ++++++- .../presentation/more/font_size_switcher.dart | 62 ++++++++++++------- .../presentation/more/more_button.dart | 6 +- .../packages/flowy_infra/lib/image.dart | 23 +++++-- 5 files changed, 91 insertions(+), 34 deletions(-) diff --git a/frontend/app_flowy/lib/plugins/document/document.dart b/frontend/app_flowy/lib/plugins/document/document.dart index 7f38db17b7..0d0107b23c 100644 --- a/frontend/app_flowy/lib/plugins/document/document.dart +++ b/frontend/app_flowy/lib/plugins/document/document.dart @@ -12,6 +12,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class DocumentPluginBuilder extends PluginBuilder { @override @@ -37,7 +38,9 @@ class DocumentPluginBuilder extends PluginBuilder { } class DocumentStyle with ChangeNotifier { - DocumentStyle(); + DocumentStyle() { + sync(); + } double _fontSize = 14.0; double get fontSize => _fontSize; @@ -45,6 +48,11 @@ class DocumentStyle with ChangeNotifier { _fontSize = fontSize; notifyListeners(); } + + void sync() async { + final prefs = await SharedPreferences.getInstance(); + fontSize = prefs.getDouble('kSelectFontSize') ?? _fontSize; + } } class DocumentPlugin extends Plugin { diff --git a/frontend/app_flowy/lib/plugins/document/editor_styles.dart b/frontend/app_flowy/lib/plugins/document/editor_styles.dart index ecd75838e2..e001622700 100644 --- a/frontend/app_flowy/lib/plugins/document/editor_styles.dart +++ b/frontend/app_flowy/lib/plugins/document/editor_styles.dart @@ -28,13 +28,13 @@ EditorStyle customEditorTheme(BuildContext context) { Iterable> customPluginTheme(BuildContext context) { final documentStyle = context.watch(); + final baseFontSize = documentStyle.fontSize; const basePadding = 12.0; var headingPluginStyle = Theme.of(context).brightness == Brightness.dark ? HeadingPluginStyle.dark : HeadingPluginStyle.light; headingPluginStyle = headingPluginStyle.copyWith( textStyle: (EditorState editorState, Node node) { - final baseFontSize = documentStyle.fontSize; final headingToFontSize = { 'h1': baseFontSize + 12, 'h2': baseFontSize + 8, @@ -60,10 +60,28 @@ Iterable> customPluginTheme(BuildContext context) { return EdgeInsets.only(bottom: padding); }, ); + var numberListPluginStyle = Theme.of(context).brightness == Brightness.dark + ? NumberListPluginStyle.dark + : NumberListPluginStyle.light; + + numberListPluginStyle = numberListPluginStyle.copyWith( + icon: (_, textNode) { + const iconPadding = EdgeInsets.only(left: 5.0, right: 5.0); + return Container( + padding: iconPadding, + child: Text( + '${textNode.attributes.number.toString()}.', + style: customEditorTheme(context).textStyle, + ), + ); + }, + ); final pluginTheme = Theme.of(context).brightness == Brightness.dark ? darkPlguinStyleExtension : lightPlguinStyleExtension; return pluginTheme.toList() - ..removeWhere((element) => element is HeadingPluginStyle) - ..add(headingPluginStyle); + ..removeWhere((element) => + element is HeadingPluginStyle || element is NumberListPluginStyle) + ..add(headingPluginStyle) + ..add(numberListPluginStyle); } diff --git a/frontend/app_flowy/lib/plugins/document/presentation/more/font_size_switcher.dart b/frontend/app_flowy/lib/plugins/document/presentation/more/font_size_switcher.dart index af5858c851..d27a60a810 100644 --- a/frontend/app_flowy/lib/plugins/document/presentation/more/font_size_switcher.dart +++ b/frontend/app_flowy/lib/plugins/document/presentation/more/font_size_switcher.dart @@ -3,8 +3,9 @@ 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:provider/provider.dart'; -import 'package:easy_localization/easy_localization.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'package:tuple/tuple.dart'; +import 'package:easy_localization/easy_localization.dart'; class FontSizeSwitcher extends StatefulWidget { const FontSizeSwitcher({ @@ -15,14 +16,29 @@ class FontSizeSwitcher extends StatefulWidget { State createState() => _FontSizeSwitcherState(); } +const String _kSelectFontSize = 'kSelectFontSize'; + class _FontSizeSwitcherState extends State { - final _selectedFontSizes = [false, true, false]; + final List _selectedFontSizes = [false, true, false]; final List> _fontSizes = [ Tuple2(LocaleKeys.moreAction_small.tr(), 12.0), Tuple2(LocaleKeys.moreAction_medium.tr(), 14.0), Tuple2(LocaleKeys.moreAction_large.tr(), 18.0), ]; + @override + void initState() { + super.initState(); + + SharedPreferences.getInstance().then((prefs) { + final index = _fontSizes.indexWhere( + (element) => element.item2 == prefs.getDouble(_kSelectFontSize)); + if (index != -1) { + _updateSelectedFontSize(index); + } + }); + } + @override Widget build(BuildContext context) { return Column( @@ -38,12 +54,7 @@ class _FontSizeSwitcherState extends State { ToggleButtons( isSelected: _selectedFontSizes, onPressed: (int index) { - setState(() { - for (int i = 0; i < _selectedFontSizes.length; i++) { - _selectedFontSizes[i] = i == index; - } - context.read().fontSize = _fontSizes[index].item2; - }); + _updateSelectedFontSize(index); }, borderRadius: const BorderRadius.all(Radius.circular(5)), selectedBorderColor: Theme.of(context).colorScheme.primaryContainer, @@ -54,22 +65,27 @@ class _FontSizeSwitcherState extends State { minHeight: 40.0, minWidth: 80.0, ), - children: const [ - Text( - 'small', - style: TextStyle(fontSize: 12), - ), - Text( - 'medium', - style: TextStyle(fontSize: 14), - ), - Text( - 'large', - style: TextStyle(fontSize: 18), - ) - ], - ) + children: _fontSizes + .map((e) => Text( + e.item1, + style: TextStyle(fontSize: e.item2), + )) + .toList(), + ), ], ); } + + void _updateSelectedFontSize(int index) { + final fontSize = _fontSizes[index].item2; + context.read().fontSize = fontSize; + SharedPreferences.getInstance().then( + (prefs) => prefs.setDouble(_kSelectFontSize, fontSize), + ); + setState(() { + for (int i = 0; i < _selectedFontSizes.length; i++) { + _selectedFontSizes[i] = i == index; + } + }); + } } diff --git a/frontend/app_flowy/lib/plugins/document/presentation/more/more_button.dart b/frontend/app_flowy/lib/plugins/document/presentation/more/more_button.dart index 3ee0a867e0..1dc5047584 100644 --- a/frontend/app_flowy/lib/plugins/document/presentation/more/more_button.dart +++ b/frontend/app_flowy/lib/plugins/document/presentation/more/more_button.dart @@ -28,7 +28,11 @@ class DocumentMoreButton extends StatelessWidget { ) ]; }, - child: svgWithSize('editor/details', const Size(18, 18)), + child: svgWidget( + 'editor/details', + size: const Size(18, 18), + color: Theme.of(context).colorScheme.onSurface, + ), ); } } diff --git a/frontend/app_flowy/packages/flowy_infra/lib/image.dart b/frontend/app_flowy/packages/flowy_infra/lib/image.dart index e70c8b4bff..21ef1a2970 100644 --- a/frontend/app_flowy/packages/flowy_infra/lib/image.dart +++ b/frontend/app_flowy/packages/flowy_infra/lib/image.dart @@ -1,15 +1,26 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_svg/flutter_svg.dart'; -Widget svgWidget(String name, {Color? color}) { - final Widget svg = SvgPicture.asset('assets/images/$name.svg', color: color); - - return svg; -} - Widget svgWithSize(String name, Size size) { return SizedBox.fromSize( size: size, child: svgWidget(name), ); } + +Widget svgWidget(String name, {Size? size, Color? color}) { + if (size != null) { + return SizedBox.fromSize( + size: size, + child: _svgWidget(name, color: color), + ); + } else { + return _svgWidget(name, color: color); + } +} + +Widget _svgWidget(String name, {Color? color}) { + final Widget svg = SvgPicture.asset('assets/images/$name.svg', color: color); + + return svg; +} From d75645c4bceb3ed6db2269f024d4107ebf8fefe2 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Mon, 28 Nov 2022 16:17:46 +0800 Subject: [PATCH 4/9] fix: remove the unnecessary text style update --- .../appflowy_editor/lib/src/render/rich_text/rich_text.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/rich_text.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/rich_text.dart index f48714045b..b739211951 100644 --- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/rich_text.dart +++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/rich_text.dart @@ -72,7 +72,7 @@ class _RichTextNodeWidgetState extends State child: FlowyRichText( key: _richTextKey, textNode: widget.textNode, - textSpanDecorator: (textSpan) => textSpan.updateTextStyle(textStyle), + textSpanDecorator: (textSpan) => textSpan, placeholderTextSpanDecorator: (textSpan) => textSpan.updateTextStyle(textStyle), lineHeight: widget.editorState.editorStyle.lineHeight, From 04e14c6bbae19255ccb2ff33496aa4394d87bf67 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Mon, 28 Nov 2022 16:22:10 +0800 Subject: [PATCH 5/9] fix: transparent color should be treated as a highlight color --- .../appflowy_editor/lib/src/render/toolbar/toolbar_item.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/toolbar/toolbar_item.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/toolbar/toolbar_item.dart index 5ab7f6cc50..b6051f4877 100644 --- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/toolbar/toolbar_item.dart +++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/toolbar/toolbar_item.dart @@ -255,7 +255,9 @@ List defaultToolbarItems = [ highlightCallback: (editorState) => _allSatisfy( editorState, BuiltInAttributeKey.backgroundColor, - (value) => value != null, + (value) { + return value != null && value != '0x00000000'; // transparent color; + }, ), handler: (editorState, context) => formatHighlight( editorState, From a162b0247633b8b82eef07e2323d8360829e9f16 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Mon, 28 Nov 2022 18:02:05 +0800 Subject: [PATCH 6/9] feat: convert provider to cubit #1479 --- .../lib/plugins/document/document.dart | 54 +++++++------------ .../lib/plugins/document/editor_styles.dart | 8 +-- .../more/cubit/document_appearance_cubit.dart | 42 +++++++++++++++ .../presentation/more/font_size_switcher.dart | 30 +++++------ .../presentation/more/more_button.dart | 11 ++-- 5 files changed, 85 insertions(+), 60 deletions(-) create mode 100644 frontend/app_flowy/lib/plugins/document/presentation/more/cubit/document_appearance_cubit.dart diff --git a/frontend/app_flowy/lib/plugins/document/document.dart b/frontend/app_flowy/lib/plugins/document/document.dart index 0d0107b23c..6ee7f65b52 100644 --- a/frontend/app_flowy/lib/plugins/document/document.dart +++ b/frontend/app_flowy/lib/plugins/document/document.dart @@ -2,6 +2,7 @@ library document_plugin; import 'package:app_flowy/generated/locale_keys.g.dart'; import 'package:app_flowy/plugins/document/document_page.dart'; +import 'package:app_flowy/plugins/document/presentation/more/cubit/document_appearance_cubit.dart'; import 'package:app_flowy/plugins/document/presentation/more/more_button.dart'; import 'package:app_flowy/plugins/document/presentation/share/share_button.dart'; import 'package:app_flowy/plugins/util.dart'; @@ -11,8 +12,7 @@ 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 'package:provider/provider.dart'; -import 'package:shared_preferences/shared_preferences.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class DocumentPluginBuilder extends PluginBuilder { @override @@ -37,27 +37,9 @@ class DocumentPluginBuilder extends PluginBuilder { ViewDataFormatPB get dataFormatType => ViewDataFormatPB.TreeFormat; } -class DocumentStyle with ChangeNotifier { - DocumentStyle() { - sync(); - } - - double _fontSize = 14.0; - double get fontSize => _fontSize; - set fontSize(double fontSize) { - _fontSize = fontSize; - notifyListeners(); - } - - void sync() async { - final prefs = await SharedPreferences.getInstance(); - fontSize = prefs.getDouble('kSelectFontSize') ?? _fontSize; - } -} - class DocumentPlugin extends Plugin { late PluginType _pluginType; - late final DocumentStyle _documentStyle; + late final DocumentAppearanceCubit _documentAppearanceCubit; @override final ViewPluginNotifier notifier; @@ -68,12 +50,12 @@ class DocumentPlugin extends Plugin { Key? key, }) : notifier = ViewPluginNotifier(view: view) { _pluginType = pluginType; - _documentStyle = DocumentStyle(); + _documentAppearanceCubit = DocumentAppearanceCubit(); } @override void dispose() { - _documentStyle.dispose(); + _documentAppearanceCubit.close(); super.dispose(); } @@ -81,7 +63,7 @@ class DocumentPlugin extends Plugin { PluginDisplay get display { return DocumentPluginDisplay( notifier: notifier, - documentStyle: _documentStyle, + documentAppearanceCubit: _documentAppearanceCubit, ); } @@ -96,11 +78,11 @@ class DocumentPluginDisplay extends PluginDisplay with NavigationItem { final ViewPluginNotifier notifier; ViewPB get view => notifier.view; int? deletedViewIndex; - DocumentStyle documentStyle; + DocumentAppearanceCubit documentAppearanceCubit; DocumentPluginDisplay({ required this.notifier, - required this.documentStyle, + required this.documentAppearanceCubit, Key? key, }); @@ -114,12 +96,16 @@ class DocumentPluginDisplay extends PluginDisplay with NavigationItem { }); }); - return ChangeNotifierProvider.value( - value: documentStyle, - child: DocumentPage( - view: view, - onDeleted: () => context.onDeleted(view, deletedViewIndex), - key: ValueKey(view.id), + return BlocProvider.value( + value: documentAppearanceCubit, + child: BlocBuilder( + builder: (_, state) { + return DocumentPage( + view: view, + onDeleted: () => context.onDeleted(view, deletedViewIndex), + key: ValueKey(view.id), + ); + }, ), ); } @@ -133,8 +119,8 @@ class DocumentPluginDisplay extends PluginDisplay with NavigationItem { children: [ DocumentShareButton(view: view), const SizedBox(width: 10), - ChangeNotifierProvider.value( - value: documentStyle, + BlocProvider.value( + value: documentAppearanceCubit, child: const DocumentMoreButton(), ), ], diff --git a/frontend/app_flowy/lib/plugins/document/editor_styles.dart b/frontend/app_flowy/lib/plugins/document/editor_styles.dart index e001622700..1993af45d8 100644 --- a/frontend/app_flowy/lib/plugins/document/editor_styles.dart +++ b/frontend/app_flowy/lib/plugins/document/editor_styles.dart @@ -1,10 +1,11 @@ -import 'package:app_flowy/plugins/document/document.dart'; +import 'package:app_flowy/plugins/document/presentation/more/cubit/document_appearance_cubit.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; EditorStyle customEditorTheme(BuildContext context) { - final documentStyle = context.watch(); + final documentStyle = + context.watch().documentAppearance; var editorStyle = Theme.of(context).brightness == Brightness.dark ? EditorStyle.dark : EditorStyle.light; @@ -27,7 +28,8 @@ EditorStyle customEditorTheme(BuildContext context) { } Iterable> customPluginTheme(BuildContext context) { - final documentStyle = context.watch(); + final documentStyle = + context.watch().documentAppearance; final baseFontSize = documentStyle.fontSize; const basePadding = 12.0; var headingPluginStyle = Theme.of(context).brightness == Brightness.dark diff --git a/frontend/app_flowy/lib/plugins/document/presentation/more/cubit/document_appearance_cubit.dart b/frontend/app_flowy/lib/plugins/document/presentation/more/cubit/document_appearance_cubit.dart new file mode 100644 index 0000000000..7498561296 --- /dev/null +++ b/frontend/app_flowy/lib/plugins/document/presentation/more/cubit/document_appearance_cubit.dart @@ -0,0 +1,42 @@ +import 'package:bloc/bloc.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +const String _kDocumentAppearenceFontSize = 'kDocumentAppearenceFontSize'; + +class DocumentAppearance { + const DocumentAppearance({ + required this.fontSize, + }); + + final double fontSize; + // Will be supported... + // final String fontName; + + DocumentAppearance copyWith({double? fontSize}) { + return DocumentAppearance( + fontSize: fontSize ?? this.fontSize, + ); + } +} + +class DocumentAppearanceCubit extends Cubit { + DocumentAppearanceCubit() : super(const DocumentAppearance(fontSize: 14.0)) { + fetch(); + } + + late DocumentAppearance documentAppearance; + + void fetch() async { + final prefs = await SharedPreferences.getInstance(); + final fontSize = prefs.getDouble(_kDocumentAppearenceFontSize) ?? 14.0; + documentAppearance = DocumentAppearance(fontSize: fontSize); + emit(documentAppearance); + } + + void sync(DocumentAppearance documentAppearance) async { + final prefs = await SharedPreferences.getInstance(); + prefs.setDouble(_kDocumentAppearenceFontSize, documentAppearance.fontSize); + this.documentAppearance = documentAppearance; + emit(documentAppearance); + } +} diff --git a/frontend/app_flowy/lib/plugins/document/presentation/more/font_size_switcher.dart b/frontend/app_flowy/lib/plugins/document/presentation/more/font_size_switcher.dart index d27a60a810..b07dcfe5ed 100644 --- a/frontend/app_flowy/lib/plugins/document/presentation/more/font_size_switcher.dart +++ b/frontend/app_flowy/lib/plugins/document/presentation/more/font_size_switcher.dart @@ -1,9 +1,8 @@ -import 'package:app_flowy/plugins/document/document.dart'; +import 'package:app_flowy/plugins/document/presentation/more/cubit/document_appearance_cubit.dart'; 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:provider/provider.dart'; -import 'package:shared_preferences/shared_preferences.dart'; import 'package:tuple/tuple.dart'; import 'package:easy_localization/easy_localization.dart'; @@ -16,8 +15,6 @@ class FontSizeSwitcher extends StatefulWidget { State createState() => _FontSizeSwitcherState(); } -const String _kSelectFontSize = 'kSelectFontSize'; - class _FontSizeSwitcherState extends State { final List _selectedFontSizes = [false, true, false]; final List> _fontSizes = [ @@ -30,13 +27,10 @@ class _FontSizeSwitcherState extends State { void initState() { super.initState(); - SharedPreferences.getInstance().then((prefs) { - final index = _fontSizes.indexWhere( - (element) => element.item2 == prefs.getDouble(_kSelectFontSize)); - if (index != -1) { - _updateSelectedFontSize(index); - } - }); + final fontSize = + context.read().documentAppearance.fontSize; + final index = _fontSizes.indexWhere((element) => element.item2 == fontSize); + _updateSelectedFontSize(index); } @override @@ -55,6 +49,7 @@ class _FontSizeSwitcherState extends State { isSelected: _selectedFontSizes, onPressed: (int index) { _updateSelectedFontSize(index); + _sync(index); }, borderRadius: const BorderRadius.all(Radius.circular(5)), selectedBorderColor: Theme.of(context).colorScheme.primaryContainer, @@ -77,15 +72,18 @@ class _FontSizeSwitcherState extends State { } void _updateSelectedFontSize(int index) { - final fontSize = _fontSizes[index].item2; - context.read().fontSize = fontSize; - SharedPreferences.getInstance().then( - (prefs) => prefs.setDouble(_kSelectFontSize, fontSize), - ); setState(() { for (int i = 0; i < _selectedFontSizes.length; i++) { _selectedFontSizes[i] = i == index; } }); } + + void _sync(int index) { + if (index < 0 || index >= _fontSizes.length) return; + final fontSize = _fontSizes[index].item2; + final cubit = context.read(); + final documentAppearance = cubit.documentAppearance; + cubit.sync(documentAppearance.copyWith(fontSize: fontSize)); + } } diff --git a/frontend/app_flowy/lib/plugins/document/presentation/more/more_button.dart b/frontend/app_flowy/lib/plugins/document/presentation/more/more_button.dart index 1dc5047584..3f1ec921df 100644 --- a/frontend/app_flowy/lib/plugins/document/presentation/more/more_button.dart +++ b/frontend/app_flowy/lib/plugins/document/presentation/more/more_button.dart @@ -1,17 +1,14 @@ -import 'package:app_flowy/plugins/document/document.dart'; +import 'package:app_flowy/plugins/document/presentation/more/cubit/document_appearance_cubit.dart'; import 'package:app_flowy/plugins/document/presentation/more/font_size_switcher.dart'; import 'package:flowy_infra/image.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class DocumentMoreButton extends StatelessWidget { const DocumentMoreButton({ Key? key, - // required this.documentStyle, }) : super(key: key); - // final DocumentStyle documentStyle; - @override Widget build(BuildContext context) { return PopupMenuButton( @@ -21,8 +18,8 @@ class DocumentMoreButton extends StatelessWidget { PopupMenuItem( value: 1, enabled: false, - child: ChangeNotifierProvider.value( - value: context.read(), + child: BlocProvider.value( + value: context.read(), child: const FontSizeSwitcher(), ), ) From 0e55cd07a4267731b73651b635b838dead03ac39 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Mon, 28 Nov 2022 18:20:30 +0800 Subject: [PATCH 7/9] chore: fix typo --- .../lib/plugins/doc/.document.dart.icloud | Bin 161 -> 0 bytes .../lib/plugins/doc/.document_page.dart.icloud | Bin 168 -> 0 bytes .../lib/plugins/doc/.editor_styles.dart.icloud | Bin 168 -> 0 bytes .../app_flowy/lib/plugins/doc/.styles.dart.icloud | Bin 159 -> 0 bytes .../app_flowy/lib/plugins/document/document.dart | 5 +++-- .../more/cubit/document_appearance_cubit.dart | 4 +--- .../document/presentation/share/share_button.dart | 1 - 7 files changed, 4 insertions(+), 6 deletions(-) delete mode 100644 frontend/app_flowy/lib/plugins/doc/.document.dart.icloud delete mode 100644 frontend/app_flowy/lib/plugins/doc/.document_page.dart.icloud delete mode 100644 frontend/app_flowy/lib/plugins/doc/.editor_styles.dart.icloud delete mode 100644 frontend/app_flowy/lib/plugins/doc/.styles.dart.icloud diff --git a/frontend/app_flowy/lib/plugins/doc/.document.dart.icloud b/frontend/app_flowy/lib/plugins/doc/.document.dart.icloud deleted file mode 100644 index 3dfd2ddd1aca4e3f372c6ee9a1099c917ec6f651..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 161 zcmYc)$jK}&F)+By$i&RT$`<1n92(@~mzbOComv?$AOPmNW#*&?XI4RkB;Z0psm1xF zMaiill?5QF*p&R_(%jU%61|kfq7p%=XYm3uSk(rlrkCa<7IE;)=zB#(Gk^gjBZOvP Jhte>r3II()ELi{m diff --git a/frontend/app_flowy/lib/plugins/doc/.document_page.dart.icloud b/frontend/app_flowy/lib/plugins/doc/.document_page.dart.icloud deleted file mode 100644 index 373f78aca282714771d6fbff98eaabc4b0a75c44..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 168 zcmYc)$jK}&F)+By$i&RT$`<1n92(@~mzbOComv?$AOPmNW#*&?XI4RkB;Z0psm1xF zMaiill?4zfp_KgO(%jU%lK6te^i;i+#G(>Go=fopGFY_)rKXqWBo=Y-%jkQ>CozBl OBO`=nV29E$su2LP4lZl} diff --git a/frontend/app_flowy/lib/plugins/doc/.editor_styles.dart.icloud b/frontend/app_flowy/lib/plugins/doc/.editor_styles.dart.icloud deleted file mode 100644 index 31095f5c0acadc7c7db54e6706d4c0ef0d42ede8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 168 zcmYc)$jK}&F)+By$i&RT$`<1n92(@~mzbOComv?$AOPmNW#*&?XI4RkB;Z0psm1xF zMaiill?4zfq12SjlKi6h;*!do)MCAq#G(>G_6zX>GFY_)rKXqWBo=Y-%jkQ>CozBl OBO`=nV29E$su2Lb?k { late PluginType _pluginType; - late final DocumentAppearanceCubit _documentAppearanceCubit; + final DocumentAppearanceCubit _documentAppearanceCubit = + DocumentAppearanceCubit(); @override final ViewPluginNotifier notifier; @@ -50,7 +51,7 @@ class DocumentPlugin extends Plugin { Key? key, }) : notifier = ViewPluginNotifier(view: view) { _pluginType = pluginType; - _documentAppearanceCubit = DocumentAppearanceCubit(); + _documentAppearanceCubit.fetch(); } @override diff --git a/frontend/app_flowy/lib/plugins/document/presentation/more/cubit/document_appearance_cubit.dart b/frontend/app_flowy/lib/plugins/document/presentation/more/cubit/document_appearance_cubit.dart index 7498561296..61d50673f1 100644 --- a/frontend/app_flowy/lib/plugins/document/presentation/more/cubit/document_appearance_cubit.dart +++ b/frontend/app_flowy/lib/plugins/document/presentation/more/cubit/document_appearance_cubit.dart @@ -20,9 +20,7 @@ class DocumentAppearance { } class DocumentAppearanceCubit extends Cubit { - DocumentAppearanceCubit() : super(const DocumentAppearance(fontSize: 14.0)) { - fetch(); - } + DocumentAppearanceCubit() : super(const DocumentAppearance(fontSize: 14.0)); late DocumentAppearance documentAppearance; diff --git a/frontend/app_flowy/lib/plugins/document/presentation/share/share_button.dart b/frontend/app_flowy/lib/plugins/document/presentation/share/share_button.dart index 6a96ed9bff..c56b70155e 100644 --- a/frontend/app_flowy/lib/plugins/document/presentation/share/share_button.dart +++ b/frontend/app_flowy/lib/plugins/document/presentation/share/share_button.dart @@ -125,7 +125,6 @@ class ShareActionWrapper extends ActionCell { ShareActionWrapper(this.inner); - @override Widget? icon(Color iconColor) => null; @override From 52ba0c0092616d25056c6738c80f0c39ca6959cd Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Mon, 28 Nov 2022 18:44:48 +0800 Subject: [PATCH 8/9] fix: the cursor shows sometimes when tapping the checkbox --- .../appflowy_editor/lib/src/render/rich_text/checkbox_text.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/checkbox_text.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/checkbox_text.dart index a2e0aa5d32..90c2eb3fb4 100644 --- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/checkbox_text.dart +++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/checkbox_text.dart @@ -84,6 +84,7 @@ class _CheckboxNodeWidgetState extends State GestureDetector( key: iconKey, child: icon, + behavior: HitTestBehavior.opaque, onTap: () async { await widget.editorState.formatTextToCheckbox( widget.editorState, From 43031b50eb3c2718843349b6c7b9a3bb2d2acf4f Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Mon, 28 Nov 2022 21:31:33 +0800 Subject: [PATCH 9/9] feat: update bold text style --- frontend/app_flowy/lib/plugins/document/editor_styles.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/app_flowy/lib/plugins/document/editor_styles.dart b/frontend/app_flowy/lib/plugins/document/editor_styles.dart index 1993af45d8..9ff3aca30d 100644 --- a/frontend/app_flowy/lib/plugins/document/editor_styles.dart +++ b/frontend/app_flowy/lib/plugins/document/editor_styles.dart @@ -20,7 +20,8 @@ EditorStyle customEditorTheme(BuildContext context) { fontSize: documentStyle.fontSize, ), bold: editorStyle.bold?.copyWith( - fontWeight: FontWeight.w500, + fontWeight: FontWeight.w600, + fontFamily: 'poppins-Bold', ), backgroundColor: Theme.of(context).colorScheme.surface, );