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,11 +109,15 @@ class JournalEditorState extends State<JournalEditor> implements EditorState {
}
void _noteTextChanged() {
if (_noteModified) return;
if (_noteModified && !widget.isNewNote) return;
var newState = !(widget.isNewNote && _textController.text.trim().isEmpty);
if (newState != _noteModified) {
setState(() {
_noteModified = true;
_noteModified = newState;
});
}
}
@override
Future<void> addImage(File file) async {

View File

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