Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] integrate memory lane into memories navigation

Priyanshu Dangare95741464753c
diff --git a/mobile/apps/photos/lib/services/memories_cache_service.dart b/mobile/apps/photos/lib/services/memories_cache_service.dart
index 71b9b89991..21aa0e9de1 100644
--- a/mobile/apps/photos/lib/services/memories_cache_service.dart
+++ b/mobile/apps/photos/lib/services/memories_cache_service.dart
@@ -1288,15 +1288,12 @@ class MemoriesCacheService {
return;
}
if (context != null && !context.mounted) return;
- await _routeToPage(
- AllMemoriesPage(
- allMemories: _cachedMemories!,
- initialPageIndex: memoryIdx,
- inititalFileIndex: fileIdx,
- isFromWidgetOrNotifications: true,
- ),
+ await openAllMemoriesPage(
+ allMemories: _cachedMemories!,
+ initialPageIndex: memoryIdx,
+ initialFileIndex: fileIdx,
+ isFromWidgetOrNotifications: true,
context: context,
- forceCustomPageRoute: true,
);
}
@@ -1318,15 +1315,11 @@ class MemoriesCacheService {
return;
}
if (context != null && !context.mounted) return;
- await _routeToPage(
- AllMemoriesPage(
- allMemories: allMemories,
- initialPageIndex: memoryIdx,
- inititalFileIndex: 0,
- isFromWidgetOrNotifications: true,
- ),
+ await openAllMemoriesPage(
+ allMemories: allMemories,
+ initialPageIndex: memoryIdx,
+ isFromWidgetOrNotifications: true,
context: context,
- forceCustomPageRoute: true,
);
}
diff --git a/mobile/apps/photos/lib/ui/home/memories/all_memories_page.dart b/mobile/apps/photos/lib/ui/home/memories/all_memories_page.dart
index 8ab561c75c..1515de3045 100644
--- a/mobile/apps/photos/lib/ui/home/memories/all_memories_page.dart
+++ b/mobile/apps/photos/lib/ui/home/memories/all_memories_page.dart
@@ -1,23 +1,70 @@
+import "package:ente_pure_utils/ente_pure_utils.dart";
import 'package:flutter/material.dart';
import "package:photos/core/event_bus.dart";
import "package:photos/events/pause_video_event.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/services/app_navigation_service.dart";
import "package:photos/theme/colors.dart";
import "package:photos/ui/home/memories/full_screen_memory.dart";
import "package:photos/ui/home/memories/memory_cover_util.dart";
import "package:photos/ui/home/memories/memory_music_session.dart";
+import "package:photos/ui/viewer/people/memory_lane_page_v2.dart";
+
+Future<void> openAllMemoriesPage({
+ required List<SmartMemory> allMemories,
+ required int initialPageIndex,
+ MemoryLanePersonTimeline? memoryLane,
+ PersonEntity? memoryLanePerson,
+ BuildContext? context,
+ int initialFileIndex = 0,
+ bool isFromWidgetOrNotifications = false,
+}) async {
+ final page = AllMemoriesPage(
+ allMemories: allMemories,
+ memoryLane: memoryLane,
+ memoryLanePerson: memoryLanePerson,
+ initialPageIndex: initialPageIndex,
+ initialFileIndex: initialFileIndex,
+ isFromWidgetOrNotifications: isFromWidgetOrNotifications,
+ );
+ if (context != null) {
+ await routeToPage(context, page, forceCustomPageRoute: true);
+ return;
+ }
+ await AppNavigationService.instance.pushPage(
+ page,
+ forceCustomPageRoute: true,
+ );
+}
+
+class MemoryPageWrapper {
+ final String id;
+ final Widget Function({
+ VoidCallback? onNextMemory,
+ VoidCallback? onPreviousMemory,
+ })
+ widget;
+
+ const MemoryPageWrapper({required this.id, required this.widget});
+}
class AllMemoriesPage extends StatefulWidget {
final int initialPageIndex;
- final int inititalFileIndex;
+ final int initialFileIndex;
final List<SmartMemory> allMemories;
+ final MemoryLanePersonTimeline? memoryLane;
+ final PersonEntity? memoryLanePerson;
final bool isFromWidgetOrNotifications;
const AllMemoriesPage({
super.key,
required this.allMemories,
required this.initialPageIndex,
- this.inititalFileIndex = 0,
+ this.memoryLane,
+ this.memoryLanePerson,
+ this.initialFileIndex = 0,
this.isFromWidgetOrNotifications = false,
});
@@ -25,97 +72,125 @@ class AllMemoriesPage extends StatefulWidget {
State<AllMemoriesPage> createState() => _AllMemoriesPageState();
}
-class _AllMemoriesPageState extends State<AllMemoriesPage>
- with SingleTickerProviderStateMixin {
- late PageController pageController;
- late final List<SmartMemory> _memories;
- late final int _initialPageIndex;
+class _AllMemoriesPageState extends State<AllMemoriesPage> {
+ late final PageController _pageController;
+ late final List<MemoryPageWrapper> _pages;
late int _activePageIndex;
bool _isMediaInteractionLocked = false;
@override
void initState() {
super.initState();
- final initialMemory = widget.allMemories[widget.initialPageIndex];
- _memories = widget.allMemories
- .where((memory) => memory.memories.isNotEmpty)
- .toList();
- _initialPageIndex = _memories.indexOf(initialMemory);
- _activePageIndex = _initialPageIndex;
- pageController = PageController(initialPage: _initialPageIndex);
+ final initialMemoryIndex =
+ widget.initialPageIndex - (widget.memoryLane == null ? 0 : 1);
+ final initialMemory = initialMemoryIndex < 0
+ ? null
+ : widget.allMemories[initialMemoryIndex];
+ _pages = _buildPages();
+ _activePageIndex = initialMemory == null
+ ? 0
+ : _pages.indexWhere((page) => page.id == initialMemory.id);
+ _pageController = PageController(initialPage: _activePageIndex);
+ }
+
+ List<MemoryPageWrapper> _buildPages() {
+ final memoryLane = widget.memoryLane;
+ final pages = <MemoryPageWrapper>[
+ if (memoryLane != null)
+ MemoryPageWrapper(
+ id: "memoryLane_${memoryLane.personId}",
+ widget: ({onNextMemory, onPreviousMemory}) => MemoryLanePageV2(
+ key: ValueKey("memoryLane_${memoryLane.personId}"),
+ personId: memoryLane.personId,
+ isCluster: memoryLane.isCluster,
+ person: widget.memoryLanePerson,
+ isActive: _activePageIndex == 0,
+ onNextMemory: onNextMemory,
+ onPreviousMemory: onPreviousMemory,
+ ),
+ ),
+ ];
+ for (final smartMemory in widget.allMemories) {
+ if (smartMemory.memories.isEmpty) continue;
+ final index = pages.length;
+ pages.add(
+ MemoryPageWrapper(
+ id: smartMemory.id,
+ widget: ({onNextMemory, onPreviousMemory}) {
+ final initialMemoryIndex =
+ widget.isFromWidgetOrNotifications &&
+ index == _pageController.initialPage
+ ? widget.initialFileIndex
+ : getNextMemoryIndex(smartMemory.memories);
+ return FullScreenMemoryDataUpdater(
+ key: ValueKey(smartMemory.id),
+ initialIndex: initialMemoryIndex,
+ memories: smartMemory.memories,
+ child: FullScreenMemory(
+ smartMemory.title,
+ initialMemoryIndex,
+ memoryID: smartMemory.id,
+ isActive: index == _activePageIndex,
+ onMediaInteractionLockChanged: (isLocked) {
+ if (index != _activePageIndex ||
+ _isMediaInteractionLocked == isLocked) {
+ return;
+ }
+ setState(() => _isMediaInteractionLocked = isLocked);
+ },
+ onNextMemory: onNextMemory,
+ onPreviousMemory: onPreviousMemory,
+ ),
+ );
+ },
+ ),
+ );
+ }
+ return pages;
}
@override
void dispose() {
- pageController.dispose();
+ _pageController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
- final page = Container(
- width: double.infinity,
- height: double.infinity,
- color: backgroundColorDark,
- child: PageView.builder(
- controller: pageController,
- physics: _isMediaInteractionLocked
- ? const NeverScrollableScrollPhysics()
- : const BouncingScrollPhysics(),
- hitTestBehavior: HitTestBehavior.translucent,
- itemCount: _memories.length,
- onPageChanged: (index) {
- Bus.instance.fire(PauseVideoEvent());
- setState(() {
- _activePageIndex = index;
- _isMediaInteractionLocked = false;
- });
- },
- itemBuilder: (context, index) {
- final smartMemory = _memories[index];
- final initialMemoryIndex = _initialItemIndexForPage(index);
- return FullScreenMemoryDataUpdater(
- initialIndex: initialMemoryIndex,
- memories: smartMemory.memories,
- child: FullScreenMemory(
- smartMemory.title,
- initialMemoryIndex,
- memoryID: smartMemory.id,
- isActive: index == _activePageIndex,
- onMediaInteractionLockChanged: (isLocked) {
- if (index != _activePageIndex ||
- _isMediaInteractionLocked == isLocked) {
- return;
- }
- setState(() => _isMediaInteractionLocked = isLocked);
- },
- onNextMemory: index < _memories.length - 1
- ? () => pageController.nextPage(
- duration: const Duration(milliseconds: 675),
- curve: Curves.easeOutQuart,
- )
- : null,
- onPreviousMemory: index > 0
- ? () => pageController.previousPage(
- duration: const Duration(milliseconds: 675),
- curve: Curves.easeOutQuart,
- )
- : null,
- ),
- );
- },
- ),
- );
return MemoryMusicSession(
- memoryIDs: _memories.map((memory) => memory.id).toList(),
- child: page,
+ memoryIDs: _pages.map((page) => page.id).toList(),
+ child: ColoredBox(
+ color: backgroundColorDark,
+ child: PageView.builder(
+ controller: _pageController,
+ physics: _isMediaInteractionLocked
+ ? const NeverScrollableScrollPhysics()
+ : const BouncingScrollPhysics(),
+ hitTestBehavior: HitTestBehavior.translucent,
+ itemCount: _pages.length,
+ onPageChanged: (index) {
+ Bus.instance.fire(PauseVideoEvent());
+ setState(() {
+ _activePageIndex = index;
+ _isMediaInteractionLocked = false;
+ });
+ },
+ itemBuilder: (context, index) => _pages[index].widget(
+ onNextMemory: index < _pages.length - 1
+ ? () => _pageController.nextPage(
+ duration: const Duration(milliseconds: 675),
+ curve: Curves.easeOutQuart,
+ )
+ : null,
+ onPreviousMemory: index > 0
+ ? () => _pageController.previousPage(
+ duration: const Duration(milliseconds: 675),
+ curve: Curves.easeOutQuart,
+ )
+ : null,
+ ),
+ ),
+ ),
);
}
-
- int _initialItemIndexForPage(int pageIndex) {
- final memories = _memories[pageIndex].memories;
- return widget.isFromWidgetOrNotifications && pageIndex == _initialPageIndex
- ? widget.inititalFileIndex
- : getNextMemoryIndex(memories);
- }
}
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 4c1f977bd3..b19278c080 100644
--- a/mobile/apps/photos/lib/ui/home/memories/memories_strip.dart
+++ b/mobile/apps/photos/lib/ui/home/memories/memories_strip.dart
@@ -27,13 +27,13 @@ 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";
import "package:photos/services/memory_lane/memory_lane_service.dart";
+import "package:photos/ui/home/memories/all_memories_page.dart";
import "package:photos/ui/home/memories/crafting_memories_card.dart";
import 'package:photos/ui/home/memories/memory_card.dart';
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_v2.dart";
class MemoryCardWrapper {
final String id;
@@ -236,7 +236,38 @@ class _MemoriesStripWidgetState extends State<MemoriesStripWidget> {
final memoryLanePerson = _memoryLanePerson;
final oldestMemoryLaneFile = _oldestMemoryLaneFile;
final newestMemoryLaneFace = _newestMemoryLaneFace;
+ final hasMemoryLane =
+ flagService.internalUser &&
+ MemoryLaneService.instance.isFeatureEnabled &&
+ memoryLane != null &&
+ (memoryLane.isCluster || memoryLanePerson != null) &&
+ oldestMemoryLaneFile != null &&
+ newestMemoryLaneFace != null;
final hasContent = memories.isNotEmpty || memoryLane != null;
+ final cardBuilders = <MemoryCardWrapper Function(VoidCallback onTap)>[
+ if (hasMemoryLane)
+ (onTap) => MemoryCardWrapper(
+ id: "memoryLane_${memoryLane.personId}",
+ widget: () => MemoryLaneCardWidget(
+ id: memoryLane.personId,
+ oldestFile: oldestMemoryLaneFile,
+ face: newestMemoryLaneFace,
+ personName: memoryLanePerson?.data.name ?? "",
+ size: Size(_cardWidth, cardHeight),
+ onTap: onTap,
+ ),
+ ),
+ for (final memory in memories)
+ (onTap) => MemoryCardWrapper(
+ id: memory.id,
+ widget: () => MemoryCardWidget(
+ memory: memory,
+ width: _cardWidth,
+ height: cardHeight,
+ onTap: onTap,
+ ),
+ ),
+ ];
return [
if (_shouldShowCraftingMemories && hasContent)
MemoryCardWrapper(
@@ -254,37 +285,18 @@ class _MemoriesStripWidgetState extends State<MemoriesStripWidget> {
},
),
),
- if (flagService.internalUser &&
- MemoryLaneService.instance.isFeatureEnabled &&
- memoryLane != null &&
- oldestMemoryLaneFile != null &&
- newestMemoryLaneFace != null)
- MemoryCardWrapper(
- id: "memoryLane_${memoryLane.personId}",
- widget: () => MemoryLaneCardWidget(
- id: memoryLane.personId,
- oldestFile: oldestMemoryLaneFile,
- face: newestMemoryLaneFace,
- personName: memoryLanePerson?.data.name ?? "",
- size: Size(_cardWidth, cardHeight),
- onTap: () => openMemoryLanePage(
- context,
- personId: memoryLane.personId,
- person: memoryLanePerson,
- isCluster: memoryLane.isCluster,
- ),
- ),
- ),
- ...memories.indexed.map(
- (entry) => MemoryCardWrapper(
- id: entry.$2.id,
- widget: () => MemoryCardWidget(
- memories: memories,
- width: _cardWidth,
- height: cardHeight,
- index: entry.$1,
- ),
- ),
+ ...cardBuilders.indexed.map(
+ (entry) => entry.$2(() async {
+ await openAllMemoriesPage(
+ context: context,
+ allMemories: memories,
+ memoryLane: hasMemoryLane ? memoryLane : null,
+ memoryLanePerson: hasMemoryLane ? memoryLanePerson : null,
+ initialPageIndex: entry.$1,
+ );
+ if (!mounted) return;
+ setState(() {});
+ }),
),
];
}
diff --git a/mobile/apps/photos/lib/ui/home/memories/memory_card.dart b/mobile/apps/photos/lib/ui/home/memories/memory_card.dart
index 5abb96c140..8039e95f42 100644
--- a/mobile/apps/photos/lib/ui/home/memories/memory_card.dart
+++ b/mobile/apps/photos/lib/ui/home/memories/memory_card.dart
@@ -1,53 +1,28 @@
import "package:ente_components/ente_components.dart";
-import "package:ente_pure_utils/ente_pure_utils.dart";
import "package:flutter/material.dart";
import "package:photos/core/constants.dart";
import "package:photos/models/memories/smart_memory.dart";
import "package:photos/theme/colors.dart";
-import "package:photos/ui/home/memories/all_memories_page.dart";
import "package:photos/ui/home/memories/memory_card_constants.dart";
import "package:photos/ui/home/memories/memory_cover_util.dart";
import "package:photos/ui/viewer/file/thumbnail_widget.dart";
-class MemoryCardWidget extends StatefulWidget {
- final List<SmartMemory> memories;
+class MemoryCardWidget extends StatelessWidget {
+ final SmartMemory memory;
+ final VoidCallback onTap;
final double width;
final double height;
- final int index;
const MemoryCardWidget({
- required this.memories,
+ required this.memory,
required this.width,
required this.height,
- required this.index,
+ required this.onTap,
super.key,
- }) : assert(index >= 0);
-
- @override
- State<MemoryCardWidget> createState() => _MemoryCardWidgetState();
-}
-
-class _MemoryCardWidgetState extends State<MemoryCardWidget> {
- Future<void> _onTap() async {
- await routeToPage(
- context,
- forceCustomPageRoute: true,
- AllMemoriesPage(
- initialPageIndex: widget.index,
- allMemories: widget.memories,
- ),
- );
- if (!mounted) return;
- setState(() {});
- }
+ });
@override
Widget build(BuildContext context) {
- // The list can be empty after deleting every memory and returning here.
- if (widget.index >= widget.memories.length) {
- return const SizedBox.shrink();
- }
- final memory = widget.memories[widget.index];
if (memory.memories.isEmpty) {
return const SizedBox.shrink();
}
@@ -58,12 +33,12 @@ class _MemoryCardWidgetState extends State<MemoryCardWidget> {
horizontal: kMemoryCardStripGap / 2.0,
),
child: GestureDetector(
- onTap: _onTap,
+ onTap: onTap,
child: ClipRRect(
borderRadius: BorderRadius.circular(kMemoryCardBorderRadius),
child: Container(
- height: widget.height,
- width: widget.width,
+ height: height,
+ width: width,
foregroundDecoration: item.isSeen()
? const BoxDecoration(
color: Color(0xFFBFBFBF),
@@ -99,7 +74,7 @@ class _MemoryCardWidgetState extends State<MemoryCardWidget> {
Positioned(
bottom: 0,
child: SizedBox(
- width: widget.width,
+ width: width,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Hero(
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
index 014c4acb7f..ff91df4aec 100644
--- 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
@@ -20,6 +20,7 @@ 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/home/memories/memory_music_session.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";
@@ -55,11 +56,17 @@ class MemoryLanePageV2 extends StatefulWidget {
final String personId;
final bool isCluster;
final PersonEntity? person;
+ final bool isActive;
+ final VoidCallback? onNextMemory;
+ final VoidCallback? onPreviousMemory;
const MemoryLanePageV2({
required this.personId,
required this.isCluster,
required this.person,
+ this.isActive = true,
+ this.onNextMemory,
+ this.onPreviousMemory,
super.key,
});
@@ -90,6 +97,32 @@ class _MemoryLanePageV2State extends State<MemoryLanePageV2> {
_memoryLaneLoaded = _loadMemoryLane();
}
+ @override
+ void didChangeDependencies() {
+ super.didChangeDependencies();
+ final musicController = MemoryMusicScope.maybeOf(context)?.controller;
+ if (widget.isActive) {
+ unawaited(musicController?.setViewerActionPaused(true));
+ }
+ }
+
+ @override
+ void didUpdateWidget(covariant MemoryLanePageV2 oldWidget) {
+ super.didUpdateWidget(oldWidget);
+ if (oldWidget.isActive == widget.isActive) return;
+ if (!widget.isActive) {
+ _pause();
+ return;
+ }
+ unawaited(_play(0));
+ unawaited(
+ MemoryMusicScope.maybeOf(
+ context,
+ listen: false,
+ )?.controller?.setViewerActionPaused(true),
+ );
+ }
+
@override
void dispose() {
_playbackTimer?.cancel();
@@ -126,9 +159,13 @@ class _MemoryLanePageV2State extends State<MemoryLanePageV2> {
previousEntry = entryFuture;
}
}
- if (_entries.isNotEmpty) unawaited(_play(0));
+ unawaited(_play(0));
} catch (error) {
- if (!mounted || ModalRoute.of(context)?.isCurrent != true) return;
+ if (!mounted ||
+ !widget.isActive ||
+ ModalRoute.of(context)?.isCurrent != true) {
+ return;
+ }
final navigator = Navigator.of(context);
navigator.pop();
await showGenericErrorDialog(context: navigator.context, error: error);
@@ -136,17 +173,27 @@ class _MemoryLanePageV2State extends State<MemoryLanePageV2> {
}
Future<void> _play(int index) async {
- if (_entries.isEmpty) return;
+ if (!widget.isActive || _entries.isEmpty) return;
final token = Object();
setState(() {
_playbackTimer?.cancel();
_selectEntry(index);
- _playbackToken = index < _entries.length - 1 ? token : null;
+ _playbackToken =
+ index < _entries.length - 1 || widget.onNextMemory != null
+ ? token
+ : null;
});
if (_playbackToken == null) return;
await _entries[index];
- if (!mounted || _playbackToken != token) return;
- _playbackTimer = Timer(_playbackInterval, () => _play(index + 1));
+ if (!mounted || !widget.isActive || _playbackToken != token) return;
+ _playbackTimer = Timer(_playbackInterval, () {
+ if (index < _entries.length - 1) {
+ unawaited(_play(index + 1));
+ } else {
+ _pause();
+ widget.onNextMemory?.call();
+ }
+ });
}
void _pause() {
@@ -255,6 +302,7 @@ class _MemoryLanePageV2State extends State<MemoryLanePageV2> {
_entries[index].then((bytes) async {
if (bytes == null ||
!mounted ||
+ !widget.isActive ||
_currentEntryKey != entryKey ||
ModalRoute.of(context)?.isCurrent != true ||
localSettings.hasSeenMemoryLane(widget.personId)) {
@@ -475,111 +523,138 @@ class _MemoryLanePageV2State extends State<MemoryLanePageV2> {
body: Column(
children: [
Expanded(
- child: Padding(
- padding: EdgeInsets.symmetric(
- horizontal: screenSize.width * 0.08,
- vertical: screenSize.height * 0.04,
- ),
- child: Align(
- child: AspectRatio(
- aspectRatio: 3 / 4,
- child: ClipRRect(
- borderRadius: BorderRadius.circular(24),
- child: AnimatedSwitcher(
- duration: Duration(
- milliseconds: _isSeeking ? 100 : 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: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTapUp:
+ widget.onNextMemory == null &&
+ widget.onPreviousMemory == null
+ ? null
+ : (details) {
+ if (!widget.isActive || _entries.isEmpty) return;
+ final previous =
+ details.localPosition.dx <
+ screenSize.width / 2;
+ final index = i + (previous ? -1 : 1);
+ if (index < 0 || index >= _entries.length) {
+ final onMemory = previous
+ ? widget.onPreviousMemory
+ : widget.onNextMemory;
+ if (onMemory != null) {
+ _pause();
+ onMemory();
+ }
+ } else if (_playbackToken != null) {
+ unawaited(_play(index));
+ } else {
+ setState(() => _selectEntry(index));
+ }
+ },
+ child: Padding(
+ padding: EdgeInsets.symmetric(
+ horizontal: screenSize.width * 0.08,
+ vertical: screenSize.height * 0.04,
+ ),
+ child: Align(
+ child: AspectRatio(
+ aspectRatio: 3 / 4,
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(24),
+ child: AnimatedSwitcher(
+ duration: Duration(
+ milliseconds: _isSeeking ? 100 : 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,
),
- 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,
+ ),
+ 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 const Center(
- child:
- CircularProgressIndicator(
- color: Colors.white,
- ),
+ return Image.memory(
+ crop.$1,
+ cacheWidth: crop.$2,
+ fit: BoxFit.cover,
+ width: double.infinity,
+ height: double.infinity,
);
- }
- 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,
+ },
+ ),
+ ),
+ 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,
+ _ => const Center(
+ key: ValueKey("memory-lane-loading"),
+ child: CircularProgressIndicator(
+ color: Colors.white,
+ ),
),
- ),
- },
+ },
+ ),
),
),
),