Git Product home page Git Product logo

Comments (6)

raysarebest avatar raysarebest commented on May 19, 2024 2

Rendering a GeometryReader as a background of the Button and making the popover a modifier of a Spacer in the GeometryReader and setting its excludedFrames to contain the GeometryReader's frame in the .global coordinate space did the trick for me

Button("Present popover!") {
    present.toggle()
}
.background(
    GeometryReader { geometry in
        Spacer()
            .popover(present: $present, attributes: { attributes in
                attributes.dismissal.excludedFrames = {
                    return [geometry.frame(in: .global)]
                }
            }, view: {
                Text("Hi, I'm a popover.")
            })
    }
)

from popovers.

whuxujiyuan avatar whuxujiyuan commented on May 19, 2024 1
Button("Present popover!") {
    present.toggle()
}
.allowsHitTesting(!present)
.popover(present: $present) { 
    Text("Hi, I'm a popover.")
}

😂

from popovers.

tazmancoder avatar tazmancoder commented on May 19, 2024

I have found that using the following works for me.

This will dismiss the popover by tapping outside
$0.dismissal.mode = .tapOutside

I have also set an auto dismissal like this: You would attach this onAppear to the popover view
.onAppear { DispatchQueue.main.asyncAfter(deadline: .now() + 5, execute: { showPopoverHint.toggle() }) }

All this works for me.

from popovers.

aehlke avatar aehlke commented on May 19, 2024

This needs to be a lib function but thank you for the creative solution!

from popovers.

aheze avatar aheze commented on May 19, 2024

Nice idea and fix, thanks. Will see what I can do

from popovers.

aehlke avatar aehlke commented on May 19, 2024

Unfortunately I can't find a working solution for accomplishing this with List items and popovers activated by selection, because List first removes the selection before adding it again. I'm now doing it by detecting extremely quick close/reopen on the same item.

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.