ashilkn 1 年之前
父节点
当前提交
dae66c4945

+ 14 - 76
lib/ui/components/bottom_action_bar/bottom_action_bar_widget.dart

@@ -1,20 +1,25 @@
 import 'package:flutter/material.dart';
 import 'package:flutter/material.dart';
 import 'package:photos/core/constants.dart';
 import 'package:photos/core/constants.dart';
+import "package:photos/models/collection.dart";
+import "package:photos/models/gallery_type.dart";
 import 'package:photos/models/selected_files.dart';
 import 'package:photos/models/selected_files.dart';
 import "package:photos/theme/effects.dart";
 import "package:photos/theme/effects.dart";
 import 'package:photos/theme/ente_theme.dart';
 import 'package:photos/theme/ente_theme.dart';
 import 'package:photos/ui/components/bottom_action_bar/action_bar_widget.dart';
 import 'package:photos/ui/components/bottom_action_bar/action_bar_widget.dart';
 import "package:photos/ui/components/divider_widget.dart";
 import "package:photos/ui/components/divider_widget.dart";
+import "package:photos/ui/viewer/actions/file_selection_actions_widget.dart";
 
 
 class BottomActionBarWidget extends StatelessWidget {
 class BottomActionBarWidget extends StatelessWidget {
-  final Widget fileSelectionActionsWidget;
-  final SelectedFiles? selectedFiles;
+  final GalleryType galleryType;
+  final Collection? collection;
+  final SelectedFiles selectedFiles;
   final VoidCallback? onCancel;
   final VoidCallback? onCancel;
   final Color? backgroundColor;
   final Color? backgroundColor;
 
 
   const BottomActionBarWidget({
   const BottomActionBarWidget({
-    required this.fileSelectionActionsWidget,
-    this.selectedFiles,
+    required this.galleryType,
+    required this.selectedFiles,
+    this.collection,
     this.onCancel,
     this.onCancel,
     this.backgroundColor,
     this.backgroundColor,
     super.key,
     super.key,
@@ -47,7 +52,11 @@ class BottomActionBarWidget extends StatelessWidget {
         mainAxisSize: MainAxisSize.min,
         mainAxisSize: MainAxisSize.min,
         children: [
         children: [
           const SizedBox(height: 12),
           const SizedBox(height: 12),
-          fileSelectionActionsWidget,
+          FileSelectionActionsWidget(
+            galleryType,
+            selectedFiles,
+            collection: collection,
+          ),
           const SizedBox(height: 20),
           const SizedBox(height: 20),
           const DividerWidget(dividerType: DividerType.bottomBar),
           const DividerWidget(dividerType: DividerType.bottomBar),
           ActionBarWidget(
           ActionBarWidget(
@@ -60,74 +69,3 @@ class BottomActionBarWidget extends StatelessWidget {
     );
     );
   }
   }
 }
 }
-
-class SelectionOptionButton extends StatefulWidget {
-  final String labelText;
-  final IconData icon;
-  final VoidCallback? onTap;
-
-  const SelectionOptionButton({
-    required this.labelText,
-    required this.icon,
-    required this.onTap,
-    super.key,
-  });
-
-  @override
-  State<SelectionOptionButton> createState() => _SelectionOptionButtonState();
-}
-
-class _SelectionOptionButtonState extends State<SelectionOptionButton> {
-  Color? backgroundColor;
-  @override
-  Widget build(BuildContext context) {
-    final colorScheme = getEnteColorScheme(context);
-    return GestureDetector(
-      onTap: widget.onTap,
-      onTapDown: (details) {
-        setState(() {
-          backgroundColor = colorScheme.fillFaintPressed;
-        });
-      },
-      onTapUp: (details) {
-        setState(() {
-          backgroundColor = null;
-        });
-      },
-      onTapCancel: () {
-        setState(() {
-          backgroundColor = null;
-        });
-      },
-      child: Container(
-        decoration: BoxDecoration(
-          borderRadius: BorderRadius.circular(8),
-          color: backgroundColor,
-        ),
-        child: Padding(
-          padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
-          child: SizedBox(
-            width: 64,
-            child: Column(
-              mainAxisAlignment: MainAxisAlignment.center,
-              mainAxisSize: MainAxisSize.min,
-              children: [
-                Icon(
-                  widget.icon,
-                  size: 24,
-                  color: getEnteColorScheme(context).textMuted,
-                ),
-                const SizedBox(height: 4),
-                Text(
-                  widget.labelText,
-                  textAlign: TextAlign.center,
-                  style: getEnteTextTheme(context).miniMuted,
-                ),
-              ],
-            ),
-          ),
-        ),
-      ),
-    );
-  }
-}

+ 73 - 0
lib/ui/components/bottom_action_bar/selection_action_button_widget.dart

@@ -0,0 +1,73 @@
+import "package:flutter/material.dart";
+import "package:photos/theme/ente_theme.dart";
+
+class SelectionActionButton extends StatefulWidget {
+  final String labelText;
+  final IconData icon;
+  final VoidCallback? onTap;
+
+  const SelectionActionButton({
+    required this.labelText,
+    required this.icon,
+    required this.onTap,
+    super.key,
+  });
+
+  @override
+  State<SelectionActionButton> createState() => _SelectionActionButtonState();
+}
+
+class _SelectionActionButtonState extends State<SelectionActionButton> {
+  Color? backgroundColor;
+  @override
+  Widget build(BuildContext context) {
+    final colorScheme = getEnteColorScheme(context);
+    return GestureDetector(
+      onTap: widget.onTap,
+      onTapDown: (details) {
+        setState(() {
+          backgroundColor = colorScheme.fillFaintPressed;
+        });
+      },
+      onTapUp: (details) {
+        setState(() {
+          backgroundColor = null;
+        });
+      },
+      onTapCancel: () {
+        setState(() {
+          backgroundColor = null;
+        });
+      },
+      child: Container(
+        decoration: BoxDecoration(
+          borderRadius: BorderRadius.circular(8),
+          color: backgroundColor,
+        ),
+        child: Padding(
+          padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
+          child: SizedBox(
+            width: 64,
+            child: Column(
+              mainAxisAlignment: MainAxisAlignment.center,
+              mainAxisSize: MainAxisSize.min,
+              children: [
+                Icon(
+                  widget.icon,
+                  size: 24,
+                  color: getEnteColorScheme(context).textMuted,
+                ),
+                const SizedBox(height: 4),
+                Text(
+                  widget.labelText,
+                  textAlign: TextAlign.center,
+                  style: getEnteTextTheme(context).miniMuted,
+                ),
+              ],
+            ),
+          ),
+        ),
+      ),
+    );
+  }
+}

+ 17 - 17
lib/ui/viewer/actions/file_selection_actions_widget.dart

@@ -17,7 +17,7 @@ import 'package:photos/ui/actions/collection/collection_file_actions.dart';
 import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
 import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
 import 'package:photos/ui/collections/collection_action_sheet.dart';
 import 'package:photos/ui/collections/collection_action_sheet.dart';
 import 'package:photos/ui/components/action_sheet_widget.dart';
 import 'package:photos/ui/components/action_sheet_widget.dart';
-import "package:photos/ui/components/bottom_action_bar/bottom_action_bar_widget.dart";
+import "package:photos/ui/components/bottom_action_bar/selection_action_button_widget.dart";
 import 'package:photos/ui/components/buttons/button_widget.dart';
 import 'package:photos/ui/components/buttons/button_widget.dart';
 import 'package:photos/ui/components/models/button_type.dart';
 import 'package:photos/ui/components/models/button_type.dart';
 import 'package:photos/ui/sharing/manage_links_widget.dart';
 import 'package:photos/ui/sharing/manage_links_widget.dart';
@@ -109,12 +109,12 @@ class _FileSelectionActionsWidgetState
     final bool anyUploadedFiles = split.ownedByCurrentUser.isNotEmpty;
     final bool anyUploadedFiles = split.ownedByCurrentUser.isNotEmpty;
     final bool showRemoveOption = widget.type.showRemoveFromAlbum();
     final bool showRemoveOption = widget.type.showRemoveFromAlbum();
     debugPrint('$runtimeType building  $mounted');
     debugPrint('$runtimeType building  $mounted');
-    final List<SelectionOptionButton> items = [];
+    final List<SelectionActionButton> items = [];
 
 
     if (widget.type.showCreateLink()) {
     if (widget.type.showCreateLink()) {
       if (_cachedCollectionForSharedLink != null && anyUploadedFiles) {
       if (_cachedCollectionForSharedLink != null && anyUploadedFiles) {
         items.add(
         items.add(
-          SelectionOptionButton(
+          SelectionActionButton(
             icon: Icons.copy_outlined,
             icon: Icons.copy_outlined,
             labelText: S.of(context).copyLink,
             labelText: S.of(context).copyLink,
             onTap: anyUploadedFiles ? _copyLink : null,
             onTap: anyUploadedFiles ? _copyLink : null,
@@ -122,7 +122,7 @@ class _FileSelectionActionsWidgetState
         );
         );
       } else {
       } else {
         items.add(
         items.add(
-          SelectionOptionButton(
+          SelectionActionButton(
             icon: Icons.link_outlined,
             icon: Icons.link_outlined,
             labelText: S.of(context).shareLink + suffix,
             labelText: S.of(context).shareLink + suffix,
             onTap: anyUploadedFiles ? _onCreatedSharedLinkClicked : null,
             onTap: anyUploadedFiles ? _onCreatedSharedLinkClicked : null,
@@ -144,7 +144,7 @@ class _FileSelectionActionsWidgetState
         widget.selectedFiles.files.length <=
         widget.selectedFiles.files.length <=
             CollageCreatorPage.collageItemsMax) {
             CollageCreatorPage.collageItemsMax) {
       items.add(
       items.add(
-        SelectionOptionButton(
+        SelectionActionButton(
           icon: Icons.grid_view_outlined,
           icon: Icons.grid_view_outlined,
           labelText: S.of(context).createCollage,
           labelText: S.of(context).createCollage,
           onTap: _onCreateCollageClicked,
           onTap: _onCreateCollageClicked,
@@ -156,7 +156,7 @@ class _FileSelectionActionsWidgetState
         split.ownedByCurrentUser.isEmpty;
         split.ownedByCurrentUser.isEmpty;
     if (widget.type.showAddToAlbum()) {
     if (widget.type.showAddToAlbum()) {
       items.add(
       items.add(
-        SelectionOptionButton(
+        SelectionActionButton(
           icon:
           icon:
               showUploadIcon ? Icons.cloud_upload_outlined : Icons.add_outlined,
               showUploadIcon ? Icons.cloud_upload_outlined : Icons.add_outlined,
           labelText: showUploadIcon
           labelText: showUploadIcon
@@ -168,7 +168,7 @@ class _FileSelectionActionsWidgetState
     }
     }
     if (widget.type.showMoveToAlbum()) {
     if (widget.type.showMoveToAlbum()) {
       items.add(
       items.add(
-        SelectionOptionButton(
+        SelectionActionButton(
           icon: Icons.arrow_forward_outlined,
           icon: Icons.arrow_forward_outlined,
           labelText: S.of(context).moveToAlbum + suffix,
           labelText: S.of(context).moveToAlbum + suffix,
           onTap: anyUploadedFiles ? _moveFiles : null,
           onTap: anyUploadedFiles ? _moveFiles : null,
@@ -178,7 +178,7 @@ class _FileSelectionActionsWidgetState
 
 
     if (showRemoveOption) {
     if (showRemoveOption) {
       items.add(
       items.add(
-        SelectionOptionButton(
+        SelectionActionButton(
           icon: Icons.remove_outlined,
           icon: Icons.remove_outlined,
           labelText: "${S.of(context).removeFromAlbum}$removeSuffix",
           labelText: "${S.of(context).removeFromAlbum}$removeSuffix",
           onTap: removeCount > 0 ? _removeFilesFromAlbum : null,
           onTap: removeCount > 0 ? _removeFilesFromAlbum : null,
@@ -188,7 +188,7 @@ class _FileSelectionActionsWidgetState
 
 
     if (widget.type.showDeleteOption()) {
     if (widget.type.showDeleteOption()) {
       items.add(
       items.add(
-        SelectionOptionButton(
+        SelectionActionButton(
           icon: Icons.delete_outline,
           icon: Icons.delete_outline,
           labelText: S.of(context).delete + suffixInPending,
           labelText: S.of(context).delete + suffixInPending,
           onTap: anyOwnedFiles ? _onDeleteClick : null,
           onTap: anyOwnedFiles ? _onDeleteClick : null,
@@ -198,7 +198,7 @@ class _FileSelectionActionsWidgetState
 
 
     if (widget.type.showHideOption()) {
     if (widget.type.showHideOption()) {
       items.add(
       items.add(
-        SelectionOptionButton(
+        SelectionActionButton(
           icon: Icons.visibility_off_outlined,
           icon: Icons.visibility_off_outlined,
           labelText: S.of(context).hide + suffix,
           labelText: S.of(context).hide + suffix,
           onTap: anyUploadedFiles ? _onHideClick : null,
           onTap: anyUploadedFiles ? _onHideClick : null,
@@ -206,7 +206,7 @@ class _FileSelectionActionsWidgetState
       );
       );
     } else if (widget.type.showUnHideOption()) {
     } else if (widget.type.showUnHideOption()) {
       items.add(
       items.add(
-        SelectionOptionButton(
+        SelectionActionButton(
           icon: Icons.visibility_off_outlined,
           icon: Icons.visibility_off_outlined,
           labelText: S.of(context).unhide + suffix,
           labelText: S.of(context).unhide + suffix,
           onTap: _onUnhideClick,
           onTap: _onUnhideClick,
@@ -215,7 +215,7 @@ class _FileSelectionActionsWidgetState
     }
     }
     if (widget.type.showArchiveOption()) {
     if (widget.type.showArchiveOption()) {
       items.add(
       items.add(
-        SelectionOptionButton(
+        SelectionActionButton(
           icon: Icons.archive_outlined,
           icon: Icons.archive_outlined,
           labelText: S.of(context).archive + suffix,
           labelText: S.of(context).archive + suffix,
           onTap: anyUploadedFiles ? _onArchiveClick : null,
           onTap: anyUploadedFiles ? _onArchiveClick : null,
@@ -223,7 +223,7 @@ class _FileSelectionActionsWidgetState
       );
       );
     } else if (widget.type.showUnArchiveOption()) {
     } else if (widget.type.showUnArchiveOption()) {
       items.add(
       items.add(
-        SelectionOptionButton(
+        SelectionActionButton(
           icon: Icons.unarchive,
           icon: Icons.unarchive,
           labelText: S.of(context).unarchive + suffix,
           labelText: S.of(context).unarchive + suffix,
           onTap: _onUnArchiveClick,
           onTap: _onUnArchiveClick,
@@ -233,7 +233,7 @@ class _FileSelectionActionsWidgetState
 
 
     if (widget.type.showFavoriteOption()) {
     if (widget.type.showFavoriteOption()) {
       items.add(
       items.add(
-        SelectionOptionButton(
+        SelectionActionButton(
           icon: Icons.favorite_border_rounded,
           icon: Icons.favorite_border_rounded,
           labelText: S.of(context).favorite + suffix,
           labelText: S.of(context).favorite + suffix,
           onTap: anyUploadedFiles ? _onFavoriteClick : null,
           onTap: anyUploadedFiles ? _onFavoriteClick : null,
@@ -241,7 +241,7 @@ class _FileSelectionActionsWidgetState
       );
       );
     } else if (widget.type.showUnFavoriteOption()) {
     } else if (widget.type.showUnFavoriteOption()) {
       items.add(
       items.add(
-        SelectionOptionButton(
+        SelectionActionButton(
           icon: Icons.favorite,
           icon: Icons.favorite,
           labelText: S.of(context).removeFromFavorite + suffix,
           labelText: S.of(context).removeFromFavorite + suffix,
           onTap: _onUnFavoriteClick,
           onTap: _onUnFavoriteClick,
@@ -251,7 +251,7 @@ class _FileSelectionActionsWidgetState
 
 
     if (widget.type.showRestoreOption()) {
     if (widget.type.showRestoreOption()) {
       items.add(
       items.add(
-        SelectionOptionButton(
+        SelectionActionButton(
           icon: Icons.restore_outlined,
           icon: Icons.restore_outlined,
           labelText: S.of(context).restore,
           labelText: S.of(context).restore,
           onTap: _restore,
           onTap: _restore,
@@ -261,7 +261,7 @@ class _FileSelectionActionsWidgetState
 
 
     if (widget.type.showPermanentlyDeleteOption()) {
     if (widget.type.showPermanentlyDeleteOption()) {
       items.add(
       items.add(
-        SelectionOptionButton(
+        SelectionActionButton(
           icon: Icons.delete_forever_outlined,
           icon: Icons.delete_forever_outlined,
           labelText: S.of(context).permanentlyDelete,
           labelText: S.of(context).permanentlyDelete,
           onTap: _permanentlyDelete,
           onTap: _permanentlyDelete,

+ 2 - 6
lib/ui/viewer/actions/file_selection_overlay_bar.dart

@@ -3,7 +3,6 @@ import 'package:photos/models/collection.dart';
 import 'package:photos/models/gallery_type.dart';
 import 'package:photos/models/gallery_type.dart';
 import 'package:photos/models/selected_files.dart';
 import 'package:photos/models/selected_files.dart';
 import 'package:photos/ui/components/bottom_action_bar/bottom_action_bar_widget.dart';
 import 'package:photos/ui/components/bottom_action_bar/bottom_action_bar_widget.dart';
-import 'package:photos/ui/viewer/actions/file_selection_actions_widget.dart';
 
 
 class FileSelectionOverlayBar extends StatefulWidget {
 class FileSelectionOverlayBar extends StatefulWidget {
   final GalleryType galleryType;
   final GalleryType galleryType;
@@ -60,11 +59,8 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
           duration: const Duration(milliseconds: 400),
           duration: const Duration(milliseconds: 400),
           firstChild: BottomActionBarWidget(
           firstChild: BottomActionBarWidget(
             selectedFiles: widget.selectedFiles,
             selectedFiles: widget.selectedFiles,
-            fileSelectionActionsWidget: FileSelectionActionsWidget(
-              widget.galleryType,
-              widget.selectedFiles,
-              collection: widget.collection,
-            ),
+            galleryType: widget.galleryType,
+            collection: widget.collection,
             onCancel: () {
             onCancel: () {
               if (widget.selectedFiles.files.isNotEmpty) {
               if (widget.selectedFiles.files.isNotEmpty) {
                 widget.selectedFiles.clearAll();
                 widget.selectedFiles.clearAll();