Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions ios/DotlottieReactNativeViewManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import SwiftUI
@Published var animation: DotLottieAnimation?
var observer: DotLottieEventObserver?
var stateMachineObserver: DotLottieStateMachineObserver?

func createAnimation() {
// Clean up existing animation
cleanupAnimation()
Expand Down Expand Up @@ -128,7 +128,7 @@ import SwiftUI

// Unsubscribe state machine observer if it exists
if let stateMachineObserver = self.stateMachineObserver, let animation = self.animation {
_ = animation.stateMachineUnSubscribe(observer: stateMachineObserver)
_ = animation.stateMachineUnsubscribe(stateMachineObserver)
}

self.observer = nil
Expand Down Expand Up @@ -292,10 +292,10 @@ class DotlottieReactNativeViewManager: RCTViewManager {
return DotlottieReactNativeView()
}





@objc
func pause(_ node:NSNumber) {
DispatchQueue.main.async {
Expand All @@ -315,7 +315,7 @@ class DotlottieReactNativeViewManager: RCTViewManager {
}
}
}

@objc
func play(_ node:NSNumber) {
DispatchQueue.main.async {
Expand All @@ -327,23 +327,23 @@ class DotlottieReactNativeViewManager: RCTViewManager {
let _ = animation.play()
}
}

@objc
func setLoop(_ node:NSNumber, loop:Bool) {
DispatchQueue.main.async {
let dotLottieView = self.bridge.uiManager.view(forReactTag: node) as! DotlottieReactNativeView
_ = dotLottieView._animation?.setLoop(loop: loop)
}
}

@objc func setSpeed(_ node:NSNumber, speed:NSNumber) {
DispatchQueue.main.async {
let convertedSpeed = Float(truncating: speed)
let dotLottieView = self.bridge.uiManager.view(forReactTag: node) as! DotlottieReactNativeView
_ = dotLottieView._animation?.setSpeed(speed: convertedSpeed)
}
}

@objc func setFrame(_ node:NSNumber, frame:NSNumber) {
DispatchQueue.main.async {
let convertedFrame = Float(truncating: frame)
Expand Down Expand Up @@ -434,17 +434,17 @@ class DotlottieReactNativeViewManager: RCTViewManager {
try? dotLottieView._animation?.loadAnimationById(String(animationId))
}
}

@objc func setFrameInterpolation(_ node:NSNumber, useFrameInterpolation:Bool) {
DispatchQueue.main.async {
let dotLottieView = self.bridge.uiManager.view(forReactTag: node) as! DotlottieReactNativeView
_ = dotLottieView._animation?.setFrameInterpolation(useFrameInterpolation)
}
}

@objc func setPlayMode(_ node:NSNumber, mode:NSNumber) {
DispatchQueue.main.async {

let actualMode: Mode = {
switch mode {
case 0: return .forward
Expand All @@ -455,29 +455,29 @@ class DotlottieReactNativeViewManager: RCTViewManager {
return .forward
}
}()

let dotLottieView = self.bridge.uiManager.view(forReactTag: node) as! DotlottieReactNativeView
_ = dotLottieView._animation?.setMode(mode: actualMode)
}
}

@objc func setMarker(_ node:NSNumber, marker:NSString) {
DispatchQueue.main.async {
let dotLottieView = self.bridge.uiManager.view(forReactTag: node) as! DotlottieReactNativeView
_ = dotLottieView._animation?.setMarker(marker: String(marker))
}
}

@objc func resize(_ node:NSNumber, width:NSNumber, height:NSNumber) {
DispatchQueue.main.async {
let dotLottieView = self.bridge.uiManager.view(forReactTag: node) as! DotlottieReactNativeView
_ = dotLottieView._animation?.resize(width: Int(truncating: width), height: Int(truncating: height))
}
}




@objc override static func requiresMainQueueSetup() -> Bool {
return true
}
Expand Down Expand Up @@ -655,7 +655,7 @@ class DotlottieReactNativeView: UIView {
}
}
}

@objc var speed: NSNumber = 1 {
didSet {
performIfActive {
Expand Down Expand Up @@ -755,20 +755,20 @@ class DotlottieReactNativeView: UIView {
dataStore.onPlay = onPlay
}
}

@objc var onLoop: RCTDirectEventBlock = {_ in} {
didSet{
dataStore.onLoop = onLoop
}
}


@objc var onLoadError: RCTDirectEventBlock = {_ in} {
didSet{
dataStore.onLoadError = onLoadError
}
}

@objc var onLoad: RCTDirectEventBlock = {_ in} {
didSet{
dataStore.onLoad = onLoad
Expand Down
Loading