From 5dcc92fadbfd022c1beec5f9feff46433ce1170d Mon Sep 17 00:00:00 2001 From: ashilkn Date: Wed, 30 Nov 2022 12:29:26 +0530 Subject: [PATCH] BottomActionBar : unselect all & close BottomActionBar on cancel --- .../bottom_action_bar_widget.dart | 14 +++++++++----- lib/ui/viewer/gallery/collection_page.dart | 7 ++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/ui/components/bottom_action_bar/bottom_action_bar_widget.dart b/lib/ui/components/bottom_action_bar/bottom_action_bar_widget.dart index a5bedc6fa..44473a83c 100644 --- a/lib/ui/components/bottom_action_bar/bottom_action_bar_widget.dart +++ b/lib/ui/components/bottom_action_bar/bottom_action_bar_widget.dart @@ -15,12 +15,14 @@ class BottomActionBarWidget extends StatefulWidget { final Widget expandedMenu; final bool showBottomActionBarByDefault; final SelectedFiles? selectedFiles; + final VoidCallback? onCancel; const BottomActionBarWidget({ required this.expandedMenu, required this.showBottomActionBarByDefault, this.selectedFiles, this.text, this.iconButtons, + this.onCancel, super.key, }); @@ -55,12 +57,13 @@ class _BottomActionBarWidgetState extends State { filter: ImageFilter.blur(sigmaX: blurBase, sigmaY: blurBase), child: Container( color: colorScheme.backdropBase, - padding: EdgeInsets.only( + padding: const EdgeInsets.only( top: 4, - bottom: !_expandableController.expanded && - ((widget.selectedFiles?.files.isNotEmpty) ?? false) - ? 24 - : 36, + // bottom: !_expandableController.expanded && + // ((widget.selectedFiles?.files.isNotEmpty) ?? false) + // ? 24 + // : 36, + bottom: 24, ), child: Column( mainAxisSize: MainAxisSize.min, @@ -87,6 +90,7 @@ class _BottomActionBarWidgetState extends State { onTap: () { //unselect all files here //or collapse the expansion panel + widget.onCancel?.call(); _expandableController.value = false; }, child: Container( diff --git a/lib/ui/viewer/gallery/collection_page.dart b/lib/ui/viewer/gallery/collection_page.dart index 2db59f708..f2c2ab4bc 100644 --- a/lib/ui/viewer/gallery/collection_page.dart +++ b/lib/ui/viewer/gallery/collection_page.dart @@ -116,12 +116,17 @@ class _CollectionPageState extends State { bottom: _bottomPosition.value, right: 0, left: 0, - duration: const Duration(milliseconds: 200), + duration: const Duration(milliseconds: 400), child: BottomActionBarWidget( selectedFiles: _selectedFiles, showBottomActionBarByDefault: false, expandedMenu: const SizedBox(height: 150), text: "3 selected", + onCancel: () { + if (_selectedFiles.files.isNotEmpty) { + _selectedFiles.clearAll(); + } + }, iconButtons: const [ IconButtonWidget( icon: Icons.delete_outlined,