Journal/Markdown Editor: Change tick-mark back to cross when empty

When creating a new note, if some text is written and then removed, we
should update the icon accordingly. Ideally it would be awesome if this
could be done for any changes, but I think comparing the body of the
note after each change might be too expensive.
This commit is contained in:
Vishesh Handa
2020-05-31 09:56:28 +02:00
parent ef29186677
commit 327fddcae2
2 changed files with 16 additions and 8 deletions

View File

@ -109,10 +109,14 @@ class JournalEditorState extends State<JournalEditor> implements EditorState {
}
void _noteTextChanged() {
if (_noteModified) return;
setState(() {
_noteModified = true;
});
if (_noteModified && !widget.isNewNote) return;
var newState = !(widget.isNewNote && _textController.text.trim().isEmpty);
if (newState != _noteModified) {
setState(() {
_noteModified = newState;
});
}
}
@override

View File

@ -149,10 +149,14 @@ class MarkdownEditorState extends State<MarkdownEditor> implements EditorState {
}
void _noteTextChanged() {
if (_noteModified) return;
setState(() {
_noteModified = true;
});
if (_noteModified && !widget.isNewNote) return;
var newState = !(widget.isNewNote && _textController.text.trim().isEmpty);
if (newState != _noteModified) {
setState(() {
_noteModified = newState;
});
}
}
@override