mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
60 lines
1.5 KiB
Swift
60 lines
1.5 KiB
Swift
// Generated code. Do not modify.
|
|
|
|
import Foundation
|
|
import Serialization
|
|
import VGSL
|
|
|
|
public final class DivFixedTranslation: Sendable {
|
|
public static let type: String = "translation-fixed"
|
|
public let unit: Expression<DivSizeUnit> // default value: dp
|
|
public let value: Expression<Int>
|
|
|
|
public func resolveUnit(_ resolver: ExpressionResolver) -> DivSizeUnit {
|
|
resolver.resolveEnum(unit) ?? DivSizeUnit.dp
|
|
}
|
|
|
|
public func resolveValue(_ resolver: ExpressionResolver) -> Int? {
|
|
resolver.resolveNumeric(value)
|
|
}
|
|
|
|
public convenience init(dictionary: [String: Any], context: ParsingContext) throws {
|
|
self.init(
|
|
unit: try dictionary.getOptionalExpressionField("unit", context: context),
|
|
value: try dictionary.getExpressionField("value", context: context)
|
|
)
|
|
}
|
|
|
|
init(
|
|
unit: Expression<DivSizeUnit>? = nil,
|
|
value: Expression<Int>
|
|
) {
|
|
self.unit = unit ?? .value(.dp)
|
|
self.value = value
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
extension DivFixedTranslation: Equatable {
|
|
public static func ==(lhs: DivFixedTranslation, rhs: DivFixedTranslation) -> Bool {
|
|
guard
|
|
lhs.unit == rhs.unit,
|
|
lhs.value == rhs.value
|
|
else {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
}
|
|
#endif
|
|
|
|
extension DivFixedTranslation: Serializable {
|
|
@_optimize(size)
|
|
public func toDictionary() -> [String: ValidSerializationValue] {
|
|
var result: [String: ValidSerializationValue] = [:]
|
|
result["type"] = Self.type
|
|
result["unit"] = unit.toValidSerializationValue()
|
|
result["value"] = value.toValidSerializationValue()
|
|
return result
|
|
}
|
|
}
|