-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(targets): update lottie-ios to 3.1.1 (#203)
- Loading branch information
Showing
19 changed files
with
176 additions
and
284 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
64 changes: 64 additions & 0 deletions
64
packages/targets/sources/ios/bindings/Lottie+AnimationView.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import Foundation | ||
import Lottie | ||
|
||
/** | ||
An error that occurred when attempting to load a `Lottie` object in a `LOTAnimationView`. | ||
*/ | ||
public enum LottieError: Error, CustomDebugStringConvertible { | ||
case invalidURL | ||
case requestFailed(Error?) | ||
case deserializationError(Data, Error) | ||
case invalidType(json: Any) | ||
|
||
public var debugDescription: String { | ||
switch self { | ||
case .invalidURL: | ||
return "Lottie URL is invalid." | ||
case .requestFailed(let error): | ||
return "Request failed: \(String(describing: error))" | ||
case .deserializationError(let data, let error): | ||
let dataAsString = String(data: data, encoding: String.Encoding.utf8) | ||
return "Lottie file failed to be deserialized: \(error)\n\(String(describing: dataAsString))" | ||
case .invalidType(let json): | ||
return "JSON was not in the correct format ([AnyHashable: Any]): \(json)" | ||
} | ||
} | ||
} | ||
|
||
extension AnimationView { | ||
/** | ||
A closure to be called when loading a `Lottie` animation has completed with a value that represents whether the animation was loaded successfully. | ||
*/ | ||
public typealias LoadCompletion = (Bool) -> Void | ||
|
||
/** | ||
Loads the provided `Lottie` animation. | ||
*/ | ||
@objc(dez_loadLottie:completion:) | ||
public func load(_ lottie: Lottie, completion: LoadCompletion? = nil) { | ||
// TODO: Add a parameter that allows a fade in animated and add a description of the parameter to doc comment. | ||
// TODO: Should this be synchronous when resource is local? | ||
guard let url = lottie.url else { | ||
completion?(false) | ||
return | ||
} | ||
|
||
Animation.loadedFrom(url: url, closure: { [weak self] animation in | ||
guard let self = self else { return } | ||
|
||
guard let animation = animation else { | ||
completion?(false) | ||
return | ||
} | ||
|
||
self.animation = animation | ||
self.loopMode = lottie.loop ? .loop : .playOnce | ||
|
||
if lottie.autoplay { | ||
self.play() | ||
} | ||
|
||
completion?(true) | ||
}, animationCache: nil) | ||
} | ||
} |
116 changes: 0 additions & 116 deletions
116
packages/targets/sources/ios/bindings/Lottie+LOTAnimationView.swift
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.