Giter VIP home page Giter VIP logo

Comments (37)

paskowski avatar paskowski commented on September 22, 2024 2

I can confirm that both 1.7.0-dev1727 and 1.7.0-dev1731 work correctly. I think I set an incorrect dependency's version yesterday, apologies for that. Thank you for fixing this, it's a real game changer @elijah-semyonov 🎉 .

from compose-multiplatform.

elijah-semyonov avatar elijah-semyonov commented on September 22, 2024 1

@yuroyami
We'll provide opt-out to previous behavior. Implementation is already there, just wait a bit for API addition.

from compose-multiplatform.

AttilaBarany avatar AttilaBarany commented on September 22, 2024 1

@elijah-semyonov the problem looks solved and perfect on published 1.7.0-alpha02. Thanks very much, now it acts how android does.

from compose-multiplatform.

elijah-semyonov avatar elijah-semyonov commented on September 22, 2024 1

@AttilaBarany
You are welcome. Please don't hesitate to post other issues and proposals on our issue tracker.

from compose-multiplatform.

brewin avatar brewin commented on September 22, 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")
        }
    }
}

from compose-multiplatform.

elijah-semyonov avatar elijah-semyonov commented on September 22, 2024

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.

from compose-multiplatform.

AttilaBarany avatar AttilaBarany commented on September 22, 2024

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).

from compose-multiplatform.

elijah-semyonov avatar elijah-semyonov commented on September 22, 2024

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

from compose-multiplatform.

AttilaBarany avatar AttilaBarany commented on September 22, 2024

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.

from compose-multiplatform.

elijah-semyonov avatar elijah-semyonov commented on September 22, 2024

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

from compose-multiplatform.

AttilaBarany avatar AttilaBarany commented on September 22, 2024

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)

from compose-multiplatform.

brewin avatar brewin commented on September 22, 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',
  ),
)

from compose-multiplatform.

elijah-semyonov avatar elijah-semyonov commented on September 22, 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.

from compose-multiplatform.

dilip640 avatar dilip640 commented on September 22, 2024

facing same issue

from compose-multiplatform.

vickyleu avatar vickyleu commented on September 22, 2024

same

from compose-multiplatform.

kavindudiyes avatar kavindudiyes commented on September 22, 2024

@elijah-semyonov could you please expand on your suggestion of "The behavior in your example is possible by the usage of Modifier.draggable and using interactable = false in UIKitView arguments.". I tried a few combinations of setting interactive = false and implementing draggable on the Modifier, without success. With interactive = false, scrolling is fine, but it doesn't register any click events as @brewin has pointed out above.

My use-case is to embed a Native Ad using Google AdMob, where the UIView for the Ad is coming from Swift for iOS. In the ideal case, I want to be able to scroll on top of the Ad, but still be able to click on the Ad.

from compose-multiplatform.

vickyleu avatar vickyleu commented on September 22, 2024

My solution is to turn off the touch event of UIView and unify the click penetration through the click event hitTest of compose to the rect of UIView.

For example, my UIView put a webview, and I need to click on the picture inside. I will first register a query of the coordinates of all pictures through js, get a set of rectangular arrays, and confirm that the picture is clicked by matching the array.

from compose-multiplatform.

elijah-semyonov avatar elijah-semyonov commented on September 22, 2024

Awaiting your feedback (and perhaps future issues) after these changes are released!
Track release notes for iOS 🌚

from compose-multiplatform.

okushnikov avatar okushnikov commented on September 22, 2024

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

from compose-multiplatform.

AttilaBarany avatar AttilaBarany commented on September 22, 2024

@elijah-semyonov I have imported 1.7.0-dev1727, But I do not experience any difference. The same lazycolumn which holds a wkwebview or a single uiview, does not scroll if the drag starts on the UIKitview (Modify.draggable also not triggered). But it does scroll with Androidview.

from compose-multiplatform.

paskowski avatar paskowski commented on September 22, 2024

I also see no difference when running 1.7.0-dev1727. In my case it's lazy column with UIKitView that has UITextField inside of it.

from compose-multiplatform.

elijah-semyonov avatar elijah-semyonov commented on September 22, 2024

@AttilaBarany @paskowski
You need to move a finger over the screen fast to recognise a scroll

from compose-multiplatform.

AttilaBarany avatar AttilaBarany commented on September 22, 2024

@AttilaBarany @paskowski You need to move a finger over the screen fast to recognise a scroll

Nothing happens. Slow, fast, long, short, delay...

Screenshot 2024-07-15 at 14 18 04

from compose-multiplatform.

brewin avatar brewin commented on September 22, 2024

I don’t think 1.7.0-dev1727 includes the changes. The next dev release will.

from compose-multiplatform.

AttilaBarany avatar AttilaBarany commented on September 22, 2024

I don’t think 1.7.0-dev1727 includes the changes. The next dev release will.

I got it from his commit linked in this issue above. JetBrains/compose-multiplatform-core@174766b

Screenshot 2024-07-15 at 14 45 49

from compose-multiplatform.

elijah-semyonov avatar elijah-semyonov commented on September 22, 2024

@AttilaBarany
Please provide a full repro project, I can't reproduce your behavior from a snippet:

val factory = remember {
    {
        UIView().apply {
            backgroundColor = UIColor.blueColor
            userInteractionEnabled = true
        }
    }
}

LazyColumn(modifier = Modifier.fillMaxSize()) {
    item {
        UIKitView(
            modifier = Modifier.fillMaxWidth().height(300.dp),
            factory = factory
        )
    }

    item {
        Box(Modifier.fillMaxWidth().height(1500.dp).background(Color.Red))
    }
}
Screen.Recording.2024-07-15.at.15.57.28.mov

from compose-multiplatform.

elijah-semyonov avatar elijah-semyonov commented on September 22, 2024

The logic is identical to UIScrollView now - if there is fast initial movement, gesture is recognised as scroll and dispatched accordingly. If there is no movement and hitTest is an interop view, it intercepts the touches and no scrolling will ever happen until touches sequence ends (all fingers are up)

from compose-multiplatform.

paskowski avatar paskowski commented on September 22, 2024

I agree with #4818 (comment) that https://github.com/JetBrains/compose-multiplatform/releases/tag/v1.7.0-dev1727 does not have the changes that were supposed to fix this issue.

from compose-multiplatform.

AttilaBarany avatar AttilaBarany commented on September 22, 2024

@elijah-semyonov The video looks very promising, thank you for testing and showing me the error maybe is in my setup!!! I had a mistake providing the library version. I have changed the lib to 1.7.0-dev1727, but the gradle was set to use the compose.plugin which had an earlier version set. After fixed (set the plugin version to 1.7.0-dev1727), or I thought I fixed, gradle does not want to sync:
Could not find org.jetbrains.compose.runtime:runtime:1.7.0-dev1727.
Required by:
project :shared

from compose-multiplatform.

AttilaBarany avatar AttilaBarany commented on September 22, 2024

@elijah-semyonov I got the versions sorted, I set 1.7.0-alpha01 whis is the latest, and the scroll still does not work. So @paskowski and @brewin are correct. The fix is still not included.

Screenshot 2024-07-15 at 20 37 04

from compose-multiplatform.

elijah-semyonov avatar elijah-semyonov commented on September 22, 2024

That's super awkward, CI shows that it was included in 1727. Anyway, let's w8 for other dev build and see if it flies.

from compose-multiplatform.

MatkovIvan avatar MatkovIvan commented on September 22, 2024

I got the versions sorted, I set 1.7.0-alpha01 whis is the latest,

1.7.0-dev1727 is newer than 1.7.0-alpha01. 1.7.0-alpha01 does not contain @elijah-semyonov 's fix, but dev1727 does. devXXXX is regular builds from master that are not uploaded to maven central (available only from dev one), so sorting is not really correct here. We might improve naming in the future, but now it is what it is.

from compose-multiplatform.

yuroyami avatar yuroyami commented on September 22, 2024

This broke one of the things that used to work fine. I am wrapping an (native iOS) eBook reader (which is basically a UIViewController) which internally responds to gestures, especially tap gestures. I am wrapping that UIViewController in Compose:

@OptIn(ExperimentalForeignApi::class)
@Composable
fun ReadiumViewport(c: UIViewController) {
    UIKitViewController(
            factory = { obtainReadiumController() },
            modifier = Modifier.fillMaxSize()
     )
}

It used to scroll, tap, pinch in/out fine, but now it's not responding to touches at all. It seems like Compose is preventing all gestures from propagating to the UIViewController itself. I am not sure why this is happening because I am not setting any external Compose tap listeners. All the gesture listening is happening internally inside the UIViewController itself.

from compose-multiplatform.

vickyleu avatar vickyleu commented on September 22, 2024

@elijah-semyonov I can confirm that compose 1.7.0 xxx has disrupted the scrolling event of webview in UIKitView, 1.6.11 work well
compose-webview-multiplatform

from compose-multiplatform.

elijah-semyonov avatar elijah-semyonov commented on September 22, 2024

You just need to hold your finger still for 150ms before scrolling.
An opt-out to previous behavior is in JetBrains/compose-multiplatform-core#1494

from compose-multiplatform.

mndsl avatar mndsl commented on September 22, 2024

I have tried all the 1.7xxx versions (dev too) and none of them works as expected. I'm using UIKitView to display PDFView, the view reacts to taps and double taps, but it's impossible to scroll the pages of the pdf documents. As other have mentioned, webview and MKMapView does not work either. Altogether, every view inside UIKitView, that needs to scroll can't scroll. There are no nested scrolls, nor click modifiers... 1.6.11 used to work perfectly, unfortunately we can't rollback to it as it has other bugs. Please fix this, it's vital part from a very large multiplatform app we are developing, and with this bug is impossible to publish the app.

from compose-multiplatform.

brewin avatar brewin commented on September 22, 2024

They are working on improving interop.

https://youtrack.jetbrains.com/issue/CMP-5875/iOS-interop-epic

from compose-multiplatform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.