Files
divkit/client/ios/DivKit/Extensions/DivCustom/DivCustomExtensions.swift
T
dashapalshau fb117357b4 Support RiveRuntime animations
Support RiveRuntime
2022-12-06 13:02:56 +03:00

41 lines
1.2 KiB
Swift

import CoreGraphics
import CommonCore
import LayoutKit
extension DivCustom: DivBlockModeling {
public func makeBlock(context: DivBlockModelingContext) throws -> Block {
let children = try items?.makeBlocks(
context: context
) ?? []
return try applyBaseProperties(
to: { try makeBaseBlock(context: context, children: children) },
context: context,
actions: nil,
actionAnimation: nil,
doubleTapActions: nil,
longTapActions: nil
)
}
private func makeBaseBlock(context: DivBlockModelingContext, children: [Block]) throws -> Block {
let contentHeightTrait = makeContentHeightTrait(with: context)
let contentWidthTrait = makeContentWidthTrait(with: context)
let customData = DivCustomData(
name: customType,
data: customProps ?? [:],
children: children,
widthTrait: contentWidthTrait,
heightTrait: contentHeightTrait
)
return try ContainerBlock(
layoutDirection: contentHeightTrait.isResizable ? .vertical : .horizontal,
widthTrait: makeContentWidthTrait(with: context),
heightTrait: contentHeightTrait,
children: [
context.divCustomBlockFactory.makeBlock(data: customData, context: context),
]
)
}
}