https://kotlinlang.org logo
#compose
Title
# compose
a

Anthony

01/21/2022, 5:35 PM
Is there a way to prevent gestures on a ModalBottomSheet? I would like only a button to be able to open/close the bottom sheet and not any drag gestures.
1
h

Hitesh Chopra

05/09/2022, 11:12 AM
@Anthony I have a similar use-case, need to prevent the closure of bottom-sheet whenever the user clicks outside of the bottom-sheet or in technical terms, prevent gestures on a ModalBottomSheet. There is an open issue for the same https://github.com/google/accompanist/issues/730 I noticed that the ModalBottomSheet calls the sheetState,hide() method after it detects any gestures
Copy code
Modifier.pointerInput(onDismiss) { detectTapGestures { onDismiss() } }
And onDimiss() is
Copy code
scope.launch { sheetState.hide() }
While testing, by commenting this line out I was able to achieve the required behaviour. So I think a flag can be added for the same as @jossiwolf recommended in the issue comments Have raised a PR for the same. https://github.com/androidx/androidx/pull/393/files If anyone can look into it 😅 Btw @Anthony how were you able to achieve your expected behaviour then?
4 Views