Skip to content

Commit ecbec2b

Browse files
committed
Remove internal constants for box grid cell position
1 parent d78c37e commit ecbec2b

File tree

3 files changed

+11
-32
lines changed

3 files changed

+11
-32
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import androidx.compose.ui.platform.InspectorInfo
77
import androidx.compose.ui.unit.Density
88

99
internal class BoxGridCellPositionElement(
10-
val row: Int = BoxGridParentData.UNSPECIFIED_ROW,
11-
val column: Int = BoxGridParentData.UNSPECIFIED_COLUMN,
10+
val row: Int? = null,
11+
val column: Int? = null,
1212
val inspectorInfo: InspectorInfo.() -> Unit
1313
) : ModifierNodeElement<BoxGridCellPositionNode>() {
1414
override fun create(): BoxGridCellPositionNode {
@@ -39,15 +39,15 @@ internal class BoxGridCellPositionElement(
3939
}
4040

4141
internal class BoxGridCellPositionNode(
42-
var row: Int,
43-
var column: Int
42+
var row: Int?,
43+
var column: Int?
4444
) : Modifier.Node(), ParentDataModifierNode {
4545
override fun Density.modifyParentData(parentData: Any?): Any {
4646
val p = parentData as? BoxGridParentData ?: BoxGridParentData()
47-
if (row != BoxGridParentData.UNSPECIFIED_ROW) {
47+
if (row != null) {
4848
p.row = row
4949
}
50-
if (column != BoxGridParentData.UNSPECIFIED_COLUMN) {
50+
if (column != null) {
5151
p.column = column
5252
}
5353
return p

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

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,10 @@ private class BoxGridMeasureHelper(
9393
}
9494

9595
private val BoxGridParentData?.rowOrDefault: Int
96-
get() {
97-
val row = this?.row
98-
return if (row == null || row == BoxGridParentData.UNSPECIFIED_ROW) {
99-
BoxGridParentData.DEFAULT_ROW
100-
} else {
101-
row
102-
}
103-
}
96+
get() = this?.row ?: 0
10497

10598
private val BoxGridParentData?.columnOrDefault: Int
106-
get() {
107-
val column = this?.column
108-
return if (column == null || column == BoxGridParentData.UNSPECIFIED_COLUMN) {
109-
BoxGridParentData.DEFAULT_COLUMN
110-
} else {
111-
column
112-
}
113-
}
99+
get() = this?.column ?: 0
114100

115101
private val BoxGridParentData?.alignmentOrDefault: Alignment
116102
get() = this?.alignment ?: defaultAlignment

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,8 @@ package com.cheonjaeung.compose.grid
33
import androidx.compose.ui.Alignment
44

55
internal data class BoxGridParentData(
6-
var row: Int = UNSPECIFIED_ROW,
7-
var column: Int = UNSPECIFIED_COLUMN,
6+
var row: Int? = null,
7+
var column: Int? = null,
88
var span: (BoxGridItemSpanScope.() -> BoxGridItemSpan)? = null,
99
var alignment: Alignment? = null
10-
) {
11-
companion object {
12-
internal const val UNSPECIFIED_ROW: Int = -1
13-
internal const val UNSPECIFIED_COLUMN: Int = -1
14-
internal const val DEFAULT_ROW: Int = 0
15-
internal const val DEFAULT_COLUMN: Int = 0
16-
}
17-
}
10+
)

0 commit comments

Comments
 (0)