mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-07-27 06:52:18 +00:00
feat: enhance DetailMetaInfo component with improved metadata display and add DetailHeroMetaBadge for age rating representation
This commit is contained in:
parent
56ccb557ad
commit
515f3de17f
2 changed files with 54 additions and 15 deletions
|
|
@ -1,7 +1,10 @@
|
|||
package com.nuvio.app.features.details.components
|
||||
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
|
|
@ -37,24 +40,37 @@ fun DetailMetaInfo(
|
|||
modifier = modifier.fillMaxWidth(),
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
val infoParts = buildList {
|
||||
formatMetaReleaseLineForDetails(meta)?.let { add(it) }
|
||||
meta.ageRating?.let { add(it) }
|
||||
meta.runtime?.let { add(it.uppercase()) }
|
||||
}
|
||||
if (infoParts.isNotEmpty() || meta.imdbRating != null) {
|
||||
val releaseLine = formatMetaReleaseLineForDetails(meta)
|
||||
val runtimeText = meta.runtime?.trim()?.takeIf { it.isNotBlank() }?.uppercase()
|
||||
val ageBadge = meta.ageRating?.trim()?.takeIf { it.isNotBlank() }
|
||||
val hasMetaRow = releaseLine != null ||
|
||||
runtimeText != null ||
|
||||
ageBadge != null ||
|
||||
meta.imdbRating != null
|
||||
if (hasMetaRow) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(14.dp),
|
||||
) {
|
||||
infoParts.forEach { part ->
|
||||
releaseLine?.let { line ->
|
||||
Text(
|
||||
text = part,
|
||||
text = line,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
}
|
||||
runtimeText?.let { rt ->
|
||||
Text(
|
||||
text = rt,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
}
|
||||
ageBadge?.let { badge ->
|
||||
DetailHeroMetaBadge(text = badge)
|
||||
}
|
||||
if (meta.imdbRating != null) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
|
|
@ -143,5 +159,29 @@ private fun MetaLabelValueRow(
|
|||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun DetailHeroMetaBadge(
|
||||
text: String,
|
||||
contentColor: Color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.border(
|
||||
border = BorderStroke(1.dp, contentColor.copy(alpha = 0.55f)),
|
||||
shape = RoundedCornerShape(6.dp),
|
||||
)
|
||||
.padding(horizontal = 8.dp, vertical = 4.dp),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Text(
|
||||
text = text,
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = contentColor,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private val ImdbYellow = Color(0xFFF5C518)
|
||||
private val ImdbBlack = Color(0xFF000000)
|
||||
|
|
|
|||
|
|
@ -140,7 +140,8 @@ object TmdbSettingsRepository {
|
|||
private fun loadFromDisk() {
|
||||
hasLoaded = true
|
||||
enabled = TmdbSettingsStorage.loadEnabled() ?: false
|
||||
language = normalizeLanguage(TmdbSettingsStorage.loadLanguage())
|
||||
val storedLanguage = TmdbSettingsStorage.loadLanguage()
|
||||
language = if (storedLanguage == null) "en" else normalizeLanguage(storedLanguage)
|
||||
useArtwork = TmdbSettingsStorage.loadUseArtwork() ?: true
|
||||
useBasicInfo = TmdbSettingsStorage.loadUseBasicInfo() ?: true
|
||||
useDetails = TmdbSettingsStorage.loadUseDetails() ?: true
|
||||
|
|
@ -172,9 +173,7 @@ object TmdbSettingsRepository {
|
|||
}
|
||||
}
|
||||
|
||||
internal fun normalizeLanguage(value: String?): String =
|
||||
value
|
||||
?.trim()
|
||||
?.replace('_', '-')
|
||||
?.takeIf { it.isNotBlank() }
|
||||
?: "en"
|
||||
internal fun normalizeLanguage(value: String?): String {
|
||||
val trimmed = value?.trim()?.replace('_', '-') ?: return ""
|
||||
return trimmed.takeIf { it.isNotBlank() } ?: ""
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue