Daviti Gogochishvili
Daviti Gogochishvili

Reputation: 93

How to disable Drag behaviour on ModalBottomSheet , android compose

How to disable Drag behaviour on ModalBottomSheet , android compose , can't find nothing on google

tried draggable on modifier , nothing happened , then i tried to disable scroll behaviour but nothing happened again , please help me

Upvotes: 7

Views: 8683

Answers (3)

DaMat
DaMat

Reputation: 31

In material3 version 1.4.0 a new attribute sheetGesturesEnabled allowing gestures disabling has been added to fun ModalBottomSheet(...). Haven't tested it myself yet but it looks like exactly what is needed.

The suggested "hackaround" has not been working reliably for me (at least not in compose multiplatform).

source: code change, issue

Upvotes: 2

Andre Sampaio
Andre Sampaio

Reputation: 452

Using the ModalBottomSheetSample from Android Code Search you can change the bottomSheetState to prevent the Hidden state. The SheetValue.Hidden assign prevents the sheet from closing.

 val bottomSheetState =
    rememberModalBottomSheetState(skipPartiallyExpanded = true, 
    confirmValueChange = { it != SheetValue.Hidden })

Upvotes: 4

zaid khan
zaid khan

Reputation: 1012

Here are some of the workarounds. But, It is better to use the sheetGesturesEnabled which is the property of BottomSheetScaffold and set it to false to get your desired result.

Upvotes: 1

Related Questions