Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS - Scroll does not work at all when touch starts on a UIKitView inside eg a LazyColumn #4818

Open
AttilaBarany opened this issue May 16, 2024 · 10 comments
Assignees
Labels
bug Something isn't working ios uikit interop

Comments

@AttilaBarany
Copy link

Affected platforms

  • iOS

Versions

  • 1.6.0, 1.6.2, 1.6.10-rc01...

To Reproduce
Just extend the "uikit-in-compose" example app like this:
Screenshot 2024-05-16 at 16 15 51

(adding a big box after the elements inside the column, and make the column scrollable)

and try to scroll by grabbing eg the textfield

You can reproduce this with any UIKitView, eg a simple UIView(), wkwebview etc... Adding eg Androidview webview does allow us to scroll by grabbing it, but UKitView does not bubble up anything, even tried with custom nestedscrollconnection just print out pre- or post scroll, but got not a single trigger. This failure just makes useless the UIKitView, or at least very limited. You can just integrate only in static pages, without any scrolling, otherwise the user will stuck on the page with invisible contents which are below in the column.

@AttilaBarany AttilaBarany added bug Something isn't working submitted labels May 16, 2024
@brewin
Copy link

brewin commented May 16, 2024

Funny, I was just about to submit this same issue. It does severely limit the use of UIKitView. Setting interactive = false makes it scrollable, but of course then it isn't interactive.

Here is my minimal reproducer:

@OptIn(ExperimentalForeignApi::class)
fun MainViewController() = ComposeUIViewController {
    Column(modifier = Modifier.verticalScroll(state = rememberScrollState())) {
        UIKitView(
            factory = {
                UIView().apply {
                    backgroundColor = UIColor.redColor
                }
            },
            modifier = Modifier.fillMaxWidth().height(400.dp)
        )
        repeat(100) {
            Text("Item #$it")
        }
    }
}

@elijah-semyonov
Copy link
Contributor

Hi, it's a known problem, and not exactly a trivial one to fix due to differences in touch processing in Compose and UIKit. We are investigating our options currently.

@AttilaBarany
Copy link
Author

Great news, thank you @elijah-semyonov . I am gonna suspend my project until than, and stay with separated UI (I am using a webview in column, which can not be done without UIKitView for iOS).

@elijah-semyonov
Copy link
Contributor

As a workaround, you could present native UIViewController with web view modally on top of compose UI.
Use LocalUIViewController.current.

@AttilaBarany
Copy link
Author

As a workaround, you could present native UIViewController with web view modally on top of compose UI. Use LocalUIViewController.current.

So how that would could be part of the scrollable content? I dont get it.

@elijah-semyonov
Copy link
Contributor

It won't be. But you don't have to reimplement entire screen natively.

@AttilaBarany
Copy link
Author

It won't be. But you don't have to reimplement entire screen natively.

Just the column content, get it. Which is the whole screen (except top and bottom bar).:) Never mind. I started and coded the UI already separately/natively, but wanted to refactor to only maintain one UI instead of two. Took almost 2 weeks, and this was the last piece which is missing, everything else looks working, thats why its so annoying :)) But I might keep going this direction and use this screen only natively as suggested.

Thanks for your help anyway, and I am looking forward to have this fixed. :)
(p.s I beleive flutter had the very same issue before)

@brewin
Copy link

brewin commented May 17, 2024

Flutter's UIKitView has a gestureRecognizers property that allows customizing the gestures that are passed to the UIKit view.

https://api.flutter.dev/flutter/widgets/UiKitView/gestureRecognizers.html

For example, with the following setup vertical drags will not be dispatched to the UIKitview as the vertical drag gesture is claimed by the parent [GestureDetector].

GestureDetector(
  onVerticalDragStart: (DragStartDetails details) {},
  child: const UiKitView(
    viewType: 'webview',
  ),
)

@elijah-semyonov
Copy link
Contributor

elijah-semyonov commented May 21, 2024

Well, we can do that! The problem is, there is no way that is currently apparent to us, to conditionally allow touches to slip to the interop view gesture recognisers (such as compose scroll in a native scroll, for example).

The behavior in your example is possible by the usage of Modifier.draggable and using interactable = false in UIKitView arguments.

@dilip640
Copy link

facing same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ios uikit interop
Projects
None yet
Development

No branches or pull requests

4 participants