Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] place memory lane card at end if seen in memories strip

Priyanshu Dangare9ed056f935bd
diff --git a/.gitignore b/.gitignore
index 7c850ab2f9..8f61d7541e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,6 @@
CLAUDE.local.md
node_modules/
+
+# FVM Version Cache
+.fvm/
\ No newline at end of file
diff --git a/mobile/apps/photos/android/gradle.properties b/mobile/apps/photos/android/gradle.properties
index 0b6d9d29bc..e0c548e6ac 100644
--- a/mobile/apps/photos/android/gradle.properties
+++ b/mobile/apps/photos/android/gradle.properties
@@ -4,4 +4,8 @@ org.gradle.caching=true
org.gradle.daemon=true
android.useAndroidX=true
android.enableJetifier=true
-android.bundle.enableUncompressedNativeLibs=true
\ No newline at end of file
+android.bundle.enableUncompressedNativeLibs=true
+# This builtInKotlin flag was added automatically by Flutter migrator
+android.builtInKotlin=false
+# This newDsl flag was added automatically by Flutter migrator
+android.newDsl=false
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 1515de3045..e8690c6fcc 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
@@ -5,6 +5,7 @@ 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/service_locator.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";
@@ -87,32 +88,26 @@ class _AllMemoriesPageState extends State<AllMemoriesPage> {
? null
: widget.allMemories[initialMemoryIndex];
_pages = _buildPages();
- _activePageIndex = initialMemory == null
- ? 0
- : _pages.indexWhere((page) => page.id == initialMemory.id);
+ _activePageIndex = _pages.indexWhere(
+ (page) =>
+ page.id ==
+ (initialMemory == null
+ ? "memoryLane_${widget.memoryLane!.personId}"
+ : 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,
- ),
- ),
- ];
+ final hasSeenMemoryLane =
+ memoryLane != null &&
+ localSettings.hasSeenMemoryLane(memoryLane.personId);
+ final pages = <MemoryPageWrapper>[];
for (final smartMemory in widget.allMemories) {
if (smartMemory.memories.isEmpty) continue;
- final index = pages.length;
+ final index =
+ pages.length + (memoryLane != null && !hasSeenMemoryLane ? 1 : 0);
pages.add(
MemoryPageWrapper(
id: smartMemory.id,
@@ -146,6 +141,25 @@ class _AllMemoriesPageState extends State<AllMemoriesPage> {
),
);
}
+ if (memoryLane != null) {
+ pages.insert(
+ hasSeenMemoryLane ? pages.length : 0,
+ MemoryPageWrapper(
+ id: "memoryLane_${memoryLane.personId}",
+ widget: ({onNextMemory, onPreviousMemory}) => MemoryLanePageV2(
+ key: ValueKey("memoryLane_${memoryLane.personId}"),
+ personId: memoryLane.personId,
+ isCluster: memoryLane.isCluster,
+ person: widget.memoryLanePerson,
+ isActive:
+ _pages[_activePageIndex].id ==
+ "memoryLane_${memoryLane.personId}",
+ onNextMemory: onNextMemory,
+ onPreviousMemory: onPreviousMemory,
+ ),
+ ),
+ );
+ }
return pages;
}
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 f8aa1c5caa..c6e75aa773 100644
--- a/mobile/apps/photos/lib/ui/home/memories/memories_strip.dart
+++ b/mobile/apps/photos/lib/ui/home/memories/memories_strip.dart
@@ -247,6 +247,24 @@ class _MemoriesStripWidgetState extends State<MemoriesStripWidget> {
),
),
];
+ final cards = 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(() {});
+ }),
+ )
+ .toList();
+ final memoryLaneCard = hasMemoryLane ? cards.first : null;
+ final hasSeenMemoryLane =
+ hasMemoryLane && localSettings.hasSeenMemoryLane(memoryLane.personId);
return [
if (_shouldShowCraftingMemories && hasContent)
MemoryCardWrapper(
@@ -264,19 +282,9 @@ class _MemoriesStripWidgetState extends State<MemoriesStripWidget> {
},
),
),
- ...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(() {});
- }),
- ),
+ if (memoryLaneCard != null && !hasSeenMemoryLane) memoryLaneCard,
+ ...cards.skip(hasMemoryLane ? 1 : 0),
+ if (memoryLaneCard != null && hasSeenMemoryLane) memoryLaneCard,
];
}