Editing notify

This commit is contained in:
LittleSheep 2024-04-16 22:45:22 +08:00
parent 964210cbe4
commit 718c715cae
4 changed files with 48 additions and 4 deletions

View File

@ -13,6 +13,7 @@
"edit": "Edit", "edit": "Edit",
"delete": "Delete", "delete": "Delete",
"action": "Action", "action": "Action",
"cancel": "Cancel",
"report": "Report", "report": "Report",
"reaction": "Reaction", "reaction": "Reaction",
"reactVerb": "React", "reactVerb": "React",
@ -27,6 +28,7 @@
"postIdentityNotify": "You will create this post as", "postIdentityNotify": "You will create this post as",
"postContentPlaceholder": "What's happened?!", "postContentPlaceholder": "What's happened?!",
"postDeleteConfirm": "Are you sure you want to delete this post? This operation cannot be revert!", "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.", "reactionAdded": "Your reaction has been added.",
"reactionRemoved": "Your reaction has been removed." "reactionRemoved": "Your reaction has been removed."
} }

View File

@ -13,6 +13,7 @@
"edit": "编辑", "edit": "编辑",
"delete": "删除", "delete": "删除",
"action": "操作", "action": "操作",
"cancel": "取消",
"report": "举报", "report": "举报",
"reaction": "反应", "reaction": "反应",
"reactVerb": "作出反应", "reactVerb": "作出反应",
@ -27,6 +28,7 @@
"postIdentityNotify": "你将会以该身份发表本帖子", "postIdentityNotify": "你将会以该身份发表本帖子",
"postContentPlaceholder": "发生什么事了?!", "postContentPlaceholder": "发生什么事了?!",
"postDeleteConfirm": "你确定要删除这篇帖子吗?这意味着这个帖子将永远被我们丢弃在硬盘海中!该操作不可被反转!", "postDeleteConfirm": "你确定要删除这篇帖子吗?这意味着这个帖子将永远被我们丢弃在硬盘海中!该操作不可被反转!",
"postEditNotify": "你正在修改一个已经发布了的帖子。",
"reactionAdded": "你的反应已被添加。", "reactionAdded": "你的反应已被添加。",
"reactionRemoved": "你的反应已被移除。" "reactionRemoved": "你的反应已被移除。"
} }

View File

@ -79,6 +79,12 @@ class _CommentEditorScreenState extends State<CommentEditorScreen> {
setState(() => _isSubmitting = false); setState(() => _isSubmitting = false);
} }
void cancelEditing() {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
}
@override @override
void initState() { void initState() {
if (widget.editing != null) { if (widget.editing != null) {
@ -94,6 +100,20 @@ class _CommentEditorScreenState extends State<CommentEditorScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final auth = context.read<AuthProvider>(); final auth = context.read<AuthProvider>();
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( return IndentWrapper(
hideDrawer: true, hideDrawer: true,
title: AppLocalizations.of(context)!.newComment, title: AppLocalizations.of(context)!.newComment,
@ -146,6 +166,7 @@ class _CommentEditorScreenState extends State<CommentEditorScreen> {
), ),
), ),
), ),
widget.editing != null ? editingBanner : Container(),
Container( Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(
border: Border( border: Border(

View File

@ -69,6 +69,12 @@ class _MomentEditorScreenState extends State<MomentEditorScreen> {
setState(() => _isSubmitting = false); setState(() => _isSubmitting = false);
} }
void cancelEditing() {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
}
@override @override
void initState() { void initState() {
if (widget.editing != null) { if (widget.editing != null) {
@ -84,6 +90,20 @@ class _MomentEditorScreenState extends State<MomentEditorScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final auth = context.read<AuthProvider>(); final auth = context.read<AuthProvider>();
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( return IndentWrapper(
hideDrawer: true, hideDrawer: true,
title: AppLocalizations.of(context)!.newMoment, title: AppLocalizations.of(context)!.newMoment,
@ -121,8 +141,7 @@ class _MomentEditorScreenState extends State<MomentEditorScreen> {
const Divider(thickness: 0.3), const Divider(thickness: 0.3),
Expanded( Expanded(
child: Container( child: Container(
padding: padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: TextField( child: TextField(
maxLines: null, maxLines: null,
autofocus: true, autofocus: true,
@ -130,12 +149,12 @@ class _MomentEditorScreenState extends State<MomentEditorScreen> {
keyboardType: TextInputType.multiline, keyboardType: TextInputType.multiline,
controller: _textController, controller: _textController,
decoration: InputDecoration.collapsed( decoration: InputDecoration.collapsed(
hintText: hintText: AppLocalizations.of(context)!.postContentPlaceholder,
AppLocalizations.of(context)!.postContentPlaceholder,
), ),
), ),
), ),
), ),
widget.editing != null ? editingBanner : Container(),
Container( Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(
border: Border( border: Border(