Post

Replies

Boosts

Views

Activity

Reply to SwiftUI NavigationLink in List with subviews
Sorry, I was trying to make the example as easy to follow as possible, apparently that backfired. Here's more code: Root view: struct ContentView { var body: some View { List { NavigationLink(destination: AnimalListView()) { SummaryView() } } } } Summary view: struct SummaryView { var body: some View { HStack { VStack { Text("24") Text("Dogs") } } HStack { VStack { Text("24") Text("Cats") } } } } AnimalListView: struct AnimalListView { enum AnimalType { case cat case dog case allAnimals } @State var animalType: AnimalType var body: some View { // list animals of selected type } } By filter already set, I mean that I want to have animalType set to .allAnimals if the user taps on the row background, or a specific animal type if the user taps on the Text items in the summaryView. ie, the user taps on "24 Dogs", so the detail view should filter on .dog Your third point is the basically the essence of my question. What is a sensible way to get the info of what the user tapped from SummaryView up into my ContentView so that the information can be used to set the filter when navigating to the AnimalListView?
Jan ’21
Reply to Can I disable the New Document menu item without losing the Open menu item as well?
I think I have found my own answer now. If you only define document types in your Info.plist with a CFBundleTypeRole of Viewer, then create your DocumentGroup like so: DocumentGroup(viewing: MyDocument.self) { file in ContentView(document: file.$document) } (Note the viewing label rather than newDocument) Then your File menu will have the New item automatically disabled as there are no types defined which can create a document.
Nov ’21