Post

Replies

Boosts

Views

Activity

Comment on SwiftUI NavigationLink with action in List
The reason it is on the link since the example was not clear is that the destination view may be different for each item. So it is not that all rows will go to a ViewB with different input params but in the ForEach based on data, it may be a ViewB or a ViewC or a ViewD, etc. And with the size of the project, some of these destinations live in a different module and are gotten via a nav resolution system not listed in the question. But to your point I think I understand a possibility like if I have ViewA (generated by a ForEach) and ViewB (a destination). struct ViewA: View { var body: some View { NavigationLink(destination: ViewB().onAppear { /* my custom action /* }) { /* row content */ } } } struct ViewB: View { var Body: some View { Text("You made it") .onAppear { /* destination custom logic unrelated to previous view */ } } } Something like that? and since the .onAppear modifiers are technically on different items (the ViewB vs the Text item) there would not be any conflict between the actions? (Edit: oof wish that was a code block and not inline for readability)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22