diff --git a/lib/state_container.dart b/lib/state_container.dart index 5558cf38..e25ad532 100644 --- a/lib/state_container.dart +++ b/lib/state_container.dart @@ -69,7 +69,6 @@ class StateContainerState extends State { } 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 { }); } + void insertNote(int index, Note note) { + setState(() { + appState.notes.insert(index, note); + }); + } + // FIXME: Implement this! void updateNote(Note note) { setState(() { diff --git a/lib/widgets/journal_list.dart b/lib/widgets/journal_list.dart index 59af0b4a..2631bd56 100644 --- a/lib/widgets/journal_list.dart +++ b/lib/widgets/journal_list.dart @@ -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), + ), + )); }, ); },