Netplay PlayerTable fixes

- Improve the column measurement logic so it updates the column width when text changes.
- Use matchParentSize on the clickable target in OutlinedBox so that it is clickable when the OutlinedBox contains contents with dynamic height.
This commit is contained in:
Tom Pratt
2026-08-24 19:36:00 +02:00
parent 3236c634d9
commit df4c394fc3
2 changed files with 13 additions and 16 deletions
@@ -972,7 +972,6 @@ private fun PlayersTable(
) {
rows.zipWithNext { a, b -> if (a.size != b.size) throw IllegalArgumentException("Rows must all contain the same number of elements.") }
val maxWidths = remember { List(rows.first().size) { mutableIntStateOf(0) } }
val density = LocalDensity.current
Column(
verticalArrangement = Arrangement.spacedBy(6.dp),
@@ -984,23 +983,21 @@ private fun PlayersTable(
) {
row.forEachIndexed { itemIndex, text ->
Box(
modifier = Modifier
.then(
when {
itemIndex == 0 -> Modifier.weight(1f)
maxWidths[itemIndex].intValue > 0 -> Modifier
.width(with(density) { maxWidths[itemIndex].intValue.toDp() })
else -> Modifier
modifier = if (itemIndex == 0) {
Modifier.weight(1f)
} else {
val maxWidth = maxWidths[itemIndex]
Modifier.layout { measurable, constraints ->
val placeable =
measurable.measure(constraints.copy(maxWidth = Constraints.Infinity))
if (placeable.width > maxWidth.intValue) {
maxWidth.intValue = placeable.width
}
)
.onGloballyPositioned { coordinates ->
val width = coordinates.size.width
if (width > maxWidths[itemIndex].intValue) {
maxWidths[itemIndex].intValue = width
layout(maxWidth.intValue, placeable.height) {
placeable.place(x = 0, y = 0)
}
}
}
) {
Text(
text = text,
@@ -257,7 +257,7 @@ fun OutlinedBox(
if (onClick != null) {
Box(
modifier = Modifier
.fillMaxSize()
.matchParentSize()
.clip(MaterialTheme.shapes.extraSmall)
.clickable(
interactionSource = interactionSource,