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

divkit.dsl.Color.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
package divkit.dsl

import com.fasterxml.jackson.annotation.JsonValue
import divkit.dsl.scope.DivScope
import kotlin.String
import kotlin.jvm.JvmInline
import kotlin.text.Regex

@JvmInline
value class Color internal constructor(
    @JsonValue
    internal val value: String,
) {
    init {
        require(pattern.matchEntire(value) != null) {
            "Malformed color string: $value"
        }
    }
    companion object {
        private val pattern: Regex =
            Regex("#([\\dA-Fa-f]{3}|[\\dA-Fa-f]{4}|[\\dA-Fa-f]{6}|[\\dA-Fa-f]{8})")
    }
}

fun DivScope.color(argb: String): Color = Color(argb)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy