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),
|
||||
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)
|
||||
AnimatedCardEntry(
|
||||
card = card,
|
||||
onClick = { onCardClick(card) },
|
||||
modifier = Modifier.padding(horizontal = 4.dp),
|
||||
isPlayable = canPlay && isCurrentTurn,
|
||||
animationDelay = player.hand.indexOf(card) * 30
|
||||
animationDelay = index * 30
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user