I'm creating a settings view that lists "libraries" you can select.
My main question is, how do you space the right-hand side view to be something like the (second) screenshot I attached below? It should essentially push the buttons and list to the left side, making the right side view use all the space there is. The current setup I'm working with is like so:
struct LibrarySettingsView: View {
@State private var libraryInstallations = [Library]()
@State private var selectedListItem: Library?
// ... (constants)
var body: some View {
Form {
HStack {
VStack {
Button("Add library...", action: /* addLibrary */)
Button("Remove", action: /* removeLibrary */)
.disabled(selectedListItem == nil)
Spacer()
}
List(selection: $selectedListItem) {
ForEach(libraryInstallations) { library in
Text(library.name)
.tag(library)
}
}
.border(SeparatorShapeStyle())
VStack {
// I'd guess a NavigationLink would be the better option right here
// as it would be more "native" with the examples I've already seen
if selectedListItem != nil {
// ... (view)
} else {
Text("No Item Selected")
}
}
}
}
.frame(width: 300)
}
// ... (functions)
}
(I removed a few irrelevant options.)
The style I'd like to go for is something like this, with the right side utilising the entire rest of the view. (Bonus: is there a native way to add this sort of "embed" around the right-hand side content?):