From df4c394fc3456ab6af8ea841d9bb94f297f75e61 Mon Sep 17 00:00:00 2001 From: Tom Pratt Date: Tue, 21 Jul 2026 18:45:44 +0200 Subject: 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. --- .../features/netplay/ui/NetplayScreen.kt | 27 ++++++++++------------ .../dolphinemu/dolphinemu/ui/theme/DolphinTheme.kt | 2 +- 2 files changed, 13 insertions(+), 16 deletions(-) (limited to 'Source/Android/app/src/main/java') diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/netplay/ui/NetplayScreen.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/netplay/ui/NetplayScreen.kt index 7df8ea35ee..018a46a71b 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/netplay/ui/NetplayScreen.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/netplay/ui/NetplayScreen.kt @@ -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, diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/theme/DolphinTheme.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/theme/DolphinTheme.kt index 4aa7e2055a..1aec1a0752 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/theme/DolphinTheme.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/theme/DolphinTheme.kt @@ -257,7 +257,7 @@ fun OutlinedBox( if (onClick != null) { Box( modifier = Modifier - .fillMaxSize() + .matchParentSize() .clip(MaterialTheme.shapes.extraSmall) .clickable( interactionSource = interactionSource, -- cgit v1.2.3