From 65457afe698cc60e3f48d573215c02f35af03dce Mon Sep 17 00:00:00 2001 From: realth000 Date: Thu, 29 Feb 2024 02:23:11 +0800 Subject: [PATCH] feat(editor): Add experimental info hint for bbcode editor --- CHANGELOG.md | 7 ++++++ lib/features/post/view/post_edit_page.dart | 29 +++++++++++++++++++++- lib/i18n/strings.i18n.json | 5 ++++ lib/i18n/strings_zh-CN.i18n.json | 5 ++++ lib/i18n/strings_zh-TW.i18n.json | 5 ++++ 5 files changed, 50 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 032de980..6a22fdfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Added + +- 编辑:提供实验性的bbcode编辑器,支持所见即所得。 + - WIP: 显示文本样式包括粗体、斜体、下划线、删除线、颜色、背景色。 + - WIP: 支持使用markdown语法书写bbcode(默认关闭)。 + - WIP: 支持引用、表情、图片、网页链接、多级标题、有序/无序列表、代码块、折叠/展开、表格、分隔符。 + ### Fixed - 帖子: 依旧是修复了很多多余或缺少的空行。 diff --git a/lib/features/post/view/post_edit_page.dart b/lib/features/post/view/post_edit_page.dart index 2ae15bf4..c5639861 100644 --- a/lib/features/post/view/post_edit_page.dart +++ b/lib/features/post/view/post_edit_page.dart @@ -14,6 +14,7 @@ import 'package:tsdm_client/generated/i18n/strings.g.dart'; import 'package:tsdm_client/shared/models/models.dart'; import 'package:tsdm_client/utils/retry_button.dart'; import 'package:tsdm_client/utils/show_bottom_sheet.dart'; +import 'package:tsdm_client/utils/show_dialog.dart'; /// Default thread title text length (bytes size in utf-8 encoding). /// @@ -292,7 +293,11 @@ class _PostEditPageState extends State { return Row( children: [ IconButton( - icon: const Icon(Icons.science_outlined), + icon: Icon( + Icons.science_outlined, + color: + useExperimentalEditor ? Theme.of(context).primaryColor : null, + ), onPressed: () { setState(() { useExperimentalEditor = !useExperimentalEditor; @@ -355,6 +360,26 @@ class _PostEditPageState extends State { ); } + Widget _buildUsingExperimentalEditorHintRow(BuildContext context) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextButton.icon( + icon: const Icon(Icons.info_outline), + label: Text(context.t.bbcodeEditor.experimentalInfo), + onPressed: () async { + await showMessageSingleButtonDialog( + context: context, + title: context.t.bbcodeEditor.experimentalInfoTitle, + message: context.t.bbcodeEditor.experimentalInfoDetail, + ); + }, + ), + const Spacer(), + ], + ); + } + Widget _buildBody(BuildContext context) { return MultiBlocProvider( providers: [ @@ -468,6 +493,8 @@ class _PostEditPageState extends State { }, ), ), + if (useExperimentalEditor) + _buildUsingExperimentalEditorHintRow(context), _buildControlRow(context, state), ].insertBetween(sizedBoxW15H15), ); diff --git a/lib/i18n/strings.i18n.json b/lib/i18n/strings.i18n.json index 39610b58..990e2542 100644 --- a/lib/i18n/strings.i18n.json +++ b/lib/i18n/strings.i18n.json @@ -394,5 +394,10 @@ }, "bountyAnswerCard": { "title": "Best Answer" + }, + "bbcodeEditor": { + "experimentalInfo": "Experimental BBCode Editor", + "experimentalInfoTitle": "Experimental BBCode Editor", + "experimentalInfoDetail": "This bbcode editor supports WYSIWYG and provides convenient ways to add text styles and other rich text components.\nIt is still in experimental state which means: Already tested but may not behave as expected." } } diff --git a/lib/i18n/strings_zh-CN.i18n.json b/lib/i18n/strings_zh-CN.i18n.json index dfee923d..3678f3eb 100644 --- a/lib/i18n/strings_zh-CN.i18n.json +++ b/lib/i18n/strings_zh-CN.i18n.json @@ -394,5 +394,10 @@ }, "bountyAnswerCard": { "title": "最佳答案" + }, + "bbcodeEditor": { + "experimentalInfo": "实验性bbcode编辑器", + "experimentalInfoTitle": "实验性bbcode编辑器", + "experimentalInfoDetail": "此bbcode编辑器支持所见即所得,可以方便地添加文本样式和其他bbcode组件。\n但处于实验阶段:已经经过测试,但可能有bug。" } } diff --git a/lib/i18n/strings_zh-TW.i18n.json b/lib/i18n/strings_zh-TW.i18n.json index a00dc295..c1a06515 100644 --- a/lib/i18n/strings_zh-TW.i18n.json +++ b/lib/i18n/strings_zh-TW.i18n.json @@ -394,5 +394,10 @@ }, "bountyAnswerCard": { "title": "最佳答案" + }, + "bbcodeEditor": { + "experimentalInfo": "實驗性bbcode編輯器", + "experimentalInfoTitle": "實驗性bbcode編輯器", + "experimentalInfoDetail": "此bbcode編輯器支援所見即所得,可以方便地添加文字樣式和其他bbcode元件。\n但處於實驗階段:已經經過測試,但可能有bug。" } }