Coder Social home page Coder Social logo

Limiting dragging area about lnpopupui HOT 23 CLOSED

leonatan avatar leonatan commented on August 17, 2024
Limiting dragging area

from lnpopupui.

Comments (23)

LeoNatan avatar LeoNatan commented on August 17, 2024 1

@svenoaks That's what I was thinking too. I will give it a go, and see if can be made to work.

from lnpopupui.

LeoNatan avatar LeoNatan commented on August 17, 2024 1

Implemented in 1.2.12

from lnpopupui.

LeoNatan avatar LeoNatan commented on August 17, 2024

Hello, can you please explain further what you are looking to do? This library uses my LNPopupFramewotk under the hood, which might have a solution. I just need to think how to integrate it with LNPopupUI.

from lnpopupui.

LeoNatan avatar LeoNatan commented on August 17, 2024

If I understand correctly, this is what would be useful in LNPopupController:

https://github.com/LeoNatan/LNPopupController/blob/c9683ef4da534a83cb9fe2481360a9c6ecf9b91f/LNPopupController/LNPopupController/UIViewController%2BLNPopupSupport.h#L96

Now the question is, how to design the SwiftUI API.

from lnpopupui.

iDevelopper avatar iDevelopper commented on August 17, 2024

Hello @LeoNatan ,

I don't think so.

@svenoaks would like to be able to limit the draggable area when the popup is open.

So I think he must be able to answer at:

gestureRecognizerShouldBegin(_:)

from lnpopupui.

LeoNatan avatar LeoNatan commented on August 17, 2024

It's possible to add a view and designate that for popup interaction. That sounds much more convenient to me than doing calculation in the gesture recognizer delegate.

from lnpopupui.

svenoaks avatar svenoaks commented on August 17, 2024

Hi, yes it would something like designate a view in the popup as the only one for interaction. As a workaround, I was trying to block the dragging from happening by adding highPriorityGestures to some views in the popup, but without success.

I have attached a screenshot of exactly what I mean.
Simulator Screen Shot - iPhone 12 Pro Max - 2021-06-06 at 08 26 23

from lnpopupui.

LeoNatan avatar LeoNatan commented on August 17, 2024

Suggestions for SwiftUI API are welcome.

from lnpopupui.

svenoaks avatar svenoaks commented on August 17, 2024

As an iOS noob, I'm not sure how possible or convenient it is, but could it just as simple as a View modifier that we place on one of the children of the popup? Like .popupInteractionView()

from lnpopupui.

LeoNatan avatar LeoNatan commented on August 17, 2024

Just make sure to read the note in the API header. You should set the interaction container to be a view that is at the back of the hierarchy, to prevent issues with blocking views underneath.

from lnpopupui.

svenoaks avatar svenoaks commented on August 17, 2024

Hi, thanks for doing it so quick. I can't get it to work though, it seems to either stop the interaction in the popup completely or not limit it at all depending on where I put the .popupInteractionContainer()

For example, here the entire popup is still able to be interacted with.

from lnpopupui.

LeoNatan avatar LeoNatan commented on August 17, 2024

Please provide a small demo project where it fails. It could be a limitation of the background modifier in SwiftUI, and so you might need to move the popup interaction container to the bottom or top of the call.

from lnpopupui.

svenoaks avatar svenoaks commented on August 17, 2024

The link above is the LNPopupUI demo app with it added

from lnpopupui.

LeoNatan avatar LeoNatan commented on August 17, 2024

I’ll try to see what’s going on soon.

from lnpopupui.

svenoaks avatar svenoaks commented on August 17, 2024

Hi, any progress on this? 🙏

from lnpopupui.

LeoNatan avatar LeoNatan commented on August 17, 2024

Sorry, not yet. Will look soon.

from lnpopupui.

LeoNatan avatar LeoNatan commented on August 17, 2024

Please test now. After my fix in 1.2.13, your example code behaves as expected.

from lnpopupui.

svenoaks avatar svenoaks commented on August 17, 2024

Thank you for continuing to work on this, I know you are probably busy with other things. If you wanted some compensation for your time for continuing to perfect this feature and also #8 you can email me at the email in my profile, let me know what your hourly rate would be.

A couple things I noticed:

  1. In the demo app I added a ScrollView to the player, when the ScrollView is at the top, the popup will be dragged back to the collapsed state, even though the popupInteractionContainer() on the View at the top of the screen should prevent this from happening.

  2. When popupInteractionContainer() is used, the popupBar no longer responds to dragging (except on the very bottom of it for some reason, possibly it's receiving gestures from the popupInteractionContainer below it). I feel like most use cases that use popupInteractionContainer() would still want the popupBar to be draggable.

from lnpopupui.

svenoaks avatar svenoaks commented on August 17, 2024

Edited the above demo app so the popupInteractionContainer() is no longer within the ScrollView to make the intention more clear.

from lnpopupui.

LeoNatan avatar LeoNatan commented on August 17, 2024

Regarding 1, I will not make a change. Scroll views are meant to interact with the framework. If your interaction view is inside a scroll view, it will not work as expected with the current implementation. It's a limitation with SwiftUI. Maybe will look to improve this in the future.

2 sounds like a bug. Does it reproduce in the above linked project?

from lnpopupui.

svenoaks avatar svenoaks commented on August 17, 2024

Regarding 1, I will not make a change. Scroll views are meant to interact with the framework. If your interaction view is inside a scroll view, it will not work as expected with the current implementation. It's a limitation with SwiftUI. Maybe will look to improve this in the future.

2 sounds like a bug. Does it reproduce in the above linked project?

In 1, the interaction view is not inside the ScrollView, the ScrollView is below the interaction view in the VStack. Not sure if it makes a difference for what you're saying about the limitation with SwiftUI, but wanted to point that out.

Yes 2, is happening with the demo app linked above.

from lnpopupui.

LeoNatan avatar LeoNatan commented on August 17, 2024

I changed the implementation recently so that the view is just a hint for the system where to limit the interaction area. The gesture recognizer is not actually added to that view. The reason is that in some cases the system does not send the gestures to the interaction view. So right now, I calculate where the interaction view's frame is in relation to the topmost content view, and limit interaction to that view only. You can see why this approach wouldn't work if the interaction view is in a scroll view.

Will take a look soon.

from lnpopupui.

LeoNatan avatar LeoNatan commented on August 17, 2024

2 should be fixed with latest LNPopupController.

from lnpopupui.

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.