Files
divkit/client/ios/DivKit/generated_sources/DivSlideTransition.swift
T
feldspar e234cd83fa Added untyped template resolver
commit_hash:299c999f2d6caad74d8568059e890770d7a6b1f2
2026-02-13 12:08:22 +03:00

104 lines
3.5 KiB
Swift

// Generated code. Do not modify.
import Foundation
import Serialization
import VGSL
public final class DivSlideTransition: DivTransitionBase, Sendable {
@frozen
public enum Edge: String, CaseIterable, Sendable {
case left = "left"
case top = "top"
case right = "right"
case bottom = "bottom"
}
public static let type: String = "slide"
public let distance: DivDimension?
public let duration: Expression<Int> // constraint: number >= 0; default value: 200
public let edge: Expression<Edge> // default value: bottom
public let interpolator: Expression<DivAnimationInterpolator> // default value: ease_in_out
public let startDelay: Expression<Int> // constraint: number >= 0; default value: 0
public func resolveDuration(_ resolver: ExpressionResolver) -> Int {
resolver.resolveNumeric(duration) ?? 200
}
public func resolveEdge(_ resolver: ExpressionResolver) -> Edge {
resolver.resolveEnum(edge) ?? Edge.bottom
}
public func resolveInterpolator(_ resolver: ExpressionResolver) -> DivAnimationInterpolator {
resolver.resolveEnum(interpolator) ?? DivAnimationInterpolator.easeInOut
}
public func resolveStartDelay(_ resolver: ExpressionResolver) -> Int {
resolver.resolveNumeric(startDelay) ?? 0
}
static let durationValidator: AnyValueValidator<Int> =
makeValueValidator(valueValidator: { $0 >= 0 })
static let startDelayValidator: AnyValueValidator<Int> =
makeValueValidator(valueValidator: { $0 >= 0 })
public convenience init(dictionary: [String: Any], context: ParsingContext) throws {
self.init(
distance: try dictionary.getOptionalField("distance", transform: { (dict: [String: Any]) in try DivDimension(dictionary: dict, context: context) }),
duration: try dictionary.getOptionalExpressionField("duration", validator: Self.durationValidator, context: context),
edge: try dictionary.getOptionalExpressionField("edge", context: context),
interpolator: try dictionary.getOptionalExpressionField("interpolator", context: context),
startDelay: try dictionary.getOptionalExpressionField("start_delay", validator: Self.startDelayValidator, context: context)
)
}
init(
distance: DivDimension? = nil,
duration: Expression<Int>? = nil,
edge: Expression<Edge>? = nil,
interpolator: Expression<DivAnimationInterpolator>? = nil,
startDelay: Expression<Int>? = nil
) {
self.distance = distance
self.duration = duration ?? .value(200)
self.edge = edge ?? .value(.bottom)
self.interpolator = interpolator ?? .value(.easeInOut)
self.startDelay = startDelay ?? .value(0)
}
}
#if DEBUG
extension DivSlideTransition: Equatable {
public static func ==(lhs: DivSlideTransition, rhs: DivSlideTransition) -> Bool {
guard
lhs.distance == rhs.distance,
lhs.duration == rhs.duration,
lhs.edge == rhs.edge
else {
return false
}
guard
lhs.interpolator == rhs.interpolator,
lhs.startDelay == rhs.startDelay
else {
return false
}
return true
}
}
#endif
extension DivSlideTransition: Serializable {
@_optimize(size)
public func toDictionary() -> [String: ValidSerializationValue] {
var result: [String: ValidSerializationValue] = [:]
result["type"] = Self.type
result["distance"] = distance?.toDictionary()
result["duration"] = duration.toValidSerializationValue()
result["edge"] = edge.toValidSerializationValue()
result["interpolator"] = interpolator.toValidSerializationValue()
result["start_delay"] = startDelay.toValidSerializationValue()
return result
}
}