mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 10:17:16 +08:00
Note Deletion: Implement undo
This commit is contained in:
@ -69,7 +69,6 @@ class StateContainerState extends State<StateContainer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void addNote(Note note) {
|
void addNote(Note note) {
|
||||||
print("Adding a note " + note.toString());
|
|
||||||
setState(() {
|
setState(() {
|
||||||
note.id = new Uuid().v4();
|
note.id = new Uuid().v4();
|
||||||
appState.notes.insert(0, note);
|
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!
|
// FIXME: Implement this!
|
||||||
void updateNote(Note note) {
|
void updateNote(Note note) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@ -38,9 +38,13 @@ class JournalList extends StatelessWidget {
|
|||||||
onDismissed: (direction) {
|
onDismissed: (direction) {
|
||||||
container.removeNote(note);
|
container.removeNote(note);
|
||||||
|
|
||||||
Scaffold
|
Scaffold.of(context).showSnackBar(new SnackBar(
|
||||||
.of(context)
|
content: new Text("Note deleted"),
|
||||||
.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