收敛降级玻璃与页面状态恢复
This commit is contained in:
1 parent
e76637c562
commit
485538f296
8 files changed
+56
-20
No files matched your search
@@ -77,7 +77,9 @@ fun AppNavHost(
|
||||
if (currentEntry?.destination?.route == AppRoute.MediaDetail.pattern &&
|
||||
currentEntry.arguments?.getString("itemId") == itemId
|
||||
) return@let
|
||||
navController.navigate(AppRoute.MediaDetail.create(serverId, itemId))
|
||||
navController.navigate(AppRoute.MediaDetail.create(serverId, itemId)) {
|
||||
launchSingleTop = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +182,9 @@ fun AppNavHost(
|
||||
val alreadyPlaying = currentEntry?.destination?.route == AppRoute.VideoPlayer.pattern &&
|
||||
currentEntry.arguments?.getString("itemId") == itemId
|
||||
if (!alreadyPlaying) {
|
||||
navController.navigate(AppRoute.VideoPlayer.create(serverId, itemId, seriesId, seasonId))
|
||||
navController.navigate(AppRoute.VideoPlayer.create(serverId, itemId, seriesId, seasonId)) {
|
||||
launchSingleTop = true
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
@@ -29,6 +29,7 @@ import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyRow
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
@@ -584,6 +585,7 @@ fun HomeScreen(
|
||||
|
||||
val heroItems = remember(latestItems) { latestItems.take(8) }
|
||||
val heroPagerState = rememberPagerState(pageCount = { heroItems.size })
|
||||
val homeListState = rememberLazyListState()
|
||||
val activeHeroItem = heroItems.getOrNull(heroPagerState.currentPage)
|
||||
val immersiveBackground = rememberPosterImmersiveBackground(heroImageUrl(activeHeroItem, activeServer?.fullUrl.orEmpty()))
|
||||
|
||||
@@ -690,7 +692,8 @@ fun HomeScreen(
|
||||
} else {
|
||||
val server = activeServer
|
||||
LazyColumn(
|
||||
Modifier.fillMaxSize(),
|
||||
state = homeListState,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentPadding = PaddingValues(bottom = bottomBarContentPadding(90.dp).calculateBottomPadding())
|
||||
) {
|
||||
if (heroItems.isNotEmpty()) {
|
||||
|
||||
@@ -80,6 +80,7 @@ import com.example.myapplication.data.EmbyServer
|
||||
import com.example.myapplication.R as Res
|
||||
import com.kyant.backdrop.Backdrop
|
||||
import top.yukonga.miuix.kmp.basic.Text
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import java.util.Locale
|
||||
|
||||
private val LocalDetailText = staticCompositionLocalOf { Color.White }
|
||||
@@ -117,22 +118,32 @@ fun MediaDetailScreen(
|
||||
LaunchedEffect(item.id, server?.id, server?.apiKey) {
|
||||
if (server == null || server.apiKey.isBlank()) return@LaunchedEffect
|
||||
refreshing = true
|
||||
val fullItem = EmbyRepository.getItem(server, item.id)
|
||||
if (fullItem == null) {
|
||||
loadError = detailLoadFailed
|
||||
} else {
|
||||
detail = fullItem
|
||||
loadError = null
|
||||
}
|
||||
refreshing = false
|
||||
try {
|
||||
val fullItem = EmbyRepository.getItem(server, item.id)
|
||||
if (fullItem == null) {
|
||||
loadError = detailLoadFailed
|
||||
} else {
|
||||
detail = fullItem
|
||||
loadError = null
|
||||
}
|
||||
|
||||
if (detail.type == "Series") {
|
||||
val loadedSeasons = EmbyRepository.getSeasons(server, item.id)
|
||||
seasons = loadedSeasons
|
||||
selectedSeasonId = loadedSeasons.firstOrNull()?.id
|
||||
} else {
|
||||
seasons = emptyList()
|
||||
selectedSeasonId = null
|
||||
if (detail.type == "Series") {
|
||||
val loadedSeasons = EmbyRepository.getSeasons(server, item.id)
|
||||
seasons = loadedSeasons
|
||||
selectedSeasonId = loadedSeasons
|
||||
.firstOrNull { it.id == selectedSeasonId }
|
||||
?.id
|
||||
?: loadedSeasons.firstOrNull()?.id
|
||||
} else {
|
||||
seasons = emptyList()
|
||||
selectedSeasonId = null
|
||||
}
|
||||
} catch (error: CancellationException) {
|
||||
throw error
|
||||
} catch (_: Exception) {
|
||||
loadError = detailLoadFailed
|
||||
} finally {
|
||||
refreshing = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +152,13 @@ fun MediaDetailScreen(
|
||||
val seriesId = item.id
|
||||
val seasonId = selectedSeasonId ?: return@LaunchedEffect
|
||||
if (detail.type != "Series" || seasonId.isBlank()) return@LaunchedEffect
|
||||
episodes = EmbyRepository.getEpisodes(currentServer, seriesId, seasonId)
|
||||
episodes = try {
|
||||
EmbyRepository.getEpisodes(currentServer, seriesId, seasonId)
|
||||
} catch (error: CancellationException) {
|
||||
throw error
|
||||
} catch (_: Exception) {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
val seriesFallbackImageUrl = EmbyRepository.buildImageUrl(server?.fullUrl.orEmpty(), detail, maxWidth = 640)
|
||||
|
||||
@@ -224,8 +224,11 @@ fun Modifier.lumaFallbackGlass(
|
||||
endY = size.height * 0.72f,
|
||||
)
|
||||
onDrawWithContent {
|
||||
drawContent()
|
||||
// The fallback surface is a material layer. Its highlight must
|
||||
// sit behind the content; drawing it after drawContent makes
|
||||
// labels and icons look washed out on devices without Backdrop.
|
||||
drawRect(highlight)
|
||||
drawContent()
|
||||
}
|
||||
}
|
||||
.then(if (border) Modifier.border(0.6.dp, edge, shape) else Modifier)
|
||||
|
||||
Reference in new issue
Block a user