Skip to content

Instantly share code, notes, and snippets.

@eternityz
Last active July 12, 2024 02:15
Show Gist options
  • Save eternityz/c5ffe61f2c55278fb33253632e918cde to your computer and use it in GitHub Desktop.
Save eternityz/c5ffe61f2c55278fb33253632e918cde to your computer and use it in GitHub Desktop.
import SwiftUI
class Object: ObservableObject {
@Published var flag = false
init() {
print("object init")
}
}
struct DetailView: View {
@StateObject var object = Object()
var body: some View {
Text("\(object.flag)")
}
}
struct ContentView: View {
@State var showingFirst = false
@State var showingSecond = false
var body: some View {
NavigationStack {
ZStack {
Button("First") {
showingFirst = true
}
.sheet(isPresented: $showingFirst) {
NavigationStack {
// replace this ZStack with Form, List, issue exists.
// remove this ZStack, issue gone.
ZStack {
Button("Second") {
showingSecond = true
}
.sheet(isPresented: $showingSecond) {
DetailView()
}
}
} // 2nd NavigationStack
} // 1st sheet
} // ZStack
} // 1st NavigationStack
} // body
} // ContentView
#Preview {
ContentView()
}
@eternityz
Copy link
Author

Screen.Recording.2024-07-12.at.12.07.34.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment