mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-13 06:30:51 +08:00
Editor: 'Discard Changes' -> Do not show confirmation dialog
It's annoying. This action is not easy to accidentally trigger.
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user