fix: unique keys for LazyRow to prevent crash with duplicate cards
This commit is contained in:
@@ -542,14 +542,15 @@ private fun PlayerHand(
|
|||||||
horizontalArrangement = Arrangement.spacedBy((-8).dp),
|
horizontalArrangement = Arrangement.spacedBy((-8).dp),
|
||||||
contentPadding = PaddingValues(horizontal = 16.dp)
|
contentPadding = PaddingValues(horizontal = 16.dp)
|
||||||
) {
|
) {
|
||||||
items(player.hand, key = { "${it.color}_${it.value}_${player.hand.indexOf(it)}" }) { card ->
|
items(player.hand.size) { index ->
|
||||||
|
val card = player.hand[index]
|
||||||
val canPlay = topCard != null && card.canPlayOn(topCard, currentColor)
|
val canPlay = topCard != null && card.canPlayOn(topCard, currentColor)
|
||||||
AnimatedCardEntry(
|
AnimatedCardEntry(
|
||||||
card = card,
|
card = card,
|
||||||
onClick = { onCardClick(card) },
|
onClick = { onCardClick(card) },
|
||||||
modifier = Modifier.padding(horizontal = 4.dp),
|
modifier = Modifier.padding(horizontal = 4.dp),
|
||||||
isPlayable = canPlay && isCurrentTurn,
|
isPlayable = canPlay && isCurrentTurn,
|
||||||
animationDelay = player.hand.indexOf(card) * 30
|
animationDelay = index * 30
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user