Last active
September 21, 2021 22:52
-
-
Save SarahAlsharif/390f41717b17b8278a990d81031a04e8 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 ParticlesModifier: ViewModifier { | |
| @State var time = 0.0 | |
| @State var scale = 0.1 | |
| let duration = 5.0 | |
| func body(content: Content) -> some View { | |
| ZStack { | |
| ForEach(0..<80, id: \.self) { index in | |
| content | |
| .hueRotation(Angle(degrees: time * 80)) | |
| .scaleEffect(scale) | |
| .modifier(FireworkParticlesGeometryEffect(time: time)) | |
| .opacity(((duration-time) / duration)) | |
| } | |
| } | |
| .onAppear { | |
| withAnimation (.easeOut(duration: duration)) { | |
| self.time = duration | |
| self.scale = 1.0 | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment