I am using ModalBottomSheetLayout in Jetpack Compose. Whenever it is shown with modalBottomSheetState.show(), it shows HalfExpanded or Expanded depending on the height of its content. This is from the source code:
val anchors = if (sheetHeight < fullHeight / 2) {
mapOf(
fullHeight to Hidden,
fullHeight - sheetHeight to Expanded
)
} else {
mapOf(
fullHeight to Hidden,
fullHeight / 2 to HalfExpanded,
max(0f, fullHeight - sheetHeight) to Expanded
)
}
Modifier.swipeable(
state = sheetState,
anchors = anchors,
orientation = Orientation.Vertical,
enabled = sheetState.currentValue != Hidden,
resistance = null
)
Then show() works like here:
internal val isHalfExpandedEnabled: Boolean
get() = anchors.values.contains(HalfExpanded)
/**
* Show the bottom sheet with animation and suspend until it's shown. If half expand is
* enabled, the bottom sheet will be half expanded. Otherwise it will be fully expanded.
*
* @throws [CancellationException] if the animation is interrupted
*/
suspend fun show() {
val targetValue =
if (isHalfExpandedEnabled) HalfExpanded
else Expanded
animateTo(targetValue = targetValue)
}
I wonder if we can set it to always Expanded somehow