I get 3 errors:
Referencing initializer 'init(_:content:)' on 'ForEach' requires that 'NavigationLink<VStack<TupleView<(some View, Text)>>, itemDetail>' conform to 'TableRowContent'
And
Static method 'buildBlock' requires that 'NavigationLink<VStack<TupleView<(some View, Text)>>, itemDetail>' conform to 'TableRowContent'
Both errors are at the ForEach Loop
And the third one is at the VStack
Contextual closure type '() -> TupleView<(some View, Text)>' expects 0 arguments, but 1 was used in closure body
(Im new to Swift/SwiftUI)
struct ContentView: View {
private let gridItems = [GridItem(.flexible()), GridItem(.flexible())]
@EnvironmentObject private var vm: LocationsViewModel
var body: some View {
NavigationView {
ScrollView(showsIndicators: false) {
LazyVGrid (columns: gridItems, spacing: 15) {
ForEach(vm.locations) {
NavigationLink (destination: itemDetail()) {
VStack {
Image($0.img)
.resizable()
.scaledToFit()
.cornerRadius(15)
.padding(3.0)
Text($0.name)
}
}
}.navigationTitle("Title")
}
}
}
}
}
Thanks for any help