Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] scaffold internal memory lane v2 viewer

Priyanshu Dangareab6f1bfbb8fd
diff --git a/mobile/apps/photos/lib/ui/home/memories/memories_strip.dart b/mobile/apps/photos/lib/ui/home/memories/memories_strip.dart
index e64cdef75f..4c1f977bd3 100644
--- a/mobile/apps/photos/lib/ui/home/memories/memories_strip.dart
+++ b/mobile/apps/photos/lib/ui/home/memories/memories_strip.dart
@@ -3,7 +3,6 @@ import "dart:math";
import "dart:typed_data";
import "package:collection/collection.dart";
-import "package:ente_pure_utils/ente_pure_utils.dart";
import 'package:flutter/material.dart';
import "package:flutter_animate/flutter_animate.dart";
import "package:photos/core/event_bus.dart";
@@ -23,6 +22,7 @@ import "package:photos/events/people_changed_event.dart";
import "package:photos/models/file/file.dart";
import "package:photos/models/memories/smart_memory.dart";
import "package:photos/models/memory_lane/memory_lane_models.dart";
+import "package:photos/models/ml/face/person.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/collections_service.dart";
import "package:photos/services/machine_learning/face_ml/person/person_service.dart";
@@ -33,7 +33,7 @@ import "package:photos/ui/home/memories/memory_card_constants.dart";
import "package:photos/ui/home/memories/memory_cover_util.dart";
import "package:photos/ui/home/memories/memory_lane_card.dart";
import "package:photos/ui/home/memories/memory_video_prefetcher.dart";
-import "package:photos/ui/viewer/people/memory_lane_page.dart";
+import "package:photos/ui/viewer/people/memory_lane_page_v2.dart";
class MemoryCardWrapper {
final String id;
@@ -70,7 +70,7 @@ class _MemoriesStripWidgetState extends State<MemoriesStripWidget> {
MemoryLanePersonTimeline? _memoryLane;
EnteFile? _oldestMemoryLaneFile;
Uint8List? _newestMemoryLaneFace;
- String? _memoryLanePersonName;
+ PersonEntity? _memoryLanePerson;
final _videoPrefetcher = MemoryVideoPrefetcher();
final _scrollController = ScrollController();
bool _shouldShowCraftingMemories = false;
@@ -233,6 +233,7 @@ class _MemoriesStripWidgetState extends State<MemoriesStripWidget> {
double cardHeight,
) {
final memoryLane = _memoryLane;
+ final memoryLanePerson = _memoryLanePerson;
final oldestMemoryLaneFile = _oldestMemoryLaneFile;
final newestMemoryLaneFace = _newestMemoryLaneFace;
final hasContent = memories.isNotEmpty || memoryLane != null;
@@ -261,11 +262,17 @@ class _MemoriesStripWidgetState extends State<MemoriesStripWidget> {
MemoryCardWrapper(
id: "memoryLane_${memoryLane.personId}",
widget: () => MemoryLaneCardWidget(
+ id: memoryLane.personId,
oldestFile: oldestMemoryLaneFile,
face: newestMemoryLaneFace,
- personName: _memoryLanePersonName ?? "",
+ personName: memoryLanePerson?.data.name ?? "",
size: Size(_cardWidth, cardHeight),
- onTap: () => _openMemoryLanePage(memoryLane),
+ onTap: () => openMemoryLanePage(
+ context,
+ personId: memoryLane.personId,
+ person: memoryLanePerson,
+ isCluster: memoryLane.isCluster,
+ ),
),
),
...memories.indexed.map(
@@ -282,21 +289,6 @@ class _MemoriesStripWidgetState extends State<MemoriesStripWidget> {
];
}
- Future<void> _openMemoryLanePage(MemoryLanePersonTimeline memoryLane) async {
- if (memoryLane.isCluster) {
- await routeToPage(
- context,
- MemoryLanePage.cluster(clusterID: memoryLane.personId),
- );
- } else {
- final person = await PersonService.instance.getPerson(
- memoryLane.personId,
- );
- if (person == null || !mounted) return;
- await routeToPage(context, MemoryLanePage(person: person));
- }
- }
-
void _fetchMemories(Event? event) {
final fetchGeneration = ++_fetchMemoriesGeneration;
setState(() {
@@ -398,11 +390,10 @@ class _MemoriesStripWidgetState extends State<MemoriesStripWidget> {
final oldestFile = (await MemoryLaneService.instance.getTimelineFiles([
oldestEntry.fileId,
]))[oldestEntry.fileId];
- final personName = timeline.isCluster
- ? null
- : (await PersonService.instance.getPerson(
- timeline.personId,
- ))?.data.name;
+ PersonEntity? person;
+ if (!timeline.isCluster) {
+ person = await PersonService.instance.getPerson(timeline.personId);
+ }
if (!mounted ||
newestFaceCrop == null ||
oldestFile == null ||
@@ -412,7 +403,7 @@ class _MemoriesStripWidgetState extends State<MemoriesStripWidget> {
_memoryLane = timeline;
_oldestMemoryLaneFile = oldestFile;
_newestMemoryLaneFace = newestFaceCrop;
- _memoryLanePersonName = personName;
+ _memoryLanePerson = person;
}
void _hideMemoryLane() {
@@ -420,7 +411,7 @@ class _MemoriesStripWidgetState extends State<MemoriesStripWidget> {
_memoryLane = null;
_oldestMemoryLaneFile = null;
_newestMemoryLaneFace = null;
- _memoryLanePersonName = null;
+ _memoryLanePerson = null;
});
}
@@ -443,7 +434,7 @@ class _MemoriesStripWidgetState extends State<MemoriesStripWidget> {
return;
}
var shouldHide = false;
- var personName = _memoryLanePersonName;
+ var memoryLanePerson = _memoryLanePerson;
if (memoryLane.isCluster) {
if (!isLocalGalleryMode) {
final assignedClusterIDs = <String>{
@@ -464,7 +455,7 @@ class _MemoriesStripWidgetState extends State<MemoriesStripWidget> {
person == null ||
person.data.isIgnored ||
person.data.hideFromMemories;
- personName = person?.data.name;
+ memoryLanePerson = person;
}
if (!shouldHide) {
final mlDataDB = isLocalGalleryMode
@@ -481,9 +472,9 @@ class _MemoriesStripWidgetState extends State<MemoriesStripWidget> {
return;
}
if (!shouldHide) {
- if (_memoryLanePersonName != personName) {
+ if (_memoryLanePerson != memoryLanePerson) {
setState(() {
- _memoryLanePersonName = personName;
+ _memoryLanePerson = memoryLanePerson;
});
}
return;
diff --git a/mobile/apps/photos/lib/ui/home/memories/memory_lane_card.dart b/mobile/apps/photos/lib/ui/home/memories/memory_lane_card.dart
index 40b8b4e467..70c7622f44 100644
--- a/mobile/apps/photos/lib/ui/home/memories/memory_lane_card.dart
+++ b/mobile/apps/photos/lib/ui/home/memories/memory_lane_card.dart
@@ -9,6 +9,7 @@ import "package:photos/ui/home/memories/memory_card_constants.dart";
import "package:photos/ui/viewer/file/thumbnail_widget.dart";
class MemoryLaneCardWidget extends StatelessWidget {
+ final String id;
final EnteFile oldestFile;
final Uint8List face;
final String personName;
@@ -16,6 +17,7 @@ class MemoryLaneCardWidget extends StatelessWidget {
final VoidCallback onTap;
const MemoryLaneCardWidget({
+ required this.id,
required this.oldestFile,
required this.face,
required this.personName,
@@ -29,7 +31,10 @@ class MemoryLaneCardWidget extends StatelessWidget {
final name = personName.trim();
final title = name.isEmpty
? context.strings.facesTimelineAppBarTitle
- : context.strings.memoryLaneCardTitle(name: name);
+ : context.strings.memoryLaneCardTitle(
+ name: name,
+ nameEndsWithS: name.toLowerCase().endsWith("s").toString(),
+ );
return Padding(
padding: const EdgeInsets.symmetric(horizontal: kMemoryCardStripGap / 2),
@@ -83,17 +88,21 @@ class MemoryLaneCardWidget extends StatelessWidget {
left: size.width * 0.081081081081,
bottom: 16,
width: size.width * 0.837837837838,
- child: Text(
- title,
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- style: TextStyles.body.copyWith(
- height: 16 / 14,
- fontFamily: TextStyles.outfitFontFamily,
- color: Colors.white,
- fontWeight: FontWeight.w700,
+ child: Hero(
+ tag: 'memory-lane-title-$id',
+ child: Text(
+ title,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyles.body.copyWith(
+ inherit: false,
+ height: 16 / 14,
+ fontFamily: TextStyles.outfitFontFamily,
+ color: Colors.white,
+ fontWeight: FontWeight.w700,
+ ),
+ textAlign: TextAlign.left,
),
- textAlign: TextAlign.left,
),
),
],
diff --git a/mobile/apps/photos/lib/ui/viewer/people/cluster_page.dart b/mobile/apps/photos/lib/ui/viewer/people/cluster_page.dart
index 841272527b..635349978d 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/cluster_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/cluster_page.dart
@@ -29,7 +29,7 @@ import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.da
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
import "package:photos/ui/viewer/people/add_person_action_sheet.dart";
import "package:photos/ui/viewer/people/cluster_app_bar.dart";
-import "package:photos/ui/viewer/people/memory_lane_page.dart";
+import "package:photos/ui/viewer/people/memory_lane_page_v2.dart";
import "package:photos/ui/viewer/people/people_page.dart";
import "package:photos/ui/viewer/people/person_face_widget.dart";
import "package:photos/ui/viewer/people/save_person_banner.dart";
@@ -183,9 +183,11 @@ class _ClusterPageState extends State<ClusterPage> {
widget.clusterID,
isCluster: true,
)) {
- await routeToPage(
+ await openMemoryLanePage(
context,
- MemoryLanePage.cluster(clusterID: widget.clusterID),
+ personId: widget.clusterID,
+ person: null,
+ isCluster: true,
);
}
if (mounted) setState(() {});
diff --git a/mobile/apps/photos/lib/ui/viewer/people/memory_lane_page.dart b/mobile/apps/photos/lib/ui/viewer/people/memory_lane_page.dart
index 179e16382e..0debd15c88 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/memory_lane_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/memory_lane_page.dart
@@ -29,16 +29,16 @@ import "package:photos/utils/face_crop_util.dart";
import "package:photos/utils/share_util.dart";
class MemoryLanePage extends StatefulWidget {
+ final String personId;
+ final bool isCluster;
final PersonEntity? person;
- final String? clusterID;
- const MemoryLanePage({required this.person, super.key}) : clusterID = null;
-
- const MemoryLanePage.cluster({required this.clusterID, super.key})
- : person = null;
-
- String get timelineId => person?.remoteID ?? clusterID ?? "";
- bool get isCluster => clusterID != null;
+ const MemoryLanePage({
+ required this.personId,
+ required this.isCluster,
+ required this.person,
+ super.key,
+ });
@override
State<MemoryLanePage> createState() => _MemoryLanePageState();
@@ -161,7 +161,7 @@ class _MemoryLanePageState extends State<MemoryLanePage>
}
Future<void> _loadFrames() async {
- _hasMarkedTimelineSeen = localSettings.hasSeenMemoryLane(widget.timelineId);
+ _hasMarkedTimelineSeen = localSettings.hasSeenMemoryLane(widget.personId);
_playTimer?.cancel();
if (mounted) {
setState(() {
@@ -170,7 +170,7 @@ class _MemoryLanePageState extends State<MemoryLanePage>
}
try {
final timeline = await MemoryLaneService.instance.getTimeline(
- widget.timelineId,
+ widget.personId,
isCluster: widget.isCluster,
);
if (!mounted) {
@@ -283,7 +283,7 @@ class _MemoryLanePageState extends State<MemoryLanePage>
return;
}
_hasMarkedTimelineSeen = true;
- unawaited(localSettings.markMemoryLaneSeen(widget.timelineId));
+ unawaited(localSettings.markMemoryLaneSeen(widget.personId));
}
void _handleFrameLoaded(_TimelineFrame frame, int loadedCount) {
@@ -515,9 +515,7 @@ class _MemoryLanePageState extends State<MemoryLanePage>
void _logPlaybackStart(int frameCount) {
if (_loggedPlaybackStart) return;
- _logger.info(
- "playback_start person=${widget.timelineId} frames=$frameCount",
- );
+ _logger.info("playback_start person=${widget.personId} frames=$frameCount");
_loggedPlaybackStart = true;
}
diff --git a/mobile/apps/photos/lib/ui/viewer/people/memory_lane_page_v2.dart b/mobile/apps/photos/lib/ui/viewer/people/memory_lane_page_v2.dart
new file mode 100644
index 0000000000..25a56cabd0
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/viewer/people/memory_lane_page_v2.dart
@@ -0,0 +1,783 @@
+import "dart:async";
+import "dart:math" as math;
+import "dart:typed_data";
+import "dart:ui";
+
+import "package:collection/collection.dart";
+import "package:ente_components/ente_components.dart";
+import "package:ente_pure_utils/ente_pure_utils.dart";
+import "package:ente_strings/ente_strings.dart";
+import "package:flutter/material.dart";
+import "package:flutter/services.dart" show SystemUiOverlayStyle;
+import "package:hugeicons/hugeicons.dart";
+import "package:intl/intl.dart" show DateFormat, NumberFormat;
+import "package:logging/logging.dart";
+import "package:photos/db/ml/db.dart";
+import "package:photos/models/file/file.dart";
+import "package:photos/models/memory_lane/memory_lane_models.dart";
+import "package:photos/models/ml/face/face.dart";
+import "package:photos/models/ml/face/person.dart";
+import "package:photos/service_locator.dart";
+import "package:photos/services/memory_lane/memory_lane_service.dart";
+import "package:photos/services/memory_share_service.dart";
+import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/viewer/gallery/jump_to_date_gallery.dart";
+import "package:photos/ui/viewer/people/memory_lane_page.dart";
+import "package:photos/utils/dialog_util.dart";
+import "package:photos/utils/face/face_thumbnail_cache.dart";
+import "package:photos/utils/share_util.dart";
+
+Future<void> openMemoryLanePage(
+ BuildContext context, {
+ required String personId,
+ required PersonEntity? person,
+ bool isCluster = false,
+}) async {
+ if (!context.mounted || (!isCluster && person == null)) return;
+
+ final Widget page;
+ if (flagService.internalUser) {
+ page = MemoryLanePageV2(
+ personId: personId,
+ isCluster: isCluster,
+ person: person,
+ );
+ } else {
+ page = MemoryLanePage(
+ personId: personId,
+ isCluster: isCluster,
+ person: person,
+ );
+ }
+ await routeToPage(context, page);
+}
+
+class MemoryLanePageV2 extends StatefulWidget {
+ final String personId;
+ final bool isCluster;
+ final PersonEntity? person;
+
+ const MemoryLanePageV2({
+ required this.personId,
+ required this.isCluster,
+ required this.person,
+ super.key,
+ });
+
+ @override
+ State<MemoryLanePageV2> createState() => _MemoryLanePageV2State();
+}
+
+class _MemoryLanePageV2State extends State<MemoryLanePageV2> {
+ static const _playbackInterval = Duration(seconds: 3);
+
+ final _logger = Logger("MemoryLanePageV2");
+ Timer? _playbackTimer;
+ Object? _playbackToken;
+ bool _wasPlayingBeforeSeek = false;
+ late final Future<void> _memoryLaneLoaded;
+ Key _currentEntryKey = UniqueKey();
+ MemoryLanePersonTimeline? _timeline;
+ final List<Future<Uint8List?>> _entries = [];
+ final Map<(Future<Uint8List?>, Size), Future<(Uint8List, int)?>>
+ _decodedEntries = {};
+ final List<EnteFile> _files = [];
+ int i = 0;
+
+ @override
+ void initState() {
+ super.initState();
+ _memoryLaneLoaded = _loadMemoryLane();
+ }
+
+ @override
+ void dispose() {
+ _playbackTimer?.cancel();
+ super.dispose();
+ }
+
+ Future<void> _loadMemoryLane() async {
+ try {
+ final timeline = await MemoryLaneService.instance.getTimeline(
+ widget.personId,
+ isCluster: widget.isCluster,
+ );
+ if (!mounted) return;
+ _timeline = timeline;
+ if (timeline == null ||
+ !timeline.isEligible ||
+ timeline.entries.isEmpty) {
+ return;
+ }
+ final files = await MemoryLaneService.instance.getTimelineFiles(
+ timeline.entries.map((entry) => entry.fileId).toSet(),
+ );
+ if (!mounted) return;
+ Future<Uint8List?> previousEntry = Future.value();
+ for (final entry in timeline.entries) {
+ final file = files[entry.fileId];
+ if (file != null) {
+ _files.add(file);
+ final entryFuture = previousEntry.then((_) async {
+ if (!mounted) return null;
+ return _loadEntry(entry, file);
+ });
+ _entries.add(entryFuture);
+ previousEntry = entryFuture;
+ }
+ }
+ if (_entries.isNotEmpty) unawaited(_play(0));
+ } catch (error) {
+ if (!mounted || ModalRoute.of(context)?.isCurrent != true) return;
+ final navigator = Navigator.of(context);
+ navigator.pop();
+ await showGenericErrorDialog(context: navigator.context, error: error);
+ }
+ }
+
+ Future<void> _play(int index) async {
+ if (_entries.isEmpty) return;
+ final token = Object();
+ setState(() {
+ _playbackTimer?.cancel();
+ _selectEntry(index);
+ _playbackToken = index < _entries.length - 1 ? token : null;
+ });
+ if (_playbackToken == null) return;
+ await _entries[index];
+ if (!mounted || _playbackToken != token) return;
+ _playbackTimer = Timer(_playbackInterval, () => _play(index + 1));
+ }
+
+ void _pause() {
+ setState(() {
+ _playbackTimer?.cancel();
+ _playbackToken = null;
+ });
+ }
+
+ void _seekFromPosition(double x, double width) {
+ if (width <= 0) return;
+ final index = (x / width * _entries.length).floor().clamp(
+ 0,
+ _entries.length - 1,
+ );
+ setState(() {
+ _playbackTimer?.cancel();
+ _playbackToken = null;
+ _selectEntry(index);
+ });
+ }
+
+ void _onPlayPauseTap() {
+ if (_playbackToken != null) {
+ _pause();
+ } else if (i == _entries.length - 1) {
+ _play(0);
+ } else {
+ unawaited(_play(i));
+ }
+ }
+
+ void _onSeekEnd() {
+ final wasPlaying = _wasPlayingBeforeSeek;
+ _wasPlayingBeforeSeek = false;
+ if (wasPlaying) unawaited(_play(i));
+ }
+
+ Future<Uint8List?> _loadEntry(MemoryLaneEntry entry, EnteFile file) async {
+ try {
+ final mlDataDB = isLocalGalleryMode
+ ? MLDataDB.localGalleryInstance
+ : MLDataDB.instance;
+ final List<Face>? faces = await mlDataDB.getFacesForGivenFileID(
+ entry.fileId,
+ );
+ final face = faces?.firstWhereOrNull(
+ (face) => face.faceID == entry.faceId,
+ );
+ if (face == null) return null;
+ final crops = await getCachedFaceCrops(file, [face], useTempCache: false);
+ final bytes = crops?[entry.faceId];
+ if (bytes != null && bytes.isNotEmpty) {
+ return bytes;
+ }
+ return null;
+ } catch (e, s) {
+ _logger.severe("Failed to load memory lane entry", e, s);
+ return null;
+ }
+ }
+
+ Future<(Uint8List, int)?> _fetchEntry(
+ Future<Uint8List?> entry,
+ Size targetSize,
+ ) {
+ return _decodedEntries.putIfAbsent((entry, targetSize), () async {
+ final bytes = await entry;
+ if (bytes == null || !mounted) return null;
+ final buffer = await ImmutableBuffer.fromUint8List(bytes);
+ try {
+ final descriptor = await ImageDescriptor.encoded(buffer);
+ try {
+ final scale = math.max(
+ targetSize.width / descriptor.width,
+ targetSize.height / descriptor.height,
+ );
+ final decodeWidth = (descriptor.width * scale).ceil().clamp(
+ 1,
+ descriptor.width,
+ );
+ return (bytes, decodeWidth);
+ } finally {
+ descriptor.dispose();
+ }
+ } finally {
+ buffer.dispose();
+ }
+ });
+ }
+
+ void _selectEntry(int index) {
+ if (i != index) _currentEntryKey = UniqueKey();
+ i = index;
+ if (index != _entries.length - 1) return;
+ final entryKey = _currentEntryKey;
+ unawaited(
+ _entries[index].then((bytes) async {
+ if (bytes == null ||
+ !mounted ||
+ _currentEntryKey != entryKey ||
+ ModalRoute.of(context)?.isCurrent != true ||
+ localSettings.hasSeenMemoryLane(widget.personId)) {
+ return;
+ }
+ await localSettings.markMemoryLaneSeen(widget.personId);
+ }),
+ );
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return FutureBuilder<void>(
+ future: _memoryLaneLoaded,
+ builder: (context, snapshot) {
+ final name = widget.person?.data.name.trim();
+ var title = context.strings.facesTimelineAppBarTitle;
+ if (name != null && name.isNotEmpty) {
+ title = context.strings.memoryLaneCardTitle(
+ name: name,
+ nameEndsWithS: name.toLowerCase().endsWith("s").toString(),
+ );
+ }
+ final file = _files.isEmpty ? null : _files[i];
+ final entry = _entries.isEmpty ? null : _entries[i];
+ final creationTime = file?.creationTime;
+ final birthDate = DateTime.tryParse(
+ widget.person?.data.birthDate ?? "",
+ );
+ final creationDate = creationTime == null
+ ? null
+ : DateTime.fromMicrosecondsSinceEpoch(creationTime);
+ int? age;
+ if (birthDate != null &&
+ creationDate != null &&
+ !creationDate.isBefore(birthDate)) {
+ age = creationDate.year - birthDate.year;
+ final lastDay = DateTime(
+ creationDate.year,
+ birthDate.month + 1,
+ 0,
+ ).day;
+ final anniversary = DateTime(
+ creationDate.year,
+ birthDate.month,
+ birthDate.day.clamp(1, lastDay),
+ );
+ if (creationDate.isBefore(anniversary)) age--;
+ }
+ const agePlaceholder = "\uFFFC";
+ final ageCaptionParts = age != null && name != null && name.isNotEmpty
+ ? context.strings
+ .memoryLaneAgeCaption(
+ name: name,
+ count: age,
+ age: agePlaceholder,
+ )
+ .split(agePlaceholder)
+ : const <String>[];
+ return Stack(
+ children: [
+ Positioned.fill(
+ child: ColoredBox(
+ color: Colors.black,
+ child: AnimatedSwitcher(
+ duration: const Duration(milliseconds: 750),
+ switchInCurve: Curves.easeOutExpo,
+ switchOutCurve: Curves.easeInExpo,
+ child: LayoutBuilder(
+ key: _currentEntryKey,
+ builder: (context, constraints) =>
+ FutureBuilder<(Uint8List, int)?>(
+ future: entry == null
+ ? null
+ : _fetchEntry(
+ entry,
+ constraints.biggest *
+ MediaQuery.devicePixelRatioOf(context),
+ ),
+ builder: (context, entrySnapshot) {
+ final crop = entrySnapshot.data;
+ if (crop == null) return const SizedBox.expand();
+ return ImageFiltered(
+ imageFilter: ImageFilter.blur(
+ sigmaX: 100,
+ sigmaY: 100,
+ ),
+ child: Image.memory(
+ crop.$1,
+ cacheWidth: crop.$2,
+ fit: BoxFit.cover,
+ width: double.infinity,
+ height: double.infinity,
+ ),
+ );
+ },
+ ),
+ ),
+ ),
+ ),
+ ),
+ Scaffold(
+ backgroundColor: Colors.transparent,
+ appBar: AppBar(
+ backgroundColor: Colors.transparent,
+ foregroundColor: Colors.white,
+ iconTheme: const IconThemeData(color: Colors.white),
+ actionsIconTheme: const IconThemeData(color: Colors.white),
+ systemOverlayStyle: SystemUiOverlayStyle.light,
+ title: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Hero(
+ tag: 'memory-lane-title-${widget.personId}',
+ child: Text(
+ title,
+ style: darkTheme.textTheme.large.copyWith(
+ inherit: false,
+ ),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ if (file != null && creationTime != null)
+ GestureDetector(
+ onTap: () => _onDateTap(file),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(
+ DateFormat.yMMMd(
+ Localizations.localeOf(context).languageCode,
+ ).format(
+ DateTime.fromMicrosecondsSinceEpoch(
+ creationTime,
+ ),
+ ),
+ style: darkTheme.textTheme.small,
+ ),
+ const Icon(
+ Icons.chevron_right,
+ size: 16,
+ color: Colors.white,
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ leadingWidth: 48 + 16,
+ actionsPadding: const EdgeInsets.only(right: 16),
+ // TODO: Replace with an Ente component when it supports this pressed overlay.
+ leading: Align(
+ alignment: Alignment.centerRight,
+ child: SizedBox.square(
+ dimension: 48,
+ child: IconButton(
+ tooltip: context.strings.close,
+ style: IconButton.styleFrom(
+ overlayColor: Colors.white.withValues(alpha: 0.08),
+ ),
+ icon: const HugeIcon(
+ icon: HugeIcons.strokeRoundedCancel01,
+ color: Colors.white,
+ ),
+ onPressed: () => Navigator.of(context).pop(),
+ ),
+ ),
+ ),
+ actions: [
+ if (widget.person != null &&
+ flagService.enableMemoryShareLink &&
+ !isLocalGalleryMode)
+ // TODO: Replace with an Ente component when it supports this pressed overlay.
+ SizedBox.square(
+ dimension: 48,
+ child: IconButton(
+ tooltip: context.strings.shareLink,
+ style: IconButton.styleFrom(
+ overlayColor: Colors.white.withValues(alpha: 0.08),
+ ),
+ icon: const HugeIcon(
+ icon: HugeIcons.strokeRoundedShare08,
+ color: Colors.white,
+ ),
+ onPressed: _onShareTap,
+ ),
+ ),
+ ],
+ ),
+ body: Column(
+ children: [
+ Expanded(
+ flex: 4,
+ child: Padding(
+ padding: const EdgeInsetsGeometry.all(32),
+ child: Align(
+ child: AspectRatio(
+ aspectRatio: 3 / 4,
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(24),
+ child: AnimatedSwitcher(
+ duration: const Duration(milliseconds: 1000),
+ switchInCurve: Curves.easeOutCubic,
+ switchOutCurve: Curves.easeInCubic,
+ transitionBuilder: (child, animation) {
+ return AnimatedBuilder(
+ animation: animation,
+ child: FadeTransition(
+ opacity: animation,
+ child: ScaleTransition(
+ scale: Tween<double>(
+ begin: 1,
+ end: 1.1,
+ ).animate(animation),
+ child: child,
+ ),
+ ),
+ builder: (context, child) {
+ final blur = 12 * (1 - animation.value);
+ return ImageFiltered(
+ imageFilter: ImageFilter.blur(
+ sigmaX: blur,
+ sigmaY: blur,
+ ),
+ child: child,
+ );
+ },
+ );
+ },
+ child: switch (snapshot.connectionState) {
+ ConnectionState.done when file != null =>
+ LayoutBuilder(
+ key: _currentEntryKey,
+ builder: (context, constraints) =>
+ FutureBuilder<(Uint8List, int)?>(
+ future: entry == null
+ ? null
+ : _fetchEntry(
+ entry,
+ constraints.biggest *
+ MediaQuery.devicePixelRatioOf(
+ context,
+ ) *
+ 1.1,
+ ),
+ builder: (context, entrySnapshot) {
+ final crop = entrySnapshot.data;
+ if (crop == null) {
+ if (entrySnapshot
+ .connectionState ==
+ ConnectionState.done) {
+ return Center(
+ child: Text(
+ context
+ .strings
+ .facesTimelineUnavailable,
+ style: darkTheme
+ .textTheme
+ .small,
+ ),
+ );
+ }
+ return const Center(
+ child:
+ CircularProgressIndicator(
+ color: Colors.white,
+ ),
+ );
+ }
+ return Image.memory(
+ crop.$1,
+ cacheWidth: crop.$2,
+ fit: BoxFit.cover,
+ width: double.infinity,
+ height: double.infinity,
+ );
+ },
+ ),
+ ),
+ ConnectionState.done => Center(
+ key: const ValueKey("memory-lane-empty"),
+ child: Text(
+ context.strings.facesTimelineUnavailable,
+ style: darkTheme.textTheme.small,
+ ),
+ ),
+ _ => const Center(
+ key: ValueKey("memory-lane-loading"),
+ child: CircularProgressIndicator(
+ color: Colors.white,
+ ),
+ ),
+ },
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ Expanded(
+ child: Column(
+ children: [
+ if (age != null && name != null && name.isNotEmpty) ...[
+ Expanded(
+ child: Align(
+ alignment: Alignment.bottomCenter,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 64,
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment:
+ CrossAxisAlignment.baseline,
+ textBaseline: TextBaseline.alphabetic,
+ spacing: 8,
+ children: [
+ for (
+ var index = 0;
+ index < ageCaptionParts.length;
+ index++
+ ) ...[
+ if (index > 0)
+ AnimatedDigitComponent(
+ value: age,
+ formatter:
+ NumberFormat.decimalPattern(
+ context.strings.localeName,
+ ).format,
+ style: darkTheme.textTheme.h2
+ .copyWith(
+ fontWeight: .w600,
+ color: darkTheme
+ .colorScheme
+ .textBase,
+ ),
+ ),
+ Flexible(
+ child: Text(
+ ageCaptionParts[index],
+ style: darkTheme.textTheme.bodyMuted,
+ textAlign: TextAlign.center,
+ ),
+ ),
+ ],
+ ],
+ ),
+ ),
+ ),
+ ),
+ const SizedBox(height: 16),
+ ],
+ Expanded(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 96),
+ child: Row(
+ mainAxisAlignment: .center,
+ children: [
+ IconButtonComponent(
+ variant: IconButtonComponentVariant
+ .circularTranslucent,
+ tooltip: _playbackToken != null
+ ? context
+ .strings
+ .facesTimelinePlaybackPause
+ : context
+ .strings
+ .facesTimelinePlaybackPlay,
+ onTap: _onPlayPauseTap,
+ icon: HugeIcon(
+ icon: _playbackToken != null
+ ? HugeIcons.strokeRoundedPause
+ : HugeIcons.strokeRoundedPlay,
+ ),
+ size: 48,
+ ),
+ if (_entries.isNotEmpty) ...[
+ const SizedBox(width: 12),
+ Expanded(
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onHorizontalDragDown: (_) {
+ _wasPlayingBeforeSeek =
+ _playbackToken != null;
+ },
+ onTapDown: (details) =>
+ _seekFromPosition(
+ details.localPosition.dx,
+ constraints.maxWidth,
+ ),
+ onTapUp: (_) => _onSeekEnd(),
+ onHorizontalDragStart: (details) =>
+ _seekFromPosition(
+ details.localPosition.dx,
+ constraints.maxWidth,
+ ),
+ onHorizontalDragUpdate: (details) =>
+ _seekFromPosition(
+ details.localPosition.dx,
+ constraints.maxWidth,
+ ),
+ onHorizontalDragEnd: (_) =>
+ _onSeekEnd(),
+ child: Row(
+ children: List.generate(
+ _entries.length,
+ (index) {
+ final distance = (index - i)
+ .abs();
+ final double size =
+ switch (distance) {
+ 0 => 15,
+ 1 => 10,
+ 2 => 7.5,
+ _ => 5,
+ };
+ return Expanded(
+ child: SizedBox(
+ height: 40,
+ child: Center(
+ child: AnimatedContainer(
+ duration:
+ const Duration(
+ milliseconds: 200,
+ ),
+ width: size,
+ height: size,
+ decoration: BoxDecoration(
+ shape:
+ BoxShape.circle,
+ color: Colors.white
+ .withValues(
+ alpha:
+ distance ==
+ 0
+ ? 1
+ : 0.5,
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ },
+ ),
+ ),
+ );
+ },
+ ),
+ ),
+ ],
+ ],
+ ),
+ ),
+ ),
+ const SizedBox(height: 44),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ );
+ },
+ );
+ }
+
+ Future<void> _onShareTap() async {
+ final timeline = _timeline;
+ final person = widget.person;
+ if (!flagService.enableMemoryShareLink ||
+ isLocalGalleryMode ||
+ timeline == null ||
+ person == null ||
+ !timeline.isEligible ||
+ timeline.entries.isEmpty) {
+ return;
+ }
+ final l10n = context.strings;
+ final name = person.data.name.trim();
+ var title = l10n.facesTimelineAppBarTitle;
+ if (name.isNotEmpty) {
+ title = l10n.memoryLaneCardTitle(
+ name: name,
+ nameEndsWithS: name.toLowerCase().endsWith("s").toString(),
+ );
+ }
+ final dialog = createProgressDialog(context, l10n.creatingLink);
+ final wasPlaying = _playbackToken != null;
+ _pause();
+
+ try {
+ await dialog.show();
+ final shareLinkData = await MemoryShareService.instance
+ .getOrCreateMemoryLaneLink(
+ entries: timeline.entries,
+ title: title,
+ personId: person.remoteID,
+ personName: person.data.name,
+ birthDate: person.data.birthDate,
+ );
+ await dialog.hide();
+ if (!mounted) return;
+ await shareText(
+ formatMemoryShareText(title, shareLinkData.$1),
+ context: context,
+ );
+ } catch (e) {
+ await dialog.hide();
+ if (!mounted) return;
+ await showGenericErrorBottomSheet(context: context, error: e);
+ } finally {
+ if (mounted && wasPlaying && ModalRoute.of(context)?.isCurrent == true) {
+ unawaited(_play(i));
+ }
+ }
+ }
+
+ Future<void> _onDateTap(EnteFile file) async {
+ final wasPlaying = _playbackToken != null;
+ _pause();
+ try {
+ await routeToPage(context, JumpToDateGallery(fileToJumpTo: file));
+ } finally {
+ if (mounted && wasPlaying && ModalRoute.of(context)?.isCurrent == true) {
+ unawaited(_play(i));
+ }
+ }
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/viewer/people/people_page.dart b/mobile/apps/photos/lib/ui/viewer/people/people_page.dart
index aaa6d80676..4887ef2cbb 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/people_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/people_page.dart
@@ -1,6 +1,5 @@
import "dart:async";
-import "package:ente_pure_utils/ente_pure_utils.dart";
import "package:ente_strings/ente_strings.dart";
import 'package:flutter/material.dart';
import "package:intl/intl.dart";
@@ -31,7 +30,7 @@ import "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/ui/viewer/people/memory_lane_banner.dart";
-import "package:photos/ui/viewer/people/memory_lane_page.dart";
+import "package:photos/ui/viewer/people/memory_lane_page_v2.dart";
import "package:photos/ui/viewer/people/people_app_bar.dart";
import "package:photos/ui/viewer/people/person_gallery_suggestion.dart";
@@ -198,7 +197,11 @@ class _PeoplePageState extends State<PeoplePage> {
Future<void> _openMemoryLanePage() async {
_timelineLogger.info("banner_tap person=${_person.remoteID}");
if (MemoryLaneService.instance.hasReadyTimelineSync(_person.remoteID)) {
- await routeToPage(context, MemoryLanePage(person: _person));
+ await openMemoryLanePage(
+ context,
+ personId: _person.remoteID,
+ person: _person,
+ );
}
if (!mounted) return;
setState(() {});
diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
index 745fa7b9fc..dd696d8dea 100644
--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
@@ -2523,13 +2523,17 @@
}
}
},
- "memoryLaneCardTitle": "{name}’s memory lane",
+ "memoryLaneCardTitle": "{nameEndsWithS, select, true{{name}’ memory lane} other{{name}’s memory lane}}",
"@memoryLaneCardTitle": {
- "description": "Title for the Memory Lane card on the home screen",
+ "description": "Title for a person's Memory Lane, used on the home screen card, viewer page, and shared link",
"placeholders": {
"name": {
"type": "String",
"description": "Person's name"
+ },
+ "nameEndsWithS": {
+ "type": "String",
+ "description": "true if the trimmed name ends in s or S; false otherwise"
}
}
},