Skip to content
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

fix: re-add usage of self for older versions of Xcode with lower versions of Swift #1084

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# Node artifact files
node_modules/
dist/
.idea

# Yarn
.pnp.*
Expand All @@ -16,4 +17,4 @@ dist/
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
!.yarn/versions
TheRogue76 marked this conversation as resolved.
Show resolved Hide resolved
20 changes: 9 additions & 11 deletions packages/core/ios/LottieReactNative/ContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ class ContainerView: RCTView {
return { [weak self] animationFinished in
guard let self = self else { return }

if let onFinish = onAnimationFinish {
if let onFinish = self.onAnimationFinish {
onFinish(["isCancelled": !animationFinished])
}

delegate?.onAnimationFinish(isCancelled: !animationFinished);
self.delegate?.onAnimationFinish(isCancelled: !animationFinished);
};
}

@objc var failureCallback: (_ error: String) -> Void {
return { [weak self] error in
guard let self = self else { return }

if let onFinish = onAnimationFailure {
if let onFinish = self.onAnimationFailure {
onFinish(["error": error])
}

delegate?.onAnimationFailure(error: error)
self.delegate?.onAnimationFailure(error: error)
};
}

Expand Down Expand Up @@ -184,9 +184,7 @@ class ContainerView: RCTView {
url = URL(fileURLWithPath: newSourceURLString, relativeTo: Bundle.main.resourceURL)
}

guard let url = url else {
return
}
guard let url = url else { return }

self.fetchRemoteAnimation(from: url)
}
Expand Down Expand Up @@ -337,12 +335,12 @@ class ContainerView: RCTView {
guard let self = self else { return }

if let error = error {
failureCallback("Unable to fetch the Lottie animation from the URL: \(error.localizedDescription)")
self.failureCallback("Unable to fetch the Lottie animation from the URL: \(error.localizedDescription)")
return
}

guard let data = data else {
failureCallback("No data received for the Lottie animation from the URL.")
self.failureCallback("No data received for the Lottie animation from the URL.")
return
}

Expand All @@ -357,10 +355,10 @@ class ContainerView: RCTView {
configuration: lottieConfiguration
)

replaceAnimationView(next: nextAnimationView)
self.replaceAnimationView(next: nextAnimationView)
}
} catch {
failureCallback("Unable to decode the Lottie animation object from the fetched URL source: \(error.localizedDescription)")
self.failureCallback("Unable to decode the Lottie animation object from the fetched URL source: \(error.localizedDescription)")
}
}.resume()
}
Expand Down