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

commonMain.io.github.lyxnx.compose.compodals.popups.PopupDialogDefaults.kt Maven / Gradle / Ivy

package io.github.lyxnx.compose.compodals.popups

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import io.github.lyxnx.compose.compodals.CompodalDefaults
import io.github.lyxnx.compose.compodals.dialogs.CompodalDialogDefaults

/**
 * Represents the colors used by a [PopupDialog]
 */
@Immutable
public data class PopupDialogColors(
    public val dimColor: Color,
    public val backgroundColor: Color
)

/**
 * Container for the default values used by a [PopupDialog]
 */
public object PopupDialogDefaults {

    /**
     * The default spacing between each button within a popup
     */
    public val DialogButtonSpacing: Dp = 8.dp

    /**
     * The default dim color to apply to the window background behind the popup, aka the scrim
     */
    public val DimColor: Color = CompodalDefaults.DimColor

    /**
     * The default background color for a popup dialog
     */
    public val BackgroundColor: Color
        @Composable
        get() = MaterialTheme.colorScheme.background

    /**
     * The default content padding for a popup dialog - this is the padding between edge of the popup window and the
     * actual inner content
     */
    public val ContentPadding: PaddingValues = PaddingValues(horizontal = 24.dp, vertical = 16.dp)

    /**
     * The default amount of space between each the the title, content and button elements within a popup
     */
    public val ContentSpacing: Dp = 16.dp

    /**
     * The default shape of a popup dialog
     */
    public val DialogShape: Shape = CompodalDialogDefaults.DialogShape

    /**
     * The default text style for an opinionated popup title
     */
    public val DialogTitleStyle: TextStyle
        @Composable
        get() = MaterialTheme.typography.titleLarge.copy(fontWeight = FontWeight.Medium)

    /**
     * The default text style for an opinionated popup message
     */
    public val DialogMessageStyle: TextStyle
        @Composable
        get() = MaterialTheme.typography.bodyLarge

    /**
     * Creates a [PopupDialogColors] instance with the given colors
     *
     * @param dimColor the color used for the dim - the portion behind the dialog, commonly known as a scrim
     * @param backgroundColor the color used for the background of the popup dialog itself
     */
    @Composable
    public fun popupColors(
        dimColor: Color = CompodalDefaults.DimColor,
        backgroundColor: Color = BackgroundColor,
    ): PopupDialogColors = PopupDialogColors(
        dimColor = dimColor,
        backgroundColor = backgroundColor
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy