package com.craigvg.lichun_android.ui.components.indicators import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.craigvg.lichun_android.ui.theme.AppColors import com.craigvg.lichun_android.ui.theme.AppSpacing import com.craigvg.lichun_android.ui.theme.AppTypography /** * Standalone progress indicator bar. * Ported from iOS ProgressBar.swift */ @Composable fun ProgressBar( value: Float, modifier: Modifier = Modifier, height: Dp = 8.dp, backgroundColor: Color = Color.White.copy(alpha = 0.2f), foregroundColor: Color = AppColors.primary, cornerRadius: Dp = 4.dp, showLabel: Boolean = false, label: String? = null ) { val clampedValue = value.coerceIn(0f, 1f) Column( modifier = modifier, verticalArrangement = Arrangement.spacedBy(AppSpacing.xs) ) { if (showLabel || label != null) { Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween ) { if (label != null) { Text( text = label, style = AppTypography.caption, color = AppColors.primaryText ) } if (showLabel) { Text( text = "${(clampedValue * 100).toInt()}%", style = AppTypography.captionBold, color = AppColors.primaryText ) } } } Box( modifier = Modifier .fillMaxWidth() .height(height) .clip(RoundedCornerShape(cornerRadius)) .background(backgroundColor) ) { Box( modifier = Modifier .fillMaxHeight() .fillMaxWidth(fraction = clampedValue) .clip(RoundedCornerShape(cornerRadius)) .background(foregroundColor) ) } } }