Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] Align album headers and refine cover controls

r4khulf8282e170ac0
diff --git a/mobile/apps/photos/changes/album-cover-redesign.md b/mobile/apps/photos/changes/album-cover-redesign.md
index 27a0ca6664..393be66655 100644
--- a/mobile/apps/photos/changes/album-cover-redesign.md
+++ b/mobile/apps/photos/changes/album-cover-redesign.md
@@ -1,2 +1,3 @@
- Refreshed the album page with a full cover, smooth thumbnail transitions, quick slideshow and map buttons, and a simpler options sheet.
- Open full album titles and descriptions from the header, with editing for album owners.
+- Improved album header alignment and controls across phones and tablets.
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.dart
index 4b7865441d..7450c3bd36 100644
--- 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.dart
@@ -129,59 +129,56 @@ class _AlbumCoverAppBarState extends State<AlbumCoverAppBar> with RouteAware {
heroTag: widget.heroTag,
contentOpacity: animation,
),
- content: SizedBox(
- width: MediaQuery.sizeOf(context).width - Spacing.lg * 2,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- _CoverCaption(
- GalleryFilesState.maybeOf(context)?.galleryFilesOrNull,
+ content: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ _CoverCaption(
+ GalleryFilesState.maybeOf(context)?.galleryFilesOrNull,
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: widget.onDetailsTap,
+ child: 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),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: widget.onDetailsTap,
- child: Semantics(
- header: true,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 18),
child: Text(
- widget.title,
- maxLines: 2,
+ description,
+ maxLines: _descriptionMaxLines,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
- style: TextStyles.display1.copyWith(
- color: colors.specialWhite,
+ style: TextStyles.mini.copyWith(
+ color: colors.specialWhite.withValues(alpha: 0.92),
),
),
),
),
- if (description != null) ...[
- const SizedBox(height: Spacing.sm),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: widget.onDetailsTap,
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 18),
- 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: _contentSpacing),
- Row(
- mainAxisSize: MainAxisSize.min,
- spacing: Spacing.md,
- children: widget.coverActions,
- ),
- ],
],
- ),
+ if (widget.coverActions.isNotEmpty) ...[
+ const SizedBox(height: _contentSpacing),
+ Row(
+ mainAxisSize: MainAxisSize.min,
+ spacing: Spacing.md,
+ children: widget.coverActions,
+ ),
+ ],
+ ],
),
),
);
@@ -221,7 +218,7 @@ class AlbumCoverActionButton extends StatelessWidget {
),
child: HugeIcon(
icon: icon,
- size: _coverActionIconSize,
+ size: IconSizes.small,
color: context.componentColors.specialWhite,
),
),
@@ -708,6 +705,7 @@ class _AlbumCoverDelegate extends SliverPersistentHeaderDelegate {
.clamp(0.0, 1.0),
)!;
final coverBottomInset = _coverBottomInset(bottomHeight);
+ final respectRightInset = Theme.of(context).platform != TargetPlatform.iOS;
return AnnotatedRegion<SystemUiOverlayStyle>(
value: pinnedProgress < 0.5 && !isCovered
@@ -745,13 +743,22 @@ class _AlbumCoverDelegate extends SliverPersistentHeaderDelegate {
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,
+ bottom: coverBottomInset + collapsedHeight,
+ child: SafeArea(
+ top: false,
+ bottom: false,
+ child: LayoutBuilder(
+ builder: (context, constraints) => Opacity(
+ opacity: contentOpacity,
+ child: FittedBox(
+ fit: BoxFit.scaleDown,
+ alignment: Alignment.center,
+ child: SizedBox(
+ width: constraints.maxWidth,
+ child: content,
+ ),
+ ),
+ ),
),
),
),
@@ -764,53 +771,59 @@ class _AlbumCoverDelegate extends SliverPersistentHeaderDelegate {
Positioned(
top:
topPadding +
- (Spacing.lg - (collapsedHeight - _headerIconSize) / 2) *
+ (Spacing.lg -
+ (collapsedHeight - _compactHeaderControlSize) / 2) *
(1 - pinnedProgress),
left: Spacing.lg,
right: Spacing.lg,
height: collapsedHeight,
- child: Row(
- spacing: Spacing.md,
- children: [
- IconButtonComponent(
- tooltip: MaterialLocalizations.of(context).backButtonTooltip,
- icon: HugeIcon(
- icon: HugeIcons.strokeRoundedArrowLeft02,
+ child: SafeArea(
+ top: false,
+ bottom: false,
+ left: false,
+ right: respectRightInset,
+ child: Row(
+ spacing: Spacing.md,
+ children: [
+ IconButton(
+ tooltip: MaterialLocalizations.of(
+ context,
+ ).backButtonTooltip,
+ icon: const Icon(Icons.arrow_back),
color: foregroundColor,
+ iconSize: IconSizes.medium,
+ onPressed: () => Navigator.maybePop(context),
),
- variant: IconButtonComponentVariant.unfilled,
- shouldSurfaceExecutionStates: false,
- onTap: () => Navigator.maybePop(context),
- ),
- Expanded(
- child: ExcludeSemantics(
- excluding: contentOpacity > 0,
- child: IgnorePointer(
- ignoring: titleOpacity == 0,
- child: Opacity(
- opacity: titleOpacity,
- child: GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: onDetailsTap,
- child: Text(
- title,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: TextStyles.display3.copyWith(
- color: foregroundColor,
+ Expanded(
+ child: ExcludeSemantics(
+ excluding: contentOpacity > 0,
+ child: IgnorePointer(
+ ignoring: titleOpacity == 0,
+ child: Opacity(
+ opacity: titleOpacity,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: onDetailsTap,
+ child: Text(
+ title,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyles.display3.copyWith(
+ color: foregroundColor,
+ ),
),
),
),
),
),
),
- ),
- Row(
- mainAxisSize: MainAxisSize.min,
- spacing: _headerActionSpacing,
- children: actionsBuilder(foregroundColor),
- ),
- ],
+ Row(
+ mainAxisSize: MainAxisSize.min,
+ spacing: _headerActionSpacing,
+ children: actionsBuilder(foregroundColor),
+ ),
+ ],
+ ),
),
),
if (bottom != null)
@@ -819,7 +832,13 @@ class _AlbumCoverDelegate extends SliverPersistentHeaderDelegate {
right: 0,
bottom: 0,
height: bottomHeight,
- child: bottom!,
+ child: SafeArea(
+ top: false,
+ bottom: false,
+ left: false,
+ right: respectRightInset,
+ child: bottom!,
+ ),
),
],
),
@@ -838,13 +857,12 @@ const _coverHeight = 441.0;
const _coverDissolveHeight = 100.0;
const _topScrimHeight = 31.0;
const _bottomOverlap = 25.0;
-const _contentBottomGap = 107.0;
const _contentSpacing = 22.0;
const _contentScrimTop = 146.0;
const _contentScrimWidth = 308.0;
const _contentScrimHeight = 157.0;
const _contentScrimBlur = 54.25;
-const _headerIconSize = 38.0;
+const _compactHeaderControlSize = 38.0;
const _headerActionSpacing = 6.0;
const _contentFadeExtent = 120.0;
const _pinnedFadeStart = 0.6;
@@ -852,7 +870,6 @@ const _foregroundSwitchStart = 0.4;
const _foregroundSwitchEnd = 0.6;
const _descriptionMaxLines = 3;
const _coverActionSize = 42.0;
-const _coverActionIconSize = 17.0;
const _photoScrimColor = Color.from(alpha: 0.24, red: 0, green: 0, blue: 0);
const _scrimColor = Color(0x33000000);
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.dart
index c9e1f580f4..d33a7a1bcd 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
@@ -60,6 +60,8 @@ Widget galleryAppBarActionsSheetAction<T>({
tooltip: tooltip,
icon: icon,
variant: IconButtonComponentVariant.unfilled,
+ size: kMinInteractiveDimension,
+ iconSize: IconSizes.medium,
shouldSurfaceExecutionStates: false,
onTap: () async {
final options = await optionsBuilder();
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.dart
index c4582edd45..48313a2638 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
@@ -675,6 +675,8 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
color: foregroundColor,
),
variant: iconButtonVariant,
+ size: onCover ? kMinInteractiveDimension : 36,
+ iconSize: onCover ? IconSizes.medium : IconSizes.small,
shouldSurfaceExecutionStates: false,
onTap: () async {
await _showAddPhotoDialog(context);
@@ -694,6 +696,8 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
color: foregroundColor,
),
variant: iconButtonVariant,
+ size: onCover ? kMinInteractiveDimension : 36,
+ iconSize: onCover ? IconSizes.medium : IconSizes.small,
shouldSurfaceExecutionStates: false,
onTap: () async {
await _showShareCollectionDialog();
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.dart
index e2c5bb6213..bc6038e5f8 100644
--- 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.dart
@@ -12,11 +12,151 @@ 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/models/metadata/collection_magic.dart";
import "package:photos/services/app_navigation_service.dart";
import "package:photos/ui/viewer/gallery/component/album_cover_app_bar.dart";
import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
void main() {
+ testWidgets("centers responsive cover content and preserves toolbar spacing", (
+ tester,
+ ) async {
+ tester.view.devicePixelRatio = 1;
+ addTearDown(tester.view.resetDevicePixelRatio);
+ addTearDown(tester.view.resetPhysicalSize);
+ final cover = EnteFile()
+ ..uploadedFileID = 3
+ ..generatedID = 3;
+ ThumbnailInMemoryLruCache.put(cover, base64Decode(_onePixelPng));
+ const title = "An album title that is long enough to need multiple lines";
+ const description =
+ "A description that takes several lines on a phone and "
+ "still needs to remain centered together with the other header contents.";
+ for (final (size, padding, caption, scale, platform) in [
+ (
+ const Size(390, 844),
+ const EdgeInsets.only(top: 47),
+ null,
+ 1.0,
+ TargetPlatform.iOS,
+ ),
+ (
+ const Size(844, 390),
+ const EdgeInsets.only(left: 54, right: 48),
+ description,
+ 1.5,
+ TargetPlatform.android,
+ ),
+ (
+ const Size(844, 390),
+ const EdgeInsets.symmetric(horizontal: 62),
+ description,
+ 1.0,
+ TargetPlatform.iOS,
+ ),
+ (
+ const Size(1024, 1366),
+ const EdgeInsets.only(top: 24, left: 48),
+ description,
+ 1.0,
+ TargetPlatform.iOS,
+ ),
+ ]) {
+ tester.view.physicalSize = size;
+ var taps = 0;
+ final header = _coverHeader(cover);
+ header.collection.pubMagicMetadata = CollectionPubMagicMetadata(
+ description: caption,
+ );
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: (scale == 1.5 ? darkThemeData : lightThemeData).copyWith(
+ platform: platform,
+ ),
+ builder: (context, child) => MediaQuery(
+ data: MediaQuery.of(
+ context,
+ ).copyWith(padding: padding, textScaler: TextScaler.linear(scale)),
+ child: child!,
+ ),
+ home: Scaffold(
+ body: SafeArea(
+ top: false,
+ bottom: false,
+ left: size.width >= 1024,
+ right: size.width >= 1024,
+ child: CustomScrollView(
+ slivers: [
+ AlbumCoverAppBar(
+ collection: header.collection,
+ cover: cover,
+ title: title,
+ onDetailsTap: () => taps++,
+ backgroundColor: header.backgroundColor,
+ collapsedHeight: kToolbarHeight,
+ actionsBuilder: (_) => List.generate(
+ 3,
+ (_) => IconButton(
+ icon: const Icon(Icons.more_vert),
+ onPressed: () {},
+ ),
+ ),
+ coverActions: const [SizedBox(width: 100, height: 42)],
+ ),
+ const SliverToBoxAdapter(child: SizedBox(height: 2000)),
+ ],
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ final expandedTitle = find.byWidgetPredicate(
+ (widget) =>
+ widget is Text && widget.data == title && widget.maxLines == 2,
+ );
+ final content = find
+ .ancestor(of: expandedTitle, matching: find.byType(Column))
+ .first;
+ expect(tester.getCenter(content).dy, closeTo(padding.top + 441 / 2, 0.1));
+ expect(
+ tester.getCenter(content).dx,
+ closeTo((padding.left + size.width - padding.right) / 2, 0.1),
+ );
+ if (size.width >= 1024) {
+ expect(
+ tester.getRect(expandedTitle).width,
+ closeTo(tester.getSize(expandedTitle).width, 0.1),
+ );
+ }
+ await tester.tap(expandedTitle);
+ if (caption != null) {
+ await tester.tap(find.text(caption));
+ }
+ expect(taps, caption == null ? 1 : 2);
+ final backIcon = tester.getRect(find.byIcon(Icons.arrow_back));
+ expect(backIcon.left, size.width >= 1024 ? padding.left + 28 : 28);
+ final lastAction = tester.getRect(find.byType(IconButton).last);
+ expect(
+ lastAction.right,
+ lessThanOrEqualTo(
+ size.width - (platform == TargetPlatform.android ? padding.right : 0),
+ ),
+ );
+ await tester.drag(find.byType(CustomScrollView), const Offset(0, -500));
+ await tester.pumpAndSettle();
+ await tester.tap(
+ find.byWidgetPredicate(
+ (widget) =>
+ widget is Text && widget.data == title && widget.maxLines == 1,
+ ),
+ );
+ expect(taps, caption == null ? 2 : 3);
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox.shrink());
+ await tester.pump(const Duration(seconds: 1));
+ }
+ });
testWidgets("keeps one accessible title and restores status bar styles", (
tester,
) async {