Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
[FEAT] Added public init for manifest and animation. Added extra anim…
Browse files Browse the repository at this point in the history
…ation parameters
  • Loading branch information
eharrison committed Apr 23, 2022
1 parent b84cf3e commit 71c3f94
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
19 changes: 17 additions & 2 deletions Sources/dotLottieLoader/DotLottieAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import Foundation

public struct DotLottieAnimation: Codable {
/// Id of Animation
public var id: String

/// Loop enabled
public var loop: Bool

Expand All @@ -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
}
}
2 changes: 1 addition & 1 deletion Sources/dotLottieLoader/DotLottieCreator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions Sources/dotLottieLoader/DotLottieManifest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

/*
Expand Down

0 comments on commit 71c3f94

Please sign in to comment.