divkit.dsl.CloudBackground.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-json-builder Show documentation
Show all versions of kotlin-json-builder Show documentation
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.
@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
/**
* Cloud text background. Lines draws a rectangular background with the specified color and rounded corners.
*
* Can be created using the method [cloudBackground].
*
* Required parameters: `type, corner_radius, color`.
*/
@Generated
data class CloudBackground internal constructor(
@JsonIgnore
val properties: Properties,
) : TextRangeBackground {
@JsonAnyGetter
internal fun getJsonProperties(): Map = properties.mergeWith(
mapOf("type" to "cloud")
)
operator fun plus(additive: Properties): CloudBackground = CloudBackground(
Properties(
color = additive.color ?: properties.color,
cornerRadius = additive.cornerRadius ?: properties.cornerRadius,
paddings = additive.paddings ?: properties.paddings,
)
)
data class Properties internal constructor(
/**
* Fill color.
*/
val color: Property?,
/**
* Corner rounding radius.
*/
val cornerRadius: Property?,
/**
* Margins between line bounds and background.
*/
val paddings: Property?,
) {
internal fun mergeWith(properties: Map): Map {
val result = mutableMapOf()
result.putAll(properties)
result.tryPutProperty("color", color)
result.tryPutProperty("corner_radius", cornerRadius)
result.tryPutProperty("paddings", paddings)
return result
}
}
}
/**
* @param color Fill color.
* @param cornerRadius Corner rounding radius.
* @param paddings Margins between line bounds and background.
*/
@Generated
fun DivScope.cloudBackground(
`use named arguments`: Guard = Guard.instance,
color: Color? = null,
cornerRadius: Int? = null,
paddings: EdgeInsets? = null,
): CloudBackground = CloudBackground(
CloudBackground.Properties(
color = valueOrNull(color),
cornerRadius = valueOrNull(cornerRadius),
paddings = valueOrNull(paddings),
)
)
/**
* @param color Fill color.
* @param cornerRadius Corner rounding radius.
* @param paddings Margins between line bounds and background.
*/
@Generated
fun DivScope.cloudBackgroundProps(
`use named arguments`: Guard = Guard.instance,
color: Color? = null,
cornerRadius: Int? = null,
paddings: EdgeInsets? = null,
) = CloudBackground.Properties(
color = valueOrNull(color),
cornerRadius = valueOrNull(cornerRadius),
paddings = valueOrNull(paddings),
)
/**
* @param color Fill color.
* @param cornerRadius Corner rounding radius.
* @param paddings Margins between line bounds and background.
*/
@Generated
fun TemplateScope.cloudBackgroundRefs(
`use named arguments`: Guard = Guard.instance,
color: ReferenceProperty? = null,
cornerRadius: ReferenceProperty? = null,
paddings: ReferenceProperty? = null,
) = CloudBackground.Properties(
color = color,
cornerRadius = cornerRadius,
paddings = paddings,
)
/**
* @param color Fill color.
* @param cornerRadius Corner rounding radius.
* @param paddings Margins between line bounds and background.
*/
@Generated
fun CloudBackground.override(
`use named arguments`: Guard = Guard.instance,
color: Color? = null,
cornerRadius: Int? = null,
paddings: EdgeInsets? = null,
): CloudBackground = CloudBackground(
CloudBackground.Properties(
color = valueOrNull(color) ?: properties.color,
cornerRadius = valueOrNull(cornerRadius) ?: properties.cornerRadius,
paddings = valueOrNull(paddings) ?: properties.paddings,
)
)
/**
* @param color Fill color.
* @param cornerRadius Corner rounding radius.
* @param paddings Margins between line bounds and background.
*/
@Generated
fun CloudBackground.defer(
`use named arguments`: Guard = Guard.instance,
color: ReferenceProperty? = null,
cornerRadius: ReferenceProperty? = null,
paddings: ReferenceProperty? = null,
): CloudBackground = CloudBackground(
CloudBackground.Properties(
color = color ?: properties.color,
cornerRadius = cornerRadius ?: properties.cornerRadius,
paddings = paddings ?: properties.paddings,
)
)
/**
* @param color Fill color.
* @param cornerRadius Corner rounding radius.
*/
@Generated
fun CloudBackground.evaluate(
`use named arguments`: Guard = Guard.instance,
color: ExpressionProperty? = null,
cornerRadius: ExpressionProperty? = null,
): CloudBackground = CloudBackground(
CloudBackground.Properties(
color = color ?: properties.color,
cornerRadius = cornerRadius ?: properties.cornerRadius,
paddings = properties.paddings,
)
)
@Generated
fun CloudBackground.asList() = listOf(this)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy