All Downloads are FREE. Search and download functionalities are using the official Maven repository.

divkit.dsl.FadeTransition.kt Maven / Gradle / Ivy

Go to download

DivKit is an open source Server-Driven UI (SDUI) framework. SDUI is a an emerging technique that leverage the server to build the user interfaces of their mobile app.

There is a newer version: 30.28.0
Show newest version
@file:Suppress(
    "unused",
    "UNUSED_PARAMETER",
)

package divkit.dsl

import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonValue
import divkit.dsl.annotation.*
import divkit.dsl.core.*
import divkit.dsl.scope.*
import kotlin.Any
import kotlin.String
import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.Map

/**
 * Transparency animation.
 * 
 * Can be created using the method [fadeTransition].
 * 
 * Required parameters: `type`.
 */
@Generated
class FadeTransition internal constructor(
    @JsonIgnore
    val properties: Properties,
) : AppearanceTransition {
    @JsonAnyGetter
    internal fun getJsonProperties(): Map = properties.mergeWith(
        mapOf("type" to "fade")
    )

    operator fun plus(additive: Properties): FadeTransition = FadeTransition(
        Properties(
            alpha = additive.alpha ?: properties.alpha,
            duration = additive.duration ?: properties.duration,
            interpolator = additive.interpolator ?: properties.interpolator,
            startDelay = additive.startDelay ?: properties.startDelay,
        )
    )

    class Properties internal constructor(
        /**
         * Value of the alpha channel which the element starts appearing from or at which it finishes disappearing.
         * Default value: `0.0`.
         */
        val alpha: Property?,
        /**
         * Animation duration in milliseconds.
         * Default value: `200`.
         */
        val duration: Property?,
        /**
         * Transition speed nature.
         * Default value: `ease_in_out`.
         */
        val interpolator: Property?,
        /**
         * Delay in milliseconds before animation starts.
         * Default value: `0`.
         */
        val startDelay: Property?,
    ) {
        internal fun mergeWith(properties: Map): Map {
            val result = mutableMapOf()
            result.putAll(properties)
            result.tryPutProperty("alpha", alpha)
            result.tryPutProperty("duration", duration)
            result.tryPutProperty("interpolator", interpolator)
            result.tryPutProperty("start_delay", startDelay)
            return result
        }
    }
}

/**
 * @param alpha Value of the alpha channel which the element starts appearing from or at which it finishes disappearing.
 * @param duration Animation duration in milliseconds.
 * @param interpolator Transition speed nature.
 * @param startDelay Delay in milliseconds before animation starts.
 */
@Generated
fun DivScope.fadeTransition(
    `use named arguments`: Guard = Guard.instance,
    alpha: Double? = null,
    duration: Int? = null,
    interpolator: AnimationInterpolator? = null,
    startDelay: Int? = null,
): FadeTransition = FadeTransition(
    FadeTransition.Properties(
        alpha = valueOrNull(alpha),
        duration = valueOrNull(duration),
        interpolator = valueOrNull(interpolator),
        startDelay = valueOrNull(startDelay),
    )
)

/**
 * @param alpha Value of the alpha channel which the element starts appearing from or at which it finishes disappearing.
 * @param duration Animation duration in milliseconds.
 * @param interpolator Transition speed nature.
 * @param startDelay Delay in milliseconds before animation starts.
 */
@Generated
fun DivScope.fadeTransitionProps(
    `use named arguments`: Guard = Guard.instance,
    alpha: Double? = null,
    duration: Int? = null,
    interpolator: AnimationInterpolator? = null,
    startDelay: Int? = null,
) = FadeTransition.Properties(
    alpha = valueOrNull(alpha),
    duration = valueOrNull(duration),
    interpolator = valueOrNull(interpolator),
    startDelay = valueOrNull(startDelay),
)

/**
 * @param alpha Value of the alpha channel which the element starts appearing from or at which it finishes disappearing.
 * @param duration Animation duration in milliseconds.
 * @param interpolator Transition speed nature.
 * @param startDelay Delay in milliseconds before animation starts.
 */
@Generated
fun TemplateScope.fadeTransitionRefs(
    `use named arguments`: Guard = Guard.instance,
    alpha: ReferenceProperty? = null,
    duration: ReferenceProperty? = null,
    interpolator: ReferenceProperty? = null,
    startDelay: ReferenceProperty? = null,
) = FadeTransition.Properties(
    alpha = alpha,
    duration = duration,
    interpolator = interpolator,
    startDelay = startDelay,
)

/**
 * @param alpha Value of the alpha channel which the element starts appearing from or at which it finishes disappearing.
 * @param duration Animation duration in milliseconds.
 * @param interpolator Transition speed nature.
 * @param startDelay Delay in milliseconds before animation starts.
 */
@Generated
fun FadeTransition.override(
    `use named arguments`: Guard = Guard.instance,
    alpha: Double? = null,
    duration: Int? = null,
    interpolator: AnimationInterpolator? = null,
    startDelay: Int? = null,
): FadeTransition = FadeTransition(
    FadeTransition.Properties(
        alpha = valueOrNull(alpha) ?: properties.alpha,
        duration = valueOrNull(duration) ?: properties.duration,
        interpolator = valueOrNull(interpolator) ?: properties.interpolator,
        startDelay = valueOrNull(startDelay) ?: properties.startDelay,
    )
)

/**
 * @param alpha Value of the alpha channel which the element starts appearing from or at which it finishes disappearing.
 * @param duration Animation duration in milliseconds.
 * @param interpolator Transition speed nature.
 * @param startDelay Delay in milliseconds before animation starts.
 */
@Generated
fun FadeTransition.defer(
    `use named arguments`: Guard = Guard.instance,
    alpha: ReferenceProperty? = null,
    duration: ReferenceProperty? = null,
    interpolator: ReferenceProperty? = null,
    startDelay: ReferenceProperty? = null,
): FadeTransition = FadeTransition(
    FadeTransition.Properties(
        alpha = alpha ?: properties.alpha,
        duration = duration ?: properties.duration,
        interpolator = interpolator ?: properties.interpolator,
        startDelay = startDelay ?: properties.startDelay,
    )
)

/**
 * @param alpha Value of the alpha channel which the element starts appearing from or at which it finishes disappearing.
 * @param duration Animation duration in milliseconds.
 * @param interpolator Transition speed nature.
 * @param startDelay Delay in milliseconds before animation starts.
 */
@Generated
fun FadeTransition.evaluate(
    `use named arguments`: Guard = Guard.instance,
    alpha: ExpressionProperty? = null,
    duration: ExpressionProperty? = null,
    interpolator: ExpressionProperty? = null,
    startDelay: ExpressionProperty? = null,
): FadeTransition = FadeTransition(
    FadeTransition.Properties(
        alpha = alpha ?: properties.alpha,
        duration = duration ?: properties.duration,
        interpolator = interpolator ?: properties.interpolator,
        startDelay = startDelay ?: properties.startDelay,
    )
)

@Generated
fun FadeTransition.asList() = listOf(this)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy