Reputation: 1
Question:
I have contentview, through content view i open Test View.. When Action performed in TestView i need to get call back to contentview?
Main View
@main
struct DemoApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
Window("test", id: Test.self) { $test in
TestView(test)
}
}
}
Content View
struct ContentView: View {
@Environment(.openWindow) private var openWindow
var body: some View {
Button {
openWindow(id: "test", for: Test(name: "Window"))
} label: {
Text("open text")
}
}
}
TestView
struct TestView: View {
let test: Test
@Environment(.dismiss) var dismiss
var body: some View {
Button {
// When this button is clicked i need to send the, button clicked to content view
} label: {
Text("RECHECK")
}
}
}
Test Model
struct Test {
let name: String
}
Expected Result:
How to Send Closure or any call from the new window to the main window?
Upvotes: 0
Views: 61