Still can't edit both parts, but reformatted and added delete functionality
This commit is contained in:
parent
67f115b798
commit
e54e8b7beb
1 changed files with 42 additions and 40 deletions
|
@ -66,46 +66,48 @@ class _NoZeroDaysState extends State<NoZeroDays> {
|
|||
}
|
||||
|
||||
void _editEntry(Entry entry) {
|
||||
Navigator.of(context).push(
|
||||
new MaterialPageRoute(
|
||||
builder: (context) {
|
||||
final t = new Form(
|
||||
child: new Column(
|
||||
children: <Widget>[
|
||||
new IconButton(icon: new Icon(Icons.date_range), onPressed:
|
||||
() {
|
||||
Future<DateTime> newDate = showDatePicker(
|
||||
context: (context),
|
||||
initialDate: entry.date,
|
||||
firstDate: new DateTime(DateTime.now().year),
|
||||
lastDate: new DateTime(DateTime.now().year + 1)
|
||||
);
|
||||
newDate.then((newValue) {
|
||||
setState(() {
|
||||
_zerodayslist.remove(entry);
|
||||
_zerodayslist.add(
|
||||
new Entry(newValue, entry.whatYouDid));
|
||||
});
|
||||
Navigator.of(context).push(new MaterialPageRoute(builder: (context) {
|
||||
final t = new Form(
|
||||
child: new Column(
|
||||
children: <Widget>[
|
||||
new IconButton(
|
||||
icon: new Icon(Icons.date_range),
|
||||
onPressed: () {
|
||||
Future<DateTime> newDate = showDatePicker(
|
||||
context: (context),
|
||||
initialDate: entry.date,
|
||||
firstDate: new DateTime(DateTime.now().year),
|
||||
lastDate: new DateTime(DateTime.now().year + 1));
|
||||
newDate.then((newValue) {
|
||||
setState(() {
|
||||
_zerodayslist.remove(entry);
|
||||
_zerodayslist.add(new Entry(newValue, entry.whatYouDid));
|
||||
});
|
||||
}),
|
||||
new TextFormField(
|
||||
initialValue: entry.whatYouDid,
|
||||
onFieldSubmitted: (newValue) {
|
||||
setState((){
|
||||
_zerodayslist.remove(entry);
|
||||
_zerodayslist.add(new Entry(entry.date, newValue));
|
||||
});
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(title: new Text("Edit this entry")),
|
||||
body: t,
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
}),
|
||||
new TextFormField(
|
||||
initialValue: entry.whatYouDid,
|
||||
onFieldSubmitted: (newValue) {
|
||||
setState(() {
|
||||
_zerodayslist.remove(entry);
|
||||
_zerodayslist.add(new Entry(entry.date, newValue));
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return new Scaffold(
|
||||
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
|
||||
|
@ -131,4 +133,4 @@ class _NoZeroDaysState extends State<NoZeroDays> {
|
|||
floatingActionButton: _buildFAB(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue