How can I make an accompanist navigation BottomSheet fully expanded?

Viewed 249

I know that a normal bottom sheet can be setup like this

rememberModalBottomSheetState(
  initialValue = ModalBottomSheetValue.Hidden, 
  confirmStateChange = { it != ModalBottomSheetValue.HalfExpanded },
)

So that it will never be half expanded. But what if I want to do the same in Accompanist navigation with bottomsheets?

1 Answers

I figured out how to do it.

val sheetState = rememberModalBottomSheetState(
    initialValue = ModalBottomSheetValue.Hidden,
    skipHalfExpanded = true
)
val bottomSheetNavigator = remember { BottomSheetNavigator(sheetState) }
val navController = rememberAnimatedNavController(bottomSheetNavigator)

Instead of using rememberBottomSheetNavigator() you can just use the constructor of BottomSheetNavigator which takes a sheetstate which can be set with a simple boolean. :)

Related