diff options
| author | 2023-07-21 09:21:37 +0000 | |
|---|---|---|
| committer | 2023-07-21 09:21:37 +0000 | |
| commit | 7e9dd498e30ebb2cc968ff68a8702a9388169908 (patch) | |
| tree | 7d207c2153f3e946287005439b7b6c3dfa7ac5db | |
| parent | 49e61e47740b3cebe269e68e666e7d008b366908 (diff) | |
| parent | fc59292e8c5199043aa8162bf7f0ee81cdafc657 (diff) | |
Fix child constraints in (Horizontal|Vertical)Grid am: 3d5bf056c3 am: fc59292e8c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24006843
Change-Id: Ic5a5129fd2ed3c04bb4fc26688ce35f4da90439f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | packages/SystemUI/compose/core/src/com/android/compose/grid/Grids.kt | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/packages/SystemUI/compose/core/src/com/android/compose/grid/Grids.kt b/packages/SystemUI/compose/core/src/com/android/compose/grid/Grids.kt index 5224c51bb7c3..27f0948d5377 100644 --- a/packages/SystemUI/compose/core/src/com/android/compose/grid/Grids.kt +++ b/packages/SystemUI/compose/core/src/com/android/compose/grid/Grids.kt @@ -22,7 +22,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.layout.Layout import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.constrainWidth import androidx.compose.ui.unit.dp import kotlin.math.ceil import kotlin.math.max @@ -126,18 +125,20 @@ private fun Grid( ((columns - 1) * horizontalSpacing.toPx()).roundToInt() val totalVerticalSpacingBetweenChildren = ((rows - 1) * verticalSpacing.toPx()).roundToInt() val childConstraints = - Constraints().apply { - if (constraints.maxWidth != Constraints.Infinity) { - constrainWidth( + Constraints( + maxWidth = + if (constraints.maxWidth != Constraints.Infinity) { (constraints.maxWidth - totalHorizontalSpacingBetweenChildren) / columns - ) - } - if (constraints.maxHeight != Constraints.Infinity) { - constrainWidth( + } else { + Constraints.Infinity + }, + maxHeight = + if (constraints.maxHeight != Constraints.Infinity) { (constraints.maxHeight - totalVerticalSpacingBetweenChildren) / rows - ) - } - } + } else { + Constraints.Infinity + } + ) val placeables = buildList { for (cellIndex in measurables.indices) { |