From bded32b02766dd37f92160a4ec51e9d767b9c88f Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Thu, 30 Jan 2020 19:28:16 +0100 Subject: [PATCH] TodoEditor: Add a 'Add Item' button at the bottom --- lib/editors/todo_editor.dart | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/editors/todo_editor.dart b/lib/editors/todo_editor.dart index d72a0b39..3da8ffeb 100644 --- a/lib/editors/todo_editor.dart +++ b/lib/editors/todo_editor.dart @@ -56,10 +56,14 @@ class TodoEditorState extends State implements EditorState { @override Widget build(BuildContext context) { - var todoItemTiles = []; + var todoItemTiles = []; todos.forEach((TodoItem todo) { todoItemTiles.add(_buildTile(todo)); }); + todoItemTiles.add(AddTodoItemButton( + key: UniqueKey(), + onPressed: () {}, + )); print("Building " + todos.toString()); Widget todoList = ReorderableListView( @@ -221,6 +225,32 @@ class _TodoItemTileState extends State { } } +class AddTodoItemButton extends StatelessWidget { + final Function onPressed; + + AddTodoItemButton({Key key, @required this.onPressed}) : super(key: key); + + @override + Widget build(BuildContext context) { + var style = Theme.of(context).textTheme.subhead; + + return ListTile( + dense: true, + leading: Row( + children: [ + Container(height: 24.0, width: 24.0), + IconButton( + icon: Icon(Icons.add), + onPressed: () {}, + ) + ], + mainAxisSize: MainAxisSize.min, + ), + title: Text("Add Item", style: style), + ); + } +} + // FIXME: The body needs to be scrollable // FIXME: Add a new todo button // FIXME: Fix padding issue with todo items