Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Unify album selection action sheets

r4khul43d7b862b93e
diff --git a/mobile/apps/photos/changes/unified-selection-sheets.md b/mobile/apps/photos/changes/unified-selection-sheets.md
new file mode 100644
index 0000000000..8465f872c2
--- /dev/null
+++ b/mobile/apps/photos/changes/unified-selection-sheets.md
@@ -0,0 +1 @@
+- Refreshed album selection with the shared expandable sheet and consistent action labels.
diff --git a/mobile/apps/photos/lib/ui/collections/collection_list_page.dart b/mobile/apps/photos/lib/ui/collections/collection_list_page.dart
index 9843632b95..678068bd75 100644
--- a/mobile/apps/photos/lib/ui/collections/collection_list_page.dart
+++ b/mobile/apps/photos/lib/ui/collections/collection_list_page.dart
@@ -95,6 +95,7 @@ class _CollectionListPageState extends State<CollectionListPage> {
widget.sectionType == UISectionType.hiddenCollections;
return Scaffold(
body: SafeArea(
+ bottom: false,
child: Stack(
alignment: Alignment.bottomCenter,
children: [
@@ -138,6 +139,7 @@ class _CollectionListPageState extends State<CollectionListPage> {
widget.sectionType,
collections!,
showSelectAllButton: true,
+ backgroundScrollController: _scrollController,
),
],
),
diff --git a/mobile/apps/photos/lib/ui/components/bottom_action_bar/album_action_bar_widget.dart b/mobile/apps/photos/lib/ui/components/bottom_action_bar/album_action_bar_widget.dart
index 30121789aa..c669771005 100644
--- a/mobile/apps/photos/lib/ui/components/bottom_action_bar/album_action_bar_widget.dart
+++ b/mobile/apps/photos/lib/ui/components/bottom_action_bar/album_action_bar_widget.dart
@@ -1,82 +1,31 @@
-import "package:ente_components/ente_components.dart" as components;
+import "package:ente_components/ente_components.dart";
import "package:ente_strings/ente_strings.dart";
import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
import "package:photos/models/selected_albums.dart";
+import "package:photos/ui/components/bottom_action_bar/action_bar_widget.dart";
-class AlbumActionBarWidget extends StatefulWidget {
- final SelectedAlbums? selectedAlbums;
+class AlbumActionBarWidget extends StatelessWidget {
+ const AlbumActionBarWidget({
+ required this.selectedAlbums,
+ this.onCancel,
+ super.key,
+ });
+ final SelectedAlbums selectedAlbums;
final VoidCallback? onCancel;
- const AlbumActionBarWidget({super.key, this.selectedAlbums, this.onCancel});
@override
- State<AlbumActionBarWidget> createState() => _AlbumActionBarWidgetState();
-}
-
-class _AlbumActionBarWidgetState extends State<AlbumActionBarWidget> {
- final ValueNotifier<int> _selectedAlbumNotifier = ValueNotifier(0);
-
- @override
- void initState() {
- widget.selectedAlbums?.addListener(_selectedAlbumListener);
- super.initState();
- }
-
- @override
- void dispose() {
- widget.selectedAlbums?.removeListener(_selectedAlbumListener);
- _selectedAlbumNotifier.dispose();
- super.dispose();
- }
-
- @override
- Widget build(BuildContext context) {
- final colors = components.ComponentTheme.colorsOf(context);
- final miniStyle = components.TextStyles.mini.copyWith(
- color: colors.textBase,
- );
- return SizedBox(
- child: Padding(
- padding: const EdgeInsets.fromLTRB(20, 8, 20, 8),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Flexible(
- flex: 1,
- child: ValueListenableBuilder(
- valueListenable: _selectedAlbumNotifier,
- builder: (context, value, child) {
- return Text(
- context.strings.selectedAlbums(
- count: widget.selectedAlbums?.albums.length ?? 0,
- ),
- style: miniStyle,
- );
- },
- ),
- ),
- Flexible(
- flex: 1,
- child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 12),
- child: GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () {
- widget.onCancel?.call();
- },
- child: Align(
- alignment: Alignment.centerRight,
- child: Text(context.strings.cancel, style: miniStyle),
- ),
- ),
- ),
- ),
- ],
- ),
+ Widget build(BuildContext context) => ListenableBuilder(
+ listenable: selectedAlbums,
+ builder: (context, _) => SelectionControlChip(
+ label: selectedAlbums.albums.length.toString(),
+ semanticLabel:
+ "${context.strings.cancel}, ${context.strings.selectedAlbums(count: selectedAlbums.albums.length)}",
+ icon: const HugeIcon(
+ icon: HugeIcons.strokeRoundedCancel01,
+ size: IconSizes.small,
),
- );
- }
-
- void _selectedAlbumListener() {
- _selectedAlbumNotifier.value = widget.selectedAlbums?.albums.length ?? 0;
- }
+ onTap: onCancel,
+ ),
+ );
}
diff --git a/mobile/apps/photos/lib/ui/components/bottom_action_bar/album_bottom_action_bar_widget.dart b/mobile/apps/photos/lib/ui/components/bottom_action_bar/album_bottom_action_bar_widget.dart
index c557fabf23..b08ee4d30e 100644
--- a/mobile/apps/photos/lib/ui/components/bottom_action_bar/album_bottom_action_bar_widget.dart
+++ b/mobile/apps/photos/lib/ui/components/bottom_action_bar/album_bottom_action_bar_widget.dart
@@ -1,7 +1,5 @@
import "package:ente_components/ente_components.dart" as components;
-import "package:ente_ui/components/divider_widget.dart";
import "package:flutter/material.dart";
-import "package:photos/core/constants.dart";
import "package:photos/models/selected_albums.dart";
import "package:photos/ui/collections/collection_list_page.dart";
import "package:photos/ui/components/bottom_action_bar/album_action_bar_widget.dart";
@@ -11,6 +9,8 @@ class AlbumBottomActionBarWidget extends StatelessWidget {
final SelectedAlbums selectedAlbums;
final VoidCallback? onCancel;
final Color? backgroundColor;
+ final ScrollController? backgroundScrollController;
+ final Widget? selectAllButton;
final UISectionType sectionType;
const AlbumBottomActionBarWidget(
@@ -19,42 +19,33 @@ class AlbumBottomActionBarWidget extends StatelessWidget {
super.key,
this.backgroundColor,
this.onCancel,
+ this.backgroundScrollController,
+ this.selectAllButton,
});
@override
Widget build(BuildContext context) {
- final bottomPadding = MediaQuery.paddingOf(context).bottom;
- final widthOfScreen = MediaQuery.sizeOf(context).width;
- final colors = components.ComponentTheme.colorsOf(context);
- final double leftRightPadding = widthOfScreen > restrictedMaxWidth
- ? (widthOfScreen - restrictedMaxWidth) / 2
- : 0;
- return Container(
- decoration: BoxDecoration(
- color: backgroundColor ?? colors.backgroundBase,
- border: Border(top: BorderSide(color: colors.strokeDark)),
- borderRadius: const BorderRadius.only(
- topLeft: Radius.circular(20),
- topRight: Radius.circular(20),
+ return AlbumSelectionActionWidget(
+ selectedAlbums,
+ sectionType,
+ backgroundColor: backgroundColor,
+ backgroundScrollController: backgroundScrollController,
+ selectionControls: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: components.Spacing.sm),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ if (selectAllButton != null) Flexible(child: selectAllButton!),
+ const SizedBox(width: components.Spacing.sm),
+ Flexible(
+ child: AlbumActionBarWidget(
+ selectedAlbums: selectedAlbums,
+ onCancel: onCancel,
+ ),
+ ),
+ ],
),
),
- padding: EdgeInsets.only(
- top: 4,
- bottom: bottomPadding,
- right: leftRightPadding,
- left: leftRightPadding,
- ),
- child: Column(
- children: [
- const SizedBox(height: 8),
- AlbumSelectionActionWidget(selectedAlbums, sectionType),
- const DividerWidget(dividerType: DividerType.bottomBar),
- AlbumActionBarWidget(
- selectedAlbums: selectedAlbums,
- onCancel: onCancel,
- ),
- ],
- ),
);
}
}
diff --git a/mobile/apps/photos/lib/ui/components/bottom_action_bar/selection_action_sheet.dart b/mobile/apps/photos/lib/ui/components/bottom_action_bar/selection_action_sheet.dart
index 2296c82523..4d451b8783 100644
--- a/mobile/apps/photos/lib/ui/components/bottom_action_bar/selection_action_sheet.dart
+++ b/mobile/apps/photos/lib/ui/components/bottom_action_bar/selection_action_sheet.dart
@@ -36,12 +36,14 @@ class SelectionActionSheet extends StatefulWidget {
required this.actions,
required this.selectionControls,
this.backgroundColor,
+ this.backgroundScrollController,
super.key,
});
final List<SelectionSheetAction> actions;
final Widget selectionControls;
final Color? backgroundColor;
+ final ScrollController? backgroundScrollController;
@override
State<SelectionActionSheet> createState() => _SelectionActionSheetState();
@@ -65,7 +67,10 @@ class _SelectionActionSheetState extends State<SelectionActionSheet> {
void didChangeDependencies() {
super.didChangeDependencies();
final boundaries = GalleryBoundariesProvider.of(context);
- if (_boundaries != boundaries) {
+ if (_boundaries != boundaries ||
+ _galleryController !=
+ (widget.backgroundScrollController ??
+ boundaries?.scrollControllerNotifier.value)) {
_boundaries?.scrollControllerNotifier.removeListener(_bindGallery);
_boundaries = boundaries;
_boundaries?.scrollControllerNotifier.addListener(_bindGallery);
@@ -73,11 +78,22 @@ class _SelectionActionSheetState extends State<SelectionActionSheet> {
}
}
+ @override
+ void didUpdateWidget(covariant SelectionActionSheet oldWidget) {
+ super.didUpdateWidget(oldWidget);
+ if (oldWidget.backgroundScrollController !=
+ widget.backgroundScrollController) {
+ _bindGallery();
+ }
+ }
+
void _bindGallery() {
_galleryController?.removeListener(_onGalleryScroll);
_galleryScrolling?.removeListener(_onGalleryActivityChanged);
_gallerySwipeActive?.removeListener(_onGalleryActivityChanged);
- _galleryController = _boundaries?.scrollControllerNotifier.value;
+ _galleryController =
+ widget.backgroundScrollController ??
+ _boundaries?.scrollControllerNotifier.value;
_galleryController?.addListener(_onGalleryScroll);
_galleryScrolling = _galleryController?.positions.length == 1
? _galleryController!.position.isScrollingNotifier
diff --git a/mobile/apps/photos/lib/ui/tabs/albums_tab.dart b/mobile/apps/photos/lib/ui/tabs/albums_tab.dart
index 8da57d4a3d..9d3563e497 100644
--- a/mobile/apps/photos/lib/ui/tabs/albums_tab.dart
+++ b/mobile/apps/photos/lib/ui/tabs/albums_tab.dart
@@ -1113,6 +1113,7 @@ class _AlbumsTabState extends State<AlbumsTab>
sectionType,
filteredCollections,
showSelectAllButton: true,
+ backgroundScrollController: _scrollController,
);
},
),
diff --git a/mobile/apps/photos/lib/ui/viewer/actions/album_selection_action_widget.dart b/mobile/apps/photos/lib/ui/viewer/actions/album_selection_action_widget.dart
index 056826a90c..cc5c8e9de4 100644
--- a/mobile/apps/photos/lib/ui/viewer/actions/album_selection_action_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/actions/album_selection_action_widget.dart
@@ -16,7 +16,7 @@ import "package:photos/services/collections_service.dart";
import "package:photos/ui/actions/collection/collection_sharing_actions.dart";
import "package:photos/ui/collections/collection_list_page.dart";
import "package:photos/ui/components/action_sheet_widget.dart";
-import "package:photos/ui/components/bottom_action_bar/selection_action_button_widget.dart";
+import "package:photos/ui/components/bottom_action_bar/selection_action_sheet.dart";
import "package:photos/ui/components/buttons/button_widget.dart";
import "package:photos/ui/components/models/button_type.dart";
import "package:photos/ui/notification/toast.dart";
@@ -28,10 +28,16 @@ import "package:photos/utils/magic_util.dart";
class AlbumSelectionActionWidget extends StatefulWidget {
final SelectedAlbums selectedAlbums;
final UISectionType sectionType;
+ final Widget selectionControls;
+ final Color? backgroundColor;
+ final ScrollController? backgroundScrollController;
const AlbumSelectionActionWidget(
this.selectedAlbums,
this.sectionType, {
+ required this.selectionControls,
+ this.backgroundColor,
+ this.backgroundScrollController,
super.key,
});
@@ -43,7 +49,6 @@ class AlbumSelectionActionWidget extends StatefulWidget {
class _AlbumSelectionActionWidgetState
extends State<AlbumSelectionActionWidget> {
final _logger = Logger("AlbumSelectionActionWidgetState");
- final _scrollController = ScrollController();
late CollectionActions collectionActions;
bool hasFavorites = false;
@@ -57,7 +62,6 @@ class _AlbumSelectionActionWidgetState
@override
void dispose() {
widget.selectedAlbums.removeListener(_selectionChangedListener);
- _scrollController.dispose();
super.dispose();
}
@@ -66,7 +70,7 @@ class _AlbumSelectionActionWidgetState
if (widget.selectedAlbums.albums.isEmpty) {
return const SizedBox.shrink();
}
- final List<SelectionActionButton> items = [];
+ final List<SelectionSheetAction> items = [];
final hasPinnedAlbum = widget.selectedAlbums.albums.any(
(album) => album.isPinned,
);
@@ -92,7 +96,7 @@ class _AlbumSelectionActionWidgetState
if (showOwnerActions) {
items.add(
- SelectionActionButton(
+ SelectionSheetAction(
labelText: context.strings.share,
hugeIcon: Platform.isIOS
? HugeIcons.strokeRoundedShare03
@@ -103,7 +107,7 @@ class _AlbumSelectionActionWidgetState
}
items.add(
- SelectionActionButton(
+ SelectionSheetAction(
labelText: context.strings.slideshow,
hugeIcon: HugeIcons.strokeRoundedPresentation03,
onTap: _startAlbumSlideshow,
@@ -112,7 +116,7 @@ class _AlbumSelectionActionWidgetState
if (showOwnerActions) {
items.add(
- SelectionActionButton(
+ SelectionSheetAction(
labelText: context.strings.pin,
hugeIcon: HugeIcons.strokeRoundedPin,
onTap: _onPinClick,
@@ -121,7 +125,7 @@ class _AlbumSelectionActionWidgetState
);
items.add(
- SelectionActionButton(
+ SelectionSheetAction(
labelText: context.strings.unpin,
hugeIcon: HugeIcons.strokeRoundedPinOff,
onTap: _onUnpinClick,
@@ -130,7 +134,7 @@ class _AlbumSelectionActionWidgetState
);
items.add(
- SelectionActionButton(
+ SelectionSheetAction(
labelText: context.strings.delete,
hugeIcon: HugeIcons.strokeRoundedDelete01,
onTap: _trashCollection,
@@ -138,7 +142,7 @@ class _AlbumSelectionActionWidgetState
),
);
items.add(
- SelectionActionButton(
+ SelectionSheetAction(
labelText: context.strings.hide,
hugeIcon: HugeIcons.strokeRoundedViewOffSlash,
onTap: _onHideOrUnHideClick,
@@ -148,7 +152,7 @@ class _AlbumSelectionActionWidgetState
if (showMixedEnteActions) {
items.add(
- SelectionActionButton(
+ SelectionSheetAction(
labelText: context.strings.hide,
hugeIcon: HugeIcons.strokeRoundedViewOffSlash,
onTap: _onHideOrUnHideClick,
@@ -158,14 +162,14 @@ class _AlbumSelectionActionWidgetState
if (widget.sectionType == UISectionType.archivedCollections) {
items.add(
- SelectionActionButton(
+ SelectionSheetAction(
labelText: context.strings.unarchive,
hugeIcon: HugeIcons.strokeRoundedUnarchive03,
onTap: _archiveClick,
),
);
items.add(
- SelectionActionButton(
+ SelectionSheetAction(
labelText: context.strings.delete,
hugeIcon: HugeIcons.strokeRoundedDelete01,
onTap: _trashCollection,
@@ -175,14 +179,14 @@ class _AlbumSelectionActionWidgetState
);
} else if (widget.sectionType == UISectionType.hiddenCollections) {
items.add(
- SelectionActionButton(
+ SelectionSheetAction(
labelText: context.strings.unhide,
hugeIcon: HugeIcons.strokeRoundedView,
onTap: _onHideOrUnHideClick,
),
);
items.add(
- SelectionActionButton(
+ SelectionSheetAction(
labelText: context.strings.delete,
hugeIcon: HugeIcons.strokeRoundedDelete01,
onTap: _trashCollection,
@@ -191,7 +195,7 @@ class _AlbumSelectionActionWidgetState
);
} else {
items.add(
- SelectionActionButton(
+ SelectionSheetAction(
labelText: context.strings.archive,
hugeIcon: HugeIcons.strokeRoundedArchive03,
onTap: _archiveClick,
@@ -209,7 +213,7 @@ class _AlbumSelectionActionWidgetState
);
items.add(
- SelectionActionButton(
+ SelectionSheetAction(
labelText: context.strings.pin,
hugeIcon: HugeIcons.strokeRoundedPin,
onTap: _onPinClickForSharee,
@@ -218,7 +222,7 @@ class _AlbumSelectionActionWidgetState
);
items.add(
- SelectionActionButton(
+ SelectionSheetAction(
labelText: context.strings.unpin,
hugeIcon: HugeIcons.strokeRoundedPinOff,
onTap: _onUnpinClickForSharee,
@@ -228,7 +232,7 @@ class _AlbumSelectionActionWidgetState
}
items.add(
- SelectionActionButton(
+ SelectionSheetAction(
labelText: context.strings.hide,
hugeIcon: HugeIcons.strokeRoundedViewOffSlash,
onTap: _onHideOrUnHideClick,
@@ -236,7 +240,7 @@ class _AlbumSelectionActionWidgetState
);
items.add(
- SelectionActionButton(
+ SelectionSheetAction(
labelText: context.strings.leaveAlbum,
hugeIcon: HugeIcons.strokeRoundedLogout05,
onTap: _leaveAlbum,
@@ -244,34 +248,11 @@ class _AlbumSelectionActionWidgetState
);
}
- return MediaQuery(
- data: MediaQuery.of(context).removePadding(removeBottom: true),
- child: SafeArea(
- child: Scrollbar(
- radius: const Radius.circular(1),
- thickness: 2,
- controller: _scrollController,
- thumbVisibility: true,
- child: SingleChildScrollView(
- controller: _scrollController,
- physics: const BouncingScrollPhysics(
- decelerationRate: ScrollDecelerationRate.fast,
- ),
- scrollDirection: Axis.horizontal,
- child: Container(
- padding: const EdgeInsets.only(bottom: 24),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const SizedBox(width: 4),
- ...items,
- const SizedBox(width: 4),
- ],
- ),
- ),
- ),
- ),
- ),
+ return SelectionActionSheet(
+ actions: items,
+ selectionControls: widget.selectionControls,
+ backgroundColor: widget.backgroundColor,
+ backgroundScrollController: widget.backgroundScrollController,
);
}
diff --git a/mobile/apps/photos/lib/ui/viewer/actions/album_selection_overlay_bar.dart b/mobile/apps/photos/lib/ui/viewer/actions/album_selection_overlay_bar.dart
index 5035ae7e1f..de28563ee8 100644
--- a/mobile/apps/photos/lib/ui/viewer/actions/album_selection_overlay_bar.dart
+++ b/mobile/apps/photos/lib/ui/viewer/actions/album_selection_overlay_bar.dart
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import "package:photos/models/collection/collection.dart";
import "package:photos/models/selected_albums.dart";
import "package:photos/ui/collections/collection_list_page.dart";
+import "package:photos/ui/components/bottom_action_bar/action_bar_widget.dart";
import "package:photos/ui/components/bottom_action_bar/album_bottom_action_bar_widget.dart";
import "package:photos/ui/viewer/actions/select_all_status_icon.dart";
@@ -14,6 +15,7 @@ class AlbumSelectionOverlayBar extends StatefulWidget {
final Color? backgroundColor;
final UISectionType sectionType;
final bool showSelectAllButton;
+ final ScrollController? backgroundScrollController;
const AlbumSelectionOverlayBar(
this.selectedAlbums,
@@ -23,6 +25,7 @@ class AlbumSelectionOverlayBar extends StatefulWidget {
this.onClose,
this.backgroundColor,
this.showSelectAllButton = false,
+ this.backgroundScrollController,
});
@override
@@ -37,11 +40,13 @@ class _AlbumSelectionOverlayBarState extends State<AlbumSelectionOverlayBar> {
void initState() {
super.initState();
widget.selectedAlbums.addListener(_selectedAlbumsListener);
+ _selectedAlbumsListener();
}
@override
void dispose() {
widget.selectedAlbums.removeListener(_selectedAlbumsListener);
+ _hasSelectedAlbumsNotifier.dispose();
super.dispose();
}
@@ -51,38 +56,28 @@ class _AlbumSelectionOverlayBarState extends State<AlbumSelectionOverlayBar> {
valueListenable: _hasSelectedAlbumsNotifier,
builder: (context, value, child) {
return AnimatedCrossFade(
- firstCurve: Curves.easeInOutExpo,
- secondCurve: Curves.easeInOutExpo,
- sizeCurve: Curves.easeInOutExpo,
+ alignment: Alignment.bottomCenter,
+ firstCurve: Curves.easeOutCubic,
+ secondCurve: Curves.easeOutCubic,
+ sizeCurve: Curves.easeOutCubic,
crossFadeState: _hasSelectedAlbumsNotifier.value
? CrossFadeState.showFirst
: CrossFadeState.showSecond,
- duration: const Duration(milliseconds: 400),
- firstChild: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.end,
- children: [
- if (widget.showSelectAllButton)
- Padding(
- padding: const EdgeInsets.only(right: 4),
- child: SelectAllAlbumsButton(
+ duration: MediaQuery.disableAnimationsOf(context)
+ ? Duration.zero
+ : components.Motion.slow,
+ firstChild: AlbumBottomActionBarWidget(
+ widget.selectedAlbums,
+ widget.sectionType,
+ onCancel: widget.selectedAlbums.clearAll,
+ backgroundColor: widget.backgroundColor,
+ backgroundScrollController: widget.backgroundScrollController,
+ selectAllButton: widget.showSelectAllButton
+ ? SelectAllAlbumsButton(
widget.selectedAlbums,
widget.collections,
- backgroundColor: widget.backgroundColor,
- ),
- ),
- const SizedBox(height: 8),
- AlbumBottomActionBarWidget(
- widget.selectedAlbums,
- widget.sectionType,
- onCancel: () {
- if (widget.selectedAlbums.albums.isNotEmpty) {
- widget.selectedAlbums.clearAll();
- }
- },
- backgroundColor: widget.backgroundColor,
- ),
- ],
+ )
+ : null,
),
secondChild: const SizedBox(width: double.infinity),
);
@@ -95,79 +90,41 @@ class _AlbumSelectionOverlayBarState extends State<AlbumSelectionOverlayBar> {
}
}
-class SelectAllAlbumsButton extends StatefulWidget {
+class SelectAllAlbumsButton extends StatelessWidget {
final SelectedAlbums selectedAlbums;
final List<Collection> collections;
- final Color? backgroundColor;
-
const SelectAllAlbumsButton(
this.selectedAlbums,
this.collections, {
super.key,
- this.backgroundColor,
});
@override
- State<SelectAllAlbumsButton> createState() => _SelectAllAlbumsButtonState();
-}
-
-class _SelectAllAlbumsButtonState extends State<SelectAllAlbumsButton> {
- bool _allSelected = false;
-
- @override
- Widget build(BuildContext context) {
- final colors = components.ComponentTheme.colorsOf(context);
- return GestureDetector(
- onTap: () {
- setState(() {
- if (_allSelected) {
- widget.selectedAlbums.clearAll();
- } else {
- widget.selectedAlbums.select(widget.collections.toSet());
- }
- _allSelected = !_allSelected;
- });
- },
- child: Padding(
- padding: const EdgeInsets.only(top: 8),
- child: Container(
- padding: const EdgeInsets.all(12),
- decoration: BoxDecoration(
- color: widget.backgroundColor ?? colors.backgroundBase,
- border: Border.all(color: colors.strokeDark),
- borderRadius: BorderRadius.circular(32),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- context.strings.selectAllShort,
- style: components.TextStyles.mini.copyWith(
- color: colors.textBase,
- ),
- ),
- const SizedBox(width: 4),
- ListenableBuilder(
- listenable: widget.selectedAlbums,
- builder: (context, _) {
- if (widget.selectedAlbums.albums.length ==
- widget.collections.length) {
- _allSelected = true;
- } else {
- _allSelected = false;
- }
- return SelectAllStatusIcon(
- isSelected: _allSelected,
- size: 16,
- unselectedColor: colors.textLighter,
- );
- },
- ),
- ],
- ),
+ Widget build(BuildContext context) => ListenableBuilder(
+ listenable: selectedAlbums,
+ builder: (context, _) {
+ final allSelected = selectedAlbums.albums.length == collections.length;
+ return SelectionControlChip(
+ label: context.strings.selectAllShort,
+ semanticLabel: context.strings.selectAll,
+ isSelected: allSelected,
+ icon: SelectAllStatusIcon(
+ isSelected: allSelected,
+ size: components.IconSizes.small,
+ unselectedColor: components.ComponentTheme.colorsOf(
+ context,
+ ).textLighter,
),
- ),
- );
- }
+ onTap: collections.isEmpty
+ ? null
+ : () {
+ if (allSelected) {
+ selectedAlbums.clearAll();
+ } else {
+ selectedAlbums.select(collections.toSet());
+ }
+ },
+ );
+ },
+ );
}
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/hooks/album_actions_sheet.dart b/mobile/apps/photos/lib/ui/viewer/gallery/hooks/album_actions_sheet.dart
index dc15dd6144..72a1b78e87 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/hooks/album_actions_sheet.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/hooks/album_actions_sheet.dart
@@ -36,8 +36,8 @@ Future<T?> showAlbumActionsSheet<T>(
final gridWidth = constraints.maxWidth - Spacing.md * 2;
final minTileWidth =
64 *
- media.textScaler.scale(TextStyles.body.fontSize!) /
- TextStyles.body.fontSize!;
+ media.textScaler.scale(TextStyles.mini.fontSize!) /
+ TextStyles.mini.fontSize!;
final columns = gridWidth >= minTileWidth * 4 + Spacing.xs * 3
? 4
: 2;
@@ -263,7 +263,7 @@ class _AlbumActionTile<T> extends StatelessWidget {
maxLines: 2,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
- style: TextStyles.body.copyWith(color: foreground),
+ style: TextStyles.mini.copyWith(color: foreground),
),
],
),
@@ -305,7 +305,7 @@ class _AlbumActionRow<T> extends StatelessWidget {
option.label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
- style: TextStyles.body.copyWith(
+ style: TextStyles.mini.copyWith(
color: option.labelColor ?? colors.textBase,
),
),
diff --git a/mobile/apps/photos/test/ui/viewer/gallery/collection_page_cover_test.dart b/mobile/apps/photos/test/ui/viewer/gallery/collection_page_cover_test.dart
index 96694701bc..4d02520bb5 100644
--- a/mobile/apps/photos/test/ui/viewer/gallery/collection_page_cover_test.dart
+++ b/mobile/apps/photos/test/ui/viewer/gallery/collection_page_cover_test.dart
@@ -52,8 +52,10 @@ import "package:photos/services/machine_learning/face_ml/person/person_service.d
import "package:photos/settings/local_settings.dart";
import "package:photos/src/rust/frb_generated.dart";
import "package:photos/ui/collections/album/row_item.dart";
+import "package:photos/ui/collections/collection_list_page.dart";
import "package:photos/ui/components/bottom_action_bar/action_bar_widget.dart";
import "package:photos/ui/components/bottom_action_bar/selection_action_sheet.dart";
+import "package:photos/ui/viewer/actions/album_selection_overlay_bar.dart";
import "package:photos/ui/viewer/actions/file_selection_overlay_bar.dart";
import "package:photos/ui/viewer/gallery/collection_page.dart";
import "package:photos/ui/viewer/gallery/component/album_cover_app_bar.dart";
@@ -597,6 +599,44 @@ void main() {
},
);
+ testWidgets("album selection controls align and fill the bottom safe area", (
+ tester,
+ ) async {
+ tester.view.physicalSize = const Size(375, 812);
+ tester.view.devicePixelRatio = 1;
+ tester.view.padding = const FakeViewPadding(bottom: 34);
+ addTearDown(tester.view.reset);
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: lightThemeData,
+ localizationsDelegates: StringsLocalizations.localizationsDelegates,
+ supportedLocales: StringsLocalizations.supportedLocales,
+ home: CollectionListPage([
+ _collection(),
+ ], sectionType: UISectionType.archivedCollections),
+ ),
+ );
+ await tester.pumpAndSettle();
+ final selected = tester
+ .widget<AlbumSelectionOverlayBar>(find.byType(AlbumSelectionOverlayBar))
+ .selectedAlbums;
+ selected.select({_collection()});
+ await tester.pumpAndSettle();
+ final material = find.descendant(
+ of: find.byType(SelectionActionSheet),
+ matching: find.byType(Material),
+ );
+ expect(tester.getBottomRight(material).dy, 812);
+ expect(
+ tester.getTopLeft(find.byType(SelectAllAlbumsButton)).dx,
+ tester.getTopLeft(material).dx + Spacing.sm,
+ );
+ await tester.tap(find.bySemanticsLabel(RegExp("Cancel,")));
+ await tester.pumpAndSettle();
+ expect(selected.albums, isEmpty);
+ expect(tester.takeException(), isNull);
+ });
+
testWidgets("anchors the selection sheet during interrupted resizing", (
tester,
) async {
diff --git a/mobile/apps/photos/test/ui/viewer/gallery/selection_action_sheet_test.dart b/mobile/apps/photos/test/ui/viewer/gallery/selection_action_sheet_test.dart
index 72d2cc2b52..f0ce4d49ba 100644
--- a/mobile/apps/photos/test/ui/viewer/gallery/selection_action_sheet_test.dart
+++ b/mobile/apps/photos/test/ui/viewer/gallery/selection_action_sheet_test.dart
@@ -282,6 +282,7 @@ Future<void> _pumpSheet(
],
),
SelectionActionSheet(
+ backgroundScrollController: gallery,
selectionControls: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Row(