From 9847cbf574d99ec28a3639987482b08830c481d6 Mon Sep 17 00:00:00 2001 From: samuelOsborne Date: Thu, 28 Nov 2024 13:10:08 +0100 Subject: [PATCH 1/2] feat: added init method from data for dotLottie files. --- Sources/DotLottie/Public/DotLottieAnimation.swift | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Sources/DotLottie/Public/DotLottieAnimation.swift b/Sources/DotLottie/Public/DotLottieAnimation.swift index 473b2cf..a2a498d 100644 --- a/Sources/DotLottie/Public/DotLottieAnimation.swift +++ b/Sources/DotLottie/Public/DotLottieAnimation.swift @@ -71,6 +71,18 @@ public final class DotLottieAnimation: ObservableObject { } } + /// Load a .lottie file from Data. + public convenience init( + dotLottieData: Data, + config: AnimationConfig + ) { + self.init(config: config) { + try $0.loadDotLottie(data: dotLottieData) + } errorMessage: { error in + "Failed to load dotLottie. Failed with error: \(error)" + } + } + @_disfavoredOverload @available(*, deprecated) public convenience init( @@ -181,7 +193,7 @@ public final class DotLottieAnimation: ObservableObject { } /// Passes the .lottie Data to the Core - private func loadDotLottie(data: Data) throws { + public func loadDotLottie(data: Data) throws { do { try player.loadDotlottieData(data: data) From ef9853820c81d8ed28b20bd55b11c5b69958eaff Mon Sep 17 00:00:00 2001 From: samuelOsborne Date: Thu, 28 Nov 2024 13:11:36 +0100 Subject: [PATCH 2/2] chore: removed public loader --- Sources/DotLottie/Public/DotLottieAnimation.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/DotLottie/Public/DotLottieAnimation.swift b/Sources/DotLottie/Public/DotLottieAnimation.swift index a2a498d..d0e6276 100644 --- a/Sources/DotLottie/Public/DotLottieAnimation.swift +++ b/Sources/DotLottie/Public/DotLottieAnimation.swift @@ -193,7 +193,7 @@ public final class DotLottieAnimation: ObservableObject { } /// Passes the .lottie Data to the Core - public func loadDotLottie(data: Data) throws { + private func loadDotLottie(data: Data) throws { do { try player.loadDotlottieData(data: data)