Skip to content

Commit cb4f78c

Browse files
authored
Merge pull request #52 from cheonjaeung/remaining-cell-size
Fix cell size distribution properly in SimpleGridCells
2 parents b4cea47 + a51835a commit cb4f78c

File tree

38 files changed

+4
-4
lines changed

38 files changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ interface SimpleGridCells {
5151
val totalSpacing = spacing * (count - 1)
5252
val totalCellSize = availableSize - totalSpacing
5353
val cellSize = totalCellSize / count
54-
val remainingPixels = cellSize % count
54+
val remainingPixels = totalCellSize % count
5555
return List(count) { index ->
56-
cellSize + if (remainingPixels > 0 && index == 0) 1 else 0
56+
cellSize + if (index < remainingPixels) 1 else 0
5757
}
5858
}
5959

@@ -105,9 +105,9 @@ interface SimpleGridCells {
105105
val totalSpacing = spacing * (count - 1)
106106
val totalCellSize = availableSize - totalSpacing
107107
val cellSize = totalCellSize / count
108-
val remainingPixels = cellSize % count
108+
val remainingPixels = totalCellSize % count
109109
return List(count) { index ->
110-
cellSize + if (remainingPixels > 0 && index == 0) 1 else 0
110+
cellSize + if (index < remainingPixels) 1 else 0
111111
}
112112
}
113113

-48 Bytes
Loading
-78 Bytes
Loading
-1 Bytes
Loading
-19 Bytes
Loading
-28 Bytes
Loading
-20 Bytes
Loading
-19 Bytes
Loading
-10 Bytes
Loading
-9 Bytes
Loading

0 commit comments

Comments
 (0)