mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
6797545374
commit_hash:8ab26a6d1a605474126fdbc3cc4314923edbc77f
41 lines
1.2 KiB
Swift
41 lines
1.2 KiB
Swift
import CoreGraphics
|
|
import LayoutKit
|
|
import VGSL
|
|
|
|
extension DivCustom: DivBlockModeling {
|
|
public func makeBlock(context: DivBlockModelingContext) throws -> Block {
|
|
let context = modifiedContextParentPath(context)
|
|
let children = items?.makeBlocks(
|
|
context: context
|
|
) ?? []
|
|
return try applyBaseProperties(
|
|
to: { try makeBaseBlock(context: context, children: children) },
|
|
context: context,
|
|
actionsHolder: nil
|
|
)
|
|
}
|
|
|
|
private func makeBaseBlock(
|
|
context: DivBlockModelingContext,
|
|
children: [Block]
|
|
) throws -> Block {
|
|
let contentWidthTrait = resolveContentWidthTrait(context)
|
|
let contentHeightTrait = resolveContentHeightTrait(context)
|
|
let customData = DivCustomData(
|
|
name: customType,
|
|
data: customProps ?? [:],
|
|
children: children,
|
|
widthTrait: contentWidthTrait,
|
|
heightTrait: contentHeightTrait
|
|
)
|
|
return try ContainerBlock(
|
|
layoutDirection: contentHeightTrait.isResizable ? .vertical : .horizontal,
|
|
widthTrait: contentWidthTrait,
|
|
heightTrait: contentHeightTrait,
|
|
children: [
|
|
context.divCustomBlockFactory.makeBlock(data: customData, context: context),
|
|
]
|
|
)
|
|
}
|
|
}
|