π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile][photos] Redesign the album page with a cover header
r4khul4fd20b55472e
diff --git a/mobile/apps/photos/changes/album-cover-redesign.md b/mobile/apps/photos/changes/album-cover-redesign.mdnew file mode 100644index 0000000000..2f61bf8cc4--- /dev/null+++ b/mobile/apps/photos/changes/album-cover-redesign.md@@ -0,0 +1 @@+- Refreshed the album page with a full cover, quick slideshow and map buttons, and a simpler options sheet.diff --git a/mobile/apps/photos/lib/app.dart b/mobile/apps/photos/lib/app.dartindex 8d95b39578..f189a2ac35 100644--- a/mobile/apps/photos/lib/app.dart+++ b/mobile/apps/photos/lib/app.dart@@ -11,6 +11,7 @@ import 'package:logging/logging.dart';import "package:media_extension/media_extension.dart";import 'package:media_extension/media_extension_action_types.dart';import "package:photos/core/event_bus.dart";+import "package:photos/core/page_route_observer.dart";import 'package:photos/ente_theme_data.dart';import "package:photos/events/memories_changed_event.dart";import "package:photos/events/people_changed_event.dart";@@ -222,6 +223,7 @@ class _EnteAppState extends State<EnteApp> with WidgetsBindingObserver {initial: widget.savedThemeMode ?? AdaptiveThemeMode.system,builder: (lightTheme, dartTheme) => MaterialApp(navigatorKey: AppNavigationService.instance.navigatorKey,+ navigatorObservers: [pageRouteObserver],title: "ente",themeMode: ThemeMode.system,theme: lightTheme,diff --git a/mobile/apps/photos/lib/core/page_route_observer.dart b/mobile/apps/photos/lib/core/page_route_observer.dartnew file mode 100644index 0000000000..5098c70177--- /dev/null+++ b/mobile/apps/photos/lib/core/page_route_observer.dart@@ -0,0 +1,3 @@+import "package:flutter/widgets.dart";++final pageRouteObserver = RouteObserver<PageRoute<dynamic>>();diff --git a/mobile/apps/photos/lib/models/gallery/gallery_groups.dart b/mobile/apps/photos/lib/models/gallery/gallery_groups.dartindex 1bb8115bb2..07b82c484d 100644--- a/mobile/apps/photos/lib/models/gallery/gallery_groups.dart+++ b/mobile/apps/photos/lib/models/gallery/gallery_groups.dart@@ -34,6 +34,7 @@ class GalleryGroups {final bool showSelectAll;final _logger = Logger("GalleryGroups");final bool showGallerySettingsCTA;+ final Widget? groupHeaderAction;final GalleryLayoutType? layoutTypeOverride;final bool justifiedLayoutAvailable;@@ -52,6 +53,7 @@ class GalleryGroups {required this.showSelectAll,this.limitSelectionToOne = false,this.showGallerySettingsCTA = false,+ this.groupHeaderAction,this.layoutTypeOverride,required this.justifiedLayoutAvailable,}) {@@ -307,6 +309,7 @@ class GalleryGroups {selectedFiles: selectedFiles,showSelectAll: showSelectAll && !limitSelectionToOne,showGalleryLayoutSettingCTA: rowIndex == 0 && showGallerySettingsCTA,+ action: rowIndex == 0 ? groupHeaderAction : null,);}diff --git a/mobile/apps/photos/lib/ui/components/bottom_action_bar/selection_action_button_widget.dart b/mobile/apps/photos/lib/ui/components/bottom_action_bar/selection_action_button_widget.dartindex 614b85cc67..0fff99150a 100644--- a/mobile/apps/photos/lib/ui/components/bottom_action_bar/selection_action_button_widget.dart+++ b/mobile/apps/photos/lib/ui/components/bottom_action_bar/selection_action_button_widget.dart@@ -9,6 +9,7 @@ class SelectionActionButton extends StatelessWidget {final VoidCallback? onTap;final bool shouldShow;final bool isCritical;+ final Color? color;const SelectionActionButton({required this.labelText,@@ -17,6 +18,7 @@ class SelectionActionButton extends StatelessWidget {this.iconWidget,this.shouldShow = true,this.isCritical = false,+ this.color,super.key,});@@ -35,6 +37,7 @@ class SelectionActionButton extends StatelessWidget {onTap: onTap,iconWidget: iconWidget,isCritical: isCritical,+ color: color,): const SizedBox(height: 60),),@@ -48,12 +51,14 @@ class _Body extends StatefulWidget {final Widget? iconWidget;final VoidCallback? onTap;final bool isCritical;+ final Color? color;const _Body({required this.labelText,required this.onTap,required this.isCritical,this.hugeIcon,this.iconWidget,+ this.color,});@override@@ -72,7 +77,7 @@ class __BodyState extends State<_Body> {final colors = components.ComponentTheme.colorsOf(context);final foregroundColor = widget.isCritical? colors.warning- : colors.textBase;+ : widget.color ?? colors.textBase;final labelStyle = components.TextStyles.mini.copyWith(color: foregroundColor,);diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dartindex 19ca854b9e..f665f14cc1 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dart@@ -1,10 +1,16 @@+import "dart:async";++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/core/configuration.dart';import 'package:photos/core/event_bus.dart';import 'package:photos/db/files_db.dart';import "package:photos/events/collection_meta_event.dart";import 'package:photos/events/collection_updated_event.dart';import 'package:photos/events/files_updated_event.dart';+import "package:photos/models/collection/collection.dart";import 'package:photos/models/collection/collection_items.dart';import 'package:photos/models/file/file.dart';import 'package:photos/models/file_load_result.dart';@@ -12,6 +18,7 @@ import 'package:photos/models/gallery_type.dart';import "package:photos/models/search/hierarchical/album_filter.dart";import "package:photos/models/search/hierarchical/hierarchical_search_filter.dart";import 'package:photos/models/selected_files.dart';+import "package:photos/services/collections_service.dart";import 'package:photos/services/ignored_files_service.dart';import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';import "package:photos/ui/viewer/gallery/empty_album_state.dart";@@ -24,14 +31,15 @@ import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.daimport "package:photos/ui/viewer/gallery/state/inherited_search_filter_data.dart";import "package:photos/ui/viewer/gallery/state/search_filter_data_provider.dart";import "package:photos/ui/viewer/gallery/state/selection_state.dart";+import "package:photos/utils/magic_util.dart";-class CollectionPage extends StatelessWidget {+class CollectionPage extends StatefulWidget {final CollectionWithThumbnail c;final String tagPrefix;final bool? hasVerifiedLock;final EnteFile? fileToJumpTo;- CollectionPage(+ const CollectionPage(this.c, {this.tagPrefix = "collection",this.hasVerifiedLock = false,@@ -39,11 +47,57 @@ class CollectionPage extends StatelessWidget {super.key,});+ @override+ State<CollectionPage> createState() => _CollectionPageState();+}++class _CollectionPageState extends State<CollectionPage> {final _selectedFiles = SelectedFiles();+ late final _searchFilterDataProvider = SearchFilterDataProvider(+ initialGalleryFilter: AlbumFilter(+ collectionID: widget.c.collection.id,+ albumName: widget.c.collection.displayName,+ occurrence: kMostRelevantFilter,+ ),+ );+ late final StreamSubscription<CollectionUpdatedEvent>+ _collectionUpdatedSubscription;+ EnteFile? _cover;++ @override+ void initState() {+ super.initState();+ final collection = widget.c.collection;+ _cover =+ widget.c.thumbnail ??+ CollectionsService.instance.getCoverCache(collection);+ _loadCover();+ _collectionUpdatedSubscription = Bus.instance+ .on<CollectionUpdatedEvent>()+ .where((event) => event.collectionID == collection.id)+ .listen((_) => _loadCover());+ }++ @override+ void dispose() {+ _collectionUpdatedSubscription.cancel();+ super.dispose();+ }++ Future<void> _loadCover() async {+ final cover = await CollectionsService.instance.getCover(+ widget.c.collection,+ );+ if (mounted && cover != _cover) {+ setState(() => _cover = cover);+ }+ }@overrideWidget build(BuildContext context) {- if (hasVerifiedLock == false && c.collection.isHidden()) {+ final c = widget.c;+ final tagPrefix = widget.tagPrefix;+ if (widget.hasVerifiedLock == false && c.collection.isHidden()) {return const EmptyState();}@@ -59,6 +113,7 @@ class CollectionPage extends StatelessWidget {c.collection.displayName,_selectedFiles,collection: c.collection,+ cover: _cover,);final gallery = Gallery(appBar: appBar,@@ -102,6 +157,9 @@ class CollectionPage extends StatelessWidget {sortAsyncFn: () => c.collection.pubMagicMetadata.asc ?? false,addHeaderOrFooterEmptyState: false,showSelectAll: true,+ groupHeaderAction: galleryType.canSort()+ ? _SortButton(c.collection)+ : null,emptyState: galleryType == GalleryType.ownedCollection? EmptyAlbumState(c.collection,@@ -116,18 +174,12 @@ class CollectionPage extends StatelessWidget {): const EmptyState(),footer: const SizedBox(height: 212),- fileToJumpTo: fileToJumpTo,+ fileToJumpTo: widget.fileToJumpTo,);return GalleryFilesState(child: InheritedSearchFilterDataWrapper(- searchFilterDataProvider: SearchFilterDataProvider(- initialGalleryFilter: AlbumFilter(- collectionID: c.collection.id,- albumName: c.collection.displayName,- occurrence: kMostRelevantFilter,- ),- ),+ searchFilterDataProvider: _searchFilterDataProvider,child: GalleryBoundariesProvider(child: Scaffold(body: SelectionState(@@ -167,3 +219,34 @@ class CollectionPage extends StatelessWidget {);}}++class _SortButton extends StatelessWidget {+ const _SortButton(this.collection);++ final Collection collection;++ @override+ Widget build(BuildContext context) {+ final strings = context.strings;+ return EntePopupMenuButton<bool>(+ optionsBuilder: () => [+ EntePopupMenuOption(value: false, label: strings.sortNewestFirst),+ EntePopupMenuOption(value: true, label: strings.sortOldestFirst),+ ],+ onSelected: (sortByAsc) {+ unawaited(changeSortOrder(context, collection, sortByAsc));+ },+ child: Tooltip(+ message: strings.sort,+ child: Padding(+ padding: const EdgeInsets.all(Spacing.xs),+ child: HugeIcon(+ icon: HugeIcons.strokeRoundedArrowUpDown,+ size: IconSizes.small,+ color: context.componentColors.textLighter,+ ),+ ),+ ),+ );+ }+}diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/component/album_cover_app_bar.dart b/mobile/apps/photos/lib/ui/viewer/gallery/component/album_cover_app_bar.dartnew file mode 100644index 0000000000..0efce913c2--- /dev/null+++ b/mobile/apps/photos/lib/ui/viewer/gallery/component/album_cover_app_bar.dart@@ -0,0 +1,557 @@+import "dart:math" as math;++import "package:ente_components/ente_components.dart";+import "package:ente_strings/ente_strings.dart";+import "package:flutter/material.dart";+import "package:flutter/rendering.dart";+import "package:flutter/services.dart";+import "package:hugeicons/hugeicons.dart";+import "package:intl/intl.dart";+import "package:photos/core/constants.dart";+import "package:photos/core/page_route_observer.dart";+import "package:photos/models/collection/collection.dart";+import "package:photos/models/file/file.dart";+import "package:photos/services/collections_service.dart";+import "package:photos/ui/viewer/file/thumbnail_widget.dart";++// Figma: https://www.figma.com/design/BuBNPPytxlVnqfmCUW0mgz/Ente-Visual-Design?node-id=25285-293816&m=dev+class AlbumCoverAppBar extends StatefulWidget {+ const AlbumCoverAppBar({+ super.key,+ required this.collection,+ required this.cover,+ required this.title,+ required this.actionsBuilder,+ required this.coverActions,+ required this.backgroundColor,+ required this.collapsedHeight,+ this.bottom,+ });++ final Collection collection;+ final EnteFile cover;+ final String title;+ final List<Widget> Function(Color foregroundColor) actionsBuilder;+ final List<Widget> coverActions;+ final Color backgroundColor;+ final double collapsedHeight;+ final PreferredSizeWidget? bottom;++ static HeaderAppBarGeometry resolveGeometry(+ BuildContext context, {+ required double collapsedHeight,+ required double bottomHeight,+ }) {+ final topPadding = MediaQuery.paddingOf(context).top;+ return HeaderAppBarGeometry(+ minExtent: topPadding + collapsedHeight + bottomHeight,+ maxExtent: topPadding + _coverHeight + _coverBottomInset(bottomHeight),+ );+ }++ @override+ State<AlbumCoverAppBar> createState() => _AlbumCoverAppBarState();+}++class _AlbumCoverAppBarState extends State<AlbumCoverAppBar> with RouteAware {+ late SystemUiOverlayStyle _pinnedOverlayStyle;+ bool _isCovered = false;++ @override+ void didChangeDependencies() {+ super.didChangeDependencies();+ final isDarkTheme = Theme.of(context).brightness == Brightness.dark;+ _pinnedOverlayStyle = SystemUiOverlayStyle(+ statusBarIconBrightness: isDarkTheme ? Brightness.light : Brightness.dark,+ statusBarBrightness: isDarkTheme ? Brightness.dark : Brightness.light,+ );+ final route = ModalRoute.of(context);+ if (route is PageRoute) {+ pageRouteObserver.subscribe(this, route);+ }+ }++ // The page below stays painted, so its style region would keep applying+ // the cover's light style to the page above it.+ @override+ void didPushNext() {+ setState(() => _isCovered = true);+ }++ @override+ void didPopNext() {+ setState(() => _isCovered = false);+ }++ @override+ void dispose() {+ pageRouteObserver.unsubscribe(this);+ // Pages without their own overlay style would keep the cover's light one.+ SystemChrome.setSystemUIOverlayStyle(_pinnedOverlayStyle);+ WidgetsBinding.instance.scheduleFrame();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ final colors = context.componentColors;+ final bottomHeight = widget.bottom?.preferredSize.height ?? 0;+ final description = widget.collection.displayDescription;++ return SliverPersistentHeader(+ pinned: true,+ delegate: _AlbumCoverDelegate(+ geometry: AlbumCoverAppBar.resolveGeometry(+ context,+ collapsedHeight: widget.collapsedHeight,+ bottomHeight: bottomHeight,+ ),+ topPadding: MediaQuery.paddingOf(context).top,+ collapsedHeight: widget.collapsedHeight,+ bottomHeight: bottomHeight,+ colors: colors,+ backgroundColor: widget.backgroundColor,+ pinnedOverlayStyle: _pinnedOverlayStyle,+ isCovered: _isCovered,+ title: widget.title,+ actionsBuilder: widget.actionsBuilder,+ bottom: widget.bottom,+ photo: _CoverPhoto(+ cover: widget.cover,+ backgroundColor: widget.backgroundColor,+ ),+ content: SizedBox(+ width: MediaQuery.sizeOf(context).width - Spacing.lg * 2,+ child: Stack(+ clipBehavior: Clip.none,+ alignment: Alignment.center,+ children: [+ const Positioned(+ left: -_contentScrimOutset,+ right: -_contentScrimOutset,+ top: -_contentScrimOutset,+ bottom: -_contentScrimOutset,+ child: IgnorePointer(+ child: FittedBox(+ fit: BoxFit.fill,+ child: SizedBox.square(+ dimension: 1,+ child: DecoratedBox(+ decoration: BoxDecoration(+ gradient: RadialGradient(+ colors: [_scrimColor, _transparentScrimColor],+ ),+ ),+ ),+ ),+ ),+ ),+ ),+ Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ _CoverCaption(widget.collection),+ Semantics(+ header: true,+ child: Text(+ widget.title,+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ textAlign: TextAlign.center,+ style: TextStyles.display1.copyWith(+ color: colors.specialWhite,+ ),+ ),+ ),+ if (description != null) ...[+ const SizedBox(height: Spacing.sm),+ Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: Spacing.lg,+ ),+ child: Text(+ description,+ maxLines: _descriptionMaxLines,+ overflow: TextOverflow.ellipsis,+ textAlign: TextAlign.center,+ style: TextStyles.mini.copyWith(+ color: colors.specialWhite.withValues(alpha: 0.92),+ ),+ ),+ ),+ ],+ if (widget.coverActions.isNotEmpty) ...[+ const SizedBox(height: Spacing.md),+ Row(+ mainAxisSize: MainAxisSize.min,+ spacing: Spacing.md,+ children: widget.coverActions,+ ),+ ],+ ],+ ),+ ],+ ),+ ),+ ),+ );+ }+}++class AlbumCoverActionButton extends StatelessWidget {+ const AlbumCoverActionButton({+ super.key,+ required this.icon,+ required this.tooltip,+ required this.onTap,+ });++ final List<List<dynamic>> icon;+ final String tooltip;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ return Tooltip(+ message: tooltip,+ child: Semantics(+ button: true,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: onTap,+ child: Container(+ width: _coverActionSize,+ height: _coverActionSize,+ alignment: Alignment.center,+ decoration: const BoxDecoration(+ shape: BoxShape.circle,+ gradient: RadialGradient(+ colors: [_coverActionFillColor, _scrimColor],+ ),+ ),+ child: HugeIcon(+ icon: icon,+ size: _coverActionIconSize,+ color: context.componentColors.specialWhite,+ ),+ ),+ ),+ ),+ );+ }+}++class _CoverPhoto extends StatelessWidget {+ const _CoverPhoto({required this.cover, required this.backgroundColor});++ final EnteFile cover;+ final Color backgroundColor;++ @override+ Widget build(BuildContext context) {+ return Stack(+ fit: StackFit.expand,+ clipBehavior: Clip.none,+ children: [+ ThumbnailWidget(+ cover,+ rawThumbnail: true,+ thumbnailSize: thumbnailLargeSize,+ useRequestedThumbnailSizeForLocalCache: true,+ ),+ const ColoredBox(color: _photoScrimColor),+ // Overshoots the photo so its antialiased edge cannot show through.+ Positioned(+ left: 0,+ right: 0,+ bottom: -_coverDissolveOvershoot,+ height: _coverDissolveHeight + _coverDissolveOvershoot,+ child: DecoratedBox(+ decoration: BoxDecoration(+ gradient: LinearGradient(+ begin: Alignment.topCenter,+ end: Alignment.bottomCenter,+ colors: [backgroundColor.withValues(alpha: 0), backgroundColor],+ stops: const [+ 0,+ _coverDissolveHeight /+ (_coverDissolveHeight + _coverDissolveOvershoot),+ ],+ ),+ ),+ ),+ ),+ ],+ );+ }+}++class _CoverCaption extends StatelessWidget {+ const _CoverCaption(this.collection);++ final Collection collection;++ Future<({int count, int? newestFileTime})> _loadSummary() async {+ final collectionsService = CollectionsService.instance;+ final count = await collectionsService.getFileCount(collection);+ final newestFileTimes = await collectionsService+ .getCollectionIDToNewestFileTime();+ return (count: count, newestFileTime: newestFileTimes[collection.id]);+ }++ @override+ Widget build(BuildContext context) {+ return FutureBuilder(+ future: _loadSummary(),+ builder: (context, snapshot) {+ final summary = snapshot.data;+ if (summary == null) {+ return const SizedBox.shrink();+ }++ final newestFileTime = summary.newestFileTime;+ final caption = [+ context.strings.memoryCount(+ count: summary.count,+ formattedCount: NumberFormat().format(summary.count),+ ),+ if (newestFileTime != null)+ DateFormat.yMMM(+ Localizations.localeOf(context).languageCode,+ ).format(DateTime.fromMicrosecondsSinceEpoch(newestFileTime)),+ ].join(" Β· ");++ return Padding(+ padding: const EdgeInsets.only(bottom: Spacing.md),+ child: DecoratedBox(+ decoration: const ShapeDecoration(+ color: _captionFillColor,+ shape: StadiumBorder(),+ ),+ child: Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: Spacing.md,+ vertical: Spacing.sm,+ ),+ child: Text(+ caption.toUpperCase(),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: TextStyles.tiny.copyWith(+ color: context.componentColors.specialWhite.withValues(+ alpha: 0.82,+ ),+ ),+ ),+ ),+ ),+ );+ },+ );+ }+}++class _AlbumCoverDelegate extends SliverPersistentHeaderDelegate {+ const _AlbumCoverDelegate({+ required this.geometry,+ required this.topPadding,+ required this.collapsedHeight,+ required this.bottomHeight,+ required this.colors,+ required this.backgroundColor,+ required this.pinnedOverlayStyle,+ required this.isCovered,+ required this.title,+ required this.actionsBuilder,+ required this.bottom,+ required this.photo,+ required this.content,+ });++ final HeaderAppBarGeometry geometry;+ final double topPadding;+ final double collapsedHeight;+ final double bottomHeight;+ final ColorTokens colors;+ final Color backgroundColor;+ final SystemUiOverlayStyle pinnedOverlayStyle;+ final bool isCovered;+ final String title;+ final List<Widget> Function(Color foregroundColor) actionsBuilder;+ final PreferredSizeWidget? bottom;+ final Widget photo;+ final Widget content;++ @override+ double get maxExtent => geometry.maxExtent;++ @override+ double get minExtent => geometry.minExtent;++ @override+ OverScrollHeaderStretchConfiguration get stretchConfiguration =>+ _stretchConfiguration;++ @override+ Widget build(+ BuildContext context,+ double shrinkOffset,+ bool overlapsContent,+ ) {+ final collapseOffset = math.min(shrinkOffset, geometry.collapseExtent);+ final pinnedProgress =+ ((collapseOffset / geometry.collapseExtent - _pinnedFadeStart) /+ (1 - _pinnedFadeStart))+ .clamp(0.0, 1.0);+ final contentOpacity = (1 - collapseOffset / _contentFadeExtent).clamp(+ 0.0,+ 1.0,+ );+ final titleOpacity = (1 - contentOpacity * 2).clamp(0.0, 1.0);+ final foregroundColor = Color.lerp(+ colors.specialWhite,+ colors.textBase,+ ((pinnedProgress - _foregroundSwitchStart) /+ (_foregroundSwitchEnd - _foregroundSwitchStart))+ .clamp(0.0, 1.0),+ )!;+ final coverBottomInset = _coverBottomInset(bottomHeight);++ return AnnotatedRegion<SystemUiOverlayStyle>(+ value: pinnedProgress < 0.5 && !isCovered+ ? _coverOverlayStyle+ : pinnedOverlayStyle,+ child: Stack(+ fit: StackFit.expand,+ children: [+ Positioned(+ top: -collapseOffset,+ left: 0,+ right: 0,+ bottom: coverBottomInset,+ child: photo,+ ),+ Positioned(+ top: 0,+ left: 0,+ right: 0,+ height: topPadding + _topScrimHeight,+ child: const IgnorePointer(+ child: DecoratedBox(+ decoration: BoxDecoration(+ gradient: LinearGradient(+ begin: Alignment.topCenter,+ end: Alignment.bottomCenter,+ colors: [_scrimColor, _transparentScrimColor],+ ),+ ),+ ),+ ),+ ),+ if (contentOpacity > 0)+ Positioned(+ top: topPadding + collapsedHeight,+ left: Spacing.lg,+ right: Spacing.lg,+ bottom: coverBottomInset + _contentBottomGap,+ child: Opacity(+ opacity: contentOpacity,+ child: FittedBox(+ fit: BoxFit.scaleDown,+ alignment: Alignment.bottomCenter,+ child: content,+ ),+ ),+ ),+ if (pinnedProgress > 0)+ Positioned.fill(+ child: ColoredBox(+ color: backgroundColor.withValues(alpha: pinnedProgress),+ ),+ ),+ Positioned(+ top: topPadding,+ left: Spacing.lg,+ right: Spacing.lg,+ height: collapsedHeight,+ child: Row(+ spacing: Spacing.sm,+ children: [+ IconButtonComponent(+ tooltip: MaterialLocalizations.of(context).backButtonTooltip,+ icon: HugeIcon(+ icon: HugeIcons.strokeRoundedArrowLeft02,+ color: foregroundColor,+ ),+ variant: IconButtonComponentVariant.unfilled,+ shouldSurfaceExecutionStates: false,+ onTap: () => Navigator.maybePop(context),+ ),+ Expanded(+ child: ExcludeSemantics(+ excluding: titleOpacity == 0,+ child: Opacity(+ opacity: titleOpacity,+ child: Text(+ title,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: TextStyles.display3.copyWith(+ color: foregroundColor,+ ),+ ),+ ),+ ),+ ),+ ...actionsBuilder(foregroundColor),+ ],+ ),+ ),+ if (bottom != null)+ Positioned(+ left: 0,+ right: 0,+ bottom: 0,+ height: bottomHeight,+ child: bottom!,+ ),+ ],+ ),+ );+ }++ @override+ bool shouldRebuild(covariant _AlbumCoverDelegate oldDelegate) => true;+}++double _coverBottomInset(double bottomHeight) {+ return math.max(0.0, bottomHeight - _bottomOverlap);+}++const _coverHeight = 441.0;+const _coverDissolveHeight = 100.0;+const _coverDissolveOvershoot = 1.0;+const _topScrimHeight = 31.0;+const _bottomOverlap = 25.0;+const _contentBottomGap = 108.0;+const _contentScrimOutset = 56.0;+const _contentFadeExtent = 120.0;+const _pinnedFadeStart = 0.6;+const _foregroundSwitchStart = 0.4;+const _foregroundSwitchEnd = 0.6;+const _descriptionMaxLines = 3;+const _coverActionSize = 42.0;+const _coverActionIconSize = 17.0;++const _photoScrimColor = Color(0x3D000000);+const _scrimColor = Color(0x33000000);+const _transparentScrimColor = Color(0x00000000);+const _captionFillColor = Color(0x52000000);+const _coverActionFillColor = Color(0x66000000);++const _coverOverlayStyle = SystemUiOverlayStyle(+ statusBarIconBrightness: Brightness.light,+ statusBarBrightness: Brightness.dark,+);++final _stretchConfiguration = OverScrollHeaderStretchConfiguration();diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/component/group/group_header_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/component/group/group_header_widget.dartindex 7edf86ed82..0003f4a2c2 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/component/group/group_header_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/component/group/group_header_widget.dart@@ -21,6 +21,7 @@ class GroupHeaderWidget extends StatefulWidget {final SelectedFiles? selectedFiles;final bool showSelectAll;final bool showGalleryLayoutSettingCTA;+ final Widget? action;final bool showTrailingIcons;final bool isPinnedHeader;final bool fadeInTrailingIcons;@@ -33,6 +34,7 @@ class GroupHeaderWidget extends StatefulWidget {required this.selectedFiles,required this.showSelectAll,this.showGalleryLayoutSettingCTA = false,+ this.action,this.height,this.showTrailingIcons = true,this.isPinnedHeader = false,@@ -113,6 +115,10 @@ class _GroupHeaderWidgetState extends State<GroupHeaderWidget> {),),Expanded(child: Container()),+ if (widget.action != null && widget.showTrailingIcons) ...[+ _fadeInTrailingIcon(widget.action!),+ const SizedBox(width: 8),+ ],!widget.showSelectAll? const SizedBox.shrink(): widget.showTrailingIcons@@ -181,11 +187,18 @@ class _GroupHeaderWidgetState extends State<GroupHeaderWidget> {}Widget _buildSelectionIcon(bool isSelected) {- final icon = SelectAllStatusIcon(- isSelected: isSelected,- size: _selectionIconSize,- unselectedColor: components.ComponentTheme.colorsOf(context).textLighter,+ return _fadeInTrailingIcon(+ SelectAllStatusIcon(+ isSelected: isSelected,+ size: _selectionIconSize,+ unselectedColor: components.ComponentTheme.colorsOf(+ context,+ ).textLighter,+ ),);+ }++ Widget _fadeInTrailingIcon(Widget icon) {if (!widget.fadeInTrailingIcons) {return icon;}diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dartindex d21a11a40f..14a6c52d5a 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart@@ -80,6 +80,7 @@ class Gallery extends StatefulWidget {final Duration priorityReloadDebounceTime;final GalleryType? galleryType;final bool showGallerySettingsCTA;+ final Widget? groupHeaderAction;final GalleryLayoutType? layoutTypeOverride;// Return null to force a full reload.@@ -133,6 +134,7 @@ class Gallery extends StatefulWidget {this.galleryType,this.disableVerticalPaddingForScrollbar = false,this.showGallerySettingsCTA = false,+ this.groupHeaderAction,this.layoutTypeOverride,this.fileToJumpTo,this.newLocalFilesResolver,@@ -396,6 +398,7 @@ class GalleryState extends State<Gallery> {showSelectAll: widget.showSelectAll,limitSelectionToOne: widget.limitSelectionToOne,showGallerySettingsCTA: widget.showGallerySettingsCTA,+ groupHeaderAction: widget.groupHeaderAction,layoutTypeOverride: widget.layoutTypeOverride,justifiedLayoutAvailable: isJustifiedLayoutAvailable,);@@ -1022,6 +1025,7 @@ class GalleryState extends State<Gallery> {scrollbarInUseNotifier: scrollBarInUseNotifier,showGallerySettingsCTA:widget.showGallerySettingsCTA,+ groupHeaderAction: widget.groupHeaderAction,): const SizedBox.shrink(),],@@ -1071,6 +1075,7 @@ class PinnedGroupHeader extends StatefulWidget {final bool showSelectAll;final ValueNotifier<bool> scrollbarInUseNotifier;final bool showGallerySettingsCTA;+ final Widget? groupHeaderAction;static const kScaleDurationInMilliseconds = 200;static const kTrailingIconsFadeInDelayMs = 0;static const kTrailingIconsFadeInDurationMs = 200;@@ -1085,6 +1090,7 @@ class PinnedGroupHeader extends StatefulWidget {required this.showSelectAll,required this.scrollbarInUseNotifier,required this.showGallerySettingsCTA,+ required this.groupHeaderAction,super.key,});@@ -1301,6 +1307,7 @@ class _PinnedGroupHeaderState extends State<PinnedGroupHeader>showSelectAll: widget.showSelectAll,showGalleryLayoutSettingCTA:widget.showGallerySettingsCTA,+ action: widget.groupHeaderAction,showTrailingIcons: !inUse,isPinnedHeader: true,fadeInTrailingIcons: fadeInTrailingIcons,diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_actions.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_actions.dartindex 105b5efb50..c9e1f580f4 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_actions.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_actions.dart@@ -2,6 +2,7 @@ import "dart:async";import "package:ente_components/ente_components.dart";import "package:flutter/material.dart";+import "package:photos/ui/viewer/gallery/hooks/album_actions_sheet.dart";class GalleryAppBarIconButtonSurface extends StatelessWidget {const GalleryAppBarIconButtonSurface({required this.icon, super.key});@@ -47,3 +48,31 @@ Widget galleryAppBarPopupMenuAction<T>({),);}++Widget galleryAppBarActionsSheetAction<T>({+ required Widget icon,+ required String tooltip,+ required FutureOr<List<EntePopupMenuOption<T>>> Function() optionsBuilder,+ required FutureOr<void> Function(T) onSelected,+}) {+ return Builder(+ builder: (context) => IconButtonComponent(+ tooltip: tooltip,+ icon: icon,+ variant: IconButtonComponentVariant.unfilled,+ shouldSurfaceExecutionStates: false,+ onTap: () async {+ final options = await optionsBuilder();+ if (!context.mounted || options.isEmpty) {+ return;+ }++ final selected = await showAlbumActionsSheet<T>(context, options);+ if (!context.mounted || selected == null) {+ return;+ }+ await onSelected(selected);+ },+ ),+ );+}diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dartindex 13dd9ce501..0aa182c0c8 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart@@ -47,6 +47,7 @@ import 'package:photos/ui/sharing/share_collection_page.dart';import 'package:photos/ui/tools/free_space_page.dart';import "package:photos/ui/viewer/album_slideshow/album_slideshow.dart";import "package:photos/ui/viewer/file/detail_page.dart";+import "package:photos/ui/viewer/gallery/component/album_cover_app_bar.dart";import "package:photos/ui/viewer/gallery/component/album_description_header.dart";import "package:photos/ui/viewer/gallery/gallery_app_bar_actions.dart";import "package:photos/ui/viewer/gallery/gallery_app_bar_config.dart";@@ -75,10 +76,12 @@ class GalleryAppBarWidget extends StatefulWidget {bool? isDeviceFolderBackedUp,Future<void> Function()? onDisableDeviceFolderBackup,Collection? collection,+ EnteFile? cover,List<EnteFile>? files,PreferredSizeWidget? bottom,bool showOverflowMenu = true,}) {+ assert(cover == null || collection != null);return GalleryAppBarConfig(sliverBuilder: (_) => GalleryAppBarWidget._(type,@@ -89,6 +92,7 @@ class GalleryAppBarWidget extends StatefulWidget {isDeviceFolderBackedUp: isDeviceFolderBackedUp,onDisableDeviceFolderBackup: onDisableDeviceFolderBackup,collection: collection,+ cover: cover,files: files,bottom: bottom,showOverflowMenu: showOverflowMenu,@@ -98,6 +102,7 @@ class GalleryAppBarWidget extends StatefulWidget {subtitle: subtitle,description: collection?.displayDescription,bottomHeight: bottom?.preferredSize.height,+ hasCover: cover != null,),);}@@ -107,6 +112,7 @@ class GalleryAppBarWidget extends StatefulWidget {String? subtitle,String? description,double? bottomHeight,+ required bool hasCover,}) {final inheritedSearchFilterData = InheritedSearchFilterData.maybeOf(context,@@ -116,6 +122,19 @@ class GalleryAppBarWidget extends StatefulWidget {bottomHeight ??= isHierarchicalSearchable? AppBarFilterChips.preferredHeight(context): 0.0;+ final isSearching =+ inheritedSearchFilterData+ ?.searchFilterDataProvider+ ?.isSearchingNotifier+ .value ??+ false;+ if (hasCover && !isSearching) {+ return AlbumCoverAppBar.resolveGeometry(+ context,+ collapsedHeight: toolbarHeight,+ bottomHeight: bottomHeight,+ );+ }final collapsibleBottomHeight = AlbumDescriptionHeader.preferredHeight(context,description,@@ -139,6 +158,7 @@ class GalleryAppBarWidget extends StatefulWidget {final bool? isDeviceFolderBackedUp;final Future<void> Function()? onDisableDeviceFolderBackup;final Collection? collection;+ final EnteFile? cover;final List<EnteFile>? files;final PreferredSizeWidget? bottom;final bool showOverflowMenu;@@ -152,6 +172,7 @@ class GalleryAppBarWidget extends StatefulWidget {this.isDeviceFolderBackedUp,this.onDisableDeviceFolderBackup,this.collection,+ this.cover,this.files,this.bottom,required this.showOverflowMenu,@@ -291,6 +312,9 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {}if (!isHierarchicalSearchable) {+ if (widget.cover != null) {+ return _albumCoverAppBar();+ }return _GallerySliverAppBar(title: _appBarTitle,subtitle: widget.subtitle,@@ -311,6 +335,9 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {child: const AppBarFilterChips(),),builder: (context, isSearching, child) {+ if (widget.cover != null && !isSearching) {+ return _albumCoverAppBar(bottom: child as PreferredSizeWidget);+ }return _GallerySliverAppBar(title: _appBarTitle,subtitle: widget.subtitle,@@ -322,6 +349,33 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {);}+ Widget _albumCoverAppBar({PreferredSizeWidget? bottom}) {+ final strings = context.strings;+ return AlbumCoverAppBar(+ collection: widget.collection!,+ cover: widget.cover!,+ title: _appBarTitle,+ backgroundColor: GalleryAppBarWidget.backgroundColor(context),+ collapsedHeight: GalleryAppBarWidget.toolbarHeight,+ bottom: bottom,+ actionsBuilder: (foregroundColor) =>+ _getDefaultActions(context, foregroundColor: foregroundColor),+ coverActions: [+ AlbumCoverActionButton(+ icon: HugeIcons.strokeRoundedPlay,+ tooltip: strings.slideshow,+ onTap: _startAlbumSlideshow,+ ),+ if (galleryType.showMap())+ AlbumCoverActionButton(+ icon: HugeIcons.strokeRoundedMapsLocation02,+ tooltip: strings.map,+ onTap: showOnMap,+ ),+ ],+ );+ }+Future<void> _editAlbumDetails(BuildContext context) async {final collection = widget.collection;if (collection == null) {@@ -497,8 +551,15 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {);}- List<Widget> _getDefaultActions(BuildContext context) {+ List<Widget> _getDefaultActions(+ BuildContext context, {+ Color? foregroundColor,+ }) {final List<Widget> actions = <Widget>[];+ final onCover = foregroundColor != null;+ final iconButtonVariant = onCover+ ? IconButtonComponentVariant.unfilled+ : IconButtonComponentVariant.primary;if (widget.selectedFiles.files.isNotEmpty) {return actions;}@@ -558,8 +619,11 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {actions.add(IconButtonComponent(tooltip: strings.addFiles,- icon: const HugeIcon(icon: HugeIcons.strokeRoundedImageAdd01),- variant: IconButtonComponentVariant.primary,+ icon: HugeIcon(+ icon: HugeIcons.strokeRoundedImageAdd01,+ color: foregroundColor,+ ),+ variant: iconButtonVariant,shouldSurfaceExecutionStates: false,onTap: () async {await _showAddPhotoDialog(context);@@ -576,8 +640,9 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {icon: isQuickLink && (widget.collection!.hasLink)? HugeIcons.strokeRoundedLink02: HugeIcons.strokeRoundedShare08,+ color: foregroundColor,),- variant: IconButtonComponentVariant.primary,+ variant: iconButtonVariant,shouldSurfaceExecutionStates: false,onTap: () async {await _showShareCollectionDialog();@@ -594,10 +659,16 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {return actions;}+ final overflowMenuAction = onCover+ ? galleryAppBarActionsSheetAction+ : galleryAppBarPopupMenuAction;actions.add(- galleryAppBarPopupMenuAction<AlbumPopupAction>(+ overflowMenuAction<AlbumPopupAction>(tooltip: strings.more,- icon: const HugeIcon(icon: HugeIcons.strokeRoundedMoreVertical),+ icon: HugeIcon(+ icon: HugeIcons.strokeRoundedMoreVertical,+ color: foregroundColor,+ ),optionsBuilder: () => _buildOverflowMenuOptions(strings: strings,userId: userId,@@ -766,7 +837,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {size: IconSizes.small,),),- if (galleryType.showMap())+ if (galleryType.showMap() && widget.cover == null)_menuOption(AlbumPopupAction.map,strings.map,@@ -775,7 +846,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {size: IconSizes.small,),),- if (galleryType.canSort())+ if (galleryType.canSort() && widget.cover == null)_menuOption(AlbumPopupAction.sort,strings.sortAlbumsBy,@@ -830,7 +901,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {(isArchived || (galleryType.canArchive() && !isHidden)))_menuOption(AlbumPopupAction.ownedArchive,- isArchived ? strings.unarchiveAlbum : strings.archiveAlbum,+ isArchived ? strings.unarchive : strings.archive,HugeIcon(icon: isArchived? HugeIcons.strokeRoundedUnarchive03@@ -849,6 +920,41 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {size: IconSizes.small,),),+ if (galleryType == GalleryType.sharedCollection)+ _menuOption(+ AlbumPopupAction.shareePinAlbum,+ widget.collection!.hasShareePinned() ? strings.unpin : strings.pin,+ HugeIcon(+ icon: widget.collection!.hasShareePinned()+ ? HugeIcons.strokeRoundedPinOff+ : HugeIcons.strokeRoundedPin,+ size: IconSizes.small,+ ),+ ),+ if (galleryType == GalleryType.sharedCollection)+ _menuOption(+ AlbumPopupAction.sharedArchive,+ widget.collection!.hasShareeArchived()+ ? strings.unarchive+ : strings.archive,+ HugeIcon(+ icon: widget.collection!.hasShareeArchived()+ ? HugeIcons.strokeRoundedUnarchive03+ : HugeIcons.strokeRoundedArchive03,+ size: IconSizes.small,+ ),+ ),+ if (galleryType == GalleryType.sharedCollection)+ _menuOption(+ AlbumPopupAction.sharedHide,+ widget.collection!.hasShareeHidden() ? strings.unhide : strings.hide,+ HugeIcon(+ icon: widget.collection!.hasShareeHidden()+ ? HugeIcons.strokeRoundedView+ : HugeIcons.strokeRoundedViewOffSlash,+ size: IconSizes.small,+ ),+ ),if (widget.collection != null)_menuOption(AlbumPopupAction.galleryGuestView,@@ -871,7 +977,8 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {size: IconSizes.small,),),- if (_isAlbumSlideshowAvailable) _slideshowMenuOption(strings),+ if (_isAlbumSlideshowAvailable && widget.cover == null)+ _slideshowMenuOption(strings),if (canAutoAdd)_menuOption(AlbumPopupAction.autoAddPhotos,@@ -884,57 +991,26 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {if (galleryType.canDelete())_menuOption(isQuickLink ? AlbumPopupAction.removeLink : AlbumPopupAction.delete,- isQuickLink ? strings.removeLink : strings.deleteAlbum,+ isQuickLink ? strings.removeLink : strings.delete,HugeIcon(icon: isQuickLink? HugeIcons.strokeRoundedLinkBackward: HugeIcons.strokeRoundedDelete01,size: IconSizes.small,+ color: warningColor,),- ),- if (galleryType == GalleryType.sharedCollection)- _menuOption(- AlbumPopupAction.shareePinAlbum,- widget.collection!.hasShareePinned() ? strings.unpin : strings.pin,- HugeIcon(- icon: widget.collection!.hasShareePinned()- ? HugeIcons.strokeRoundedPinOff- : HugeIcons.strokeRoundedPin,- size: IconSizes.small,- ),- ),- if (galleryType == GalleryType.sharedCollection)- _menuOption(- AlbumPopupAction.sharedArchive,- widget.collection!.hasShareeArchived()- ? strings.unarchiveAlbum- : strings.archiveAlbum,- HugeIcon(- icon: widget.collection!.hasShareeArchived()- ? HugeIcons.strokeRoundedUnarchive03- : HugeIcons.strokeRoundedArchive03,- size: IconSizes.small,- ),- ),- if (galleryType == GalleryType.sharedCollection)- _menuOption(- AlbumPopupAction.sharedHide,- widget.collection!.hasShareeHidden() ? strings.unhide : strings.hide,- HugeIcon(- icon: widget.collection!.hasShareeHidden()- ? HugeIcons.strokeRoundedView- : HugeIcons.strokeRoundedViewOffSlash,- size: IconSizes.small,- ),+ labelColor: warningColor,),if (galleryType == GalleryType.sharedCollection)_menuOption(AlbumPopupAction.leave,strings.leaveAlbum,- const HugeIcon(+ HugeIcon(icon: HugeIcons.strokeRoundedLogout05,size: IconSizes.small,+ color: warningColor,),+ labelColor: warningColor,),if (galleryType == GalleryType.localFolder && !_isICloudSharedAlbum)_menuOption(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.dartnew file mode 100644index 0000000000..b18b0b2994--- /dev/null+++ b/mobile/apps/photos/lib/ui/viewer/gallery/hooks/album_actions_sheet.dart@@ -0,0 +1,145 @@+import "package:ente_components/ente_components.dart";+import "package:flutter/material.dart";+import "package:photos/ui/components/bottom_action_bar/selection_action_button_widget.dart";++// Figma: https://www.figma.com/design/BuBNPPytxlVnqfmCUW0mgz/Ente-Visual-Design?node-id=25316-7380&m=dev+Future<T?> showAlbumActionsSheet<T>(+ BuildContext context,+ List<EntePopupMenuOption<T>> options,+) {+ final criticalIndex = options.indexWhere(+ (option) => option.labelColor != null,+ );+ final tiles = [+ ...options+ .where((option) => option.labelColor == null)+ .take(criticalIndex == -1 ? _tilesPerShelf : _tilesPerShelf - 1),+ if (criticalIndex != -1) options[criticalIndex],+ ];+ final rows = options.where((option) => !tiles.contains(option)).toList();++ return showBottomSheetComponent<T>(+ context: context,+ builder: (context) {+ final colors = context.componentColors;+ return BottomSheetComponent(+ showCloseButton: false,+ backgroundColor: colors.fillLight,+ padding: const EdgeInsets.only(top: Spacing.lg, bottom: Spacing.sm),+ content: ConstrainedBox(+ constraints: BoxConstraints(+ maxHeight: MediaQuery.sizeOf(context).height * _maxHeightFraction,+ ),+ child: SingleChildScrollView(+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ Container(+ width: 36,+ height: 5,+ decoration: BoxDecoration(+ color: colors.textLightest,+ borderRadius: BorderRadius.circular(3),+ ),+ ),+ const SizedBox(height: Spacing.xxl),+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: Spacing.md),+ child: Row(+ crossAxisAlignment: CrossAxisAlignment.start,+ spacing: Spacing.xs,+ children: [+ for (final option in tiles)+ Expanded(+ child: SelectionActionButton(+ labelText: option.label,+ iconWidget:+ option.leadingWidget ?? const SizedBox.shrink(),+ isCritical: option.labelColor != null,+ color: colors.textLight,+ onTap: () =>+ Navigator.of(context).pop(option.value),+ ),+ ),+ ],+ ),+ ),+ if (rows.isNotEmpty)+ const DividerComponent(+ padding: EdgeInsets.fromLTRB(+ Spacing.lg,+ Spacing.lg,+ Spacing.lg,+ Spacing.xl,+ ),+ ),+ for (final option in rows)+ _AlbumActionRow(+ option: option,+ onTap: () => Navigator.of(context).pop(option.value),+ ),+ const SizedBox(height: Spacing.lg),+ ],+ ),+ ),+ ),+ );+ },+ );+}++class _AlbumActionRow<T> extends StatelessWidget {+ const _AlbumActionRow({required this.option, required this.onTap});++ final EntePopupMenuOption<T> option;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ final colors = context.componentColors;++ return Semantics(+ button: true,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: onTap,+ child: ConstrainedBox(+ constraints: const BoxConstraints(minHeight: 48),+ child: Padding(+ padding: const EdgeInsets.symmetric(horizontal: Spacing.lg),+ child: Row(+ spacing: Spacing.md,+ children: [+ SizedBox.square(+ dimension: 34,+ child: Center(+ child: IconTheme.merge(+ data: IconThemeData(+ color: option.labelColor ?? colors.textLight,+ size: IconSizes.small,+ ),+ child: option.leadingWidget ?? const SizedBox.shrink(),+ ),+ ),+ ),+ Expanded(+ child: Text(+ option.label,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: TextStyles.mini.copyWith(+ color: option.labelColor ?? colors.textBase,+ ),+ ),+ ),+ ],+ ),+ ),+ ),+ ),+ );+ }+}++const _tilesPerShelf = 4;+const _maxHeightFraction = 0.8;diff --git a/mobile/apps/photos/test/ui/viewer/gallery/album_actions_sheet_test.dart b/mobile/apps/photos/test/ui/viewer/gallery/album_actions_sheet_test.dartnew file mode 100644index 0000000000..b2a8048cf2--- /dev/null+++ b/mobile/apps/photos/test/ui/viewer/gallery/album_actions_sheet_test.dart@@ -0,0 +1,122 @@+import "package:ente_components/ente_components.dart";+import "package:ente_strings/ente_strings.dart";+import "package:flutter/material.dart";+import "package:flutter_test/flutter_test.dart";+import "package:photos/ente_theme_data.dart";+import "package:photos/ui/components/bottom_action_bar/selection_action_button_widget.dart";+import "package:photos/ui/viewer/gallery/hooks/album_actions_sheet.dart";++void main() {+ group("showAlbumActionsSheet", () {+ testWidgets("keeps the destructive option last in the shelf", (+ tester,+ ) async {+ await _pumpLauncher(tester, (_) {});+ await _openLauncher(tester);++ final tileLabels = tester+ .widgetList<SelectionActionButton>(find.byType(SelectionActionButton))+ .map((tile) => tile.labelText);+ expect(tileLabels, ["Edit", "Pin", "Archive", "Delete"]);+ expect(find.text("Hide"), findsOneWidget);+ expect(find.text("Cast"), findsOneWidget);+ });++ testWidgets("returns the tapped row", (tester) async {+ String? result;+ await _pumpLauncher(tester, (value) => result = value);+ await _openLauncher(tester);++ await tester.tap(find.text("Hide"));+ await tester.pumpAndSettle();++ expect(result, "hide");+ expect(find.byType(BottomSheetComponent), findsNothing);+ });++ testWidgets("scrolls instead of overflowing on short screens", (+ tester,+ ) async {+ tester.view.physicalSize = const Size(667, 240);+ tester.view.devicePixelRatio = 1;+ addTearDown(tester.view.reset);+ String? result;+ await _pumpLauncher(tester, (value) => result = value);+ await _openLauncher(tester);++ await tester.dragUntilVisible(+ find.text("Cast"),+ find.byType(SingleChildScrollView),+ const Offset(0, -50),+ );+ await tester.tap(find.text("Cast"));+ await tester.pumpAndSettle();++ expect(tester.takeException(), isNull);+ expect(result, "cast");+ });++ testWidgets("returns the tapped tile", (tester) async {+ String? result;+ await _pumpLauncher(tester, (value) => result = value);+ await _openLauncher(tester);++ await tester.tap(find.text("Delete"));+ await tester.pumpAndSettle();++ expect(result, "delete");+ });+ });+}++List<EntePopupMenuOption<String>> _options(BuildContext context) {+ EntePopupMenuOption<String> option(String label, {Color? labelColor}) {+ return EntePopupMenuOption(+ value: label.toLowerCase(),+ label: label,+ labelColor: labelColor,+ leadingWidget: const Icon(Icons.circle),+ );+ }++ return [+ option("Edit"),+ option("Pin"),+ option("Archive"),+ option("Hide"),+ option("Cast"),+ option("Delete", labelColor: context.componentColors.warning),+ ];+}++Future<void> _pumpLauncher(+ WidgetTester tester,+ ValueChanged<String?> onResult,+) async {+ await tester.pumpWidget(+ MaterialApp(+ theme: lightThemeData,+ localizationsDelegates: StringsLocalizations.localizationsDelegates,+ supportedLocales: StringsLocalizations.supportedLocales,+ home: Scaffold(+ body: Builder(+ builder: (context) {+ return TextButton(+ onPressed: () async {+ onResult(+ await showAlbumActionsSheet(context, _options(context)),+ );+ },+ child: const Text("Open sheet"),+ );+ },+ ),+ ),+ ),+ );+}++Future<void> _openLauncher(WidgetTester tester) async {+ await tester.tap(find.text("Open sheet"));+ await tester.pumpAndSettle();+}diff --git a/mobile/apps/photos/test/ui/viewer/gallery/album_cover_app_bar_test.dart b/mobile/apps/photos/test/ui/viewer/gallery/album_cover_app_bar_test.dartnew file mode 100644index 0000000000..8566c3dffa--- /dev/null+++ b/mobile/apps/photos/test/ui/viewer/gallery/album_cover_app_bar_test.dart@@ -0,0 +1,108 @@+import "dart:async";+import "dart:convert";++import "package:ente_pure_utils/ente_pure_utils.dart";+import "package:flutter/material.dart";+import "package:flutter/services.dart";+import "package:flutter_test/flutter_test.dart";+import "package:photos/core/cache/thumbnail_in_memory_cache.dart";+import "package:photos/core/page_route_observer.dart";+import "package:photos/ente_theme_data.dart";+import "package:photos/models/api/collection/user.dart";+import "package:photos/models/collection/collection.dart";+import "package:photos/models/file/file.dart";+import "package:photos/ui/viewer/gallery/component/album_cover_app_bar.dart";++void main() {+ testWidgets("resets the status bar style only when a page covers it", (+ tester,+ ) async {+ final iconBrightness = <String>[];+ tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(+ SystemChannels.platform,+ (call) async {+ if (call.method == "SystemChrome.setSystemUIOverlayStyle") {+ iconBrightness.add(+ (call.arguments as Map)["statusBarIconBrightness"] as String,+ );+ }+ return null;+ },+ );+ addTearDown(+ () => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(+ SystemChannels.platform,+ null,+ ),+ );++ final cover = EnteFile()+ ..uploadedFileID = 1+ ..generatedID = 1;+ ThumbnailInMemoryLruCache.put(cover, base64Decode(_onePixelPng));++ await tester.pumpWidget(+ MaterialApp(+ theme: lightThemeData,+ navigatorObservers: [pageRouteObserver],+ home: Scaffold(+ body: CustomScrollView(+ slivers: [+ AlbumCoverAppBar(+ collection: Collection(+ 1,+ User(id: 1, email: "[email protected]"),+ "",+ null,+ "Album",+ null,+ null,+ CollectionType.album,+ CollectionAttributes(),+ [],+ [],+ 0,+ ),+ cover: cover,+ title: "Album",+ backgroundColor: Colors.white,+ collapsedHeight: kToolbarHeight,+ actionsBuilder: (_) => const [],+ coverActions: const [],+ ),+ ],+ ),+ ),+ ),+ );+ await tester.pump();+ expect(iconBrightness.last, "Brightness.light");++ final context = tester.element(find.byType(Scaffold));+ unawaited(+ showDialog<void>(+ context: context,+ builder: (_) => const AlertDialog(title: Text("dialog")),+ ),+ );+ await tester.pumpAndSettle();+ expect(iconBrightness.last, "Brightness.light");++ Navigator.of(context).pop();+ await tester.pumpAndSettle();++ unawaited(routeToPage(context, const Scaffold(body: Text("next page"))));+ await tester.pumpAndSettle();+ expect(iconBrightness.last, "Brightness.dark");++ Navigator.of(context).pop();+ await tester.pumpAndSettle();+ expect(iconBrightness.last, "Brightness.light");++ await tester.pumpWidget(const SizedBox.shrink());+ await tester.pump(const Duration(seconds: 1));+ });+}++const _onePixelPng =+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==";