Last active
July 12, 2024 02:15
-
-
Save eternityz/c5ffe61f2c55278fb33253632e918cde to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Screen.Recording.2024-07-12.at.12.07.34.mp4