mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-09-18 02:40:11 +00:00
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:
+12
-15
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user