From 99392955c957f01dc22951e973e76eb27da213b4 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Fri, 18 Jan 2019 15:45:02 +0100 Subject: [PATCH] Note Editing: Show a different message Also allow us to go back if the note has not been modified. I say note but I really mean 'journal'. These two words are used interchangably. --- lib/note_editor.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/note_editor.dart b/lib/note_editor.dart index c723f3b0..84a6798b 100644 --- a/lib/note_editor.dart +++ b/lib/note_editor.dart @@ -46,6 +46,12 @@ class NoteEditorState extends State { if (noteContent.isEmpty) { return true; } + if (note != null) { + if (noteContent == note.body) { + return true; + } + } + return showDialog( context: context, builder: _buildAlertDialog, @@ -97,10 +103,14 @@ class NoteEditorState extends State { } Widget _buildAlertDialog(BuildContext context) { + var title = newNote + ? "Do you want to discard the entry" + : "Do you want to discard the changes?"; + return new AlertDialog( // FIXME: Change this to 'Save' vs 'Discard' title: new Text('Are you sure?'), - content: new Text('Do you want to discard the entry'), + content: new Text(title), actions: [ new FlatButton( onPressed: () => Navigator.of(context).pop(false),