4

I have a BottomSheetScaffold(), on button push the bottomsheet is coming up, all is working fine, but i want to prevent the user from swiping down the bottomsheet. Instead a button on the bottomsheet is use to close it on click.

I see the option drawerGesturesEnabled, but this not doing anything.

z.g.y
  • 5,512
  • 4
  • 10
  • 36
saro
  • 705
  • 3
  • 13

2 Answers2

1

You can set its sheetGesturesEnabled parameter to false

BottomSheetScaffold(
    sheetGesturesEnabled = false,
    …
    …
z.g.y
  • 5,512
  • 4
  • 10
  • 36
0

The code above works as long as there is no scrollable content inside.

I had a task to prevent the BottomSheet collapsing by swiping down (or rather, in the process of scrolling nested content). Here is the solution I found (use confirmStateChange callback). I hope this will be useful to someone.

    val scaffoldState = rememberBottomSheetScaffoldState(
    bottomSheetState = rememberBottomSheetState(
        initialValue = BottomSheetValue.Collapsed,
        confirmStateChange = {
            // Prevent collapsing by swipe down gesture
            it != BottomSheetValue.Collapsed
        }
    ),
    snackbarHostState = remember { SnackbarHostState() }
)