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

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

package io.github.lyxnx.compose.pine

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import io.github.lyxnx.compose.ui.AnimatedInteractionStateColorSelector

/**
 * Contains the default values used by a [Button]
 */
public object ButtonDefaults {

    /**
     * The default padding of button content between the content and its border
     */
    public val Padding: PaddingValues = PaddingValues(horizontal = 15.dp, vertical = 8.dp)

    /**
     * The default padding of a button that contains only an icon
     */
    public val IconPadding: PaddingValues = PaddingValues(10.dp)

    /**
     * The default size of a button icon
     */
    public val IconSize: DpSize = DpSize(24.dp, 24.dp)

    /**
     * Creates a [ButtonColors] instance that represents the colors of a primary in different states
     */
    @Composable
    public fun buttonColors(
        borderColor: Color = PineTheme.colors.primary500,
        pressedBorderColor: Color = PineTheme.colors.primary600,
        focusedBorderColor: Color = PineTheme.colors.primary400,
        disabledBorderColor: Color = PineTheme.colors.grey300,
        backgroundColor: Color = PineTheme.colors.primary500,
        pressedBackgroundColor: Color = PineTheme.colors.primary600,
        focusedBackgroundColor: Color = PineTheme.colors.primary400,
        disabledBackgroundColor: Color = PineTheme.colors.grey300,
        contentColor: Color = PineTheme.colors.white,
        pressedContentColor: Color = PineTheme.colors.white,
        focusedContentColor: Color = PineTheme.colors.white,
        disabledContentColor: Color = PineTheme.colors.grey400,
        focusedShadowColor: Color = PineTheme.colors.primary600.copy(alpha = 0.5f),
        loadingTrackColor: Color = PineTheme.colors.primary400,
        loadingBarColor: Color = PineTheme.colors.white
    ): ButtonColors = ButtonColors(
        borderColor = AnimatedInteractionStateColorSelector(
            default = borderColor,
            pressed = pressedBorderColor,
            focused = focusedBorderColor,
            disabled = disabledBorderColor
        ),
        backgroundColor = AnimatedInteractionStateColorSelector(
            default = backgroundColor,
            pressed = pressedBackgroundColor,
            focused = focusedBackgroundColor,
            disabled = disabledBackgroundColor
        ),
        contentColor = AnimatedInteractionStateColorSelector(
            default = contentColor,
            pressed = pressedContentColor,
            focused = focusedContentColor,
            disabled = disabledContentColor
        ),
        focusedShadowColor = focusedShadowColor,
        loadingTrackColor = loadingTrackColor,
        loadingBarColor = loadingBarColor
    )

    /**
     * Creates a [ButtonColors] instance that represents the colors of a secondary button in different states
     */
    @Composable
    public fun secondaryButtonColors(
        borderColor: Color = PineTheme.colors.primary200,
        pressedBorderColor: Color = PineTheme.colors.primary700,
        focusedBorderColor: Color = PineTheme.colors.primary400,
        disabledBorderColor: Color = PineTheme.colors.grey300,
        backgroundColor: Color = PineTheme.colors.primary100,
        pressedBackgroundColor: Color = PineTheme.colors.primary100,
        focusedBackgroundColor: Color = PineTheme.colors.primary100,
        disabledBackgroundColor: Color = PineTheme.colors.grey300,
        contentColor: Color = PineTheme.colors.primary600,
        pressedContentColor: Color = PineTheme.colors.primary700,
        focusedContentColor: Color = PineTheme.colors.primary400,
        disabledContentColor: Color = PineTheme.colors.grey400,
        focusedShadowColor: Color = PineTheme.colors.primary600.copy(alpha = 0.5f),
        loadingTrackColor: Color = PineTheme.colors.primary200,
        loadingBarColor: Color = PineTheme.colors.primary600
    ): ButtonColors = ButtonColors(
        borderColor = AnimatedInteractionStateColorSelector(
            default = borderColor,
            pressed = pressedBorderColor,
            focused = focusedBorderColor,
            disabled = disabledBorderColor
        ),
        backgroundColor = AnimatedInteractionStateColorSelector(
            default = backgroundColor,
            pressed = pressedBackgroundColor,
            focused = focusedBackgroundColor,
            disabled = disabledBackgroundColor
        ),
        contentColor = AnimatedInteractionStateColorSelector(
            default = contentColor,
            pressed = pressedContentColor,
            focused = focusedContentColor,
            disabled = disabledContentColor
        ),
        focusedShadowColor = focusedShadowColor,
        loadingTrackColor = loadingTrackColor,
        loadingBarColor = loadingBarColor
    )

    /**
     * Creates a [ButtonColors] instance that represents the colors of a tertiary button in different states
     */
    @Composable
    public fun tertiaryButtonColors(
        borderColor: Color = PineTheme.colors.grey200,
        pressedBorderColor: Color = PineTheme.colors.grey700,
        focusedBorderColor: Color = PineTheme.colors.grey500,
        disabledBorderColor: Color = PineTheme.colors.grey300,
        backgroundColor: Color = PineTheme.colors.background,
        pressedBackgroundColor: Color = PineTheme.colors.grey100,
        focusedBackgroundColor: Color = PineTheme.colors.grey100,
        disabledBackgroundColor: Color = PineTheme.colors.grey300,
        contentColor: Color = PineTheme.colors.grey600,
        pressedContentColor: Color = PineTheme.colors.grey700,
        focusedContentColor: Color = PineTheme.colors.grey500,
        disabledContentColor: Color = PineTheme.colors.grey400,
        focusedShadowColor: Color = PineTheme.colors.grey600.copy(alpha = 0.5f),
        loadingTrackColor: Color = PineTheme.colors.grey200,
        loadingBarColor: Color = PineTheme.colors.grey600
    ): ButtonColors = ButtonColors(
        borderColor = AnimatedInteractionStateColorSelector(
            default = borderColor,
            pressed = pressedBorderColor,
            focused = focusedBorderColor,
            disabled = disabledBorderColor
        ),
        backgroundColor = AnimatedInteractionStateColorSelector(
            default = backgroundColor,
            pressed = pressedBackgroundColor,
            focused = focusedBackgroundColor,
            disabled = disabledBackgroundColor
        ),
        contentColor = AnimatedInteractionStateColorSelector(
            default = contentColor,
            pressed = pressedContentColor,
            focused = focusedContentColor,
            disabled = disabledContentColor
        ),
        focusedShadowColor = focusedShadowColor,
        loadingTrackColor = loadingTrackColor,
        loadingBarColor = loadingBarColor
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy