Files
divkit/client/ios/DivKitExtensions/Animations/Rive/RiveAnimationBlock.swift
T
babaevmm 956c055cd8 update swiftformat, add organize rule
commit_hash:0f7ba811b37db6d2a9fc05efe5f94502feda4856
2025-08-04 16:24:48 +03:00

66 lines
1.6 KiB
Swift

#if os(iOS)
import Foundation
import LayoutKit
import VGSL
public final class RiveAnimationBlock: BlockWithTraits {
public let widthTrait: LayoutTrait
public let heightTrait: LayoutTrait
let animationHolder: AnimationHolder
let animatableView: Lazy<AsyncSourceAnimatableView>
public var debugDescription: String {
"Sized Animation Block is playing animation with \(animationHolder)"
}
public var intrinsicContentWidth: CGFloat {
switch widthTrait {
case let .fixed(value):
value
case let .intrinsic(_, minSize, _):
minSize
case .weighted:
0
}
}
public init(
animationHolder: AnimationHolder,
animatableView: Lazy<AsyncSourceAnimatableView>,
widthTrait: LayoutTrait,
heightTrait: LayoutTrait
) {
self.animationHolder = animationHolder
self.animatableView = animatableView
self.widthTrait = widthTrait
self.heightTrait = heightTrait
}
public func intrinsicContentHeight(forWidth _: CGFloat) -> CGFloat {
switch heightTrait {
case let .fixed(value):
value
case let .intrinsic(_, minSize, _):
minSize
case .weighted:
0
}
}
public func equals(_ other: Block) -> Bool {
guard let other = other as? RiveAnimationBlock else {
return false
}
return self.widthTrait == other.widthTrait &&
self.heightTrait == other.heightTrait &&
self.animationHolder == other.animationHolder
}
public func getImageHolders() -> [ImageHolder] { [] }
}
extension RiveAnimationBlock: LayoutCachingDefaultImpl {}
extension RiveAnimationBlock: ElementStateUpdatingDefaultImpl {}
#endif