NoteEditor: Only enable 'Discard Changes' option if we have changes

Otherwise disable the button.
This commit is contained in:
Vishesh Handa
2020-05-19 00:02:07 +02:00
parent e5cd707ac1
commit 4208b05bb4
5 changed files with 15 additions and 0 deletions

View File

@ -279,6 +279,9 @@ class ChecklistEditorState extends State<ChecklistEditor>
_noteModified = true;
});
}
@override
bool get noteModified => _noteModified;
}
typedef TextChangedFunction = void Function(String);

View File

@ -26,6 +26,8 @@ abstract class Editor {
abstract class EditorState {
Note getNote();
Future<void> addImage(File file);
bool get noteModified;
}
class EditorAppBar extends StatelessWidget implements PreferredSizeWidget {
@ -214,6 +216,7 @@ Widget _buildBottomMenuSheet(
editor.discardChangesSelected(note);
},
enabled: editorState.noteModified,
),
ListTile(
leading: Icon(Icons.share),

View File

@ -123,6 +123,9 @@ class JournalEditorState extends State<JournalEditor> implements EditorState {
_noteModified = true;
});
}
@override
bool get noteModified => _noteModified;
}
class _NoteBodyEditor extends StatelessWidget {

View File

@ -163,6 +163,9 @@ class MarkdownEditorState extends State<MarkdownEditor> implements EditorState {
_noteModified = true;
});
}
@override
bool get noteModified => _noteModified;
}
class _NoteBodyEditor extends StatelessWidget {

View File

@ -119,6 +119,9 @@ class RawEditorState extends State<RawEditor> implements EditorState {
_noteModified = true;
});
}
@override
bool get noteModified => _noteModified;
}
class _NoteEditor extends StatelessWidget {