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

divkit.dsl.LinearGradient.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.19.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

/**
 * Linear gradient.
 * 
 * Can be created using the method [linearGradient].
 * 
 * Required parameters: `type, colors`.
 */
@Generated
class LinearGradient internal constructor(
    @JsonIgnore
    val properties: Properties,
) : Background, TextGradient {
    @JsonAnyGetter
    internal fun getJsonProperties(): Map = properties.mergeWith(
        mapOf("type" to "gradient")
    )

    operator fun plus(additive: Properties): LinearGradient = LinearGradient(
        Properties(
            angle = additive.angle ?: properties.angle,
            colors = additive.colors ?: properties.colors,
        )
    )

    class Properties internal constructor(
        /**
         * Angle of gradient direction.
         * Default value: `0`.
         */
        val angle: Property?,
        /**
         * Colors. Gradient points are located at an equal distance from each other.
         */
        val colors: Property>>?,
    ) {
        internal fun mergeWith(properties: Map): Map {
            val result = mutableMapOf()
            result.putAll(properties)
            result.tryPutProperty("angle", angle)
            result.tryPutProperty("colors", colors)
            return result
        }
    }
}

/**
 * @param angle Angle of gradient direction.
 * @param colors Colors. Gradient points are located at an equal distance from each other.
 */
@Generated
fun DivScope.linearGradient(
    `use named arguments`: Guard = Guard.instance,
    angle: Int? = null,
    colors: List>? = null,
): LinearGradient = LinearGradient(
    LinearGradient.Properties(
        angle = valueOrNull(angle),
        colors = valueOrNull(colors),
    )
)

/**
 * @param angle Angle of gradient direction.
 * @param colors Colors. Gradient points are located at an equal distance from each other.
 */
@Generated
fun DivScope.linearGradientProps(
    `use named arguments`: Guard = Guard.instance,
    angle: Int? = null,
    colors: List>? = null,
) = LinearGradient.Properties(
    angle = valueOrNull(angle),
    colors = valueOrNull(colors),
)

/**
 * @param angle Angle of gradient direction.
 * @param colors Colors. Gradient points are located at an equal distance from each other.
 */
@Generated
fun TemplateScope.linearGradientRefs(
    `use named arguments`: Guard = Guard.instance,
    angle: ReferenceProperty? = null,
    colors: ReferenceProperty>>? = null,
) = LinearGradient.Properties(
    angle = angle,
    colors = colors,
)

/**
 * @param angle Angle of gradient direction.
 * @param colors Colors. Gradient points are located at an equal distance from each other.
 */
@Generated
fun LinearGradient.override(
    `use named arguments`: Guard = Guard.instance,
    angle: Int? = null,
    colors: List>? = null,
): LinearGradient = LinearGradient(
    LinearGradient.Properties(
        angle = valueOrNull(angle) ?: properties.angle,
        colors = valueOrNull(colors) ?: properties.colors,
    )
)

/**
 * @param angle Angle of gradient direction.
 * @param colors Colors. Gradient points are located at an equal distance from each other.
 */
@Generated
fun LinearGradient.defer(
    `use named arguments`: Guard = Guard.instance,
    angle: ReferenceProperty? = null,
    colors: ReferenceProperty>>? = null,
): LinearGradient = LinearGradient(
    LinearGradient.Properties(
        angle = angle ?: properties.angle,
        colors = colors ?: properties.colors,
    )
)

/**
 * @param angle Angle of gradient direction.
 */
@Generated
fun LinearGradient.evaluate(
    `use named arguments`: Guard = Guard.instance,
    angle: ExpressionProperty? = null,
): LinearGradient = LinearGradient(
    LinearGradient.Properties(
        angle = angle ?: properties.angle,
        colors = properties.colors,
    )
)

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy