Created
February 1, 2022 09:07
-
-
Save SarahAlsharif/bfbb1d1f150acd609e06bf7a2edf6bfc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here you go -> https://gist.github.com/SarahAlsharif/83f3cb0c0cac11478bc9cfc424ac82d4