Is there a way to make a Material3 ModalBottomShee...
# compose
j
Is there a way to make a Material3 ModalBottomSheet not dismissible? Like the old View/XML based ModalBottomSheets?
s
I think “modal” implies that it’s dismissible no? Maybe you’re looking for BottomSheetScaffold?
j
In the View land
BottomSheetDialogFragment()
had a
isCancelable
property you could set. I’m basically looking for the equivalent.
s
Yeah, that one did not say “modal” then. Did you check out the link I sent you?
j
Yeah, unfortunately I’m using Voyager for Navigation, and it’s
BottomSheetNavigator
uses a
ModalBottomSheetLayout()
. I guess I’ll have to look for an alternative, thanks 👍
s
If you want the sheet to stay there permanently, it sounds like it shouldn’t be a navigation destination really, but more like part of the screen in which you are currently in, potentially using this Scaffold as the way to bring it in. But of course I may be missing part of your requirements which makes what I am saying not true
a
You can use
confirmValueChange
to specify logic on when to hide the bottom sheet.
Copy code
@Composable
@ExperimentalMaterial3Api
fun rememberModalBottomSheetState(
    skipPartiallyExpanded: Boolean = false,
    confirmValueChange: (SheetValue) -> Boolean = { true },
) = rememberSheetState(skipPartiallyExpanded, confirmValueChange, Hidden)