mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
69 lines
2.1 KiB
Swift
69 lines
2.1 KiB
Swift
// Generated code. Do not modify.
|
|
|
|
import Foundation
|
|
import Serialization
|
|
import VGSL
|
|
|
|
public final class DivCloudBackground: Sendable {
|
|
public static let type: String = "cloud"
|
|
public let color: Expression<Color>
|
|
public let cornerRadius: Expression<Int> // constraint: number >= 0
|
|
public let paddings: DivEdgeInsets?
|
|
|
|
public func resolveColor(_ resolver: ExpressionResolver) -> Color? {
|
|
resolver.resolveColor(color)
|
|
}
|
|
|
|
public func resolveCornerRadius(_ resolver: ExpressionResolver) -> Int? {
|
|
resolver.resolveNumeric(cornerRadius)
|
|
}
|
|
|
|
static let cornerRadiusValidator: AnyValueValidator<Int> =
|
|
makeValueValidator(valueValidator: { $0 >= 0 })
|
|
|
|
public convenience init(dictionary: [String: Any], context: ParsingContext) throws {
|
|
self.init(
|
|
color: try dictionary.getExpressionField("color", transform: Color.color(withHexString:), context: context),
|
|
cornerRadius: try dictionary.getExpressionField("corner_radius", validator: Self.cornerRadiusValidator, context: context),
|
|
paddings: try dictionary.getOptionalField("paddings", transform: { (dict: [String: Any]) in try DivEdgeInsets(dictionary: dict, context: context) })
|
|
)
|
|
}
|
|
|
|
init(
|
|
color: Expression<Color>,
|
|
cornerRadius: Expression<Int>,
|
|
paddings: DivEdgeInsets? = nil
|
|
) {
|
|
self.color = color
|
|
self.cornerRadius = cornerRadius
|
|
self.paddings = paddings
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
extension DivCloudBackground: Equatable {
|
|
public static func ==(lhs: DivCloudBackground, rhs: DivCloudBackground) -> Bool {
|
|
guard
|
|
lhs.color == rhs.color,
|
|
lhs.cornerRadius == rhs.cornerRadius,
|
|
lhs.paddings == rhs.paddings
|
|
else {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
}
|
|
#endif
|
|
|
|
extension DivCloudBackground: Serializable {
|
|
@_optimize(size)
|
|
public func toDictionary() -> [String: ValidSerializationValue] {
|
|
var result: [String: ValidSerializationValue] = [:]
|
|
result["type"] = Self.type
|
|
result["color"] = color.toValidSerializationValue()
|
|
result["corner_radius"] = cornerRadius.toValidSerializationValue()
|
|
result["paddings"] = paddings?.toDictionary()
|
|
return result
|
|
}
|
|
}
|