Add list support

This commit is contained in:
Jonas Franz 2018-09-15 19:40:59 +02:00
parent 08df1bf2c2
commit 0e6d7778ea
No known key found for this signature in database
GPG Key ID: 506AEEBE80BEDECD
4 changed files with 61 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

View File

@ -77,6 +77,13 @@ class HomePageState extends State<HomePage> {
new UserAccountsDrawerHeader(
accountEmail: const Text('jonas@try.vikunja.io'),
accountName: const Text('Jonas Franz'),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/graphics/hypnotize.png"),
repeat: ImageRepeat.repeat,
colorFilter: ColorFilter.mode(Theme.of(context).primaryColor, BlendMode.multiply)
),
),
),
new Expanded(
child: ListView(

View File

@ -10,17 +10,66 @@ class ListPage extends StatefulWidget {
}
class _ListPageState extends State<ListPage> {
Map<String, bool> items = {
"Butter": true,
"Milch": false
};
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: new Text(widget.listName),
),
body: Center(
child: RaisedButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text("Go back")),
body: ListView(
padding: EdgeInsets.symmetric(vertical: 8.0),
children: ListTile.divideTiles(context: context,
tiles: items.map((item, checked) =>
MapEntry(item, CheckboxListTile(
title: Text(item),
controlAffinity: ListTileControlAffinity.leading,
value: checked,
onChanged: (bool value) => setState(() => items[item] = value),
))
).values
).toList(),
),
floatingActionButton: FloatingActionButton(onPressed: () => _addItem(), child: Icon(Icons.add)),
);
}
_addItem() {
var textController = new TextEditingController();
showDialog(
context: context,
child: new AlertDialog(
contentPadding: const EdgeInsets.all(16.0),
content: new Row(children: <Widget>[
Expanded(
child: new TextField(
autofocus: true,
decoration: new InputDecoration(
labelText: 'List Item',
hintText: 'eg. Milk'),
controller: textController,
),
)
]),
actions: <Widget>[
new FlatButton(
child: const Text('CANCEL'),
onPressed: () => Navigator.pop(context),
),
new FlatButton(
child: const Text('ADD'),
onPressed: () {
if (textController.text.isNotEmpty)
setState(() => items[textController.text] = false);
Navigator.pop(context);
},
)
],
),
);
}
}

View File

@ -78,6 +78,7 @@ flutter:
# see https://flutter.io/custom-fonts/#from-packages
assets:
- assets/graphics/background.jpg
- assets/graphics/hypnotize.png
fonts:
- family: Quicksand
fonts: