mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 02:07:39 +08:00
Note Deletion: Implement undo
This commit is contained in:
@ -69,7 +69,6 @@ class StateContainerState extends State<StateContainer> {
|
||||
}
|
||||
|
||||
void addNote(Note note) {
|
||||
print("Adding a note " + note.toString());
|
||||
setState(() {
|
||||
note.id = new Uuid().v4();
|
||||
appState.notes.insert(0, note);
|
||||
@ -82,6 +81,12 @@ class StateContainerState extends State<StateContainer> {
|
||||
});
|
||||
}
|
||||
|
||||
void insertNote(int index, Note note) {
|
||||
setState(() {
|
||||
appState.notes.insert(index, note);
|
||||
});
|
||||
}
|
||||
|
||||
// FIXME: Implement this!
|
||||
void updateNote(Note note) {
|
||||
setState(() {
|
||||
|
@ -38,9 +38,13 @@ class JournalList extends StatelessWidget {
|
||||
onDismissed: (direction) {
|
||||
container.removeNote(note);
|
||||
|
||||
Scaffold
|
||||
.of(context)
|
||||
.showSnackBar(new SnackBar(content: new Text("Note deleted")));
|
||||
Scaffold.of(context).showSnackBar(new SnackBar(
|
||||
content: new Text("Note deleted"),
|
||||
action: new SnackBarAction(
|
||||
label: 'Undo',
|
||||
onPressed: () => container.insertNote(i, note),
|
||||
),
|
||||
));
|
||||
},
|
||||
);
|
||||
},
|
||||
|
Reference in New Issue
Block a user