Created
February 9, 2022 09:56
-
-
Save SarahAlsharif/83f3cb0c0cac11478bc9cfc424ac82d4 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 likesPile : View { | |
@State var likes :[LikeView] = [] | |
let timer = Timer.publish(every: 0.3, on: .main, in: .common).autoconnect() | |
var body: some View { | |
ZStack { | |
ForEach(likes) { like in | |
like.image | |
.resizable() | |
.frame(width: 50, height: 50) | |
.opacity(0.5) | |
.modifier(LikesModifier()) | |
.padding() | |
} | |
}.onReceive(timer) { value in | |
if likes.count > 5 { | |
likes += [LikeView()] | |
likes.removeFirst() | |
} else { | |
likes += [LikeView()] | |
} | |
} | |
} | |
} |
You're welcome. Here is LikesModifier() : https://gist.github.com/SarahAlsharif/5acd0fb007069ba87ff487b78d1c15c8
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!
But now where can I find the
LikesModifier()
?