Hi everyone. I'm trying to set height of my bottom...
# compose
y
Hi everyone. I'm trying to set height of my bottom sheet from Material3BottomSheetScaffold by subtracting top position of element in the scaffold's content from the scaffold's bottom but there's a gap on android and ios, but not on jvm, any ideas where this gap is coming from? Adding screenshots and snippets in the thread
Copy code
@Composable
fun letterPracticeWritingWordsBottomSheetHeight(
    scaffoldCoordinates: SharedFlow<LayoutCoordinates?>,
    expressionSectionCoordinates: SharedFlow<LayoutCoordinates?>
): State<Dp> {
    val height = remember { mutableStateOf(DefaultHeight) }
    val density = LocalDensity.current
    val extraBottomSheetHeight = 0.dp// WindowInsets.navigationBars.getBottom(density).let { with(density) { it.toDp() } }

    LaunchedEffect(Unit) {
        val scaffoldBoundFlow = scaffoldCoordinates
            .map { it?.takeIf { it.isAttached }?.boundsInWindow() }
        val expressionSectionBoundsFlow = expressionSectionCoordinates
            .map { it?.takeIf { it.isAttached }?.boundsInWindow() }

        scaffoldBoundFlow.combine(expressionSectionBoundsFlow) { a, b -> a to b }
            .map { (scaffold, expressions) ->
                Logger.d("scaffold[$scaffold] expressions[$expressions]")
                when {
                    scaffold == null || expressions == null -> DefaultHeight
                    else -> {
                        val maxHeight = with(density) {
                            scaffold.height.toDp().plus(extraBottomSheetHeight)
                        }

                        val bottomSheetHeight = scaffold.bottom
                            .minus(<http://expressions.top|expressions.top>)
                            .let { with(density) { it.toDp() } }
                            .plus(extraBottomSheetHeight)
                            .takeIf { it >= MinHeightThreshold }
                            ?: maxHeight

                        bottomSheetHeight
                    }
                }
            }
            .onEach { vocabSheetHeight ->
                Logger.d("changing bottom sheet height to ${vocabSheetHeight.value}")
                height.value = vocabSheetHeight
            }
            .launchIn(this)
    }
    return height
}