i want to implement switching to another view by clicking on an item in LazyGrid. how can i do it? i attach my code from LazyGrid
As far as I understand, it should be done with NavigationLink and onTapGesture, but I’m not sure how exactly to do it. I’ve tried different tutorials, but I’m not quite sure how I can combine them with my code
struct LazyGridView: View {
let columns = Array(repeating: GridItem(.flexible(minimum: 20)), count: 3)
var body: some View {
ScrollView{
LazyVGrid(columns: columns) {
ForEach(MockData.colors, id: .self) {
RoundedRectangle(cornerRadius: 10)
.fill($0.gradient)
.frame(height: 110)
.contextMenu{
Button("Edit item"){
}
Button("Delete item"){
}
}
}
}
.padding()
}
}
}