Browse Source

Remove code irrelevant to new bottom selection sheet

ashilkn 2 năm trước cách đây
mục cha
commit
e37e4957ca

+ 44 - 76
lib/ui/components/bottom_action_bar/action_bar_widget.dart

@@ -1,23 +1,16 @@
 import 'package:flutter/material.dart';
 import 'package:photos/core/configuration.dart';
 import "package:photos/generated/l10n.dart";
-import 'package:photos/models/gallery_type.dart';
 import 'package:photos/models/selected_files.dart';
 import 'package:photos/theme/ente_theme.dart';
 
 class ActionBarWidget extends StatefulWidget {
-  final String? text;
-  final List<Widget> iconButtons;
   final SelectedFiles? selectedFiles;
-  final GalleryType galleryType;
-  final bool isCollaborator;
+  final VoidCallback? onCancel;
 
   const ActionBarWidget({
-    required this.iconButtons,
-    required this.galleryType,
-    this.text,
+    required this.onCancel,
     this.selectedFiles,
-    this.isCollaborator = false,
     super.key,
   });
 
@@ -38,83 +31,58 @@ class _ActionBarWidgetState extends State<ActionBarWidget> {
 
   @override
   void dispose() {
+    _selectedFilesNotifier.dispose();
+    _selectedOwnedFilesNotifier.dispose();
     widget.selectedFiles?.removeListener(_selectedFilesListener);
     super.dispose();
   }
 
   @override
   Widget build(BuildContext context) {
-    return SizedBox(
-      child: Row(
-        mainAxisAlignment: MainAxisAlignment.spaceBetween,
-        children: _actionBarWidgets(context),
-      ),
-    );
-  }
-
-  List<Widget> _actionBarWidgets(BuildContext context) {
-    final actionBarWidgets = <Widget>[];
-    final initialLength = widget.iconButtons.length;
     final textTheme = getEnteTextTheme(context);
     final colorScheme = getEnteColorScheme(context);
-
-    actionBarWidgets.addAll(widget.iconButtons);
-    if (widget.text != null) {
-      //adds 12 px spacing at the start and between iconButton elements
-      for (var i = 0; i < initialLength; i++) {
-        actionBarWidgets.insert(
-          2 * i,
-          const SizedBox(
-            width: 12,
-          ),
-        );
-      }
-      actionBarWidgets.insertAll(0, [
-        const SizedBox(width: 20),
-        Flexible(
-          child: Row(
-            children: [
-              widget.selectedFiles != null
-                  ? ValueListenableBuilder(
-                      valueListenable: _selectedFilesNotifier,
-                      builder: (context, value, child) {
-                        return Text(
-                          _selectedOwnedFilesNotifier.value !=
-                                  _selectedFilesNotifier.value
-                              ? S.of(context).selectedPhotosWithYours(
-                                    _selectedFilesNotifier.value,
-                                    _selectedOwnedFilesNotifier.value,
-                                  )
-                              : S.of(context).selectedPhotos(
-                                    _selectedFilesNotifier.value,
-                                  ),
-                          style: textTheme.body.copyWith(
-                            color: colorScheme.blurTextBase,
+    return SizedBox(
+      child: Padding(
+        padding: const EdgeInsets.fromLTRB(20, 16, 20, 64),
+        child: Row(
+          mainAxisAlignment: MainAxisAlignment.spaceBetween,
+          children: [
+            ValueListenableBuilder(
+              valueListenable: _selectedFilesNotifier,
+              builder: (context, value, child) {
+                return Text(
+                  _selectedOwnedFilesNotifier.value !=
+                          _selectedFilesNotifier.value
+                      ? S.of(context).selectedPhotosWithYours(
+                            _selectedFilesNotifier.value,
+                            _selectedOwnedFilesNotifier.value,
+                          )
+                      : S.of(context).selectedPhotos(
+                            _selectedFilesNotifier.value,
                           ),
-                        );
-                      },
-                    )
-                  : Text(
-                      widget.text!,
-                      style:
-                          textTheme.body.copyWith(color: colorScheme.textMuted),
-                    ),
-            ],
-          ),
+                  style: textTheme.body.copyWith(
+                    color: colorScheme.blurTextBase,
+                  ),
+                );
+              },
+            ),
+            GestureDetector(
+              behavior: HitTestBehavior.opaque,
+              onTap: () {
+                widget.onCancel?.call();
+              },
+              child: Center(
+                child: Text(
+                  S.of(context).cancel,
+                  style: textTheme.bodyBold
+                      .copyWith(color: colorScheme.blurTextBase),
+                ),
+              ),
+            ),
+          ],
         ),
-      ]);
-      //to add whitespace of 8pts or 12 pts at the end
-      if (widget.iconButtons.length > 1) {
-        actionBarWidgets.add(
-          const SizedBox(width: 8),
-        );
-      } else {
-        actionBarWidgets.add(
-          const SizedBox(width: 12),
-        );
-      }
-    }
-    return actionBarWidgets;
+      ),
+    );
   }
 
   void _selectedFilesListener() {

+ 4 - 133
lib/ui/components/bottom_action_bar/bottom_action_bar_widget.dart

@@ -1,44 +1,30 @@
-import 'package:expandable/expandable.dart';
 import 'package:flutter/material.dart';
 import 'package:photos/core/constants.dart';
-import "package:photos/generated/l10n.dart";
-import 'package:photos/models/gallery_type.dart';
 import 'package:photos/models/selected_files.dart';
 import "package:photos/theme/effects.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/buttons/icon_button_widget.dart';
 
 class BottomActionBarWidget extends StatelessWidget {
-  final String? text;
-  final List<Widget>? iconButtons;
   final Widget expandedMenu;
   final SelectedFiles? selectedFiles;
   final VoidCallback? onCancel;
   final bool hasSmallerBottomPadding;
-  final GalleryType type;
   final Color? backgroundColor;
 
-  BottomActionBarWidget({
+  const BottomActionBarWidget({
     required this.expandedMenu,
     required this.hasSmallerBottomPadding,
-    required this.type,
     this.selectedFiles,
-    this.text,
-    this.iconButtons,
     this.onCancel,
     this.backgroundColor,
     super.key,
   });
 
-  final ExpandableController _expandableController =
-      ExpandableController(initialExpanded: false);
-
   @override
   Widget build(BuildContext context) {
     final widthOfScreen = MediaQuery.of(context).size.width;
     final colorScheme = getEnteColorScheme(context);
-    final textTheme = getEnteTextTheme(context);
     final double leftRightPadding = widthOfScreen > restrictedMaxWidth
         ? (widthOfScreen - restrictedMaxWidth) / 2
         : 0;
@@ -56,127 +42,12 @@ class BottomActionBarWidget extends StatelessWidget {
       child: Column(
         mainAxisSize: MainAxisSize.min,
         children: [
-          ExpandableNotifier(
-            controller: _expandableController,
-            child: ExpandablePanel(
-              theme: _getExpandableTheme(),
-              header: Padding(
-                padding: EdgeInsets.symmetric(
-                  horizontal: text == null ? 12 : 0,
-                ),
-                child: ActionBarWidget(
-                  selectedFiles: selectedFiles,
-                  galleryType: type,
-                  text: text,
-                  iconButtons: _iconButtons(context),
-                ),
-              ),
-              expanded: expandedMenu,
-              collapsed: const SizedBox.shrink(),
-              controller: _expandableController,
-            ),
+          ActionBarWidget(
+            selectedFiles: selectedFiles,
+            onCancel: onCancel,
           ),
-          Padding(
-            padding: const EdgeInsets.symmetric(
-              horizontal: 16,
-              vertical: 14,
-            ),
-            child: GestureDetector(
-              behavior: HitTestBehavior.opaque,
-              onTap: () {
-                onCancel?.call();
-                _expandableController.value = false;
-              },
-              child: Center(
-                child: Text(
-                  S.of(context).cancel,
-                  style: textTheme.bodyBold
-                      .copyWith(color: colorScheme.blurTextBase),
-                ),
-              ),
-            ),
-          )
         ],
       ),
     );
   }
-
-  List<Widget> _iconButtons(BuildContext context) {
-    final iconButtonsWithExpansionIcon = <Widget>[
-      ...?iconButtons,
-      ExpansionIconWidget(expandableController: _expandableController)
-    ];
-    return iconButtonsWithExpansionIcon;
-  }
-
-  ExpandableThemeData _getExpandableTheme() {
-    return const ExpandableThemeData(
-      hasIcon: false,
-      useInkWell: false,
-      tapBodyToCollapse: false,
-      tapBodyToExpand: false,
-      tapHeaderToExpand: false,
-      animationDuration: Duration(milliseconds: 400),
-      crossFadePoint: 0.5,
-    );
-  }
-}
-
-class ExpansionIconWidget extends StatefulWidget {
-  final ExpandableController expandableController;
-
-  const ExpansionIconWidget({required this.expandableController, super.key});
-
-  @override
-  State<ExpansionIconWidget> createState() => _ExpansionIconWidgetState();
-}
-
-class _ExpansionIconWidgetState extends State<ExpansionIconWidget> {
-  @override
-  void initState() {
-    widget.expandableController.addListener(_expandableListener);
-    super.initState();
-  }
-
-  @override
-  void dispose() {
-    widget.expandableController.removeListener(_expandableListener);
-    super.dispose();
-  }
-
-  @override
-  Widget build(BuildContext context) {
-    final iconColor = getEnteColorScheme(context).blurStrokeBase;
-    return AnimatedSwitcher(
-      duration: const Duration(milliseconds: 200),
-      switchInCurve: Curves.easeInOutExpo,
-      child: widget.expandableController.value
-          ? IconButtonWidget(
-              key: const ValueKey<bool>(false),
-              onTap: () {
-                widget.expandableController.value = false;
-                setState(() {});
-              },
-              icon: Icons.expand_more_outlined,
-              iconButtonType: IconButtonType.primary,
-              iconColor: iconColor,
-            )
-          : IconButtonWidget(
-              key: const ValueKey<bool>(true),
-              onTap: () {
-                widget.expandableController.value = true;
-                setState(() {});
-              },
-              icon: Icons.more_horiz_outlined,
-              iconButtonType: IconButtonType.primary,
-              iconColor: iconColor,
-            ),
-    );
-  }
-
-  _expandableListener() {
-    if (mounted) {
-      setState(() {});
-    }
-  }
 }

+ 1 - 94
lib/ui/viewer/actions/file_selection_overlay_bar.dart

@@ -1,31 +1,20 @@
 import 'package:flutter/material.dart';
-import "package:photos/generated/l10n.dart";
 import 'package:photos/models/collection.dart';
-import 'package:photos/models/device_collection.dart';
 import 'package:photos/models/gallery_type.dart';
-import "package:photos/models/metadata/common_keys.dart";
 import 'package:photos/models/selected_files.dart';
-import 'package:photos/theme/ente_theme.dart';
-import 'package:photos/ui/collections/collection_action_sheet.dart';
 import 'package:photos/ui/components/bottom_action_bar/bottom_action_bar_widget.dart';
-import 'package:photos/ui/components/buttons/icon_button_widget.dart';
 import 'package:photos/ui/viewer/actions/file_selection_actions_widget.dart';
-import 'package:photos/utils/delete_file_util.dart';
-import 'package:photos/utils/magic_util.dart';
-import 'package:photos/utils/share_util.dart';
 
 class FileSelectionOverlayBar extends StatefulWidget {
   final GalleryType galleryType;
   final SelectedFiles selectedFiles;
   final Collection? collection;
-  final DeviceCollection? deviceCollection;
   final Color? backgroundColor;
 
   const FileSelectionOverlayBar(
     this.galleryType,
     this.selectedFiles, {
     this.collection,
-    this.deviceCollection,
     this.backgroundColor,
     Key? key,
   }) : super(key: key);
@@ -38,17 +27,16 @@ class FileSelectionOverlayBar extends StatefulWidget {
 class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
   final GlobalKey shareButtonKey = GlobalKey();
   final ValueNotifier<bool> _hasSelectedFilesNotifier = ValueNotifier(false);
-  late bool showDeleteOption;
 
   @override
   void initState() {
     super.initState();
-    showDeleteOption = widget.galleryType.showDeleteIconOption();
     widget.selectedFiles.addListener(_selectedFilesListener);
   }
 
   @override
   void dispose() {
+    _hasSelectedFilesNotifier.dispose();
     widget.selectedFiles.removeListener(_selectedFilesListener);
     super.dispose();
   }
@@ -58,74 +46,7 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
     debugPrint(
       '$runtimeType building with ${widget.selectedFiles.files.length}',
     );
-    final List<IconButtonWidget> iconsButton = [];
-    final iconColor = getEnteColorScheme(context).blurStrokeBase;
-    if (showDeleteOption) {
-      iconsButton.add(
-        IconButtonWidget(
-          icon: Icons.delete_outlined,
-          iconButtonType: IconButtonType.primary,
-          iconColor: iconColor,
-          onTap: () => showDeleteSheet(context, widget.selectedFiles),
-        ),
-      );
-    }
 
-    if (widget.galleryType.showUnArchiveOption()) {
-      iconsButton.add(
-        IconButtonWidget(
-          icon: Icons.unarchive,
-          iconButtonType: IconButtonType.primary,
-          iconColor: iconColor,
-          onTap: () => _onUnArchiveClick(),
-        ),
-      );
-    }
-    if (widget.galleryType.showUnHideOption()) {
-      iconsButton.add(
-        IconButtonWidget(
-          icon: Icons.visibility_off_outlined,
-          iconButtonType: IconButtonType.primary,
-          iconColor: iconColor,
-          onTap: () {
-            showCollectionActionSheet(
-              context,
-              selectedFiles: widget.selectedFiles,
-              actionType: CollectionActionType.unHide,
-            );
-          },
-        ),
-      );
-    }
-    if (widget.galleryType == GalleryType.trash) {
-      iconsButton.add(
-        IconButtonWidget(
-          icon: Icons.delete_forever_outlined,
-          iconButtonType: IconButtonType.primary,
-          iconColor: iconColor,
-          onTap: () async {
-            if (await deleteFromTrash(
-              context,
-              widget.selectedFiles.files.toList(),
-            )) {
-              widget.selectedFiles.clearAll();
-            }
-          },
-        ),
-      );
-    }
-    iconsButton.add(
-      IconButtonWidget(
-        icon: Icons.adaptive.share_outlined,
-        iconButtonType: IconButtonType.primary,
-        iconColor: iconColor,
-        onTap: () => shareSelected(
-          context,
-          shareButtonKey,
-          widget.selectedFiles.files.toList(),
-        ),
-      ),
-    );
     return ValueListenableBuilder(
       valueListenable: _hasSelectedFilesNotifier,
       builder: (context, value, child) {
@@ -140,21 +61,16 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
           firstChild: BottomActionBarWidget(
             selectedFiles: widget.selectedFiles,
             hasSmallerBottomPadding: true,
-            type: widget.galleryType,
             expandedMenu: FileSelectionActionWidget(
               widget.galleryType,
               widget.selectedFiles,
               collection: widget.collection,
             ),
-            text: S
-                .of(context)
-                .itemSelectedCount(widget.selectedFiles.files.length),
             onCancel: () {
               if (widget.selectedFiles.files.isNotEmpty) {
                 widget.selectedFiles.clearAll();
               }
             },
-            iconButtons: iconsButton,
             backgroundColor: widget.backgroundColor,
           ),
           secondChild: const SizedBox(width: double.infinity),
@@ -163,15 +79,6 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
     );
   }
 
-  Future<void> _onUnArchiveClick() async {
-    await changeVisibility(
-      context,
-      widget.selectedFiles.files.toList(),
-      visibleVisibility,
-    );
-    widget.selectedFiles.clearAll();
-  }
-
   _selectedFilesListener() {
     _hasSelectedFilesNotifier.value = widget.selectedFiles.files.isNotEmpty;
   }