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

commonMain.io.github.lyxnx.compose.pine.CheckboxDefaults.kt Maven / Gradle / Ivy

package io.github.lyxnx.compose.pine

import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import io.github.lyxnx.compose.ui.AnimatedInteractionStateColorSelector

/**
 * Contains the default values used by a [Checkbox] or [TriStateCheckbox]
 */
public object CheckboxDefaults {

    /**
     * Creates a [CheckboxColors] instance that represents the colors in different states
     */
    @Composable
    public fun checkboxColors(
        uncheckedBorderColor: Color = PineTheme.colors.grey300,
        pressedUncheckedBorderColor: Color = PineTheme.colors.primary500,
        focusedUncheckedBorderColor: Color = PineTheme.colors.primary500,
        disabledUncheckedBorderColor: Color = PineTheme.colors.grey300,
        checkedBorderColor: Color = PineTheme.colors.primary500,
        pressedCheckedBorderColor: Color = PineTheme.colors.primary600,
        focusedCheckedBorderColor: Color = PineTheme.colors.primary400,
        disabledCheckedBorderColor: Color = PineTheme.colors.grey300,
        uncheckedBackgroundColor: Color = PineTheme.colors.background,
        pressedUncheckedBackgroundColor: Color = PineTheme.colors.primary100,
        focusedUncheckedBackgroundColor: Color = PineTheme.colors.background,
        disabledUncheckedBackgroundColor: Color = PineTheme.colors.grey300,
        checkedBackgroundColor: Color = PineTheme.colors.primary500,
        pressedCheckedBackgroundColor: Color = PineTheme.colors.primary600,
        focusedCheckedBackgroundColor: Color = PineTheme.colors.primary400,
        disabledCheckedBackgroundColor: Color = PineTheme.colors.grey300,
        tickColor: Color = PineTheme.colors.white,
        pressedTickColor: Color = PineTheme.colors.white,
        focusedTickColor: Color = PineTheme.colors.white,
        disabledTickColor: Color = PineTheme.colors.background,
        uncheckedFocusedShadowColor: Color = PineTheme.colors.primary600.copy(alpha = 0.25f),
        checkedFocusedShadowColor: Color = PineTheme.colors.primary600.copy(alpha = 0.25f),
    ): CheckboxColors = triStateCheckboxColors(
        uncheckedBorderColor = uncheckedBorderColor,
        pressedUncheckedBorderColor = pressedUncheckedBorderColor,
        focusedUncheckedBorderColor = focusedUncheckedBorderColor,
        disabledUncheckedBorderColor = disabledUncheckedBorderColor,
        checkedBorderColor = checkedBorderColor,
        pressedCheckedBorderColor = pressedCheckedBorderColor,
        focusedCheckedBorderColor = focusedCheckedBorderColor,
        disabledCheckedBorderColor = disabledCheckedBorderColor,
        // unspecified for indeterminate state as checkbox only has 2 states
        indeterminateBorderColor = Color.Unspecified,
        pressedIndeterminateBorderColor = Color.Unspecified,
        focusedIndeterminateBorderColor = Color.Unspecified,
        disabledIndeterminateBorderColor = Color.Unspecified,
        uncheckedBackgroundColor = uncheckedBackgroundColor,
        pressedUncheckedBackgroundColor = pressedUncheckedBackgroundColor,
        focusedUncheckedBackgroundColor = focusedUncheckedBackgroundColor,
        disabledUncheckedBackgroundColor = disabledUncheckedBackgroundColor,
        checkedBackgroundColor = checkedBackgroundColor,
        pressedCheckedBackgroundColor = pressedCheckedBackgroundColor,
        focusedCheckedBackgroundColor = focusedCheckedBackgroundColor,
        disabledCheckedBackgroundColor = disabledCheckedBackgroundColor,
        indeterminateBackgroundColor = Color.Unspecified,
        pressedIndeterminateBackgroundColor = Color.Unspecified,
        focusedIndeterminateBackgroundColor = Color.Unspecified,
        disabledIndeterminateBackgroundColor = Color.Unspecified,
        tickColor = tickColor,
        pressedTickColor = pressedTickColor,
        focusedTickColor = focusedTickColor,
        disabledTickColor = disabledTickColor,
        indeterminateIndicatorColor = Color.Unspecified,
        pressedIndeterminateIndicatorColor = Color.Unspecified,
        focusedIndeterminateIndicatorColor = Color.Unspecified,
        disabledIndeterminateIndicatorColor = Color.Unspecified,
        uncheckedFocusedShadowColor = uncheckedFocusedShadowColor,
        checkedFocusedShadowColor = checkedFocusedShadowColor,
        indeterminateFocusedShadowColor = Color.Unspecified,
    )

