Hey everyone. I’m trying to create a simple bottom...
# compose
t
Hey everyone. I’m trying to create a simple bottom sheet like gesture. For this I have a surface, and I apply the scrollable modifier with this scrollableState:
Copy code
val maxTopOffset = with(LocalDensity.current) { 240.dp.toPx() }
val topOffset = remember { mutableStateOf(maxTopOffset) }
val scrollableState = ScrollableState { delta ->
    val newOffset =
        (topOffset.value + delta).coerceIn(0f, maxTopOffset)
    val consumed = newOffset - topOffset.value
    topOffset.value = newOffset
    consumed
}
Surface(Modifier.fillMaxSize().scrollable(scrollableState, Orientation.Vertical).graphicsLayer { translationY = topOffset.value }) {}
This works, but the default fling behavior behaves weird. I think this is because I’m not calculating the consumeScrollDelta properly, but I can’t find any good examples for this. Any help?