Hi
How can we add multi view to NavigationPath in one go like in code below maybe using something like path.append(mobiles.all) ? where all 3 views of mobiles Array get added at once ?
Kindest Regards
`struct NavigationPathView: View {
var mobiles: [Mobiles] = [.init (name: "iPhone", imageName: "folder", color: .mint),
.init (name: "Samsung", imageName: "pin", color: .pink),
.init (name: "Mac Pro", imageName: "book", color: .gray)]
@State var path = NavigationPath()
var body: some View {
NavigationStack (path: $path) {
List {
Section ("Platforms") {
Button("Go To Platform") {
path.append(mobiles.first!)
}
Button("Go To Mobile") {
path.append(mobiles.last!)
}
Button("Add All Mobiles") {
}
}
}
}
.navigationDestination(for: Mobiles.self) {mobile in
ZStack {
mobile.color.ignoresSafeArea()
VStack {
Image(systemName: mobile.imageName)
Label (mobile.name, systemImage: mobile.imageName)
.font(.largeTitle).bold().foregroundColor(.white)
Button("Go Home") {
path.removeLast(path.count)
}
}
}
}
}
}