AndreaMiotto / PartialSheet

A SwiftUI Partial Sheet fully customizable with dynamic height
https://github.com/AndreaMiotto/PartialSheet/wiki
MIT License
1.73k stars 194 forks source link

PartialSheet auto close when openURL in sheet content with `@Environment(\.scenePhase)` #162

Open Notsfsssf opened 2 years ago

Notsfsssf commented 2 years ago

When I add @Environment(\.scenePhase) var scenePhase,partialSheet will auto close and never show again

import SwiftUI
import PartialSheet

@main
struct nnonoApp: App {
    @State private var isPresented = false
    @Environment(\.openURL) private var openURL
    @Environment(\.scenePhase) var scenePhase // <-

    var body: some Scene {
        WindowGroup {
            ZStack {
                Rectangle().onTapGesture {
                    isPresented = true
                }.partialSheet(isPresented: $isPresented) {
                    Button {
                        openURL(URL(string: "https://github.com")!)
                    } label: {
                        Label("Get Help", systemImage: "person.fill.questionmark")
                    }

                }
            }.attachPartialSheetToRoot()
        }
    }
}

https://user-images.githubusercontent.com/16934707/179238498-38f0f43b-cef7-47f7-8b90-2dec6d2f6036.mp4