I am playing around with a Tinder-style interface. Right now I have the cards hard-coded in. I have an array of my Card objects. I would like to know how to populate the Zstack with an array or something more scalable(if you have any suggestions for that). I would also like to increment the .offset x and y values. I have searched all day and can't find anything on how to do any of this.
struct ContentView : View {
@State var cards = Array(repeating: NewCard(), count: 3)
var body: some View {
ZStack {
Image("plant")
.resizable()
ZStack {
ForEach(cards, id: \.id) { card in
card.offset(x: card.x, y: card.y)
}
// cards[2]
// .offset(x: -10, y: -20)
// cards[1]
// .offset(x: -5, y: -10)
// cards[0]
}
}
}
}