diff --git a/app/build.gradle.kts b/app/build.gradle.kts index d319647..99c9f6d 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -27,8 +27,8 @@ android { applicationId = "com.ledga.app" minSdk = 26 targetSdk = 34 - versionCode = 5 - versionName = "1.3.2" + versionCode = 6 + versionName = "1.3.3" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/com/ledga/app/ui/components/DonutChart.kt b/app/src/main/java/com/ledga/app/ui/components/DonutChart.kt index 18d13a8..85e1603 100644 --- a/app/src/main/java/com/ledga/app/ui/components/DonutChart.kt +++ b/app/src/main/java/com/ledga/app/ui/components/DonutChart.kt @@ -5,7 +5,9 @@ import androidx.compose.animation.core.tween import androidx.compose.foundation.Canvas import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -41,9 +43,18 @@ fun DonutChart( val total = segments.sumOf { it.value.toDouble() }.toFloat() - Box(modifier = modifier, contentAlignment = Alignment.Center) { - Canvas(modifier = Modifier.size(180.dp)) { - val strokeWidth = 32.dp.toPx() + Box( + modifier = modifier + .fillMaxWidth() + // Force square so the donut stays circular even when the parent + // is narrower than the historical 180dp fixed size (e.g. inside + // a 50/50 Row in Home's "Where it went" card). + .aspectRatio(1f), + contentAlignment = Alignment.Center, + ) { + Canvas(modifier = Modifier.fillMaxSize()) { + // Stroke scales with the box so the ring looks right at any size. + val strokeWidth = (size.minDimension * 0.18f).coerceAtMost(32.dp.toPx()) val radius = (size.minDimension - strokeWidth) / 2 var startAngle = -90f diff --git a/app/src/main/java/com/ledga/app/ui/home/HomeScreen.kt b/app/src/main/java/com/ledga/app/ui/home/HomeScreen.kt index 9524f92..e277430 100644 --- a/app/src/main/java/com/ledga/app/ui/home/HomeScreen.kt +++ b/app/src/main/java/com/ledga/app/ui/home/HomeScreen.kt @@ -34,11 +34,13 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import com.ledga.app.ui.components.DonutChart +import com.ledga.app.ui.components.Period import com.ledga.app.ui.components.parseColor import com.ledga.app.ui.components.v2.AccountChip import com.ledga.app.ui.components.v2.AccountSwitcherSheet import com.ledga.app.ui.components.v2.Avatar import com.ledga.app.ui.components.v2.BentoCard +import com.ledga.app.ui.components.v2.LedgaChip import com.ledga.app.ui.components.v2.LedgaTopBar import com.ledga.app.ui.components.v2.StatCard import com.ledga.app.ui.components.v2.TopBarIconButton @@ -151,10 +153,29 @@ fun HomeScreen( ) } - // ---- HERO: spent this month ---- + // ---- Period selector ---- + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(Space.s3), + ) { + Period.entries.forEach { period -> + LedgaChip( + label = period.label, + selected = state.selectedPeriod == period, + onClick = { viewModel.selectPeriod(period) }, + ) + } + } + + // ---- HERO: spent for selected period ---- BentoCard(onClick = onNavigateToActivity) { + val overlineLabel = when (state.selectedPeriod) { + Period.TODAY -> "SPENT TODAY" + Period.THIS_WEEK -> "SPENT THIS WEEK" + Period.THIS_MONTH -> "SPENT THIS MONTH" + } Text( - text = "SPENT THIS MONTH", + text = overlineLabel, style = LedgaText.Overline, color = MaterialTheme.colorScheme.onSurfaceVariant, )