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

divkit.dsl.Shadow.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

/**
 * Element shadow.
 * 
 * Can be created using the method [shadow].
 * 
 * Required parameters: `offset`.
 */
@Generated
class Shadow internal constructor(
    @JsonIgnore
    val properties: Properties,
) {
    @JsonAnyGetter
    internal fun getJsonProperties(): Map = properties.mergeWith(emptyMap())

    operator fun plus(additive: Properties): Shadow = Shadow(
        Properties(
            alpha = additive.alpha ?: properties.alpha,
            blur = additive.blur ?: properties.blur,
            color = additive.color ?: properties.color,
            offset = additive.offset ?: properties.offset,
        )
    )

    class Properties internal constructor(
        /**
         * Shadow transparency.
         * Default value: `0.19`.
         */
        val alpha: Property?,
        /**
         * Blur intensity.
         * Default value: `2`.
         */
        val blur: Property?,
        /**
         * Shadow color.
         * Default value: `#000000`.
         */
        val color: Property?,
        /**
         * Shadow offset.
         */
        val offset: Property?,
    ) {
        internal fun mergeWith(properties: Map): Map {
            val result = mutableMapOf()
            result.putAll(properties)
            result.tryPutProperty("alpha", alpha)
            result.tryPutProperty("blur", blur)
            result.tryPutProperty("color", color)
            result.tryPutProperty("offset", offset)
            return result
        }
    }
}

/**
 * @param alpha Shadow transparency.
 * @param blur Blur intensity.
 * @param color Shadow color.
 * @param offset Shadow offset.
 */
@Generated
fun DivScope.shadow(
    `use named arguments`: Guard = Guard.instance,
    alpha: Double? = null,
    blur: Int? = null,
    color: Color? = null,
    offset: Point? = null,
): Shadow = Shadow(
    Shadow.Properties(
        alpha = valueOrNull(alpha),
        blur = valueOrNull(blur),
        color = valueOrNull(color),
        offset = valueOrNull(offset),
    )
)

/**
 * @param alpha Shadow transparency.
 * @param blur Blur intensity.
 * @param color Shadow color.
 * @param offset Shadow offset.
 */
@Generated
fun DivScope.shadowProps(
    `use named arguments`: Guard = Guard.instance,
    alpha: Double? = null,
    blur: Int? = null,
    color: Color? = null,
    offset: Point? = null,
) = Shadow.Properties(
    alpha = valueOrNull(alpha),
    blur = valueOrNull(blur),
    color = valueOrNull(color),
    offset = valueOrNull(offset),
)

/**
 * @param alpha Shadow transparency.
 * @param blur Blur intensity.
 * @param color Shadow color.
 * @param offset Shadow offset.
 */
@Generated
fun TemplateScope.shadowRefs(
    `use named arguments`: Guard = Guard.instance,
    alpha: ReferenceProperty? = null,
    blur: ReferenceProperty? = null,
    color: ReferenceProperty? = null,
    offset: ReferenceProperty? = null,
) = Shadow.Properties(
    alpha = alpha,
    blur = blur,
    color = color,
    offset = offset,
)

/**
 * @param alpha Shadow transparency.
 * @param blur Blur intensity.
 * @param color Shadow color.
 * @param offset Shadow offset.
 */
@Generated
fun Shadow.override(
    `use named arguments`: Guard = Guard.instance,
    alpha: Double? = null,
    blur: Int? = null,
    color: Color? = null,
    offset: Point? = null,
): Shadow = Shadow(
    Shadow.Properties(
        alpha = valueOrNull(alpha) ?: properties.alpha,
        blur = valueOrNull(blur) ?: properties.blur,
        color = valueOrNull(color) ?: properties.color,
        offset = valueOrNull(offset) ?: properties.offset,
    )
)

/**
 * @param alpha Shadow transparency.
 * @param blur Blur intensity.
 * @param color Shadow color.
 * @param offset Shadow offset.
 */
@Generated
fun Shadow.defer(
    `use named arguments`: Guard = Guard.instance,
    alpha: ReferenceProperty? = null,
    blur: ReferenceProperty? = null,
    color: ReferenceProperty? = null,
    offset: ReferenceProperty? = null,
): Shadow = Shadow(
    Shadow.Properties(
        alpha = alpha ?: properties.alpha,
        blur = blur ?: properties.blur,
        color = color ?: properties.color,
        offset = offset ?: properties.offset,
    )
)

/**
 * @param alpha Shadow transparency.
 * @param blur Blur intensity.
 * @param color Shadow color.
 */
@Generated
fun Shadow.evaluate(
    `use named arguments`: Guard = Guard.instance,
    alpha: ExpressionProperty? = null,
    blur: ExpressionProperty? = null,
    color: ExpressionProperty? = null,
): Shadow = Shadow(
    Shadow.Properties(
        alpha = alpha ?: properties.alpha,
        blur = blur ?: properties.blur,
        color = color ?: properties.color,
        offset = properties.offset,
    )
)

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy