我只想要图像上的链接。我不知道这是错误还是我的问题。我不知道这一点。任何想法都会受到赞赏
导入SwiftUI
struct ItemRow: View {
static let colors: [String: Color] = ["D": .purple, "G": .blue, "N": .red,"S": .green, "V": .black]
var item: MenuItem
var body: some View {
VStack {
NavigationLink(destination: ItemDetail(item: item)) {
Image(item.thumbnailImage)
.renderingMode(.original)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 320, height: 200)
.cornerRadius(20)
.shadow(color: .black, radius: 5, x: 5, y: 5)
}
HStack() {
Text(item.name)
.font(.headline)
Text("$\(item.price)")
}
HStack {
ForEach (item.restrictions, id: \.self) { restriction in
Text(restriction)
.font(.caption)
.fontWeight(.black)
.padding(5)
.background(Self.colors[restriction, default: .black])
.clipShape(Circle())
.foregroundColor(.white)
}
}
}
}
}
struct ItemRow_Previews: PreviewProvider {
static var previews: some View {
ItemRow(item: MenuItem.example)
}
}