Skip to content

Commit

Permalink
Merge pull request #44 from LottieFiles/feat/dotlottie-v2
Browse files Browse the repository at this point in the history
feat: dotlottie v2 specs support
  • Loading branch information
samuelOsborne authored Nov 20, 2024
2 parents d84ba19 + eda821b commit f2be1be
Show file tree
Hide file tree
Showing 11 changed files with 1,157 additions and 351 deletions.
35 changes: 26 additions & 9 deletions Sources/DotLottie/Public/DotLottieAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public final class DotLottieAnimation: ObservableObject {
segment: config.segments != nil ? [config.segments!.0, config.segments!.1] : [],
backgroundColor: 0,
layout: config.layout ?? createDefaultLayout(),
marker: config.marker ?? "")
marker: config.marker ?? "",
themeId: config.themeId ?? "")
self.player = Player(config: self.config)

if (config.width != nil || config.height != nil) {
Expand Down Expand Up @@ -472,6 +473,30 @@ public final class DotLottieAnimation: ObservableObject {
return pe
}

public func setSlots(_ slots: String) -> Bool {
player.setSlots(slots)
}

public func setTheme(_ themeId: String) -> Bool {
player.setTheme(themeId)
}

public func setThemeData(_ themeData: String) -> Bool {
player.setThemeData(themeData)
}

public func resetTheme() -> Bool {
player.resetTheme()
}

public func activeThemeId() -> String {
player.activeThemeId()
}

public func activeAnimationId() -> String {
player.activeAnimationId()
}

public func stateMachineSubscribe(oberserver: StateMachineObserver) -> Bool {
player.stateMachineSubscribe(oberserver: oberserver)
}
Expand Down Expand Up @@ -548,14 +573,6 @@ public final class DotLottieAnimation: ObservableObject {
player.setConfig(config: config)
}

public func loadTheme(themeId: String) -> Bool {
return player.loadTheme(themeId: themeId)
}

public func loadThemeData(themeData: String) -> Bool {
return player.loadThemeData(themeData: themeData)
}

public func resize(width: Int, height: Int) {
self.animationModel.width = width
self.animationModel.height = height
Expand Down
5 changes: 4 additions & 1 deletion Sources/DotLottie/Public/Models/AnimationConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public struct AnimationConfig {
public var height: Int? = 512
public var layout: Layout? = createDefaultLayout()
public var marker: String? = ""
public var themeId: String? = ""

public init(
autoplay: Bool? = false,
Expand All @@ -32,7 +33,8 @@ public struct AnimationConfig {
width: Int? = nil,
height: Int? = nil,
layout: Layout? = createDefaultLayout(),
marker: String? = nil
marker: String? = nil,
themeId: String? = nil
) {
self.autoplay = autoplay
self.loop = loop
Expand All @@ -45,5 +47,6 @@ public struct AnimationConfig {
self.height = height
self.layout = layout
self.marker = marker
self.themeId = themeId
}
}
32 changes: 24 additions & 8 deletions Sources/DotLottie/Public/Player.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,6 @@ class Player: ObservableObject {
dotLottiePlayer.totalFrames()
}

public func loadTheme(themeId: String) -> Bool {
dotLottiePlayer.loadTheme(themeId: themeId)
}

public func loadThemeData(themeData: String) -> Bool {
dotLottiePlayer.loadThemeData(themeData: themeData)
}

public func setFrame(no: Float32) -> Bool {
dotLottiePlayer.setFrame(no: no)
}
Expand Down Expand Up @@ -258,6 +250,30 @@ class Player: ObservableObject {
dotLottiePlayer.clear()
}

public func setSlots(_ slots: String) -> Bool {
dotLottiePlayer.setSlots(slots: slots);
}

public func setTheme(_ themeId: String) -> Bool {
dotLottiePlayer.setTheme(themeId: themeId)
}

public func setThemeData(_ themeData: String) -> Bool {
dotLottiePlayer.setThemeData(themeData: themeData)
}

public func resetTheme() -> Bool {
dotLottiePlayer.resetTheme();
}

public func activeThemeId() -> String {
dotLottiePlayer.activeThemeId()
}

public func activeAnimationId() -> String {
dotLottiePlayer.activeAnimationId()
}

public func setStateMachineNumericContext(key: String, value: Float) -> Bool {
dotLottiePlayer.setStateMachineNumericContext(key: key, value: value)
}
Expand Down
Loading

0 comments on commit f2be1be

Please sign in to comment.