feat: Refactor poster card click handling to use posterCardClickable modifier for consistency

This commit is contained in:
tapframe 2026-03-28 21:01:54 +05:30
parent 44785331bb
commit 36552b4237
4 changed files with 23 additions and 37 deletions

View file

@ -99,15 +99,7 @@ fun NuvioPosterCard(
onLongClick: (() -> Unit)? = null,
) {
Column(
modifier = modifier
.width(110.dp)
.then(
if (onClick != null || onLongClick != null) {
Modifier.posterCardClickable(onClick = onClick, onLongClick = onLongClick)
} else {
Modifier
}
),
modifier = modifier.width(110.dp),
verticalArrangement = Arrangement.spacedBy(6.dp),
) {
Box(
@ -115,7 +107,8 @@ fun NuvioPosterCard(
.fillMaxWidth()
.aspectRatio(shape.aspectRatio)
.clip(RoundedCornerShape(16.dp))
.background(MaterialTheme.colorScheme.surface),
.background(MaterialTheme.colorScheme.surface)
.posterCardClickable(onClick = onClick, onLongClick = onLongClick),
contentAlignment = Alignment.Center,
) {
if (imageUrl != null) {
@ -253,11 +246,15 @@ private val NuvioPosterShape.aspectRatio: Float
}
@OptIn(ExperimentalFoundationApi::class)
private fun Modifier.posterCardClickable(
internal fun Modifier.posterCardClickable(
onClick: (() -> Unit)?,
onLongClick: (() -> Unit)?,
): Modifier =
combinedClickable(
onClick = { onClick?.invoke() },
onLongClick = onLongClick,
)
if (onClick != null || onLongClick != null) {
combinedClickable(
onClick = { onClick?.invoke() },
onLongClick = onLongClick,
)
} else {
this
}

View file

@ -44,6 +44,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import coil3.compose.AsyncImage
import com.nuvio.app.core.ui.posterCardClickable
import com.nuvio.app.core.ui.nuvioPlatformExtraBottomPadding
import com.nuvio.app.features.home.MetaPreview
import com.nuvio.app.features.home.PosterShape
@ -199,7 +200,6 @@ private fun CatalogPosterTile(
onClick: (() -> Unit)? = null,
) {
Column(
modifier = if (onClick != null) Modifier.clickable(onClick = onClick) else Modifier,
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
Box(
@ -207,7 +207,8 @@ private fun CatalogPosterTile(
.fillMaxWidth()
.aspectRatio(item.posterShape.catalogAspectRatio())
.clip(RoundedCornerShape(22.dp))
.background(MaterialTheme.colorScheme.surface),
.background(MaterialTheme.colorScheme.surface)
.posterCardClickable(onClick = onClick, onLongClick = null),
) {
if (item.poster != null) {
AsyncImage(

View file

@ -38,6 +38,7 @@ import androidx.compose.ui.unit.sp
import coil3.compose.AsyncImage
import com.nuvio.app.core.ui.NuvioProgressBar
import com.nuvio.app.core.ui.NuvioShelfSection
import com.nuvio.app.core.ui.posterCardClickable
import com.nuvio.app.features.watchprogress.ContinueWatchingItem
import com.nuvio.app.features.watchprogress.ContinueWatchingSectionStyle
import kotlin.math.roundToInt
@ -279,13 +280,7 @@ private fun ContinueWatchingPosterCard(
onLongClick: (() -> Unit)?,
) {
Column(
modifier = Modifier
.width(layout.posterCardWidth)
.combinedClickable(
enabled = onClick != null || onLongClick != null,
onClick = { onClick?.invoke() },
onLongClick = onLongClick,
),
modifier = Modifier.width(layout.posterCardWidth),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
Box(
@ -298,7 +293,8 @@ private fun ContinueWatchingPosterCard(
width = 1.5.dp,
color = Color.White.copy(alpha = 0.15f),
shape = RoundedCornerShape(layout.cardRadius),
),
)
.posterCardClickable(onClick = onClick, onLongClick = onLongClick),
) {
val imageUrl = item.imageUrl
if (imageUrl != null) {

View file

@ -3,7 +3,6 @@ package com.nuvio.app.features.search
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@ -43,6 +42,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import coil3.compose.AsyncImage
import com.nuvio.app.core.ui.NuvioAnimatedWatchedBadge
import com.nuvio.app.core.ui.posterCardClickable
import com.nuvio.app.features.home.MetaPreview
import com.nuvio.app.features.home.PosterShape
import com.nuvio.app.features.home.components.HomeEmptyStateCard
@ -268,16 +268,7 @@ private fun DiscoverPosterTile(
onLongClick: (() -> Unit)? = null,
) {
Column(
modifier = modifier.then(
if (onClick != null || onLongClick != null) {
Modifier.combinedClickable(
onClick = { onClick?.invoke() },
onLongClick = onLongClick,
)
} else {
Modifier
},
),
modifier = modifier,
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
Box(
@ -285,7 +276,8 @@ private fun DiscoverPosterTile(
.fillMaxWidth()
.aspectRatio(item.posterShape.discoverAspectRatio())
.clip(RoundedCornerShape(22.dp))
.background(MaterialTheme.colorScheme.surface),
.background(MaterialTheme.colorScheme.surface)
.posterCardClickable(onClick = onClick, onLongClick = onLongClick),
) {
if (item.poster != null) {
AsyncImage(