27 lines
822 B
Kotlin
27 lines
822 B
Kotlin
package components
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
import androidx.compose.foundation.layout.fillMaxHeight
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.ui.Modifier
|
|
import data.Player
|
|
|
|
@Suppress("FunctionName")
|
|
@Composable
|
|
fun PlayerBar(players: MutableMap<Player, Long>) {
|
|
val numberOfCards = players.size
|
|
Column(
|
|
modifier = Modifier.fillMaxHeight()
|
|
.fillMaxWidth()
|
|
) {
|
|
for (
|
|
(index, playerEntry) in players.entries.sortedBy { it.key.name }.sortedByDescending { it.value }
|
|
.withIndex()
|
|
) {
|
|
val maxHeightFraction = 1f / (numberOfCards - index)
|
|
PlayerCard(playerEntry.key, maxHeightFraction, playerEntry.value)
|
|
}
|
|
}
|
|
}
|