Editor: 'Discard Changes' -> Do not show confirmation dialog

It's annoying. This action is not easy to accidentally trigger.
This commit is contained in:
Vishesh Handa
2020-05-18 23:58:25 +02:00
parent 8aa96c1b9c
commit e5cd707ac1

View File

@ -338,39 +338,10 @@ class NoteEditorState extends State<NoteEditor> {
void _discardChangesSelected(Note note) {
if (_noteModified(note)) {
showDialog(context: context, builder: _buildDiscardChangesAlertDialog);
} else {
Navigator.pop(context);
}
}
Widget _buildDiscardChangesAlertDialog(BuildContext context) {
var title = _isNewNote
? "Do you want to discard this?"
: "Do you want to ignore the changes?";
var editText = _isNewNote ? "Keep Writing" : "Keep Editing";
var discardText = _isNewNote ? "Discard" : "Discard Changes";
return AlertDialog(
title: Text(title),
actions: <Widget>[
FlatButton(
onPressed: () => Navigator.of(context).pop(false),
child: Text(editText),
),
FlatButton(
onPressed: () {
// FIXME: This shouldn't be required. Why is the original note modified?
note.data = originalNoteData;
}
Navigator.pop(context); // Alert box
Navigator.pop(context); // Note Editor
},
child: Text(discardText),
),
],
);
Navigator.pop(context);
}
void _editTagsSelected(Note _note) async {