mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 02:07:39 +08:00
TodoEditor: Only show remove buttons when that item has focus
Looks less cluttered.
This commit is contained in:
@ -170,11 +170,15 @@ class TodoItemTile extends StatefulWidget {
|
|||||||
|
|
||||||
class _TodoItemTileState extends State<TodoItemTile> {
|
class _TodoItemTileState extends State<TodoItemTile> {
|
||||||
TextEditingController _textController;
|
TextEditingController _textController;
|
||||||
|
FocusNode _focusNode = FocusNode();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_textController = TextEditingController(text: widget.todo.body);
|
_textController = TextEditingController(text: widget.todo.body);
|
||||||
|
_focusNode.addListener(() {
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -182,6 +186,7 @@ class _TodoItemTileState extends State<TodoItemTile> {
|
|||||||
var style = Theme.of(context).textTheme.subhead;
|
var style = Theme.of(context).textTheme.subhead;
|
||||||
|
|
||||||
var editor = TextField(
|
var editor = TextField(
|
||||||
|
focusNode: _focusNode,
|
||||||
keyboardType: TextInputType.text,
|
keyboardType: TextInputType.text,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: style,
|
style: style,
|
||||||
@ -194,6 +199,7 @@ class _TodoItemTileState extends State<TodoItemTile> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
|
dense: true,
|
||||||
leading: Row(
|
leading: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(height: 24.0, width: 24.0, child: Icon(Icons.reorder)),
|
Container(height: 24.0, width: 24.0, child: Icon(Icons.reorder)),
|
||||||
@ -205,11 +211,12 @@ class _TodoItemTileState extends State<TodoItemTile> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
),
|
),
|
||||||
title: editor,
|
title: editor,
|
||||||
trailing: IconButton(
|
trailing: _focusNode.hasFocus
|
||||||
icon: Icon(Icons.cancel),
|
? IconButton(
|
||||||
onPressed: widget.todoRemoved,
|
icon: Icon(Icons.cancel),
|
||||||
),
|
onPressed: widget.todoRemoved,
|
||||||
dense: true,
|
)
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -217,4 +224,4 @@ class _TodoItemTileState extends State<TodoItemTile> {
|
|||||||
// 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
|
||||||
// FIXME: Only show 'x' when active
|
// FIXME: When removing an item the focus should jump to the next/prev in line
|
||||||
|
Reference in New Issue
Block a user