π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Add device album cover headers
r4khul35a0bf182f6a
diff --git a/mobile/apps/photos/changes/device-album-covers.md b/mobile/apps/photos/changes/device-album-covers.mdnew file mode 100644index 0000000000..6932f1878d--- /dev/null+++ b/mobile/apps/photos/changes/device-album-covers.md@@ -0,0 +1 @@+- Added cover headers and smooth transitions to device albums, preserving backup status and gallery actions.diff --git a/mobile/apps/photos/lib/ui/collections/device/device_folder_list_item.dart b/mobile/apps/photos/lib/ui/collections/device/device_folder_list_item.dartindex ed31097784..59a76e523d 100644--- a/mobile/apps/photos/lib/ui/collections/device/device_folder_list_item.dart+++ b/mobile/apps/photos/lib/ui/collections/device/device_folder_list_item.dart@@ -22,22 +22,31 @@ class DeviceFolderListItem extends StatelessWidget {return ThumbnailListItem(backgroundColor: thumbnailListItemBackgroundColor(context),onTap: () {- routeToPage(context, DeviceFolderPage(deviceCollection));+ routeToPage(+ context,+ DeviceFolderPage(deviceCollection),+ useFadeTransition: true,+ );},leading: Stack(clipBehavior: Clip.none,children: [- ClipRRect(- borderRadius: BorderRadius.circular(- ThumbnailListItem.defaultLeadingRadius,- ),- child: ThumbnailWidget(- deviceCollection.thumbnail!,- shouldShowSyncStatus: false,- key: Key(- "device_folder:" +- deviceCollection.name +- deviceCollection.thumbnail!.tag,+ Hero(+ tag: "device_folder:${deviceCollection.id}",+ createRectTween: (begin, end) => RectTween(begin: begin, end: end),+ transitionOnUserGestures: true,+ child: ClipRRect(+ borderRadius: BorderRadius.circular(+ ThumbnailListItem.defaultLeadingRadius,+ ),+ child: ThumbnailWidget(+ deviceCollection.thumbnail!,+ shouldShowSyncStatus: false,+ key: Key(+ "device_folder:" ++ deviceCollection.name ++ deviceCollection.thumbnail!.tag,+ ),),),),diff --git a/mobile/apps/photos/lib/ui/collections/device/device_folder_row_item.dart b/mobile/apps/photos/lib/ui/collections/device/device_folder_row_item.dartindex bc77ba2e0c..f472c49bdd 100644--- a/mobile/apps/photos/lib/ui/collections/device/device_folder_row_item.dart+++ b/mobile/apps/photos/lib/ui/collections/device/device_folder_row_item.dart@@ -40,20 +40,19 @@ class DeviceFolderRowItem extends StatelessWidget {clipBehavior: Clip.none,alignment: Alignment.center,children: [- ClipSmoothRect(- radius: SmoothBorderRadius(- cornerRadius: _cornerRadius,- cornerSmoothing: _cornerSmoothing,- ),- child: SizedBox(- height: sideOfThumbnail,- width: sideOfThumbnail,- child: Hero(- tag:- "device_folder:" +- deviceCollection.name +- deviceCollection.thumbnail!.tag,- transitionOnUserGestures: true,+ Hero(+ tag: "device_folder:${deviceCollection.id}",+ createRectTween: (begin, end) =>+ RectTween(begin: begin, end: end),+ transitionOnUserGestures: true,+ child: ClipSmoothRect(+ radius: SmoothBorderRadius(+ cornerRadius: _cornerRadius,+ cornerSmoothing: _cornerSmoothing,+ ),+ child: SizedBox(+ height: sideOfThumbnail,+ width: sideOfThumbnail,child: Stack(children: [ThumbnailWidget(@@ -106,7 +105,11 @@ class DeviceFolderRowItem extends StatelessWidget {],),onTap: () {- routeToPage(context, DeviceFolderPage(deviceCollection));+ routeToPage(+ context,+ DeviceFolderPage(deviceCollection),+ useFadeTransition: true,+ );},);}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.dartindex 1e8560ef49..f3230a8d8d 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@@ -22,8 +22,9 @@ import "package:photos/ui/viewer/gallery/state/inherited_search_filter_data.dartclass AlbumCoverAppBar extends StatefulWidget {const AlbumCoverAppBar({super.key,- required this.collection,+ this.collection,required this.cover,+ this.subtitle,required this.title,required this.actionsBuilder,required this.coverActions,@@ -33,8 +34,9 @@ class AlbumCoverAppBar extends StatefulWidget {this.bottom,});- final Collection collection;+ final Collection? collection;final EnteFile cover;+ final String? subtitle;final String title;final List<Widget> Function(Color foregroundColor) actionsBuilder;final List<Widget> coverActions;@@ -104,7 +106,7 @@ class _AlbumCoverAppBarState extends State<AlbumCoverAppBar> with RouteAware {Widget build(BuildContext context) {final colors = context.componentColors;final bottomHeight = widget.bottom?.preferredSize.height ?? 0;- final description = widget.collection.displayDescription;+ final description = widget.collection?.displayDescription;final geometry = AlbumCoverAppBar.resolveGeometry(context,collapsedHeight: widget.collapsedHeight,@@ -150,6 +152,14 @@ class _AlbumCoverAppBarState extends State<AlbumCoverAppBar> with RouteAware {style: TextStyles.display1.copyWith(color: colors.specialWhite),),),+ if (widget.subtitle != null) ...[+ const SizedBox(height: Spacing.sm),+ Text(+ widget.subtitle!,+ textAlign: TextAlign.center,+ style: TextStyles.mini.copyWith(color: colors.specialWhite),+ ),+ ],if (description != null) ...[const SizedBox(height: Spacing.sm),Padding(diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/device/device_folder_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/device/device_folder_page.dartindex f1bde04c53..c85606bc0a 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/device/device_folder_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/device/device_folder_page.dart@@ -36,12 +36,16 @@ class DeviceFolderPage extends StatefulWidget {class _DeviceFolderPageState extends State<DeviceFolderPage> {final _logger = Logger("_DeviceFolderPageState");final _selectedFiles = SelectedFiles();+ final _coverAppBarKey = GlobalKey();late bool _shouldBackup;+ EnteFile? _cover;+ int _loadGeneration = 0;@overridevoid initState() {super.initState();_shouldBackup = widget.deviceCollection.shouldBackup;+ _cover = widget.deviceCollection.thumbnail;}Future<FileLoadResult> _loadFiles(@@ -51,7 +55,8 @@ class _DeviceFolderPageState extends State<DeviceFolderPage> {bool? asc,}) async {final int? userID = Configuration.instance.getUserID();- return FilesDB.instance.getFilesInDeviceCollection(+ final generation = ++_loadGeneration;+ final result = await FilesDB.instance.getFilesInDeviceCollection(widget.deviceCollection,userID,creationStartTime,@@ -59,6 +64,10 @@ class _DeviceFolderPageState extends State<DeviceFolderPage> {limit: limit,asc: asc,);+ if (mounted && generation == _loadGeneration) {+ setState(() => _cover = result.files.firstOrNull);+ }+ return result;}@override@@ -68,8 +77,11 @@ class _DeviceFolderPageState extends State<DeviceFolderPage> {GalleryType.localFolder,widget.deviceCollection.name,_selectedFiles,+ coverAppBarKey: _coverAppBarKey,subtitle: _shouldBackup ? l10n.backedUpAutomatically : l10n.notBackedUp,deviceCollection: widget.deviceCollection,+ cover: _cover,+ coverHeroTag: "device_folder:${widget.deviceCollection.id}",isDeviceFolderBackedUp: _shouldBackup,onDisableDeviceFolderBackup: () async {await _updateBackupStatus(false);@@ -85,7 +97,7 @@ class _DeviceFolderPageState extends State<DeviceFolderPage> {EventType.deletedFromEverywhere,EventType.hide,},- tagPrefix: "device_folder:${widget.deviceCollection.name}",+ tagPrefix: "device_folder_files:${widget.deviceCollection.id}",galleryType: GalleryType.localFolder,selectedFiles: _selectedFiles,header: Configuration.instance.hasConfiguredAccount()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 a686960e92..60cc27c6fc 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@@ -84,7 +84,7 @@ class GalleryAppBarWidget extends StatefulWidget {PreferredSizeWidget? bottom,bool showOverflowMenu = true,}) {- assert(cover == null || collection != null);+ assert(cover == null || collection != null || deviceCollection != null);return GalleryAppBarConfig(extendBodyForCollapse: cover != null && bottom == null,sliverBuilder: (_) => GalleryAppBarWidget._(@@ -367,8 +367,9 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {final strings = context.strings;return AlbumCoverAppBar(key: widget.coverAppBarKey,- collection: widget.collection!,+ collection: widget.collection,cover: widget.cover!,+ subtitle: widget.subtitle,heroTag: widget.coverHeroTag,title: _appBarTitle,backgroundColor: GalleryAppBarWidget.backgroundColor(context),@@ -1027,7 +1028,9 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {size: IconSizes.small,),),- if (_isAlbumSlideshowAvailable && !onCover) _slideshowMenuOption(strings),+ if (_isAlbumSlideshowAvailable &&+ (!onCover || widget.deviceCollection != null))+ _slideshowMenuOption(strings),if (canAutoAdd)_menuOption(AlbumPopupAction.autoAddPhotos,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.dartindex 106d1525a6..f02c739355 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@@ -18,6 +18,40 @@ 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("supports a device folder cover with its backup status", (+ tester,+ ) async {+ final cover = EnteFile()..generatedID = 7;+ ThumbnailInMemoryLruCache.put(cover, base64Decode(_onePixelPng));+ for (final theme in [lightThemeData, darkThemeData]) {+ await tester.pumpWidget(+ MaterialApp(+ theme: theme,+ home: Scaffold(+ body: CustomScrollView(+ slivers: [+ AlbumCoverAppBar(+ cover: cover,+ title: "Camera",+ subtitle: "Backup status",+ backgroundColor: theme.scaffoldBackgroundColor,+ collapsedHeight: kToolbarHeight,+ actionsBuilder: (_) => const [],+ coverActions: const [],+ ),+ ],+ ),+ ),+ ),+ );+ await tester.pumpAndSettle();+ expect(find.text("Backup status"), findsOneWidget);+ expect(tester.takeException(), isNull);+ }+ await tester.pumpWidget(const SizedBox.shrink());+ await tester.pump(const Duration(seconds: 1));+ });+testWidgets("centers responsive cover content and preserves toolbar spacing", (tester,) async {@@ -64,7 +98,7 @@ void main() {]) {tester.view.physicalSize = size;final header = _coverHeader(cover);- header.collection.pubMagicMetadata = CollectionPubMagicMetadata(+ header.collection!.pubMagicMetadata = CollectionPubMagicMetadata(description: caption,);await tester.pumpWidget(@@ -157,7 +191,7 @@ void main() {valueListenable: files,builder: (_, files, _) {final header = _coverHeader(cover);- header.collection.pubMagicMetadata = CollectionPubMagicMetadata(+ header.collection!.pubMagicMetadata = CollectionPubMagicMetadata(description:"An album description that wraps onto several lines.",);