Files
divkit/client/ios/DivKit/Extensions/DivCustom/DivCustomExtensions.swift
T
ventywing 9b151d2a54 Fallback match_parent child size on wrap_content constrained
Новый подход с фолбеком размеров с match_parent на wrap_content constrained
2022-10-07 12:44:02 +03:00

38 lines
1.1 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 customData = DivCustomData(
name: customType,
data: customProps ?? [:],
children: children
)
let contentHeightTrait = makeContentHeightTrait(with: context)
return try ContainerBlock(
layoutDirection: contentHeightTrait.isResizable ? .vertical : .horizontal,
widthTrait: makeContentWidthTrait(with: context),
heightTrait: contentHeightTrait,
children: [
context.divCustomBlockFactory.makeBlock(data: customData, context: context),
]
)
}
}