Piotr Prus
02/15/2021, 11:57 AMBottomSheetScaffold
and encountered one problem. I do not know how to open the bottomSheet to certain value.
Example:
1. The view shows the list
2. User clicks the element in list
3. BottomSheet opens to certain height
4. User drags the sheet up
5. Sheet reveals to full screen
I tried to use BottomSheetScaffoldState.bottomSheetState.expand { }, but this function always open the sheet to full height. I was searching for something like: BottomSheetScaffoldState.bottomSheetState.expandByHalf()
or BottomSheetScaffoldState.bottomSheetState.setAnchor(200.dp)
or similar to this, but no luck.
Anyone knows how to make a mid step for BottomSheet?jossiwolf
02/15/2021, 1:18 PMBottomSheetScaffold
. There's ModalBottomSheet
which has a HalfExpand
state if the content is taller than 50% of the root element, so maybe that's what you're looking for?Piotr Prus
02/15/2021, 1:37 PMjossiwolf
02/15/2021, 2:02 PMPiotr Prus
02/15/2021, 2:11 PMjulioromano
03/18/2021, 10:49 AMPiotr Prus
03/18/2021, 11:04 AMColumn(
modifier = Modifier
.fillMaxWidth()
.background(MaterialTheme.colors.primary)
.verticalScroll(rememberScrollState())
.pointerInput(Unit) {
detectVerticalDragGestures(
onVerticalDrag = { change, dragAmount ->
if (dragAmount > 1f) onDragDown()
})
}
)
in onDragDown()
I am calling:
changePeekHeight(0.dp)
Important thing to notice is that .pointerInput
needs to be after Modifier.verticalScroll
. If not, all the drag will be consumed by the scrolljulioromano
03/18/2021, 3:26 PMchangePeekHeight()
a Compose API ?Piotr Prus
03/18/2021, 3:34 PMsheetPeekHeight = mapsViewState?.peekHeight ?: 0.dp,
in VM:
fun changePeekHeight(height: Dp) {
mapsViewState.peekHeight = height
}
Saurabh Khare
04/28/2022, 3:20 AMPiotr Prus
04/28/2022, 6:25 AM