Marco Pierucci
09/04/2023, 3:55 PMval bottomSheetScaffoldState = rememberBottomSheetScaffoldState(
bottomSheetState =
rememberStandardBottomSheetState(
initialValue = SheetValue.Hidden,
skipHiddenState = false
)
)
BottomSheetScaffold(
scaffoldState = bottomSheetScaffoldState,
sheetPeekHeight = INFO_SHEET_PEEK_HEIGHT,
sheetContent = { JobInfoSheet(jobInfoSlice = form.value.jobInfoSlice) }) {
... content
}
svenjacobs
09/04/2023, 5:57 PMshow()
and hide()
, you also need to wrap the ModalBottomSheet in an if
condition or it will always show and when you call hide()
without the if
condition, it will be invisible but still block any interaction with the UI. Also see the example code here. Since I didn’t want to have an additional state I wrote an extension function for SheetState
@ExperimentalMaterial3Api
val SheetState.shouldShowModalBottomSheet
get() = isVisible || targetValue == SheetValue.Expanded
and then I use it in Compose like
if (sheetState.shouldShowModalBottomSheet) {
ModalBottomSheet(
...
)
}
Marco Pierucci
09/04/2023, 6:12 PMsvenjacobs
09/04/2023, 6:13 PMSheetValue.PartiallyExpanded