简体   繁体   English

有没有办法禁用 ModalBottomSheetLayout 手势? - 喷气背包组成

[英]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.

相关问题 Jetpack Compose 中一个 ModalBottomSheetLayout 的多个 BottomSheet - Multiple BottomSheets for one ModalBottomSheetLayout in Jetpack Compose 听 Jetpack Compose 中的 ModalBottomSheetLayout state 变化 - Listen ModalBottomSheetLayout state change in Jetpack Compose 在 Jetpack compose 中删除键盘和 ModalBottomSheetLayout - Remove keypad along with ModalBottomSheetLayout in Jetpack compose 如何在 ModalBottomSheetLayout - Jetpack Compose 中配置 HalfExpanded 值 - How to configure HalfExpanded value in ModalBottomSheetLayout - Jetpack Compose 我在使用jetpack compose的material3中找不到ModalBottomSheetLayout? - I can't find ModalBottomSheetLayout in material3 with jetpack compose? Jetpack Compose ModalBottomSheetLayout SheetContent 不在屏幕底部出现 - Jetpack Compose ModalBottomSheetLayout SheetContent appears not from the bottom of the screen Jetpack Compose:允许手势通过 Scaffold - Jetpack Compose: Allow gestures to pass through Scaffold Jetpack Compose:禁用与 TextField 的交互 - Jetpack Compose: Disable Interaction with TextField 有什么方法可以将 Jetpack Compose 字体转换为原生字体? - Is there any way for converting Jetpack Compose Typeface to native Typeface? 是否有任何工具或方法可以测试重组发生在一段代码中还是不发生在 Jetpack compose 中? - Are there any tools or way to test recomposition happens in a piece of code or not in Jetpack compose?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM