JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.33k stars 1.12k forks source link

On iOS platforms, Compose gestures(scroll or drag) conflict with native gestures. #5026

Open Gaubee opened 1 week ago

Gaubee commented 1 week ago

Describe the bug The gestures discussed here include scrolling and dragging. I haven't tested in other scenarios yet.

Regarding dragging: I implemented a native listener (using addGestureRecognizer attached to a UIView, which is rendered in Compose by UIKitView) and received one time UIGestureRecognizerStateBegan, two to three times UIGestureRecognizerStateChanged, and one time UIGestureRecognizerStateCancelled event. However, I didn't perform any cancelled operation, yet it was triggered.

Additionally, there's scrolling: For this, I've prepared reproducible code. I suspect it's the same issue, so I'm raising it in this issue together. But if you think these are two separate problems, please feel free to split this issue.

I'm rendering Compose content in a UIKitSheet, which has its own scrolling behavior, and this scrolling seems to interrupt Compose's scrolling. This issue is particularly noticeable in the new version, but it also occurs occasionally in the old version.

BugGestureDemo.zip

you can toggle the compose version in libs.versions.toml

compose-plugin = "1.6.11"
#compose-plugin = "1.7.0-dev1686"

Their behavior is similar: the finger clearly hasn't left the screen, but the code thinks it has.

You can add clickable to the demo I provided, and you'll see that it's triggered click-event during scroll dragging.

Affected platforms

Versions

To Reproduce Steps to reproduce the behavior:

  1. Click on 'Click Me'
  2. Scroll the UIKit-Sheet
  3. See error

Screenshots

https://github.com/JetBrains/compose-multiplatform/assets/2151644/eed91e2c-376d-4225-b26d-b44a28fa9f99

https://github.com/JetBrains/compose-multiplatform/assets/2151644/2d87c18a-e119-4c15-81a6-44d33eb7d976

Gaubee commented 1 week ago

@Levi-Moreira

elijah-semyonov commented 1 week ago

It's a part of meta issue for proper touch interop with native gesture recognizers. The reported problem is just a single facet of it:

https://github.com/JetBrains/compose-multiplatform/issues/3806 https://github.com/JetBrains/compose-multiplatform/issues/4818 https://github.com/JetBrains/compose-multiplatform/issues/3525