I'm not really sure what you're asking. If you want to know how to show a different view based on the current selection then you can see the ammended code below:
@State var selectedNavigationCategory: NavigationCategory?
let navigationCategories = [
NavigationCategory(id: UUID(), name: "One", sfSymbol: "circle"),
NavigationCategory(id: UUID(), name: "Two", sfSymbol: "circle.fill")
]
var body: some View {
NavigationSplitView {
List(navigationCategories, selection: $selectedNavigationCategory) { category in
NavigationLink(value: category) {
Label(category.name, systemImage: category.sfSymbol)
}
}
} detail: {
ZStack { // workaround in beta 2
if let selectedNavigationCategory {
// Something has been selected
// Show the corresponding view for this
Text("You selected \(selectedNavigationCategory.name)")
} else {
// Nothing is selected
// Placeholder text
Text("Select something")
}
}
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: