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( final t = new Form(
builder: (context) { child: new Column(
final t = new Form( children: <Widget>[
child: new Column( new IconButton(
children: <Widget>[ icon: new Icon(Icons.date_range),
new IconButton(icon: new Icon(Icons.date_range), onPressed: 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) {
); setState(() {
newDate.then((newValue) { _zerodayslist.remove(entry);
setState(() { _zerodayslist.add(new Entry(newValue, entry.whatYouDid));
_zerodayslist.remove(entry);
_zerodayslist.add(
new Entry(newValue, entry.whatYouDid));
});
}); });
}), });
new TextFormField( }),
initialValue: entry.whatYouDid, new TextFormField(
onFieldSubmitted: (newValue) { initialValue: entry.whatYouDid,
setState((){ onFieldSubmitted: (newValue) {
_zerodayslist.remove(entry); setState(() {
_zerodayslist.add(new Entry(entry.date, newValue)); _zerodayslist.remove(entry);
}); _zerodayslist.add(new Entry(entry.date, newValue));
}, });
) },
], ),
), ],
); ),
return new Scaffold( );
appBar: new AppBar(title: new Text("Edit this entry")), return new Scaffold(
body: t, appBar: new AppBar(title: new Text("Edit this entry")),
); body: t,
}) floatingActionButton: new FloatingActionButton(onPressed: () {
); setState(() {_zerodayslist.remove(entry); });
Navigator.pop(context);
},
child: new Icon(Icons.delete)
),
);
}));
} }
@override @override
@ -131,4 +133,4 @@ class _NoZeroDaysState extends State<NoZeroDays> {
floatingActionButton: _buildFAB(), floatingActionButton: _buildFAB(),
); );
} }
} }