Editing notify

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

View File

@ -79,6 +79,12 @@ class _CommentEditorScreenState extends State<CommentEditorScreen> {
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<CommentEditorScreen> {
Widget build(BuildContext context) {
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(
hideDrawer: true,
title: AppLocalizations.of(context)!.newComment,
@ -146,6 +166,7 @@ class _CommentEditorScreenState extends State<CommentEditorScreen> {
),
),
),
widget.editing != null ? editingBanner : Container(),
Container(
decoration: const BoxDecoration(
border: Border(

View File

@ -69,6 +69,12 @@ class _MomentEditorScreenState extends State<MomentEditorScreen> {
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<MomentEditorScreen> {
Widget build(BuildContext context) {
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(
hideDrawer: true,
title: AppLocalizations.of(context)!.newMoment,
@ -121,8 +141,7 @@ class _MomentEditorScreenState extends State<MomentEditorScreen> {
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<MomentEditorScreen> {
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(