Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] Open full album details from the cover

r4khul8c918d1a8bf9
diff --git a/mobile/apps/photos/changes/album-cover-redesign.md b/mobile/apps/photos/changes/album-cover-redesign.md
index 95cc53da47..27a0ca6664 100644
--- a/mobile/apps/photos/changes/album-cover-redesign.md
+++ b/mobile/apps/photos/changes/album-cover-redesign.md
@@ -1 +1,2 @@
- 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.
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 0c5ad00110..4b7865441d 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
@@ -29,6 +29,7 @@ class AlbumCoverAppBar extends StatefulWidget {
required this.collapsedHeight,
this.heroTag,
this.bottom,
+ this.onDetailsTap,
});
final Collection collection;
@@ -40,6 +41,7 @@ class AlbumCoverAppBar extends StatefulWidget {
final double collapsedHeight;
final String? heroTag;
final PreferredSizeWidget? bottom;
+ final VoidCallback? onDetailsTap;
static HeaderAppBarGeometry resolveGeometry(
BuildContext context, {
@@ -119,6 +121,7 @@ class _AlbumCoverAppBarState extends State<AlbumCoverAppBar> with RouteAware {
isCovered: _isCovered,
title: widget.title,
actionsBuilder: widget.actionsBuilder,
+ onDetailsTap: widget.onDetailsTap,
bottom: widget.bottom,
photo: _CoverPhoto(
cover: widget.cover,
@@ -134,29 +137,37 @@ class _AlbumCoverAppBarState extends State<AlbumCoverAppBar> with RouteAware {
_CoverCaption(
GalleryFilesState.maybeOf(context)?.galleryFilesOrNull,
),
- Semantics(
- header: true,
- child: Text(
- widget.title,
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- textAlign: TextAlign.center,
- style: TextStyles.display1.copyWith(
- color: colors.specialWhite,
+ 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),
- 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),
+ 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),
+ ),
),
),
),
@@ -645,6 +656,7 @@ class _AlbumCoverDelegate extends SliverPersistentHeaderDelegate {
required this.bottom,
required this.photo,
required this.content,
+ required this.onDetailsTap,
});
final HeaderAppBarGeometry geometry;
@@ -658,6 +670,7 @@ class _AlbumCoverDelegate extends SliverPersistentHeaderDelegate {
final String title;
final List<Widget> Function(Color foregroundColor) actionsBuilder;
final PreferredSizeWidget? bottom;
+ final VoidCallback? onDetailsTap;
final Widget photo;
final Widget content;
@@ -772,14 +785,21 @@ class _AlbumCoverDelegate extends SliverPersistentHeaderDelegate {
Expanded(
child: ExcludeSemantics(
excluding: contentOpacity > 0,
- child: Opacity(
- opacity: titleOpacity,
- child: Text(
- title,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: TextStyles.display3.copyWith(
- color: foregroundColor,
+ 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,
+ ),
+ ),
),
),
),
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 2aa31dc143..c4582edd45 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
@@ -365,6 +365,9 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
cover: widget.cover!,
heroTag: widget.coverHeroTag,
title: _appBarTitle,
+ onDetailsTap: widget.selectedFiles.files.isEmpty
+ ? () => _showAlbumDetails(context)
+ : null,
backgroundColor: GalleryAppBarWidget.backgroundColor(context),
collapsedHeight: GalleryAppBarWidget.toolbarHeight,
bottom: bottom,
@@ -388,6 +391,42 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
);
}
+ Future<void> _showAlbumDetails(BuildContext context) async {
+ if (galleryType.canEditDetails()) {
+ await _editAlbumDetails(context);
+ return;
+ }
+
+ await showBottomSheetComponent<void>(
+ context: context,
+ builder: (context) => BottomSheetComponent(
+ title: context.strings.details,
+ closeTooltip: context.strings.close,
+ isScrollable: true,
+ content: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ _appBarTitle,
+ style: TextStyles.h2.copyWith(
+ color: context.componentColors.textBase,
+ ),
+ ),
+ if (widget.collection!.displayDescription != null) ...[
+ const SizedBox(height: Spacing.lg),
+ Text(
+ widget.collection!.displayDescription!,
+ style: TextStyles.body.copyWith(
+ color: context.componentColors.textLight,
+ ),
+ ),
+ ],
+ ],
+ ),
+ ),
+ );
+ }
+
Future<void> _editAlbumDetails(BuildContext context) async {
final collection = widget.collection;
if (collection == null) {
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/hooks/edit_album_details_sheet.dart b/mobile/apps/photos/lib/ui/viewer/gallery/hooks/edit_album_details_sheet.dart
index b724ffa834..b4d49a0eb9 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/hooks/edit_album_details_sheet.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/hooks/edit_album_details_sheet.dart
@@ -40,32 +40,34 @@ Future<void> showEditAlbumDetailsSheet({
await showBottomSheetComponent<void>(
context: context,
- builder: (sheetContext) => EditAlbumDetailsSheet(
- initialName: collection.displayName,
- initialDescription: collection.displayDescription ?? "",
- initialCover: initialCover,
- onSelectCover: (pendingCoverID) async {
- final hasEffectiveCustomCover = pendingCoverID == null
- ? collection.hasCover
- : pendingCoverID != 0;
- final coverID = await showPickCoverPhotoSheet(
- sheetContext,
- collection,
- hasEffectiveCustomCover: hasEffectiveCustomCover,
- );
- if (coverID == null) {
- return null;
- }
+ builder: (sheetContext) => SingleChildScrollView(
+ child: EditAlbumDetailsSheet(
+ initialName: collection.displayName,
+ initialDescription: collection.displayDescription ?? "",
+ initialCover: initialCover,
+ onSelectCover: (pendingCoverID) async {
+ final hasEffectiveCustomCover = pendingCoverID == null
+ ? collection.hasCover
+ : pendingCoverID != 0;
+ final coverID = await showPickCoverPhotoSheet(
+ sheetContext,
+ collection,
+ hasEffectiveCustomCover: hasEffectiveCustomCover,
+ );
+ if (coverID == null) {
+ return null;
+ }
- final file = coverID == 0
- ? await FilesDB.instance.getCollectionFileFirstOrLast(
- collection.id,
- collection.pubMagicMetadata.asc ?? false,
- )
- : await FilesDB.instance.getUploadedFile(coverID, collection.id);
- return AlbumCoverSelection(id: coverID, file: file);
- },
- onSave: onSave,
+ final file = coverID == 0
+ ? await FilesDB.instance.getCollectionFileFirstOrLast(
+ collection.id,
+ collection.pubMagicMetadata.asc ?? false,
+ )
+ : await FilesDB.instance.getUploadedFile(coverID, collection.id);
+ return AlbumCoverSelection(id: coverID, file: file);
+ },
+ onSave: onSave,
+ ),
),
);
}
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 e92bc3828c..5d0fa8c9c5 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
@@ -125,6 +125,71 @@ void main() {
expect(find.text("Open album"), findsOneWidget);
});
+ testWidgets("opens full album details and preserves editing permissions", (
+ tester,
+ ) async {
+ tester.view.devicePixelRatio = 1;
+ tester.view.physicalSize = const Size(844, 390);
+ addTearDown(tester.view.resetDevicePixelRatio);
+ addTearDown(tester.view.resetPhysicalSize);
+ addTearDown(tester.view.resetViewInsets);
+ const title = "An album title that is long enough to overflow the header";
+ const description = "The complete album description";
+ final cover = _file(1);
+ await tester.runAsync(() => FilesDB.instance.insertMultiple([cover]));
+ for (final ownerID in [1, 2]) {
+ final collection = _collection(ownerID: ownerID)
+ ..decryptedName = title
+ ..pubMagicMetadata = CollectionPubMagicMetadata(
+ description: description,
+ );
+ await _pumpAlbum(tester, collection);
+ await _expectCover(tester, cover);
+ final selectedFiles = tester
+ .widget<GalleryAppBarWidget>(find.byType(GalleryAppBarWidget))
+ .selectedFiles;
+ selectedFiles.toggleSelection(cover);
+ await tester.pumpAndSettle();
+ await tester.tap(find.text(title).first);
+ await tester.pumpAndSettle();
+ expect(find.byType(BottomSheet), findsNothing);
+ selectedFiles.clearAll();
+ await tester.pumpAndSettle();
+ await tester.tap(find.text(ownerID == 1 ? title : description).first);
+ await tester.pumpAndSettle();
+ if (ownerID == 1) {
+ expect(
+ tester
+ .widgetList<EditableText>(find.byType(EditableText))
+ .map((field) => field.controller.text),
+ containsAll([title, description]),
+ );
+ tester.view.viewInsets = const FakeViewPadding(bottom: 200);
+ await tester.showKeyboard(find.byType(EditableText).last);
+ await tester.pumpAndSettle();
+ final save = find.byKey(const ValueKey("save_album_details"));
+ await tester.ensureVisible(save);
+ await tester.pumpAndSettle();
+ expect(save.hitTestable(), findsOneWidget);
+ tester.view.resetViewInsets();
+ tester.testTextInput.hide();
+ await tester.pumpAndSettle();
+ } else {
+ expect(find.byType(EditableText), findsNothing);
+ final sheet = find.byType(BottomSheet);
+ for (final text in [title, description]) {
+ expect(
+ find.descendant(of: sheet, matching: find.text(text)),
+ findsOneWidget,
+ );
+ }
+ }
+ await tester.tap(find.byTooltip("Close").last);
+ await tester.pumpAndSettle();
+ await _disposeAlbum(tester);
+ }
+ });
+
testWidgets("uses a pending local photo and excludes ignored photos", (
tester,
) async {
@@ -354,9 +419,9 @@ void main() {
);
}
-Collection _collection() => Collection(
+Collection _collection({int ownerID = 1}) => Collection(
1,
- User(id: 1, email: "[email protected]"),
+ User(id: ownerID, email: "[email protected]"),
"",
null,
"Album",