[英]Is there any way to disable ModalBottomSheetLayout gestures? - Jetpack compose
I'm trying to implement google map inside the content of modal bottom sheet layout.我正在尝试在模态底页布局的内容中实现google map 。 The problem is when I try to drag on map, the modal bottom sheet is moving.问题是当我尝试拖动 map 时,模态底页正在移动。 I tried to find a solution for a google map to take an advantage of sheet's gestures, but with no luck.我试图为谷歌 map 找到一个解决方案来利用工作表的手势,但没有运气。
I know that bottom sheet scaffold has option of disabling gestures, but then I can't use scrim color that is necessary in my project.我知道底板脚手架有禁用手势的选项,但是我不能使用项目中必需的稀松布颜色。
Thanks!谢谢!
You can capture the pointer events, apply the scrolling offset directly to the map, and then mark the event as consumed, so it does not reach the parent component.可以捕获指针事件,将滚动偏移量直接应用到map,然后将事件标记为已消耗,这样就不会到达父组件。
Note: This does not handle pinch to zoom or rotate.注意:这不处理捏缩放或旋转。
val targetPosition = LatLng(SOME_LAT, SOME_LNG)
val cameraPositionState = rememberCameraPositionState {
position = CameraPosition.fromLatLngZoom(targetPosition, 17f)
}
GoogleMap(
modifier =
Modifier.fillMaxWidth()
.height(300.dp)
.pointerInput(Unit) {
awaitPointerEventScope {
while (true) {
awaitPointerEvent(pass = PointerEventPass.Main).changes.forEach {
val offset = it.positionChange()
cameraPositionState.move(
CameraUpdateFactory.scrollBy(-offset.x, -offset.y)
)
it.consume()
}
}
}
},
cameraPositionState = cameraPositionState,
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.