val itemHeights = remember { mutableStateMapOf<Int, Int>() }
val baseHeight = 530.dp
val density = LocalDensity.current
val maxHeight = remember(itemHeights.toMap()) {
if (itemHeights.keys.toSet() != listOfItems.indices.toSet()) {
// if we don't have all heights calculated yet, return default value
return@remember baseHeight
}
val baseHeightInt = with(density) { baseHeight.toPx().toInt() }
// top+bottom system padding
var sum = with(density) { DropdownMenuVerticalPadding.toPx().toInt() } * 2
for ((i, itemSize) in itemHeights.toSortedMap()) {
sum += itemSize
if (sum >= baseHeightInt) {
return@remember with(density) { (sum - itemSize / 2).toDp() }
}
}
// all items fit into base height
baseHeight
}
i think it never passes
if (itemHeights.keys.toSet() != listOfItems.indices.toSet()) {
// if we don't have all heights calculated yet, return default value
return@remember baseHeight
}
val itemHeights = remember { mutableStateMapOf<Int, Int>() } val baseHeight = 530.dp val density = LocalDensity.current
i think it never passes
if (itemHeights.keys.toSet() != listOfItems.indices.toSet()) { // if we don't have all heights calculated yet, return default value return@remember baseHeight }