Skip to content

Commit 6abc2a8

Browse files
committed
Rename and refactor getting span in HorizontalVerticalGrid
1 parent 8df5d83 commit 6abc2a8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

grid/src/commonMain/kotlin/com/cheonjaeung/compose/grid/HorizontalVerticalGridMeasurePolicy.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ private class HorizontalVerticalGridMeasureHelper(
118118
measurables[it].parentData as? HorizontalVerticalGridParentData
119119
}
120120

121-
private val HorizontalVerticalGridParentData?.spanOrDefault: (GridItemSpanScope.() -> Int)
122-
get() = this?.span ?: HorizontalVerticalGridParentData.DefaultSpan
123-
124121
/**
125122
* Measures children composable constraints.
126123
*/
@@ -158,9 +155,14 @@ private class HorizontalVerticalGridMeasureHelper(
158155
maxCurrentLineSpan = maxSpan - spanSum,
159156
maxLineSpan = maxSpan
160157
)
161-
val scopeFunction = gridParentDataArrays[measurableIndex].spanOrDefault
162-
val span = scopeFunction(spanScope)
158+
val spanFunction = gridParentDataArrays[measurableIndex]?.span
159+
val span = if (spanFunction != null) {
160+
with(spanScope) { spanFunction() }
161+
} else {
162+
1
163+
}
163164
require(span > 0) { "span must be bigger than zero, $span is zero or negative" }
165+
164166
if (span > maxSpan) {
165167
measurableIndex++
166168
continue

0 commit comments

Comments
 (0)