Files
divkit/client/ios/DivKitExtensions/Animations/AnimationBlockView.swift
T
morevsavva 52ccd56888 Format files by codestyle.
Прогнал форматтер на всех файлах.
2022-12-22 16:21:24 +03:00

54 lines
1.2 KiB
Swift

import UIKit
import CommonCore
import LayoutKit
final class AnimationBlockView: BlockView {
var animatableView: AnimatableView? {
didSet {
if let animatablView = animatableView {
oldValue?.removeFromSuperview()
addSubview(animatablView)
}
}
}
private var animationRequest: Cancellable?
var animationHolder: AnimationHolder? {
didSet {
animationRequest?.cancel()
let newValue = animationHolder
animationRequest = animationHolder?
.requestAnimationWithCompletion { [weak self] animationSource in
guard let self = self,
newValue === self.animationHolder,
let animationSource = animationSource else {
return
}
self.animatableView?.setSource(animationSource)
self.animatableView?.play()
}
}
}
init() {
super.init(frame: .zero)
}
override func layoutSubviews() {
super.layoutSubviews()
animatableView?.frame = bounds
}
@available(*, unavailable)
required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
let effectiveBackgroundColor: UIColor? = nil
}
extension AnimationBlockView: VisibleBoundsTrackingLeaf {}