Breens-Mbaka / Searchable-Dropdown-Menu-Jetpack-Compose

🎨A Jetpack Compose searchable drop down menu library
Apache License 2.0
105 stars 6 forks source link

height issue #45

Open mdhossain8121 opened 1 year ago

mdhossain8121 commented 1 year ago

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 }

Breens-Mbaka commented 11 months ago

What is the issue you're facing? @mdhossain8121