浏览代码

BottomActionBar : unselect all & close BottomActionBar on cancel

ashilkn 2 年之前
父节点
当前提交
5dcc92fadb

+ 9 - 5
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<BottomActionBarWidget> {
         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<BottomActionBarWidget> {
                 onTap: () {
                   //unselect all files here
                   //or collapse the expansion panel
+                  widget.onCancel?.call();
                   _expandableController.value = false;
                 },
                 child: Container(

+ 6 - 1
lib/ui/viewer/gallery/collection_page.dart

@@ -116,12 +116,17 @@ class _CollectionPageState extends State<CollectionPage> {
                 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,