TodoEditor: Add a 'Add Item' button at the bottom

This commit is contained in:
Vishesh Handa
2020-01-30 19:28:16 +01:00
parent 698e741851
commit bded32b027

View File

@ -56,10 +56,14 @@ class TodoEditorState extends State<TodoEditor> implements EditorState {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var todoItemTiles = <TodoItemTile>[]; var todoItemTiles = <Widget>[];
todos.forEach((TodoItem todo) { todos.forEach((TodoItem todo) {
todoItemTiles.add(_buildTile(todo)); todoItemTiles.add(_buildTile(todo));
}); });
todoItemTiles.add(AddTodoItemButton(
key: UniqueKey(),
onPressed: () {},
));
print("Building " + todos.toString()); print("Building " + todos.toString());
Widget todoList = ReorderableListView( Widget todoList = ReorderableListView(
@ -221,6 +225,32 @@ class _TodoItemTileState extends State<TodoItemTile> {
} }
} }
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: <Widget>[
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: The body needs to be scrollable
// FIXME: Add a new todo button // FIXME: Add a new todo button
// FIXME: Fix padding issue with todo items // FIXME: Fix padding issue with todo items