From 75133f05f270a4990c8640aca6c6b79253f3500f Mon Sep 17 00:00:00 2001 From: Liz Bui Date: Thu, 21 Jul 2022 14:50:29 +0700 Subject: [PATCH] add rich text style strike through --- assets/images/ic_style_strikethroughs.svg | 3 +++ core/lib/presentation/resources/image_paths.dart | 1 + lib/features/composer/presentation/composer_view.dart | 9 +++++++++ .../controller/rich_text_mobile_tablet_controller.dart | 4 ++++ .../presentation/model/rich_text_style_type.dart | 7 ++++++- 5 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 assets/images/ic_style_strikethroughs.svg diff --git a/assets/images/ic_style_strikethroughs.svg b/assets/images/ic_style_strikethroughs.svg new file mode 100644 index 000000000..08606828f --- /dev/null +++ b/assets/images/ic_style_strikethroughs.svg @@ -0,0 +1,3 @@ + + + diff --git a/core/lib/presentation/resources/image_paths.dart b/core/lib/presentation/resources/image_paths.dart index 449201dde..9490acc52 100644 --- a/core/lib/presentation/resources/image_paths.dart +++ b/core/lib/presentation/resources/image_paths.dart @@ -132,6 +132,7 @@ class ImagePaths { String get icStyleItalic => _getImagePath('ic_style_italic.svg'); String get icStyleUnderline => _getImagePath('ic_style_underline.svg'); String get icInsertImage => _getImagePath('ic_insert_image.svg'); + String get icStyleStrikeThrough => _getImagePath('ic_style_strikethroughs.svg'); String _getImagePath(String imageName) { return AssetsPaths.images + imageName; diff --git a/lib/features/composer/presentation/composer_view.dart b/lib/features/composer/presentation/composer_view.dart index a28e6f71e..3d8649b0f 100644 --- a/lib/features/composer/presentation/composer_view.dart +++ b/lib/features/composer/presentation/composer_view.dart @@ -514,6 +514,15 @@ class ComposerView extends GetWidget with AppLoaderMixin, Ri }); } ), + buildIconStyleText( + path: RichTextStyleType.strikeThrough.getIcon(imagePaths), + isSelected: controller.richTextMobileTabletController.isTextStyleTypeSelected(RichTextStyleType.strikeThrough), + onTap: () async { + await controller.htmlEditorApi?.formatStrikeThrough().then((value) { + controller.richTextMobileTabletController.selectTextStyleType(RichTextStyleType.strikeThrough); + }); + } + ), buildIconStyleText( path: RichTextStyleType.underline.getIcon(imagePaths), isSelected: controller.richTextMobileTabletController.isTextStyleTypeSelected(RichTextStyleType.underline), diff --git a/lib/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart b/lib/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart index f604ce051..31dcabb81 100644 --- a/lib/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart +++ b/lib/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart @@ -20,6 +20,10 @@ class RichTextMobileTabletController extends GetxController { if (formatSettings.isUnderline) { listTextStyleApply.add(RichTextStyleType.underline); } + + if (formatSettings.isStrikeThrough) { + listTextStyleApply.add(RichTextStyleType.strikeThrough); + } }; } diff --git a/lib/features/composer/presentation/model/rich_text_style_type.dart b/lib/features/composer/presentation/model/rich_text_style_type.dart index 694ee210e..4d6d9961e 100644 --- a/lib/features/composer/presentation/model/rich_text_style_type.dart +++ b/lib/features/composer/presentation/model/rich_text_style_type.dart @@ -4,7 +4,8 @@ import 'package:core/presentation/resources/image_paths.dart'; enum RichTextStyleType { bold, italic, - underline; + underline, + strikeThrough; String get commandAction { switch (this) { @@ -14,6 +15,8 @@ enum RichTextStyleType { return 'italic'; case underline: return 'underline'; + case strikeThrough: + return 'strikeThrough'; default: return ''; } @@ -27,6 +30,8 @@ enum RichTextStyleType { return imagePaths.icStyleItalic; case underline: return imagePaths.icStyleUnderline; + case strikeThrough: + return imagePaths.icStyleStrikeThrough; default: return ''; }