-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add LottieView.animationDidLoad API #2172
Conversation
@@ -6,7 +6,6 @@ import SwiftUI | |||
|
|||
// MARK: - AnimationPreviewView | |||
|
|||
/// TODO: Implement functionality from UIKit `AnimationPreviewViewController` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this since it's out of date (AnimationPreviewViewController
no longer exists)
@@ -15,7 +15,7 @@ | |||
<BuildableReference | |||
BuildableIdentifier = "primary" | |||
BlueprintIdentifier = "080DEF612A95707B00BE2D96" | |||
BuildableName = "Lottie_visionOS.framework" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Xcode did this automatically 🤷🏻
… called if you manually updated the animation in the underlying LottieAnimationView somehow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM @calda
This PR adds a new
animationDidLoad
API to the SwiftUILottieView
.LottieAnimationView
has ananimationLoaded
API, but its design makes it hard to use from SwiftUI. To support some specific implementation details of supporting bothLottieAnimation
andDotLottieFile
inLottieAnimationView
, the closure is called immediately when set ifanimation
isn't nil:This doesn't work well when paired with
.configure
, because a call like this will invokeanimationLoaded
every timeconfigure
is called (which is arbitrarily often):In retrospect this was a bad API choice (imo) and we would have been better off with an API more similar to how
LottieView
works withLottieAnimationSource
. Unfortunately we're stuck with this design onLottieAnimationView
due to backwards compatibility.To make this more obvious when using
LottieView
, lets just add a newanimationDidLoad
API with the expected semantics (only called after callinganimationView.loadAnimation(animationSource)
):