Created
October 23, 2022 23:01
-
-
Save Edudjr/81ca1e266427857ee656806edc5ada30 to your computer and use it in GitHub Desktop.
This file contains 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
extension View { | |
func animate(duration: CGFloat, _ execute: @escaping () -> Void) async { | |
await withCheckedContinuation { continuation in | |
withAnimation(.linear(duration: duration)) { | |
execute() | |
} | |
DispatchQueue.main.asyncAfter(deadline: .now() + duration) { | |
continuation.resume() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment