GestureDectector to clear keyboard
This commit is contained in:
parent
a7f4838ce9
commit
5bb8060a95
|
|
@ -53,73 +53,76 @@ class _CheckList extends State<CheckList> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: implement build
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text((listData != null) ? listData!.name : 'Check List: $id'),
|
||||
actions: (listData != null && listData!.isTemplate! && !_editable)
|
||||
? [
|
||||
IconButton(
|
||||
onPressed: () => _toggleEditable(),
|
||||
icon: const Icon(Icons.lock))
|
||||
]
|
||||
: (listData != null && listData!.isTemplate!)
|
||||
? [
|
||||
IconButton(
|
||||
onPressed: () => _toggleEditable(),
|
||||
icon: const Icon(Icons.lock_open))
|
||||
]
|
||||
: [],
|
||||
),
|
||||
body: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
_loadListData();
|
||||
_loadList();
|
||||
},
|
||||
child: ListView.builder(
|
||||
itemCount: list.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Card(
|
||||
child: CheckboxListTile(
|
||||
title: TextFormField(
|
||||
enabled: (listData != null &&
|
||||
(!listData!.isTemplate! || _editable)),
|
||||
decoration: InputDecoration(border: InputBorder.none),
|
||||
initialValue: list[index].text,
|
||||
onChanged: (value) {
|
||||
list[index].text = value;
|
||||
_updateItem(list[index]);
|
||||
},
|
||||
),
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
value: list[index].value,
|
||||
onChanged:
|
||||
(listData != null && (!listData!.isTemplate! || _editable))
|
||||
? ((value) {
|
||||
_updateItem(list[index]);
|
||||
setState(() {
|
||||
list[index].value = value!;
|
||||
});
|
||||
})
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
return GestureDetector(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text((listData != null) ? listData!.name : 'Check List: $id'),
|
||||
actions: (listData != null && listData!.isTemplate! && !_editable)
|
||||
? [
|
||||
IconButton(
|
||||
onPressed: () => _toggleEditable(),
|
||||
icon: const Icon(Icons.lock))
|
||||
]
|
||||
: (listData != null && listData!.isTemplate!)
|
||||
? [
|
||||
IconButton(
|
||||
onPressed: () => _toggleEditable(),
|
||||
icon: const Icon(Icons.lock_open))
|
||||
]
|
||||
: [],
|
||||
),
|
||||
body: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
_loadListData();
|
||||
_loadList();
|
||||
},
|
||||
child: ListView.builder(
|
||||
itemCount: list.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Card(
|
||||
child: CheckboxListTile(
|
||||
title: TextFormField(
|
||||
enabled: (listData != null &&
|
||||
(!listData!.isTemplate! || _editable)),
|
||||
decoration: InputDecoration(border: InputBorder.none),
|
||||
initialValue: list[index].text,
|
||||
onChanged: (value) {
|
||||
list[index].text = value;
|
||||
_updateItem(list[index]);
|
||||
},
|
||||
),
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
value: list[index].value,
|
||||
onChanged: (listData != null &&
|
||||
(!listData!.isTemplate! || _editable))
|
||||
? ((value) {
|
||||
_updateItem(list[index]);
|
||||
setState(() {
|
||||
list[index].value = value!;
|
||||
});
|
||||
})
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
if (listData!.isTemplate! && !_editable) {
|
||||
ScaffoldMessenger.of(context)
|
||||
..clearSnackBars()
|
||||
..showSnackBar(SnackBar(content: Text("Template is locked")));
|
||||
return;
|
||||
}
|
||||
// TODO implment adding items to lists
|
||||
},
|
||||
child: const Icon(Icons.check_box_outlined),
|
||||
tooltip: "Add Item",
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
if (listData!.isTemplate! && !_editable) {
|
||||
ScaffoldMessenger.of(context)
|
||||
..clearSnackBars()
|
||||
..showSnackBar(SnackBar(content: Text("Template is locked")));
|
||||
return;
|
||||
}
|
||||
// TODO implment adding items to lists
|
||||
},
|
||||
child: const Icon(Icons.check_box_outlined),
|
||||
tooltip: "Add Item",
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue