Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save SarahAlsharif/bfbb1d1f150acd609e06bf7a2edf6bfc to your computer and use it in GitHub Desktop.

Select an option

Save SarahAlsharif/bfbb1d1f150acd609e06bf7a2edf6bfc to your computer and use it in GitHub Desktop.
struct ContentView: View {
@State var likes :[LikeView] = []
func likeAction () {
likes += [LikeView()]
}
var body: some View {
ZStack {
Color.black.ignoresSafeArea()
ZStack {
Image(systemName: "heart")
.resizable()
.frame(width: 50, height: 50)
.padding()
.onTapGesture {
likeAction()
}
likesPile()
.offset(y: -30)
ForEach (likes) { like in
like.image.resizable()
.frame(width: 50, height: 50)
.modifier(LikeTapModifier())
.padding()
.id(like.id)
}.onChange(of: likes) { newValue in
if likes.count > 5 {
likes.removeFirst()
}
}
}.foregroundColor(.white.opacity(0.5))
.offset(x: 0, y: 60)
}
}
}
struct LikeView : Identifiable, Equatable {
let image = Image(systemName: "heart.fill")
let id = UUID()
}
@SarahAlsharif
Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment