Skip to content

Instantly share code, notes, and snippets.

@lawreyios
Created May 14, 2020 14:57
Show Gist options
  • Save lawreyios/a509b72aaa867d9b97aeb88378e1219d to your computer and use it in GitHub Desktop.
Save lawreyios/a509b72aaa867d9b97aeb88378e1219d to your computer and use it in GitHub Desktop.
struct ContentView: View {
let itemsForSale = [
Item(id: 1, title: "Mask", price: 5.0, description: "A mask is an object normally worn on the face, typically for protection, disguise, performance, or entertainment. ... They are usually worn on the face, although they may also be positioned for effect elsewhere on the wearer's body", onSale: true),
Item(id: 2, title: "Sanitizer", price: 15.0, description: "Hand sanitiser, hand antiseptic, hand disinfectant, hand rub, handrub. Hand sanitizer is a liquid, gel, or foam generally used to decrease infectious agents on the hands.", onSale: false),
Item(id: 3, title: "Vitamin", price: 25.0, description: "Vitamins are nutrients your body needs to develop and function properly. There are 13 essential vitamins: A, D, E, and K, which are fat-soluble, and vitamins C and the B-complex group, which are water-soluble. Each vitamin has a distinct role in keeping you healthy.", onSale: false),
]
var body: some View {
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 25.0) {
ForEach(itemsForSale) { item in
CardView(title: item.title, description: item.description, price: item.price, isOnSale: item.onSale)
}
}
}
.background(Color.white)
.padding(14.0)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment