Files
divkit/client/ios/DivKitExtensions/Animations/AnimationBlockView+UIViewRenderableBlock.swift
T
pkurchatov 27a3472171 Enabled blankLinesBetweenImports swiftformat rule
commit_hash:84ea24cbdf21ef89741080f38ec5e583172a2458
2024-12-20 12:41:02 +03:00

41 lines
973 B
Swift

import AVFoundation
import DivKit
import LayoutKit
import UIKit
import VGSL
extension LottieAnimationBlock {
static func makeBlockView() -> BlockView {
AnimationBlockView()
}
func canConfigureBlockView(_ view: BlockView) -> Bool {
view is AnimationBlockView
}
func configureBlockView(
_ view: BlockView,
observer _: ElementStateObserver?,
overscrollDelegate _: ScrollDelegate?,
renderingDelegate _: RenderingDelegate?
) {
let lottieView = view as! AnimationBlockView
if lottieView.animationHolder != animationHolder {
lottieView.animatableView = animatableView.value
lottieView.animationContentMode = scale.contentMode
lottieView.animationHolder = animationHolder
}
}
}
extension DivImageScale {
fileprivate var contentMode: UIView.ContentMode {
switch self {
case .fit: .scaleAspectFit
case .fill: .scaleAspectFill
case .noScale: .center
case .stretch: .scaleToFill
}
}
}