I want to use Foreach and NavigationLink with SfSymbol for menu where each rectangle comes out SFSymbol differently and be able to link to the different View.
HStack()
{
ForEach(MockData.items)
{item in
//NavigationLink(
RoundedRectangle(cornerRadius: 10 )
.frame(width: 70, height: 70)
.foregroundStyle(item.color.gradient)
}
}//scrollview
//opciones
}//cierre del VStack
.padding(.top, 20)
.padding(.leading)
Spacer()
}//cierre Zstack
} //cierre de Zstack
.navigationTitle("Caracteristicas")
.toolbar{
ToolbarItem(placement: .navigationBarLeading)
{
Button(action:{},
label: {
Image(systemName: "switch.2")})
}
ToolbarItem(placement: .navigationBarTrailing)
{
Button(action:{},
label: {Image(systemName: "person.circle")})
}
}//toolBar
.accentColor(.red)
}
}
}
struct Item: Identifiable {
let id = UUID()
let color: Color
let image: String
}
struct MockData {
static var items = [Item(color: .red, image:"heart" ),
Item(color: .blue, image:"pill"),
Item(color: .orange, image: "syringe"),
Item(color: .green, image:"microbe"),
Item(color:.purple, image: "allergens")]
}
I need help figuring out how to do it.