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

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

/**
 * It sets margins.
 * 
 * Can be created using the method [edgeInsets].
 */
@Generated
class EdgeInsets internal constructor(
    @JsonIgnore
    val properties: Properties,
) {
    @JsonAnyGetter
    internal fun getJsonProperties(): Map = properties.mergeWith(emptyMap())

    operator fun plus(additive: Properties): EdgeInsets = EdgeInsets(
        Properties(
            bottom = additive.bottom ?: properties.bottom,
            end = additive.end ?: properties.end,
            left = additive.left ?: properties.left,
            right = additive.right ?: properties.right,
            start = additive.start ?: properties.start,
            top = additive.top ?: properties.top,
            unit = additive.unit ?: properties.unit,
        )
    )

    class Properties internal constructor(
        /**
         * Bottom margin.
         * Default value: `0`.
         */
        val bottom: Property?,
        /**
         * End margin. Margin position depends on the interface orientation. Has higher priority than the left and right margins.
         */
        val end: Property?,
        /**
         * Left margin.
         * Default value: `0`.
         */
        val left: Property?,
        /**
         * Right margin.
         * Default value: `0`.
         */
        val right: Property?,
        /**
         * Start margin. Margin position depends on the interface orientation. Has higher priority than the left and right margins.
         */
        val start: Property?,
        /**
         * Top margin.
         * Default value: `0`.
         */
        val top: Property?,
        /**
         * Default value: `dp`.
         */
        val unit: Property?,
    ) {
        internal fun mergeWith(properties: Map): Map {
            val result = mutableMapOf()
            result.putAll(properties)
            result.tryPutProperty("bottom", bottom)
            result.tryPutProperty("end", end)
            result.tryPutProperty("left", left)
            result.tryPutProperty("right", right)
            result.tryPutProperty("start", start)
            result.tryPutProperty("top", top)
            result.tryPutProperty("unit", unit)
            return result
        }
    }
}

/**
 * @param bottom Bottom margin.
 * @param end End margin. Margin position depends on the interface orientation. Has higher priority than the left and right margins.
 * @param left Left margin.
 * @param right Right margin.
 * @param start Start margin. Margin position depends on the interface orientation. Has higher priority than the left and right margins.
 * @param top Top margin.
 */
@Generated
fun DivScope.edgeInsets(
    `use named arguments`: Guard = Guard.instance,
    bottom: Int? = null,
    end: Int? = null,
    left: Int? = null,
    right: Int? = null,
    start: Int? = null,
    top: Int? = null,
    unit: SizeUnit? = null,
): EdgeInsets = EdgeInsets(
    EdgeInsets.Properties(
        bottom = valueOrNull(bottom),
        end = valueOrNull(end),
        left = valueOrNull(left),
        right = valueOrNull(right),
        start = valueOrNull(start),
        top = valueOrNull(top),
        unit = valueOrNull(unit),
    )
)

/**
 * @param bottom Bottom margin.
 * @param end End margin. Margin position depends on the interface orientation. Has higher priority than the left and right margins.
 * @param left Left margin.
 * @param right Right margin.
 * @param start Start margin. Margin position depends on the interface orientation. Has higher priority than the left and right margins.
 * @param top Top margin.
 */
@Generated
fun DivScope.edgeInsetsProps(
    `use named arguments`: Guard = Guard.instance,
    bottom: Int? = null,
    end: Int? = null,
    left: Int? = null,
    right: Int? = null,
    start: Int? = null,
    top: Int? = null,
    unit: SizeUnit? = null,
) = EdgeInsets.Properties(
    bottom = valueOrNull(bottom),
    end = valueOrNull(end),
    left = valueOrNull(left),
    right = valueOrNull(right),
    start = valueOrNull(start),
    top = valueOrNull(top),
    unit = valueOrNull(unit),
)

/**
 * @param bottom Bottom margin.
 * @param end End margin. Margin position depends on the interface orientation. Has higher priority than the left and right margins.
 * @param left Left margin.
 * @param right Right margin.
 * @param start Start margin. Margin position depends on the interface orientation. Has higher priority than the left and right margins.
 * @param top Top margin.
 */
