diff --git a/lib/note_viewer.dart b/lib/note_viewer.dart index f25c5fe3..03162679 100644 --- a/lib/note_viewer.dart +++ b/lib/note_viewer.dart @@ -1,5 +1,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:journal/state_container.dart'; import 'package:journal/widgets/note_header.dart'; import 'note.dart'; @@ -40,17 +41,24 @@ class NoteBrowsingScreenState extends State { return Scaffold( appBar: AppBar( title: Text('TIMELINE'), + actions: [ + IconButton( + icon: Icon(Icons.delete), + onPressed: () { + final stateContainer = StateContainer.of(context); + Note note = widget.notes[_currentIndex()]; + stateContainer.removeNote(note); + Navigator.pop(context); + }, + ), + ], ), body: pageView, floatingActionButton: FloatingActionButton( child: Icon(Icons.edit), onPressed: () { var route = MaterialPageRoute(builder: (context) { - int currentIndex = pageController.page.toInt(); - assert(currentIndex >= 0); - assert(currentIndex < widget.notes.length); - - Note note = widget.notes[currentIndex]; + Note note = widget.notes[_currentIndex()]; return NoteEditor.fromNote(note); }); Navigator.of(context).push(route); @@ -58,6 +66,13 @@ class NoteBrowsingScreenState extends State { ), ); } + + int _currentIndex() { + int currentIndex = pageController.page.toInt(); + assert(currentIndex >= 0); + assert(currentIndex < widget.notes.length); + return currentIndex; + } } class NoteViewer extends StatelessWidget {