Post

Replies

Boosts

Views

Activity

How Does Freeform on visionOS Get A Larger Size Initial Window?
Hello community, I'm trying to open a window with larger than the original initial dimensions. Because the native Freeform app doing it just fine with wider-than-usual window dimensions. But I found on the documentation saying that "In visionOS, all windows open with the same initial dimensions." I tried to set a greater width on the window frame but there indeed seems to be a hard fixed max length on it since I can make the window to be smaller but not bigger programmatically. Am I doing something wrong or missing anything? What are your thoughts on how the larger window of Freeform even gets implemented? Or it could even not be a window for example might be a layered on a large reality view? Any input would be appreciated!
0
0
686
Jul ’23
Unable to Dismiss A Particular Window from WindowGroup
Hello guys, I'm working on a visionOS project and I defined a WindowGroup in the app structure file with an ID and accepting String as values because I'm not sure how many windows could be opened so couldn't hard code an ID for each window. Now I can open multiple windows by using openWindow(id: value:). What I expect to happen is that by using the dismissWindow(id: value:) function I could close a single window individually while others remain active. But when I click on the button to dismiss one particular window, nothing happens. I couldn't use the 0 opacity or hidden() method because that would still leave the bar below the bottom of the window visible. And I have to close the window programmatically, not manually tap on the close button. Below is the simplified files of my code. Any workaround or way to solve this issue would be greatly appreciated! Thank you in advance! // main structure file. import SwiftUI @main struct testerApp: App { @StateObject private var linkModel = LinkModel() var body: some Scene { WindowGroup { ContentView() .environmentObject(linkModel) } .windowStyle(.plain) WindowGroup(id: "MyWindow", for: String.self) { $windowID in WindowView(windowID: windowID ?? "") .environmentObject(linkModel) } .windowStyle(.plain) } } // model to save unique window IDs. import Foundation import Observation /// Using this observable to save for the IDs. @Observable class LinkModel: ObservableObject { var windowIDs = [String]() } // ContentView to open new windows, works as expected. import SwiftUI import RealityKit import RealityKitContent struct ContentView: View { @Environment(\.openWindow) private var openWindow @Environment(LinkModel.self) private var linkModel var body: some View { NavigationStack { VStack { /// By clicking this btn, a new window will be opened with its own unique id. Button { let id = UUID().uuidString linkModel.windowIDs.append(id) openWindow(id: "MyWindow", value: id) print("WINDOW ID: \(id)") } label: { Text("Open New Window") } } } } } // dismissWindow here DOESN'T WORK. import Foundation import SwiftUI struct WindowView: View { @Environment(\.dismissWindow) private var dismissWindow /// Each newly opened window has a unique window ID, used as value for closing this window later. let windowID: String var body: some View { NavigationStack { Text("Window ID: \(windowID)") /// Expect the window to be closed by clicking here but not responsive at all. Button { print("DISMISSING \(windowID)") dismissWindow(id: "MyWindow", value: windowID) } label: { Text("Dismiss Window") } Text("\nPlease check connection to the transmitter.") } } }
1
1
2.7k
Jul ’23