Hello, I'm trying to mock up a simple UI for a typical Mac app with a sidebar and a content area.
Starting from the SwiftUI Xcode template, I got this far:
struct ContentView : View {
var body: some View {
HSplitView() {
List() {
Text("Sidebar")
Text("Sidebar")
Text("Sidebar")
Text("Sidebar")
}
List() {
Text("Content")
Text("Content")
Text("Content")
Text("Content")
}
}
.frame(minWidth: 100, maxWidth: .infinity, minHeight: 100, maxHeight: .infinity, alignment: .topLeading)
}
}Two big issues so far:
1. The top-level HSplitView does not resize with the window. It remains at the size it is created when the app launches, regardless of how you resize the window. Does the NSHostingView need to have an autoresizing mask or layout constraints? (It doesn't come with any in the Xcode template.)
2. I can't seem to make the two subviews of the splitView resizable by the splitter, even if I give them frame() modifiers.
Since this API is so new, I can't find any examples online.
Has anyone successfully made a macOS app in SwiftUI that has typical sidebar/content splitView that resizes with the window, and whose subviews can be resized by dragging the spliiter?
Thanks!