MarkdownEditor: Handle title change marking note as modified

This commit is contained in:
Vishesh Handa
2021-02-02 16:25:43 +01:00
parent 8c3abe7b65
commit 350fbb1ccf

View File

@ -104,7 +104,7 @@ class MarkdownEditorState extends State<MarkdownEditor>
children: <Widget>[
NoteTitleEditor(
_titleTextController,
_noteTextChanged,
_noteTitleTextChanged,
),
NoteBodyEditor(
textController: _textController,
@ -176,6 +176,20 @@ class MarkdownEditorState extends State<MarkdownEditor>
notifyListeners();
}
void _noteTitleTextChanged() {
if (_noteModified && !widget.editMode) return;
var newState =
!(widget.editMode && _titleTextController.text.trim().isEmpty);
if (newState != _noteModified) {
setState(() {
_noteModified = newState;
});
}
notifyListeners();
}
void _applyHeuristics() {
var selection = _textController.selection;
if (selection.baseOffset != selection.extentOffset) {