xxfast
02/14/2024, 6:24 AMLazyVerticalStaggeredGrids
, is there a way to dynamically add padding in order to indent only certain items in appropriate positions? Code in 🧵xxfast
02/14/2024, 6:26 AMxxfast
02/14/2024, 6:29 AMJoel Denke
02/14/2024, 9:35 AMinternal fun placeSpaceAround(
totalSize: Int,
size: IntArray,
outPosition: IntArray,
reverseInput: Boolean
) {
val consumedSize = size.fold(0) { a, b -> a + b }
val gapSize = if (size.isNotEmpty()) {
(totalSize - consumedSize).toFloat() / size.size
} else {
0f
}
var current = gapSize / 2
size.forEachIndexed(reverseInput) { index, it ->
outPosition[index] = current.roundToInt()
current += it.toFloat() + gapSize
}
}
Joel Denke
02/14/2024, 9:36 AM