package com.craigvg.lichun_android.ui.screens.home.components import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.* 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.res.stringResource import androidx.compose.ui.unit.dp import com.craigvg.lichun_android.R import com.craigvg.lichun_android.ui.theme.AppColors import com.craigvg.lichun_android.ui.theme.AppSpacing import com.craigvg.lichun_android.ui.theme.AppTypography /** * Health, happiness, intelligence, prestige stat bars * Ported from iOS QuickStatsCard.swift */ @Composable fun QuickStatsCard( health: Double, happiness: Int, intelligence: Int, prestige: Int ) { Card( modifier = Modifier.fillMaxWidth(), shape = RoundedCornerShape(AppSpacing.cornerRadius), colors = CardDefaults.cardColors(containerColor = AppColors.surfaceElevated) ) { Column( modifier = Modifier .fillMaxWidth() .padding(AppSpacing.md) ) { Text( text = stringResource(R.string.stats), style = AppTypography.headline, color = AppColors.primaryText ) Spacer(modifier = Modifier.height(AppSpacing.sm)) StatBar(label = stringResource(R.string.health), value = (health / 100).toFloat(), color = AppColors.health) Spacer(modifier = Modifier.height(AppSpacing.xs)) StatBar(label = stringResource(R.string.happiness), value = happiness / 100f, color = AppColors.happiness) Spacer(modifier = Modifier.height(AppSpacing.xs)) StatBar(label = stringResource(R.string.intelligence), value = intelligence / 100f, color = AppColors.intelligence) Spacer(modifier = Modifier.height(AppSpacing.xs)) StatBar(label = stringResource(R.string.prestige), value = prestige / 100f, color = AppColors.prestige) } } } @Composable fun StatBar( label: String, value: Float, color: Color ) { Column { Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween ) { Text( text = label, style = AppTypography.caption, color = AppColors.secondaryText ) Text( text = "${(value * 100).toInt()}%", style = AppTypography.captionBold, color = color ) } Spacer(modifier = Modifier.height(4.dp)) Box( modifier = Modifier .fillMaxWidth() .height(AppSpacing.progressBarHeight) .clip(RoundedCornerShape(4.dp)) .background(color.copy(alpha = 0.2f)) ) { Box( modifier = Modifier .fillMaxWidth(value.coerceIn(0f, 1f)) .fillMaxHeight() .clip(RoundedCornerShape(4.dp)) .background(color) ) } } }