    /**
     * Creates a [CheckboxColors] instance that represents the colors in the 3 different states
     */
    @Composable
    public fun triStateCheckboxColors(
        uncheckedBorderColor: Color = PineTheme.colors.grey300,
        pressedUncheckedBorderColor: Color = PineTheme.colors.primary500,
        focusedUncheckedBorderColor: Color = PineTheme.colors.primary500,
        disabledUncheckedBorderColor: Color = PineTheme.colors.grey300,
        checkedBorderColor: Color = PineTheme.colors.primary500,
        pressedCheckedBorderColor: Color = PineTheme.colors.primary600,
        focusedCheckedBorderColor: Color = PineTheme.colors.primary400,
        disabledCheckedBorderColor: Color = PineTheme.colors.grey300,
        indeterminateBorderColor: Color = PineTheme.colors.primary500,
        pressedIndeterminateBorderColor: Color = PineTheme.colors.primary600,
        focusedIndeterminateBorderColor: Color = PineTheme.colors.primary400,
        disabledIndeterminateBorderColor: Color = PineTheme.colors.grey300,
        uncheckedBackgroundColor: Color = PineTheme.colors.background,
        pressedUncheckedBackgroundColor: Color = PineTheme.colors.primary100,
        focusedUncheckedBackgroundColor: Color = PineTheme.colors.background,
        disabledUncheckedBackgroundColor: Color = PineTheme.colors.grey300,
        checkedBackgroundColor: Color = PineTheme.colors.primary500,
        pressedCheckedBackgroundColor: Color = PineTheme.colors.primary600,
        focusedCheckedBackgroundColor: Color = PineTheme.colors.primary400,
        disabledCheckedBackgroundColor: Color = PineTheme.colors.grey300,
        indeterminateBackgroundColor: Color = PineTheme.colors.background,
        pressedIndeterminateBackgroundColor: Color = PineTheme.colors.primary100,
        focusedIndeterminateBackgroundColor: Color = PineTheme.colors.background,
        disabledIndeterminateBackgroundColor: Color = PineTheme.colors.background,
        tickColor: Color = PineTheme.colors.white,
        pressedTickColor: Color = PineTheme.colors.white,
        focusedTickColor: Color = PineTheme.colors.white,
        disabledTickColor: Color = PineTheme.colors.background,
        indeterminateIndicatorColor: Color = PineTheme.colors.primary500,
        pressedIndeterminateIndicatorColor: Color = PineTheme.colors.primary600,
        focusedIndeterminateIndicatorColor: Color = PineTheme.colors.primary400,
        disabledIndeterminateIndicatorColor: Color = PineTheme.colors.grey300,
        uncheckedFocusedShadowColor: Color = PineTheme.colors.primary600.copy(alpha = 0.5f),
        checkedFocusedShadowColor: Color = PineTheme.colors.primary600.copy(alpha = 0.5f),
        indeterminateFocusedShadowColor: Color = PineTheme.colors.primary600.copy(alpha = 0.5f)
    ): CheckboxColors = CheckboxColors(
        uncheckedBorderColor = AnimatedInteractionStateColorSelector(
            default = uncheckedBorderColor,
            pressed = pressedUncheckedBorderColor,
            focused = focusedUncheckedBorderColor,
            disabled = disabledUncheckedBorderColor
        ),
        checkedBorderColor = AnimatedInteractionStateColorSelector(
            default = checkedBorderColor,
            pressed = pressedCheckedBorderColor,
            focused = focusedCheckedBorderColor,
            disabled = disabledCheckedBorderColor
        ),
        indeterminateBorderColor = AnimatedInteractionStateColorSelector(
            default = indeterminateBorderColor,
            pressed = pressedIndeterminateBorderColor,
            focused = focusedIndeterminateBorderColor,
            disabled = disabledIndeterminateBorderColor
        ),
        uncheckedBackgroundColor = AnimatedInteractionStateColorSelector(
            default = uncheckedBackgroundColor,
            pressed = pressedUncheckedBackgroundColor,
            focused = focusedUncheckedBackgroundColor,
            disabled = disabledUncheckedBackgroundColor
        ),
        checkedBackgroundColor = AnimatedInteractionStateColorSelector(
            default = checkedBackgroundColor,
            pressed = pressedCheckedBackgroundColor,
            focused = focusedCheckedBackgroundColor,
            disabled = disabledCheckedBackgroundColor
        ),
        indeterminateBackgroundColor = AnimatedInteractionStateColorSelector(
            default = indeterminateBackgroundColor,
            pressed = pressedIndeterminateBackgroundColor,
            focused = focusedIndeterminateBackgroundColor,
            disabled = disabledIndeterminateBackgroundColor
        ),
        tickColor = AnimatedInteractionStateColorSelector(
            default = tickColor,
            pressed = pressedTickColor,
            focused = focusedTickColor,
            disabled = disabledTickColor
        ),
        indeterminateIndicatorColor = AnimatedInteractionStateColorSelector(
            default = indeterminateIndicatorColor,
            pressed = pressedIndeterminateIndicatorColor,
            focused = focusedIndeterminateIndicatorColor,
            disabled = disabledIndeterminateIndicatorColor
        ),
        uncheckedFocusedShadowColor = uncheckedFocusedShadowColor,
        checkedFocusedShadowColor = checkedFocusedShadowColor,
        indeterminateFocusedShadowColor = indeterminateFocusedShadowColor
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy