compose-menu icon indicating copy to clipboard operation
compose-menu copied to clipboard

BottomSheet: Update detents height

Open carvalho2707 opened this issue 8 months ago • 0 comments

Hi again 😄

I'm having another issue but this one could be just me tired. Anyway I would like to share that with you.

` @Composable fun RecordingReviewContent() { var halfContentHeight by remember { mutableStateOf(50.dp) }

val halfDetent =
    SheetDetent(identifier = "Half") { containerHeight, sheetHeight ->
        Napier.e("sheetHeight: $sheetHeight, containerHeight: $containerHeight")
        halfContentHeight
    }
val fullDetent = getFullDetent()

val sheetState =
    rememberBottomSheetState(
        initialDetent = halfDetent,
        detents = listOf(halfDetent, fullDetent),
    )

XRacingBottomSheet(
    sheetState = sheetState,
    snackbarHostState = snackbarHostState,
    content = {
        RecordingReviewTopContent(
            uiState = uiState,
            mapViewType = mapViewType,
        )
    },
    sheetContent = {
        RecordingReviewSheetContent(
            uiState = uiState,
            onHalfHeightChanged = { height ->
                halfContentHeight = height
                Napier.e("Half height changed to $height")
            },
            onPeekHeighChanged = { height ->
                peekContentHeight = height
                Napier.e("Peek height changed to $height")
            },
        )
    },
    actions = { iconTint, iconBackground, backgroundAlpha ->
    },
    onBackClick = navigateBack,
)

} `

you can see some logs: sheetHeight: 773.4545.dp, containerHeight: Dp.Unspecified sheetHeight: 773.4545.dp, containerHeight: 773.4545.dp sheetHeight: 773.4545.dp, containerHeight: 773.4545.dp sheetHeight: 703.63635.dp, containerHeight: 773.4545.dp Half height changed to 266.18182.dp Peek height changed to 41.090908.dp sheetHeight: 773.4545.dp, containerHeight: 773.4545.dp

So the half detent should be almost half of the screen but it's instead taking the original value of halfContentHeight. Somehow is related to https://github.com/composablehorizons/compose-unstyled/issues/51

carvalho2707 avatar May 23 '25 13:05 carvalho2707