mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-27 09:06:43 +08:00
NoteEditor: Only enable 'Discard Changes' option if we have changes
Otherwise disable the button.
This commit is contained in:
@ -279,6 +279,9 @@ class ChecklistEditorState extends State<ChecklistEditor>
|
||||
_noteModified = true;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
bool get noteModified => _noteModified;
|
||||
}
|
||||
|
||||
typedef TextChangedFunction = void Function(String);
|
||||
|
@ -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),
|
||||
|
@ -123,6 +123,9 @@ class JournalEditorState extends State<JournalEditor> implements EditorState {
|
||||
_noteModified = true;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
bool get noteModified => _noteModified;
|
||||
}
|
||||
|
||||
class _NoteBodyEditor extends StatelessWidget {
|
||||
|
@ -163,6 +163,9 @@ class MarkdownEditorState extends State<MarkdownEditor> implements EditorState {
|
||||
_noteModified = true;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
bool get noteModified => _noteModified;
|
||||
}
|
||||
|
||||
class _NoteBodyEditor extends StatelessWidget {
|
||||
|
@ -119,6 +119,9 @@ class RawEditorState extends State<RawEditor> implements EditorState {
|
||||
_noteModified = true;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
bool get noteModified => _noteModified;
|
||||
}
|
||||
|
||||
class _NoteEditor extends StatelessWidget {
|
||||
|
Reference in New Issue
Block a user