elai950 / AlertToast

Create Apple-like alerts & toasts using SwiftUI
https://elai950.github.io/AlertToast/
MIT License
2.08k stars 187 forks source link

Popover cuts off `.hud` alert #64

Open nouun opened 1 year ago

nouun commented 1 year ago

Describe the bug Using .hud in a popover causes the top of it to be cut off.

To Reproduce

struct ContentView: View {
    @State var showPopover = false
    @State var showToast = false

    var body: some View {
        Button("Show Popover") {
            self.showPopover.toggle()
        }
        .popover(isPresented: self.$showPopover) {
            List {
                Button("Show Toast") {
                    self.showToast.toggle()
                }
            }
            .toast(isPresenting: self.$showToast) {
                AlertToast(displayMode: .hud, type: .regular, title: "Test")
            }
        }
    }
}

Expected behaviour The toast to be visible.

Screenshots

image
metedata commented 1 year ago

Same issue when using .hud on MacOS:

image
ImTheSquid commented 1 year ago

This is most likely due to an implementation decision to reference the device's full screen bounds when positioning the toast instead of the presented view's bounds, so it can't take into account anything like sheets or title bars. As far as I know, to fix this you'd need to use an anchor/root view to handle all toast requests, I may work on a PR for this if I get time or fork it off into a separate library.

ImTheSquid commented 1 year ago

Made it.

XuWeinan123 commented 1 year ago

may be the same problem? WX20230824-204951@2x toast overlap the navigationTitle

kaanselhep commented 5 months ago

This is most likely due to an implementation decision to reference the device's full screen bounds when positioning the toast instead of the presented view's bounds, so it can't take into account anything like sheets or title bars. As far as I know, to fix this you'd need to use an anchor/root view to handle all toast requests, I may work on a PR for this if I get time or fork it off into a separate library.

Hi, I checked out your package to test out if the sheet issue is fixed (AlertToast not completely visible when the view is shown as a sheet) but when I added the .toast modifier on the NavigationStack, it doesn't display it at all. Were you able to fix it? Am I doing something wrong?