refactored lock button

This commit is contained in:
andrei
2021-11-04 22:36:27 -04:00
parent a613292095
commit d6dbe5234e

View File

@@ -63,6 +63,13 @@ class _CheckList extends State<CheckList> {
super.initState(); super.initState();
} }
Widget iconButton() {
return IconButton(
onPressed: () => _toggleEditable(),
icon: Icon(_editable ? Icons.lock_open : Icons.lock),
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return GestureDetector(
@@ -70,19 +77,8 @@ class _CheckList extends State<CheckList> {
child: Scaffold( child: Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text((listData != null) ? listData!.name : 'Check List: $id'), title: Text((listData != null) ? listData!.name : 'Check List: $id'),
actions: (listData != null && listData!.isTemplate! && !_editable) actions:
? [ (listData != null && listData!.isTemplate!) ? [iconButton()] : [],
IconButton(
onPressed: () => _toggleEditable(),
icon: const Icon(Icons.lock))
]
: (listData != null && listData!.isTemplate!)
? [
IconButton(
onPressed: () => _toggleEditable(),
icon: const Icon(Icons.lock_open))
]
: [],
), ),
body: RefreshIndicator( body: RefreshIndicator(
onRefresh: () async { onRefresh: () async {