From 71c3f9419943c472e5be939e6fdba8dcf4267039 Mon Sep 17 00:00:00 2001 From: Evandro Date: Sat, 23 Apr 2022 08:36:33 +0545 Subject: [PATCH] [FEAT] Added public init for manifest and animation. Added extra animation parameters --- .../dotLottieLoader/DotLottieAnimation.swift | 19 +++++++++++++++++-- .../dotLottieLoader/DotLottieCreator.swift | 2 +- .../dotLottieLoader/DotLottieManifest.swift | 6 ++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Sources/dotLottieLoader/DotLottieAnimation.swift b/Sources/dotLottieLoader/DotLottieAnimation.swift index 70568fa..71bc806 100644 --- a/Sources/dotLottieLoader/DotLottieAnimation.swift +++ b/Sources/dotLottieLoader/DotLottieAnimation.swift @@ -8,6 +8,9 @@ import Foundation public struct DotLottieAnimation: Codable { + /// Id of Animation + public var id: String + /// Loop enabled public var loop: Bool @@ -17,6 +20,18 @@ public struct DotLottieAnimation: Codable { /// Animation Playback Speed public var speed: Float - /// Id of Animation - public var id: String + /// 1 or -1 + public var direction: Int = 1 + + /// mode - "bounce" | "normal" + public var mode: String = "normal" + + public init(id: String, loop: Bool, themeColor: String, speed: Float, direction: Int = 1, mode: String = "normal") { + self.id = id + self.loop = loop + self.themeColor = themeColor + self.speed = speed + self.direction = direction + self.mode = mode + } } diff --git a/Sources/dotLottieLoader/DotLottieCreator.swift b/Sources/dotLottieLoader/DotLottieCreator.swift index 3d50345..a02ce80 100644 --- a/Sources/dotLottieLoader/DotLottieCreator.swift +++ b/Sources/dotLottieLoader/DotLottieCreator.swift @@ -115,7 +115,7 @@ public struct DotLottieCreator { /// - Throws: Error private func createManifest(completed: @escaping (Bool) -> Void) { let manifest = DotLottieManifest(animations: [ - DotLottieAnimation(loop: loop, themeColor: themeColor, speed: 1.0, id: fileName) + DotLottieAnimation(id: fileName, loop: loop, themeColor: themeColor, speed: 1.0) ], version: "1.0", author: "LottieFiles", generator: "LottieFiles dotLottieLoader-iOS 0.1.4") do { diff --git a/Sources/dotLottieLoader/DotLottieManifest.swift b/Sources/dotLottieLoader/DotLottieManifest.swift index 1979503..3e92f4f 100644 --- a/Sources/dotLottieLoader/DotLottieManifest.swift +++ b/Sources/dotLottieLoader/DotLottieManifest.swift @@ -39,6 +39,12 @@ public struct DotLottieManifest: Codable { return try? decode(from: data) } + public init(animations: [DotLottieAnimation], version: String, author: String, generator: String) { + self.animations = animations + self.version = version + self.author = author + self.generator = generator + } } /*