Still can't edit both parts, but reformatted and added delete functionality

This commit is contained in:
anthonycicc 2018-05-12 14:39:35 -04:00
parent 67f115b798
commit e54e8b7beb

View file

@ -66,46 +66,48 @@ class _NoZeroDaysState extends State<NoZeroDays> {
} }
void _editEntry(Entry entry) { void _editEntry(Entry entry) {
Navigator.of(context).push( Navigator.of(context).push(new MaterialPageRoute(builder: (context) {
new MaterialPageRoute(
builder: (context) {
final t = new Form( final t = new Form(
child: new Column( child: new Column(
children: <Widget>[ children: <Widget>[
new IconButton(icon: new Icon(Icons.date_range), onPressed: new IconButton(
() { icon: new Icon(Icons.date_range),
onPressed: () {
Future<DateTime> newDate = showDatePicker( Future<DateTime> newDate = showDatePicker(
context: (context), context: (context),
initialDate: entry.date, initialDate: entry.date,
firstDate: new DateTime(DateTime.now().year), firstDate: new DateTime(DateTime.now().year),
lastDate: new DateTime(DateTime.now().year + 1) lastDate: new DateTime(DateTime.now().year + 1));
);
newDate.then((newValue) { newDate.then((newValue) {
setState(() { setState(() {
_zerodayslist.remove(entry); _zerodayslist.remove(entry);
_zerodayslist.add( _zerodayslist.add(new Entry(newValue, entry.whatYouDid));
new Entry(newValue, entry.whatYouDid));
}); });
}); });
}), }),
new TextFormField( new TextFormField(
initialValue: entry.whatYouDid, initialValue: entry.whatYouDid,
onFieldSubmitted: (newValue) { onFieldSubmitted: (newValue) {
setState((){ setState(() {
_zerodayslist.remove(entry); _zerodayslist.remove(entry);
_zerodayslist.add(new Entry(entry.date, newValue)); _zerodayslist.add(new Entry(entry.date, newValue));
}); });
}, },
) ),
], ],
), ),
); );
return new Scaffold( return new Scaffold(
appBar: new AppBar(title: new Text("Edit this entry")), appBar: new AppBar(title: new Text("Edit this entry")),
body: t, body: t,
floatingActionButton: new FloatingActionButton(onPressed: () {
setState(() {_zerodayslist.remove(entry); });
Navigator.pop(context);
},
child: new Icon(Icons.delete)
),
); );
}) }));
);
} }
@override @override