Code Monkey home page Code Monkey logo

Comments (2)

raysarebest avatar raysarebest commented on June 17, 2024

I came to a partial solution for this an PRed it with #73, but that strictly supports cases where the view that's presented in the popover has its own properties defined with @State, @StateObject, @Binding, @ObservedObject, @Environment, or @EnvironmentObject properties

It seems that supporting the specific case originally laid out in this issue is pretty non-trivial, because the popover is rendered in its own UIHostingController, which means it's effectively an entirely different context from the code that presents the popover. This means that even though the code that presents the popover knows that the popover's view needs to be updated, the hosting controller that actually renders the popover has no clue

That has proved a rather difficult challenge to overcome. I've tried to no avail:

  • Hiding and re-presenting the popover on every render
  • Forcing the PopoverGestureContainer to re-lay out its subviews on every render
  • Creating a new PopoverGestureContainer and re-setting the popover's UIHostingController's rootView on every render

It seems that SwiftUI needs to expose an API for updating a UIHostingController whenever a related SwiftUI host re-renders its view, which doesn't seem to currently be possible. I wonder if it might be possible if we add the popover's hosting controller as a child of the source hosting controller, but that would require SwiftUI exposing a proper way to get a reference to the source hosting controller. Would love to see someone prove me wrong on either of those, though

from popovers.

aheze avatar aheze commented on June 17, 2024

I wonder if it might be possible if we add the popover's hosting controller as a child of the source hosting controller, but that would require SwiftUI exposing a proper way to get a reference to the source hosting controller.

Presenting the popover has been one of the hardest challenges since the start of this library. At first I was adding a new UIWindow, but that stole the status bar color (#5). And now it's been so long since I edited the code that I forgot what exactly I'm doing... so I'm working on a complete refactor right now

from popovers.

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.