From aac93df46ba45f5b38754d201fba000eda450852 Mon Sep 17 00:00:00 2001 From: andrei Date: Wed, 3 Nov 2021 18:07:00 -0400 Subject: [PATCH] updated locking icons and functionality --- lib/box_checker.dart | 1 + lib/check_list.dart | 28 ++++++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/lib/box_checker.dart b/lib/box_checker.dart index 789eb1b..6077ed6 100644 --- a/lib/box_checker.dart +++ b/lib/box_checker.dart @@ -20,6 +20,7 @@ class BoxChecker extends StatelessWidget { cardColor: Colors.grey[800], scaffoldBackgroundColor: Colors.black12, shadowColor: Colors.black38, + toggleableActiveColor: Colors.blue, colorScheme: ColorScheme.fromSwatch( primarySwatch: Colors.blue, ), diff --git a/lib/check_list.dart b/lib/check_list.dart index 7b3969e..c66491a 100644 --- a/lib/check_list.dart +++ b/lib/check_list.dart @@ -56,13 +56,19 @@ class _CheckList extends State { return Scaffold( appBar: AppBar( title: Text((listData != null) ? listData!.name : 'Check List: $id'), - actions: [ - (listData != null && listData!.isTemplate! && !_editable) - ? IconButton( - onPressed: () => _toggleEditable(), icon: Icon(Icons.edit)) - : IconButton( - onPressed: () => _toggleEditable(), icon: Icon(Icons.save)), - ], + 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: ListView.builder( itemCount: list.length, @@ -87,9 +93,15 @@ class _CheckList extends State { ), 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), + child: const Icon(Icons.check_box_outlined), tooltip: "Add Item", ), floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,