Exploring visionOS: Creating Side Window for Main Window with Animation
var body: some Scene {
WindowGroup {
ContentView()
}
.windowStyle(.plain)
}
}
struct ContentView: View {
@State private var showSideWindow = false
var body: some View {
HStack {
VStack {
Text("Hello, world!")
.frame(maxWidth: .infinity, maxHeight: .infinity)
Button(action: {
showSideWindow.toggle()
}, label: {
Text("Show Side Window")
})
.padding()
}
.glassBackgroundEffect()
if showSideWindow {
VStack {
Model3D(named: "Scene", bundle: realityKitContentBundle)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
.frame(width: 400)
.glassBackgroundEffect()
.transition(.opacity)
}
}
.animation(.default, value: showSideWindow)
}
}