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

commonMain.com.seiko.imageloader.size.Dimension.kt Maven / Gradle / Ivy

There is a newer version: 1.9.0
Show newest version
package com.seiko.imageloader.size

sealed class Dimension {
    data class Pixels(val px: Int) : Dimension()
    object Undefined : Dimension()
}

@Suppress("FunctionName")
fun Dimension(px: Int) = Dimension.Pixels(px)

inline fun Dimension.pxOrElse(block: () -> Int): Int {
    return if (this is Dimension.Pixels) px else block()
}

internal fun Dimension.toPx(scale: Scale) = pxOrElse {
    when (scale) {
        Scale.FILL -> Int.MIN_VALUE
        Scale.FIT -> Int.MAX_VALUE
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy