mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Use aspect ratio for banner cards
This commit is contained in:
parent
b6f9aee5d4
commit
933dc4fd5a
3 changed files with 10 additions and 5 deletions
|
|
@ -5,6 +5,7 @@ import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
|
@ -36,22 +37,22 @@ fun BannerCard(
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit,
|
||||||
onLongClick: () -> Unit,
|
onLongClick: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
cardWidth: Dp = 200.dp,
|
cardHeight: Dp = 140.dp,
|
||||||
cardHeight: Dp = cardWidth * 9 / 16,
|
aspectRatio: Float = 16f / 9,
|
||||||
interactionSource: MutableInteractionSource? = null,
|
interactionSource: MutableInteractionSource? = null,
|
||||||
) {
|
) {
|
||||||
Card(
|
Card(
|
||||||
modifier = modifier.size(cardWidth, cardHeight),
|
modifier = modifier.size(cardHeight * aspectRatio, cardHeight),
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
onLongClick = onLongClick,
|
onLongClick = onLongClick,
|
||||||
interactionSource = interactionSource,
|
interactionSource = interactionSource,
|
||||||
) {
|
) {
|
||||||
Box {
|
Box(modifier = Modifier.fillMaxSize()) {
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
model = imageUrl,
|
model = imageUrl,
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
contentScale = ContentScale.Fit,
|
contentScale = ContentScale.Fit,
|
||||||
modifier = Modifier,
|
modifier = Modifier.fillMaxSize(),
|
||||||
)
|
)
|
||||||
if (played || cornerText.isNotNullOrBlank()) {
|
if (played || cornerText.isNotNullOrBlank()) {
|
||||||
Row(
|
Row(
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@ class SeriesViewModel
|
||||||
ItemFields.OVERVIEW,
|
ItemFields.OVERVIEW,
|
||||||
ItemFields.CUSTOM_RATING,
|
ItemFields.CUSTOM_RATING,
|
||||||
ItemFields.TRICKPLAY,
|
ItemFields.TRICKPLAY,
|
||||||
|
ItemFields.PRIMARY_IMAGE_ASPECT_RATIO,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
val pager = ApiRequestPager(api, request, GetEpisodesRequestHandler, viewModelScope)
|
val pager = ApiRequestPager(api, request, GetEpisodesRequestHandler, viewModelScope)
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,9 @@ fun SeriesOverviewContent(
|
||||||
}
|
}
|
||||||
BannerCard(
|
BannerCard(
|
||||||
imageUrl = episode?.imageUrl,
|
imageUrl = episode?.imageUrl,
|
||||||
|
aspectRatio =
|
||||||
|
episode?.data?.primaryImageAspectRatio?.toFloat()
|
||||||
|
?: (16f / 9),
|
||||||
cornerText = "E${episode?.data?.indexNumber}",
|
cornerText = "E${episode?.data?.indexNumber}",
|
||||||
played = episode?.data?.userData?.played ?: false,
|
played = episode?.data?.userData?.played ?: false,
|
||||||
playPercent = episode?.data?.userData?.playedPercentage ?: 0.0,
|
playPercent = episode?.data?.userData?.playedPercentage ?: 0.0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue