mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-22 09:42:06 +00:00
feat: state managing for cw cards
This commit is contained in:
parent
cff9512d47
commit
8464f4db48
1 changed files with 51 additions and 27 deletions
|
|
@ -26,6 +26,7 @@ import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.contentColorFor
|
import androidx.compose.material3.contentColorFor
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.key
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
|
@ -159,37 +160,60 @@ private fun HomeContinueWatchingSectionContent(
|
||||||
HomeCatalogSettingsRepository.uiState
|
HomeCatalogSettingsRepository.uiState
|
||||||
}.collectAsStateWithLifecycle()
|
}.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
NuvioShelfSection(
|
val itemOrderKey = remember(items) {
|
||||||
title = stringResource(Res.string.compose_settings_page_continue_watching),
|
items.joinToString(separator = "|") { item -> item.continueWatchingRowOrderKey() }
|
||||||
entries = items,
|
}
|
||||||
modifier = modifier,
|
|
||||||
headerHorizontalPadding = sectionPadding,
|
key(itemOrderKey) {
|
||||||
rowContentPadding = PaddingValues(horizontal = sectionPadding),
|
NuvioShelfSection(
|
||||||
itemSpacing = layout.itemGap,
|
title = stringResource(Res.string.compose_settings_page_continue_watching),
|
||||||
showHeaderAccent = !homeCatalogSettings.hideCatalogUnderline,
|
entries = items,
|
||||||
key = { item -> item.videoId },
|
modifier = modifier,
|
||||||
) { item ->
|
headerHorizontalPadding = sectionPadding,
|
||||||
when (style) {
|
rowContentPadding = PaddingValues(horizontal = sectionPadding),
|
||||||
ContinueWatchingSectionStyle.Wide -> ContinueWatchingWideCard(
|
itemSpacing = layout.itemGap,
|
||||||
item = item,
|
showHeaderAccent = !homeCatalogSettings.hideCatalogUnderline,
|
||||||
layout = layout,
|
key = { item -> item.videoId },
|
||||||
useEpisodeThumbnails = useEpisodeThumbnails,
|
) { item ->
|
||||||
blurNextUp = blurNextUp,
|
when (style) {
|
||||||
onClick = onItemClick?.let { { it(item) } },
|
ContinueWatchingSectionStyle.Wide -> ContinueWatchingWideCard(
|
||||||
onLongClick = onItemLongPress?.let { { it(item) } },
|
item = item,
|
||||||
)
|
layout = layout,
|
||||||
ContinueWatchingSectionStyle.Poster -> ContinueWatchingPosterCard(
|
useEpisodeThumbnails = useEpisodeThumbnails,
|
||||||
item = item,
|
blurNextUp = blurNextUp,
|
||||||
layout = layout,
|
onClick = onItemClick?.let { { it(item) } },
|
||||||
useEpisodeThumbnails = useEpisodeThumbnails,
|
onLongClick = onItemLongPress?.let { { it(item) } },
|
||||||
blurNextUp = blurNextUp,
|
)
|
||||||
onClick = onItemClick?.let { { it(item) } },
|
ContinueWatchingSectionStyle.Poster -> ContinueWatchingPosterCard(
|
||||||
onLongClick = onItemLongPress?.let { { it(item) } },
|
item = item,
|
||||||
)
|
layout = layout,
|
||||||
|
useEpisodeThumbnails = useEpisodeThumbnails,
|
||||||
|
blurNextUp = blurNextUp,
|
||||||
|
onClick = onItemClick?.let { { it(item) } },
|
||||||
|
onLongClick = onItemLongPress?.let { { it(item) } },
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun ContinueWatchingItem.continueWatchingRowOrderKey(): String =
|
||||||
|
buildString {
|
||||||
|
append(if (isNextUp) "next" else "progress")
|
||||||
|
append(':')
|
||||||
|
append(parentMetaId)
|
||||||
|
append(':')
|
||||||
|
append(videoId)
|
||||||
|
append(':')
|
||||||
|
append(seasonNumber)
|
||||||
|
append('x')
|
||||||
|
append(episodeNumber)
|
||||||
|
append(":seed=")
|
||||||
|
append(nextUpSeedSeasonNumber)
|
||||||
|
append('x')
|
||||||
|
append(nextUpSeedEpisodeNumber)
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ContinueWatchingStylePreview(
|
fun ContinueWatchingStylePreview(
|
||||||
style: ContinueWatchingSectionStyle,
|
style: ContinueWatchingSectionStyle,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue