Hi , Is there a way to make ModalBottomSheetLayout...
# compose
w
Hi , Is there a way to make ModalBottomSheetLayout non dismissable.
Doing this is not recommended,
Copy code
val bottomsheetState =
  rememberModalBottomSheetState(
    initialValue = ModalBottomSheetValue.Hidden,
    confirmStateChange = {false}
  )
Is there a workaround.
t
You can override the behavior of the back button with your own logic in this case. Does not fix the case when user click on the outside of the content though
w
Back button handling is fine, only the main issue is when touched outside the content
t
Is the bottom sheet general for all screens or just 1 specific screen?
If it’s specific then I think the only way to workaround this is to control the bottom sheet yourself and ditch the bottom sheet navigation
w
I see my usecase is basically create a wrapper around ModalBottomSheetLayout and expose it for all bottomsheet usecases.
t
U can still use it in other screens that do not require special logic to dismiss the bottom sheet though. It’d save some effort
With the above approach i was facing unintended behaviours.
t
Let’s say u have screen A with bottom sheet B Instead of doing this
Copy code
composable("/a){}
bottomSheet("/b"){}
You can do this
Copy code
composable("/a)
{
 val bottomsheetState =
  rememberModalBottomSheetState(
    initialValue =   ModalBottomSheetValue.Hidden,
    confirmStateChange = {
       // your logic
   }
  BottomSheetModalLayout{


  }

}
w
Thanks Tin,I will check for the confirmStatChange logic much more deeper
t
It’s basically just this
Copy code
onDismiss = {
                    if (sheetState.confirmStateChange(Hidden)) {
                        scope.launch { sheetState.hide() }
                    }
                },
But you can’t override it in the case of bottom sheet navigator because it has to do some synchronization to control the state of the back stack
857 Views