mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 18:03:14 +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;
|
_noteModified = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get noteModified => _noteModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef TextChangedFunction = void Function(String);
|
typedef TextChangedFunction = void Function(String);
|
||||||
|
@ -26,6 +26,8 @@ abstract class Editor {
|
|||||||
abstract class EditorState {
|
abstract class EditorState {
|
||||||
Note getNote();
|
Note getNote();
|
||||||
Future<void> addImage(File file);
|
Future<void> addImage(File file);
|
||||||
|
|
||||||
|
bool get noteModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
class EditorAppBar extends StatelessWidget implements PreferredSizeWidget {
|
class EditorAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
@ -214,6 +216,7 @@ Widget _buildBottomMenuSheet(
|
|||||||
|
|
||||||
editor.discardChangesSelected(note);
|
editor.discardChangesSelected(note);
|
||||||
},
|
},
|
||||||
|
enabled: editorState.noteModified,
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(Icons.share),
|
leading: Icon(Icons.share),
|
||||||
|
@ -123,6 +123,9 @@ class JournalEditorState extends State<JournalEditor> implements EditorState {
|
|||||||
_noteModified = true;
|
_noteModified = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get noteModified => _noteModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
class _NoteBodyEditor extends StatelessWidget {
|
class _NoteBodyEditor extends StatelessWidget {
|
||||||
|
@ -163,6 +163,9 @@ class MarkdownEditorState extends State<MarkdownEditor> implements EditorState {
|
|||||||
_noteModified = true;
|
_noteModified = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get noteModified => _noteModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
class _NoteBodyEditor extends StatelessWidget {
|
class _NoteBodyEditor extends StatelessWidget {
|
||||||
|
@ -119,6 +119,9 @@ class RawEditorState extends State<RawEditor> implements EditorState {
|
|||||||
_noteModified = true;
|
_noteModified = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get noteModified => _noteModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
class _NoteEditor extends StatelessWidget {
|
class _NoteEditor extends StatelessWidget {
|
||||||
|
Reference in New Issue
Block a user