diff --git a/lib/i18n/app_en.arb b/lib/i18n/app_en.arb index 7827a82..85d3e3a 100644 --- a/lib/i18n/app_en.arb +++ b/lib/i18n/app_en.arb @@ -13,6 +13,7 @@ "edit": "Edit", "delete": "Delete", "action": "Action", + "cancel": "Cancel", "report": "Report", "reaction": "Reaction", "reactVerb": "React", @@ -27,6 +28,7 @@ "postIdentityNotify": "You will create this post as", "postContentPlaceholder": "What's happened?!", "postDeleteConfirm": "Are you sure you want to delete this post? This operation cannot be revert!", + "postEditNotify": "You are about editing a post that already published.", "reactionAdded": "Your reaction has been added.", "reactionRemoved": "Your reaction has been removed." } diff --git a/lib/i18n/app_zh.arb b/lib/i18n/app_zh.arb index cca4b8c..81e58d9 100644 --- a/lib/i18n/app_zh.arb +++ b/lib/i18n/app_zh.arb @@ -13,6 +13,7 @@ "edit": "编辑", "delete": "删除", "action": "操作", + "cancel": "取消", "report": "举报", "reaction": "反应", "reactVerb": "作出反应", @@ -27,6 +28,7 @@ "postIdentityNotify": "你将会以该身份发表本帖子", "postContentPlaceholder": "发生什么事了?!", "postDeleteConfirm": "你确定要删除这篇帖子吗?这意味着这个帖子将永远被我们丢弃在硬盘海中!该操作不可被反转!", + "postEditNotify": "你正在修改一个已经发布了的帖子。", "reactionAdded": "你的反应已被添加。", "reactionRemoved": "你的反应已被移除。" } \ No newline at end of file diff --git a/lib/screens/posts/comment_editor.dart b/lib/screens/posts/comment_editor.dart index e13a7e9..e76d9eb 100644 --- a/lib/screens/posts/comment_editor.dart +++ b/lib/screens/posts/comment_editor.dart @@ -79,6 +79,12 @@ class _CommentEditorScreenState extends State { setState(() => _isSubmitting = false); } + void cancelEditing() { + if (Navigator.canPop(context)) { + Navigator.pop(context); + } + } + @override void initState() { if (widget.editing != null) { @@ -94,6 +100,20 @@ class _CommentEditorScreenState extends State { Widget build(BuildContext context) { final auth = context.read(); + final editingBanner = MaterialBanner( + padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 20), + leading: const Icon(Icons.edit_note), + backgroundColor: const Color(0xFFE0E0E0), + dividerColor: const Color.fromARGB(1, 0, 0, 0), + content: Text(AppLocalizations.of(context)!.postEditNotify), + actions: [ + TextButton( + child: Text(AppLocalizations.of(context)!.cancel), + onPressed: () => cancelEditing(), + ), + ], + ); + return IndentWrapper( hideDrawer: true, title: AppLocalizations.of(context)!.newComment, @@ -146,6 +166,7 @@ class _CommentEditorScreenState extends State { ), ), ), + widget.editing != null ? editingBanner : Container(), Container( decoration: const BoxDecoration( border: Border( diff --git a/lib/screens/posts/moment_editor.dart b/lib/screens/posts/moment_editor.dart index 7179a67..dc92296 100644 --- a/lib/screens/posts/moment_editor.dart +++ b/lib/screens/posts/moment_editor.dart @@ -69,6 +69,12 @@ class _MomentEditorScreenState extends State { setState(() => _isSubmitting = false); } + void cancelEditing() { + if (Navigator.canPop(context)) { + Navigator.pop(context); + } + } + @override void initState() { if (widget.editing != null) { @@ -84,6 +90,20 @@ class _MomentEditorScreenState extends State { Widget build(BuildContext context) { final auth = context.read(); + final editingBanner = MaterialBanner( + padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 20), + leading: const Icon(Icons.edit_note), + backgroundColor: const Color(0xFFE0E0E0), + dividerColor: const Color.fromARGB(1, 0, 0, 0), + content: Text(AppLocalizations.of(context)!.postEditNotify), + actions: [ + TextButton( + child: Text(AppLocalizations.of(context)!.cancel), + onPressed: () => cancelEditing(), + ), + ], + ); + return IndentWrapper( hideDrawer: true, title: AppLocalizations.of(context)!.newMoment, @@ -121,8 +141,7 @@ class _MomentEditorScreenState extends State { const Divider(thickness: 0.3), Expanded( child: Container( - padding: - const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), child: TextField( maxLines: null, autofocus: true, @@ -130,12 +149,12 @@ class _MomentEditorScreenState extends State { keyboardType: TextInputType.multiline, controller: _textController, decoration: InputDecoration.collapsed( - hintText: - AppLocalizations.of(context)!.postContentPlaceholder, + hintText: AppLocalizations.of(context)!.postContentPlaceholder, ), ), ), ), + widget.editing != null ? editingBanner : Container(), Container( decoration: const BoxDecoration( border: Border(