Skip to content

Instantly share code, notes, and snippets.

@huwr
Last active March 23, 2023 04:09
Show Gist options
  • Save huwr/f588cd448d8064a8505df6801e93b3a6 to your computer and use it in GitHub Desktop.
Save huwr/f588cd448d8064a8505df6801e93b3a6 to your computer and use it in GitHub Desktop.
FB12076468
import SwiftUI
/*
In Xcode 14.3 RC1, running against iOS 16.4:
When you run this app, the first and second screens show fine. When you tap the last "Third Presentation" button, the last
screen should slide on.
For some reason, if you have the last few lines uncommented (the ones which mention SFSafariViewController, when you
tap the "Third Presentation" button, the app locks up and the CPU goes to 100%.
Another way to fix it is to remove the 'SecondScreen' view's @Environment(\.dismiss)
*/
@main
struct NavFunApp: App {
@State var presenting: Bool = false
var body: some Scene {
WindowGroup {
NavigationStack {
Button("Show Product list", action: { presenting = true })
.navigationDestination(
isPresented: $presenting,
destination: {
SecondScreen(model: .init())
}
)
}
}
}
}
final class SecondScreenModel: ObservableObject {
@Published var presenting: Bool = false
}
struct SecondScreen: View {
@Environment(\.dismiss) var dismiss
@ObservedObject var model: SecondScreenModel
var body: some View {
Button("Third Presentation!", action: { model.presenting = true })
.navigationDestination(
isPresented: $model.presenting,
destination: { Text("It's working") }
)
}
}
/**
UNCOMMENT BELOW TO BREAK `Third Presentation` BUTTON
*/
import SafariServices
struct SomeThing {
func getSpecial() -> SFSafariViewController {
SFSafariViewController(url: URL(string: "https://example.com")!)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment