From 0a260a47c69cc2b3419ad21fd190226485896d94 Mon Sep 17 00:00:00 2001
From: beyond
Date: Sat, 5 Sep 2026 21:30:08 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A6=96=E9=A1=B5=E5=92=8C?=
=?UTF-8?q?=E5=BA=95=E9=83=A8=E5=AF=BC=E8=88=AA=E6=A0=8F=E6=80=A7=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../navigation/NavigationTransitions.kt | 6 +
.../myapplication/screens/HomeScreen.kt | 128 +++++++++++-------
.../myapplication/ui/ImmersiveBackground.kt | 27 +++-
.../screens/HomeScreenDataTest.kt | 32 +++++
4 files changed, 140 insertions(+), 53 deletions(-)
diff --git a/app/src/main/kotlin/com/example/myapplication/navigation/NavigationTransitions.kt b/app/src/main/kotlin/com/example/myapplication/navigation/NavigationTransitions.kt
index 41f5fa9..3baff7c 100644
--- a/app/src/main/kotlin/com/example/myapplication/navigation/NavigationTransitions.kt
+++ b/app/src/main/kotlin/com/example/myapplication/navigation/NavigationTransitions.kt
@@ -63,6 +63,9 @@ fun AnimatedContentTransitionScope.appExitTransition(): ExitT
}
fun AnimatedContentTransitionScope.appPopEnterTransition(): EnterTransition {
+ if (isRootRoute(initialState.destination.route) && isRootRoute(targetState.destination.route)) {
+ return appEnterTransition()
+ }
if (isReturningFromSettingsChild()) return EnterTransition.None
return slideInHorizontally(
animationSpec = tween(NavigationMotionTokens.detailPopDuration, easing = NavigationMotionTokens.popEasing),
@@ -71,6 +74,9 @@ fun AnimatedContentTransitionScope.appPopEnterTransition(): E
}
fun AnimatedContentTransitionScope.appPopExitTransition(): ExitTransition {
+ if (isRootRoute(initialState.destination.route) && isRootRoute(targetState.destination.route)) {
+ return appExitTransition()
+ }
if (isReturningFromSettingsChild()) return ExitTransition.None
return slideOutHorizontally(
animationSpec = tween(NavigationMotionTokens.detailPopDuration, easing = NavigationMotionTokens.popEasing),
diff --git a/app/src/main/kotlin/com/example/myapplication/screens/HomeScreen.kt b/app/src/main/kotlin/com/example/myapplication/screens/HomeScreen.kt
index 5ad02cb..89dbdeb 100644
--- a/app/src/main/kotlin/com/example/myapplication/screens/HomeScreen.kt
+++ b/app/src/main/kotlin/com/example/myapplication/screens/HomeScreen.kt
@@ -99,6 +99,10 @@ import com.example.myapplication.ui.design.rememberLumaLayerBackdrop
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.PagerState
import androidx.compose.foundation.pager.rememberPagerState
+import androidx.lifecycle.Lifecycle
+import androidx.lifecycle.compose.LocalLifecycleOwner
+import androidx.lifecycle.repeatOnLifecycle
+import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.async
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.delay
@@ -113,14 +117,14 @@ val LocalHomeContentColor = staticCompositionLocalOf { Color.Unspecified }
val LocalHomeSecondaryColor = staticCompositionLocalOf { Color.Unspecified }
val LocalHomeAccentColor = staticCompositionLocalOf { Color.Unspecified }
-private data class HomeSnapshot(
+internal data class HomeSnapshot(
val libraries: List,
val resumeItems: List,
val latestItems: List,
val resourceStats: EmbyResourceStats,
)
-private object HomeContentCache {
+internal object HomeContentCache {
private val snapshots = mutableMapOf()
private val libraryPages = mutableMapOf()
private val episodeCounts = mutableMapOf() // cacheKey + seriesId → total episode count
@@ -202,12 +206,17 @@ private fun HeroCarousel(
onItemClick: (EmbyItem) -> Unit = {},
) {
val context = LocalContext.current
- LaunchedEffect(pagerState, items.size) {
- while (true) {
- delay(5000)
- if (items.isEmpty()) break
- val next = (pagerState.currentPage + 1) % items.size
- pagerState.animateScrollToPage(next)
+ val lifecycleOwner = LocalLifecycleOwner.current
+ LaunchedEffect(pagerState, items.size, lifecycleOwner) {
+ lifecycleOwner.lifecycle.repeatOnLifecycle(Lifecycle.State.RESUMED) {
+ if (items.size < 2) return@repeatOnLifecycle
+ while (true) {
+ delay(5000)
+ if (!pagerState.isScrollInProgress) {
+ val next = (pagerState.currentPage + 1) % items.size
+ pagerState.animateScrollToPage(next)
+ }
+ }
}
}
@@ -519,13 +528,19 @@ private fun LazyLibrarySection(
mutableStateOf(HomeContentCache.libraryPage(cacheKey, folder.id))
}
var episodeCounts by remember(cacheKey, folder.id, refreshToken) {
- mutableStateOf