@Generated
fun TemplateScope.edgeInsetsRefs(
    `use named arguments`: Guard = Guard.instance,
    bottom: ReferenceProperty? = null,
    end: ReferenceProperty? = null,
    left: ReferenceProperty? = null,
    right: ReferenceProperty? = null,
    start: ReferenceProperty? = null,
    top: ReferenceProperty? = null,
    unit: ReferenceProperty? = null,
) = EdgeInsets.Properties(
    bottom = bottom,
    end = end,
    left = left,
    right = right,
    start = start,
    top = top,
    unit = unit,
)

/**
 * @param bottom Bottom margin.
 * @param end End margin. Margin position depends on the interface orientation. Has higher priority than the left and right margins.
 * @param left Left margin.
 * @param right Right margin.
 * @param start Start margin. Margin position depends on the interface orientation. Has higher priority than the left and right margins.
 * @param top Top margin.
 */
@Generated
fun EdgeInsets.override(
    `use named arguments`: Guard = Guard.instance,
    bottom: Int? = null,
    end: Int? = null,
    left: Int? = null,
    right: Int? = null,
    start: Int? = null,
    top: Int? = null,
    unit: SizeUnit? = null,
): EdgeInsets = EdgeInsets(
    EdgeInsets.Properties(
        bottom = valueOrNull(bottom) ?: properties.bottom,
        end = valueOrNull(end) ?: properties.end,
        left = valueOrNull(left) ?: properties.left,
        right = valueOrNull(right) ?: properties.right,
        start = valueOrNull(start) ?: properties.start,
        top = valueOrNull(top) ?: properties.top,
        unit = valueOrNull(unit) ?: properties.unit,
    )
)

/**
 * @param bottom Bottom margin.
 * @param end End margin. Margin position depends on the interface orientation. Has higher priority than the left and right margins.
 * @param left Left margin.
 * @param right Right margin.
 * @param start Start margin. Margin position depends on the interface orientation. Has higher priority than the left and right margins.
 * @param top Top margin.
 */
@Generated
fun EdgeInsets.defer(
    `use named arguments`: Guard = Guard.instance,
    bottom: ReferenceProperty? = null,
    end: ReferenceProperty? = null,
    left: ReferenceProperty? = null,
    right: ReferenceProperty? = null,
    start: ReferenceProperty? = null,
    top: ReferenceProperty? = null,
    unit: ReferenceProperty? = null,
): EdgeInsets = EdgeInsets(
    EdgeInsets.Properties(
        bottom = bottom ?: properties.bottom,
        end = end ?: properties.end,
        left = left ?: properties.left,
        right = right ?: properties.right,
        start = start ?: properties.start,
        top = top ?: properties.top,
        unit = unit ?: properties.unit,
    )
)

/**
 * @param bottom Bottom margin.
 * @param end End margin. Margin position depends on the interface orientation. Has higher priority than the left and right margins.
 * @param left Left margin.
 * @param right Right margin.
 * @param start Start margin. Margin position depends on the interface orientation. Has higher priority than the left and right margins.
 * @param top Top margin.
 */
@Generated
fun EdgeInsets.evaluate(
    `use named arguments`: Guard = Guard.instance,
    bottom: ExpressionProperty? = null,
    end: ExpressionProperty? = null,
    left: ExpressionProperty? = null,
    right: ExpressionProperty? = null,
    start: ExpressionProperty? = null,
    top: ExpressionProperty? = null,
    unit: ExpressionProperty? = null,
): EdgeInsets = EdgeInsets(
    EdgeInsets.Properties(
        bottom = bottom ?: properties.bottom,
        end = end ?: properties.end,
        left = left ?: properties.left,
        right = right ?: properties.right,
        start = start ?: properties.start,
        top = top ?: properties.top,
        unit = unit ?: properties.unit,
    )
)

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy