I guess I've solved my question as follows.
import SwiftUI
struct ContentView: View {
@ObservedObject var monster: MonsterObservable
var body: some View {
GeometryReader { geo in
ZStack {
HStack(spacing: 0.0) {
LeftView()
.frame(width: geo.size.width / 2.0, height: geo.size.height, alignment: .leading)
RightView(showMe: $monster.showDialog)
.frame(width: geo.size.width / 2.0, height: geo.size.height, alignment: .trailing)
}
ShowDialogView(isShowing: monster.showDialog) {
}
.frame(width: 500, height: 600, alignment: .center)
.cornerRadius(10.0)
}
}
}
}
class MonsterObservable: ObservableObject {
@Published var showDialog = false
}
import SwiftUI
struct RightView: View {
@Binding var showMe: Bool
var body: some View {
ZStack {
Color.red
Button {
showMe = true
} label: {
Text("Tap me")
.font(.largeTitle)
}
}
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: