refactored lock button

This commit is contained in:
andrei 2021-11-04 22:36:27 -04:00
parent a613292095
commit d6dbe5234e
1 changed files with 9 additions and 13 deletions

View File

@ -63,6 +63,13 @@ class _CheckList extends State<CheckList> {
super.initState();
}
Widget iconButton() {
return IconButton(
onPressed: () => _toggleEditable(),
icon: Icon(_editable ? Icons.lock_open : Icons.lock),
);
}
@override
Widget build(BuildContext context) {
return GestureDetector(
@ -70,19 +77,8 @@ class _CheckList extends State<CheckList> {
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))
]
: [],
actions:
(listData != null && listData!.isTemplate!) ? [iconButton()] : [],
),
body: RefreshIndicator(
onRefresh: () async {