mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
33 lines
931 B
Swift
33 lines
931 B
Swift
import LayoutKit
|
|
|
|
extension DivSwitch: DivBlockModeling {
|
|
public func makeBlock(context: DivBlockModelingContext) throws -> Block {
|
|
let context = modifiedContextParentPath(context)
|
|
let resolver = context.expressionResolver
|
|
let switchVariable = context.makeBinding(
|
|
variableName: isOnVariable,
|
|
defaultValue: false
|
|
)
|
|
|
|
return try applyBaseProperties(
|
|
to: {
|
|
SwitchBlock(
|
|
widthTrait: resolveWidthTrait(context),
|
|
heightTrait: resolveHeightTrait(context),
|
|
on: switchVariable,
|
|
enabled: resolveIsEnabled(resolver),
|
|
action: nil,
|
|
onTintColor: resolveOnColor(resolver)
|
|
)
|
|
},
|
|
context: context,
|
|
actionsHolder: nil,
|
|
customAccessibilityParams: CustomAccessibilityParams(
|
|
defaultTraits: .switchButton
|
|
) { [unowned self] in
|
|
accessibility?.resolveDescription(resolver)
|
|
}
|
|
)
|
|
}
|
|
}
|