mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
fb117357b4
Support RiveRuntime
41 lines
1.2 KiB
Swift
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),
|
|
]
|
|
)
|
|
}
|
|
}
|