π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Enhance wrapped collages
laurenspriemd0ebb2ad361e
diff --git a/mobile/apps/photos/lib/services/wrapped/builders/people_candidate_builder.dart b/mobile/apps/photos/lib/services/wrapped/builders/people_candidate_builder.dartindex 3ca08aa7cf..1ac18a3076 100644--- a/mobile/apps/photos/lib/services/wrapped/builders/people_candidate_builder.dart+++ b/mobile/apps/photos/lib/services/wrapped/builders/people_candidate_builder.dart@@ -95,7 +95,7 @@ class PeopleCandidateBuilder extends WrappedCandidateBuilder {final List<MediaRef> media = WrappedMediaSelector.selectMediaRefs(context: context,candidateUploadedFileIDs: candidateIds,- maxCount: 3,+ maxCount: 5,scoreHints: scoreHints,preferNamedPeople: true,minimumSpacing: const Duration(days: 30),@@ -177,7 +177,7 @@ class PeopleCandidateBuilder extends WrappedCandidateBuilder {final List<MediaRef> media = WrappedMediaSelector.selectMediaRefs(context: context,candidateUploadedFileIDs: candidateIds,- maxCount: 3,+ maxCount: 4,scoreHints: scoreHints,preferNamedPeople: true,minimumSpacing: const Duration(days: 21),@@ -272,7 +272,7 @@ class PeopleCandidateBuilder extends WrappedCandidateBuilder {final List<MediaRef> media = WrappedMediaSelector.selectMediaRefs(context: context,candidateUploadedFileIDs: candidateIds,- maxCount: 3,+ maxCount: 5,preferNamedPeople: true,minimumSpacing: const Duration(days: 45),);@@ -384,7 +384,7 @@ class PeopleCandidateBuilder extends WrappedCandidateBuilder {final List<MediaRef> media = WrappedMediaSelector.selectMediaRefs(context: context,candidateUploadedFileIDs: candidateIds,- maxCount: 3,+ maxCount: 5,scoreHints: scoreHints,preferNamedPeople: true,minimumSpacing: const Duration(days: 30),diff --git a/mobile/apps/photos/lib/ui/wrapped/cards/aesthetics_card_content.dart b/mobile/apps/photos/lib/ui/wrapped/cards/aesthetics_card_content.dartindex 33631853ca..de20162f2e 100644--- a/mobile/apps/photos/lib/ui/wrapped/cards/aesthetics_card_content.dart+++ b/mobile/apps/photos/lib/ui/wrapped/cards/aesthetics_card_content.dart@@ -49,6 +49,8 @@ class _BlurryFacesCardContent extends StatelessWidget {@overrideWidget build(BuildContext context) {final List<String> chips = _stringListFromMeta(card.meta, "detailChips");+ final List<MediaRef> supportingMedia =+ card.media.skip(3).take(2).toList(growable: false);return Column(crossAxisAlignment: CrossAxisAlignment.start,@@ -68,6 +70,14 @@ class _BlurryFacesCardContent extends StatelessWidget {textTheme.bodyMuted,padding: const EdgeInsets.only(top: 12),),+ if (supportingMedia.isNotEmpty) ...[+ const SizedBox(height: 20),+ _MediaPairRow(+ media: supportingMedia,+ colorScheme: colorScheme,+ height: 132,+ ),+ ],if (chips.isNotEmpty) ...[const SizedBox(height: 20),_DetailChips(diff --git a/mobile/apps/photos/lib/ui/wrapped/cards/people_card_content.dart b/mobile/apps/photos/lib/ui/wrapped/cards/people_card_content.dartindex 1c229b709a..fd8e0b71f8 100644--- a/mobile/apps/photos/lib/ui/wrapped/cards/people_card_content.dart+++ b/mobile/apps/photos/lib/ui/wrapped/cards/people_card_content.dart@@ -49,6 +49,8 @@ class _TopPersonCardContent extends StatelessWidget {@overrideWidget build(BuildContext context) {final List<String> chips = _stringListFromMeta(card.meta, "detailChips");+ final List<MediaRef> supportingMedia =+ card.media.skip(3).take(2).toList(growable: false);return Column(crossAxisAlignment: CrossAxisAlignment.start,@@ -68,6 +70,14 @@ class _TopPersonCardContent extends StatelessWidget {textTheme.bodyMuted,padding: const EdgeInsets.only(top: 12),),+ if (supportingMedia.isNotEmpty) ...[+ const SizedBox(height: 20),+ _MediaPairRow(+ media: supportingMedia,+ colorScheme: colorScheme,+ height: 132,+ ),+ ],if (chips.isNotEmpty) ...[const SizedBox(height: 20),_DetailChips(@@ -96,6 +106,7 @@ class _TopThreePeopleCardContent extends StatelessWidget {@overrideWidget build(BuildContext context) {final List<String> chips = _stringListFromMeta(card.meta, "detailChips");+ final List<MediaRef> gridMedia = card.media.take(4).toList(growable: false);return Column(crossAxisAlignment: CrossAxisAlignment.start,@@ -110,10 +121,10 @@ class _TopThreePeopleCardContent extends StatelessWidget {textTheme.bodyMuted,padding: const EdgeInsets.only(top: 12),),- if (card.media.isNotEmpty) ...[+ if (gridMedia.isNotEmpty) ...[const SizedBox(height: 24),- _MediaRow(- media: card.media.take(3).toList(growable: false),+ _SquareMediaGrid(+ media: gridMedia,colorScheme: colorScheme,),],@@ -145,6 +156,8 @@ class _GroupVsSoloCardContent extends StatelessWidget {@overrideWidget build(BuildContext context) {final List<String> chips = _stringListFromMeta(card.meta, "detailChips");+ final List<MediaRef> collageMedia =+ card.media.take(5).toList(growable: false);return Column(crossAxisAlignment: CrossAxisAlignment.start,@@ -159,10 +172,10 @@ class _GroupVsSoloCardContent extends StatelessWidget {textTheme.bodyMuted,padding: const EdgeInsets.only(top: 12),),- if (card.media.isNotEmpty) ...[+ if (collageMedia.isNotEmpty) ...[const SizedBox(height: 20),- _MediaRow(- media: card.media.take(3).toList(growable: false),+ _GroupSoloMediaCollage(+ media: collageMedia,colorScheme: colorScheme,),],@@ -194,6 +207,8 @@ class _NewFacesCardContent extends StatelessWidget {@overrideWidget build(BuildContext context) {final List<String> chips = _stringListFromMeta(card.meta, "detailChips");+ final List<MediaRef> supportingMedia =+ card.media.skip(3).take(2).toList(growable: false);return Column(crossAxisAlignment: CrossAxisAlignment.start,@@ -213,6 +228,14 @@ class _NewFacesCardContent extends StatelessWidget {textTheme.bodyMuted,padding: const EdgeInsets.only(top: 12),),+ if (supportingMedia.isNotEmpty) ...[+ const SizedBox(height: 20),+ _MediaPairRow(+ media: supportingMedia,+ colorScheme: colorScheme,+ height: 132,+ ),+ ],if (chips.isNotEmpty) ...[const SizedBox(height: 20),_DetailChips(diff --git a/mobile/apps/photos/lib/ui/wrapped/cards/shared_widgets.dart b/mobile/apps/photos/lib/ui/wrapped/cards/shared_widgets.dartindex 4aecdb02a0..79e06635c8 100644--- a/mobile/apps/photos/lib/ui/wrapped/cards/shared_widgets.dart+++ b/mobile/apps/photos/lib/ui/wrapped/cards/shared_widgets.dart@@ -46,6 +46,32 @@ Widget _buildCenteredCardText({return label;}+Widget _mediaTileOrPlaceholder(+ MediaRef? ref,+ EnteColorScheme colorScheme, {+ double borderRadius = 20,+ double? aspectRatio,+}) {+ if (ref == null) {+ Widget placeholder = _MediaPlaceholder(+ colorScheme: colorScheme,+ borderRadius: borderRadius,+ );+ if (aspectRatio != null) {+ placeholder = AspectRatio(+ aspectRatio: aspectRatio,+ child: placeholder,+ );+ }+ return placeholder;+ }+ return _MediaTile(+ mediaRef: ref,+ borderRadius: borderRadius,+ aspectRatio: aspectRatio,+ );+}+class _DetailChips extends StatelessWidget {const _DetailChips({required this.chips,@@ -250,6 +276,240 @@ class _MediaGrid extends StatelessWidget {}}+class _SquareMediaGrid extends StatelessWidget {+ const _SquareMediaGrid({+ required this.media,+ required this.colorScheme,+ });++ static const int _kCrossAxisCount = 2;+ static const double _kSpacing = 12;++ final List<MediaRef> media;+ final EnteColorScheme colorScheme;++ @override+ Widget build(BuildContext context) {+ if (media.isEmpty) {+ return _MediaPlaceholder(+ colorScheme: colorScheme,+ borderRadius: 20,+ height: 120,+ );+ }+ return LayoutBuilder(+ builder: (BuildContext context, BoxConstraints constraints) {+ final double availableWidth = constraints.hasBoundedWidth &&+ constraints.maxWidth.isFinite &&+ constraints.maxWidth > 0+ ? constraints.maxWidth+ : MediaQuery.of(context).size.width;+ final double rawTileSize =+ (availableWidth - _kSpacing * (_kCrossAxisCount - 1)) /+ _kCrossAxisCount;+ final double tileSize =+ rawTileSize.isFinite && rawTileSize > 0 ? rawTileSize : 140;++ return Wrap(+ spacing: _kSpacing,+ runSpacing: _kSpacing,+ children: media+ .map(+ (MediaRef ref) => SizedBox(+ width: tileSize,+ height: tileSize,+ child: _mediaTileOrPlaceholder(+ ref,+ colorScheme,+ borderRadius: 20,+ ),+ ),+ )+ .toList(growable: false),+ );+ },+ );+ }+}++class _MediaPairRow extends StatelessWidget {+ const _MediaPairRow({+ required this.media,+ required this.colorScheme,+ this.height,+ });++ final List<MediaRef> media;+ final EnteColorScheme colorScheme;+ final double? height;+ static const double _kBorderRadius = 20;++ @override+ Widget build(BuildContext context) {+ final List<MediaRef?> slots = <MediaRef?>[+ media.isNotEmpty ? media.first : null,+ media.length > 1 ? media[1] : null,+ ];+ Widget row = Row(+ children: [+ for (final (int index, MediaRef? ref) in slots.indexed) ...[+ Expanded(+ child: Padding(+ padding: EdgeInsets.only(+ right: index == slots.length - 1 ? 0 : 12,+ ),+ child: _mediaTileOrPlaceholder(+ ref,+ colorScheme,+ borderRadius: _kBorderRadius,+ ),+ ),+ ),+ ],+ ],+ );+ if (height != null) {+ row = SizedBox(+ height: height,+ child: row,+ );+ }+ return row;+ }+}++class _GroupSoloMediaCollage extends StatelessWidget {+ const _GroupSoloMediaCollage({+ required this.media,+ required this.colorScheme,+ });++ final List<MediaRef> media;+ final EnteColorScheme colorScheme;++ MediaRef? _at(int index) => index < media.length ? media[index] : null;++ @override+ Widget build(BuildContext context) {+ if (media.isEmpty) {+ return _MediaPlaceholder(+ height: 200,+ colorScheme: colorScheme,+ borderRadius: 24,+ );+ }++ final MediaRef? primary = _at(0);+ final MediaRef? rightTop = _at(1);+ final MediaRef? rightBottom = _at(2);+ final MediaRef? bottomLeft = _at(3);+ final MediaRef? bottomRight = _at(4);++ final List<MediaRef> bottomMedia = <MediaRef>[+ if (bottomLeft != null) bottomLeft,+ if (bottomRight != null) bottomRight,+ ];++ return Column(+ children: [+ SizedBox(+ height: 200,+ child: Row(+ children: [+ Expanded(+ flex: (rightTop != null || rightBottom != null) ? 3 : 1,+ child: _mediaTileOrPlaceholder(+ primary,+ colorScheme,+ borderRadius: 24,+ ),+ ),+ if (rightTop != null || rightBottom != null) ...[+ const SizedBox(width: 12),+ Expanded(+ flex: 2,+ child: Align(+ alignment: Alignment.topCenter,+ child: Column(+ children: [+ Expanded(+ child: _mediaTileOrPlaceholder(+ rightTop,+ colorScheme,+ borderRadius: 22,+ ),+ ),+ if (rightTop != null && rightBottom != null)+ const SizedBox(height: 12),+ if (rightBottom != null)+ Expanded(+ child: _mediaTileOrPlaceholder(+ rightBottom,+ colorScheme,+ borderRadius: 22,+ ),+ ),+ ],+ ),+ ),+ ),+ ],+ ],+ ),+ ),+ if (bottomMedia.isNotEmpty) ...[+ const SizedBox(height: 12),+ _buildBottomRow(bottomMedia, colorScheme),+ ],+ ],+ );+ }++ Widget _buildBottomRow(+ List<MediaRef> refs,+ EnteColorScheme colorScheme,+ ) {+ if (refs.length == 1) {+ return SizedBox(+ height: 120,+ child: Align(+ alignment: Alignment.center,+ child: FractionallySizedBox(+ widthFactor: 0.65,+ child: _mediaTileOrPlaceholder(+ refs.first,+ colorScheme,+ borderRadius: 22,+ ),+ ),+ ),+ );+ }+ return SizedBox(+ height: 110,+ child: Row(+ children: [+ Expanded(+ child: _mediaTileOrPlaceholder(+ refs[0],+ colorScheme,+ borderRadius: 22,+ ),+ ),+ const SizedBox(width: 12),+ Expanded(+ child: _mediaTileOrPlaceholder(+ refs[1],+ colorScheme,+ borderRadius: 22,+ ),+ ),+ ],+ ),+ );+ }+}+class _MediaTile extends StatelessWidget {const _MediaTile({required this.mediaRef,