Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package io.github.lyxnx.compose.pine
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.NonRestartableComposable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
/**
* Represents the status box type
*/
public enum class StatusBoxStyle {
/**
* Represents an informative status box - by default this will be styled with `infoXXX` colors
*/
Info,
/**
* Represents a warning status box - by default this will be styled with `warningXXX` colors
*/
Warning,
/**
* Represents an error status box - by default this will be styled with `errorXXX` colors
*/
Error,
/**
* Represents a success status box - by default this will be styled with `successXXX` colors
*/
Success
}
/**
* A Pine Theme status box
*
* A status box is a non interactive component used for conveying information to the user
*
* @param style the style of the status box
* @param icon the optional icon to display in the status box
* @param title the title of the status box
* @param message the optional message of the status box
* @param modifier modifier to apply to the status box
* @param iconSize the size of the icon (if applicable)
* @param contentPadding padding to apply to the content of the status box
* @param titleStyle style to apply to the title
* @param messageStyle style to apply to the message
*/
@Composable
@NonRestartableComposable
public fun StatusBox(
style: StatusBoxStyle,
icon: Painter?,
title: String,
message: String?,
modifier: Modifier = Modifier,
iconSize: DpSize = StatusBoxDefaults.IconSize,
contentPadding: PaddingValues = StatusBoxDefaults.ContentPadding,
titleStyle: TextStyle = PineTheme.typography.bodySmall.copy(fontWeight = FontWeight.SemiBold),
messageStyle: TextStyle = PineTheme.typography.bodySmall,
) {
StatusBox(
colors = StatusBoxDefaults.statusBoxColors(style),
icon = icon,
title = title,
message = message,
modifier = modifier,
iconSize = iconSize,
contentPadding = contentPadding,
titleStyle = titleStyle,
messageStyle = messageStyle
)
}
/**
* A Pine Theme status box
*
* A status box is a non interactive component used for conveying information to the user
*
* @param colors the colors to apply to the status box
* @param icon the optional icon to display in the status box
* @param title the title of the status box
* @param message the optional message of the status box
* @param modifier modifier to apply to the status box
* @param iconSize the size of the icon (if applicable)
* @param contentPadding padding to apply to the content of the status box
* @param titleStyle style to apply to the title
* @param messageStyle style to apply to the message
*/
@Composable
public fun StatusBox(
colors: StatusBoxColors,
icon: Painter?,
title: String,
message: String?,
modifier: Modifier = Modifier,
iconSize: DpSize = StatusBoxDefaults.IconSize,
contentPadding: PaddingValues = StatusBoxDefaults.ContentPadding,
titleStyle: TextStyle = PineTheme.typography.bodySmall.copy(fontWeight = FontWeight.SemiBold),
messageStyle: TextStyle = PineTheme.typography.bodySmall,
) {
StatusBox(
colors = colors,
modifier = modifier,
contentPadding = contentPadding
) {
if (icon != null) {
Icon(
painter = icon,
contentDescription = null,
tint = colors.iconColor,
modifier = Modifier.padding(end = 12.dp).size(iconSize)
)
}
Column {
Row(verticalAlignment = Alignment.CenterVertically) {
Text(
text = title,
style = titleStyle,
color = colors.titleColor
)
}
if (message != null) {
Text(
text = message,
style = messageStyle,
color = colors.messageColor,
modifier = Modifier.padding(top = 4.dp)
)
}
}
}
}
@Composable
private fun StatusBox(
colors: StatusBoxColors,
contentPadding: PaddingValues,
modifier: Modifier = Modifier,
content: @Composable RowScope.() -> Unit
) {
Box(
modifier = modifier
.clip(PineTheme.shapes.medium)
.border(width = 1.dp, color = colors.borderColor, shape = PineTheme.shapes.medium)
.height(IntrinsicSize.Min)
.background(colors.backgroundColor)
.padding(contentPadding)
) {
Row {
content()
}
}
}