Menu navigation

Hello.

I've just started to learn Swift, SwiftUI programming, so lot of things that do not understand at the moment. First i tried to teach with SwiftUI tutorials, some things some things is understandable, some things very unusual for my 20+ years C/C++ programming experience.

I'd say that SwiftUI is one of the worse documented and usable that i saw in my carier.

So i'm trying to build using tutorials simple navigation secuence:

Main menu - some of items loaded in List, each item must navigate to different other pages. In Apple's examples they use NavigationLink and show new View of items (rows) of same type.

So i'm trying to find the way how to create other views of different type ofter tapping on List item.

I suppose that it is easy question, but i can not find even that answer in Apple's docs.

So may be someone can share example or link how to build View which works like i described?

Thanks,

Take the Button insteed.


You can also use the List with Navigation Links, but not on a ForEach loop.


Kind regards

DWD

Ok, thanks for reply. Apple's tutorial showed following example:


NavigationView {
List(landmarkData) { landmark in
NavigationLink(destination: LandmarkDetail(landmark: landmark)) {
LandmarkRow(landmark: landmark)
}
}
.navigationBarTitle(Text("Landmarks"))


In that case after tapping on list item it will create other View with same type and send element of same type to this View.

In my case i need to create Views of different type. Each item creates View of different type.

In case of others GUI frameworks i would receive id of tapped row of list and according this id create new window of correct type for example in switch block....but in that GUI framework i can not see how to do such things. All things is doing statically, no runtime checks...

Take a look on this thread


Greeds

DWD

Menu navigation
 
 
Q