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

commonMain.com.bselzer.ktx.compose.ui.layout.merge.TriStateMerger.kt Maven / Gradle / Ivy

There is a newer version: 6.5.0
Show newest version
package com.bselzer.ktx.compose.ui.layout.merge

import androidx.compose.runtime.Stable

class TriStateMerger : ComponentMerger {
    override val default: TriState = Default

    companion object {
        @Stable
        val Default = TriState.DEFAULT
    }
}

enum class TriState {
    DEFAULT,
    TRUE,
    FALSE;

    /**
     * @return true if this is [TRUE]
     */
    fun toBoolean(): Boolean = this == TRUE
}

/**
 * @return [TriState.DEFAULT] if null, [TriState.FALSE] if false, otherwise true
 */
fun Boolean?.toTriState() = when (this) {
    null -> TriState.DEFAULT
    false -> TriState.FALSE
    true -> TriState.TRUE
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy