Background
- I have built a custom bottom sheet with three anchors.
- There is a FAB for transitioning from
BottomSheetState.GonetoBottomSheetState.Half. - This bottom sheet's content either doesn't
cover, half covers, or fully covers a full screen
GoogleMapComposable. - The
maxHeightparameter is the full height in pixels of the parentComposable.
@ExperimentalMaterialApi
@Composable
fun AnchoredBottomSheet(
state: BottomSheetState,
maxHeight: Float,
content: @Composable () -> Unit,
) {
val swipeableState = rememberSwipeableState(initialValue = state)
val anchors = mapOf(
BottomSheetState.Gone.toAnchor(maxHeight),
BottomSheetState.Half.toAnchor(maxHeight/2),
BottomSheetState.Full.toAnchor(0),
)
Column(
modifier = Modifier
.height(maxHeight.toDp())
.swipeable(
enabled = swipeableState.currentValue != BottomSheetState.Gone,
state = swipeableState,
orientation = Orientation.Vertical,
anchors = anchors,
)
.offset {
IntOffset(
0,
swipeableState.offset.value.roundToInt()
)
}
) {
content()
}
}
Problem
- When the app is in the
BottomSheetState.Halfstate or theBottomSheetState.Gone, - and the user clicks on the
GoogleMapportion of the screen, - clicks are caught by the
AnchoredBottomSheetand do not pass through to the visible (GoogleMap)Composable. - For example in this photo the cyan portion of the screen represents the
GoogleMapportion of the view in theBottomSheetState.Halfstate and it does not receive clicks.
Question
How can I make the my bottom sheet implementation only consume clicks/drags that occur on the content of the bottom sheet?