mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-17 15:32:01 +00:00
ref: adjust tablet hero height calculation
This commit is contained in:
parent
21793b8ac7
commit
4609398b59
3 changed files with 43 additions and 11 deletions
|
|
@ -580,6 +580,7 @@ fun MetaDetailsScreen(
|
||||||
|
|
||||||
BoxWithConstraints(modifier = Modifier.fillMaxSize()) {
|
BoxWithConstraints(modifier = Modifier.fillMaxSize()) {
|
||||||
val isTablet = maxWidth >= 720.dp
|
val isTablet = maxWidth >= 720.dp
|
||||||
|
val viewportHeight = maxHeight
|
||||||
val contentHorizontalPadding = if (isTablet) 32.dp else 18.dp
|
val contentHorizontalPadding = if (isTablet) 32.dp else 18.dp
|
||||||
val contentMaxWidth = detailTabletContentMaxWidth(maxWidth, isTablet)
|
val contentMaxWidth = detailTabletContentMaxWidth(maxWidth, isTablet)
|
||||||
val cinematicEnabled = metaScreenSettingsUiState.cinematicBackground
|
val cinematicEnabled = metaScreenSettingsUiState.cinematicBackground
|
||||||
|
|
@ -612,6 +613,7 @@ fun MetaDetailsScreen(
|
||||||
DetailHero(
|
DetailHero(
|
||||||
meta = meta,
|
meta = meta,
|
||||||
isTablet = isTablet,
|
isTablet = isTablet,
|
||||||
|
viewportHeight = viewportHeight,
|
||||||
contentMaxWidth = contentMaxWidth,
|
contentMaxWidth = contentMaxWidth,
|
||||||
scrollOffset = scrollState.value,
|
scrollOffset = scrollState.value,
|
||||||
onHeightChanged = { heroHeightPx = it },
|
onHeightChanged = { heroHeightPx = it },
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,14 @@ import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.graphics.graphicsLayer
|
import androidx.compose.ui.graphics.graphicsLayer
|
||||||
import coil3.compose.AsyncImage
|
import coil3.compose.AsyncImage
|
||||||
import com.nuvio.app.features.details.MetaDetails
|
import com.nuvio.app.features.details.MetaDetails
|
||||||
|
import com.nuvio.app.features.home.components.homeHeroLayout
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DetailHero(
|
fun DetailHero(
|
||||||
meta: MetaDetails,
|
meta: MetaDetails,
|
||||||
isTablet: Boolean = false,
|
isTablet: Boolean = false,
|
||||||
scrollOffset: Int = 0,
|
scrollOffset: Int = 0,
|
||||||
|
viewportHeight: Dp? = null,
|
||||||
contentMaxWidth: Dp = 560.dp,
|
contentMaxWidth: Dp = 560.dp,
|
||||||
onHeightChanged: (Int) -> Unit = {},
|
onHeightChanged: (Int) -> Unit = {},
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
|
@ -38,7 +40,10 @@ fun DetailHero(
|
||||||
BoxWithConstraints(
|
BoxWithConstraints(
|
||||||
modifier = modifier.fillMaxWidth(),
|
modifier = modifier.fillMaxWidth(),
|
||||||
) {
|
) {
|
||||||
val heroHeight = detailHeroHeight(maxWidth, isTablet)
|
val heroHeight = homeHeroLayout(
|
||||||
|
maxWidthDp = maxWidth.value,
|
||||||
|
viewportHeightDp = viewportHeight?.value,
|
||||||
|
).heroHeight
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|
@ -134,10 +139,3 @@ fun DetailHero(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun detailHeroHeight(maxWidth: Dp, isTablet: Boolean): Dp =
|
|
||||||
if (!isTablet) {
|
|
||||||
(maxWidth * 1.33f).coerceIn(420.dp, 760.dp)
|
|
||||||
} else {
|
|
||||||
(maxWidth * 0.42f).coerceIn(300.dp, 420.dp)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ private const val HERO_SWIPE_VELOCITY_THRESHOLD = 300f
|
||||||
private const val MOBILE_HERO_VIEWPORT_RATIO = 0.78f
|
private const val MOBILE_HERO_VIEWPORT_RATIO = 0.78f
|
||||||
private const val MOBILE_HERO_MIN_HEIGHT_DP = 360f
|
private const val MOBILE_HERO_MIN_HEIGHT_DP = 360f
|
||||||
private const val MOBILE_HERO_MAX_HEIGHT_DP = 760f
|
private const val MOBILE_HERO_MAX_HEIGHT_DP = 760f
|
||||||
|
private const val TABLET_HERO_VIEWPORT_RATIO = 0.62f
|
||||||
|
|
||||||
internal data class HomeHeroLayout(
|
internal data class HomeHeroLayout(
|
||||||
val isTablet: Boolean,
|
val isTablet: Boolean,
|
||||||
|
|
@ -426,7 +427,13 @@ internal fun homeHeroLayout(
|
||||||
when {
|
when {
|
||||||
maxWidthDp >= 1200f -> HomeHeroLayout(
|
maxWidthDp >= 1200f -> HomeHeroLayout(
|
||||||
isTablet = true,
|
isTablet = true,
|
||||||
heroHeight = (maxWidthDp * 0.42f).dp.coerceIn(360.dp, 440.dp),
|
heroHeight = tabletHeroHeight(
|
||||||
|
maxWidthDp = maxWidthDp,
|
||||||
|
viewportHeightDp = viewportHeightDp,
|
||||||
|
widthRatio = 0.42f,
|
||||||
|
minHeight = 500.dp,
|
||||||
|
maxHeight = 640.dp,
|
||||||
|
),
|
||||||
contentMaxWidth = 640.dp,
|
contentMaxWidth = 640.dp,
|
||||||
contentWidthFraction = 0.56f,
|
contentWidthFraction = 0.56f,
|
||||||
contentHorizontalPadding = 56.dp,
|
contentHorizontalPadding = 56.dp,
|
||||||
|
|
@ -436,7 +443,13 @@ internal fun homeHeroLayout(
|
||||||
)
|
)
|
||||||
maxWidthDp >= 840f -> HomeHeroLayout(
|
maxWidthDp >= 840f -> HomeHeroLayout(
|
||||||
isTablet = true,
|
isTablet = true,
|
||||||
heroHeight = (maxWidthDp * 0.46f).dp.coerceIn(340.dp, 420.dp),
|
heroHeight = tabletHeroHeight(
|
||||||
|
maxWidthDp = maxWidthDp,
|
||||||
|
viewportHeightDp = viewportHeightDp,
|
||||||
|
widthRatio = 0.46f,
|
||||||
|
minHeight = 460.dp,
|
||||||
|
maxHeight = 580.dp,
|
||||||
|
),
|
||||||
contentMaxWidth = 560.dp,
|
contentMaxWidth = 560.dp,
|
||||||
contentWidthFraction = 0.62f,
|
contentWidthFraction = 0.62f,
|
||||||
contentHorizontalPadding = 40.dp,
|
contentHorizontalPadding = 40.dp,
|
||||||
|
|
@ -446,7 +459,13 @@ internal fun homeHeroLayout(
|
||||||
)
|
)
|
||||||
maxWidthDp >= 600f -> HomeHeroLayout(
|
maxWidthDp >= 600f -> HomeHeroLayout(
|
||||||
isTablet = true,
|
isTablet = true,
|
||||||
heroHeight = (maxWidthDp * 0.58f).dp.coerceIn(320.dp, 380.dp),
|
heroHeight = tabletHeroHeight(
|
||||||
|
maxWidthDp = maxWidthDp,
|
||||||
|
viewportHeightDp = viewportHeightDp,
|
||||||
|
widthRatio = 0.58f,
|
||||||
|
minHeight = 420.dp,
|
||||||
|
maxHeight = 520.dp,
|
||||||
|
),
|
||||||
contentMaxWidth = 520.dp,
|
contentMaxWidth = 520.dp,
|
||||||
contentWidthFraction = 0.72f,
|
contentWidthFraction = 0.72f,
|
||||||
contentHorizontalPadding = 32.dp,
|
contentHorizontalPadding = 32.dp,
|
||||||
|
|
@ -489,6 +508,19 @@ private fun mobileHeroHeight(
|
||||||
return cappedHeight.coerceIn(MOBILE_HERO_MIN_HEIGHT_DP.dp, MOBILE_HERO_MAX_HEIGHT_DP.dp)
|
return cappedHeight.coerceIn(MOBILE_HERO_MIN_HEIGHT_DP.dp, MOBILE_HERO_MAX_HEIGHT_DP.dp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun tabletHeroHeight(
|
||||||
|
maxWidthDp: Float,
|
||||||
|
viewportHeightDp: Float?,
|
||||||
|
widthRatio: Float,
|
||||||
|
minHeight: Dp,
|
||||||
|
maxHeight: Dp,
|
||||||
|
): Dp {
|
||||||
|
val widthDrivenHeight = (maxWidthDp * widthRatio).dp
|
||||||
|
val viewportDrivenHeight = viewportHeightDp?.let { (it * TABLET_HERO_VIEWPORT_RATIO).dp }
|
||||||
|
val baseHeight = maxOf(widthDrivenHeight, viewportDrivenHeight ?: widthDrivenHeight)
|
||||||
|
return baseHeight.coerceIn(minHeight, maxHeight)
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun HeroMetaDot() {
|
private fun HeroMetaDot() {
|
||||||
Box(
|
Box(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue