diff --git a/app/src/main/java/com/yovinchen/bookkeeping/ui/screen/AnalysisScreen.kt b/app/src/main/java/com/yovinchen/bookkeeping/ui/screen/AnalysisScreen.kt index de05639..1e1bd1c 100644 --- a/app/src/main/java/com/yovinchen/bookkeeping/ui/screen/AnalysisScreen.kt +++ b/app/src/main/java/com/yovinchen/bookkeeping/ui/screen/AnalysisScreen.kt @@ -1,19 +1,38 @@ package com.yovinchen.bookkeeping.ui.screen +import android.annotation.SuppressLint import androidx.compose.foundation.background import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.KeyboardArrowLeft import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight -import androidx.compose.material3.* -import androidx.compose.runtime.* +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.FilterChip +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.LinearProgressIndicator +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel @@ -22,9 +41,7 @@ import com.yovinchen.bookkeeping.ui.components.MonthYearPicker import com.yovinchen.bookkeeping.viewmodel.AnalysisType import com.yovinchen.bookkeeping.viewmodel.AnalysisViewModel import com.yovinchen.bookkeeping.viewmodel.CategoryStat -import java.time.YearMonth -@OptIn(ExperimentalMaterial3Api::class) @Composable fun AnalysisScreen( modifier: Modifier = Modifier, @@ -73,7 +90,7 @@ fun AnalysisScreen( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceEvenly ) { - AnalysisType.values().forEach { type -> + AnalysisType.entries.forEach { type -> FilterChip( selected = selectedType == type, onClick = { viewModel.setAnalysisType(type) }, @@ -160,6 +177,7 @@ fun AnalysisScreen( } } +@SuppressLint("DefaultLocale") @Composable fun CategoryStatItem(stat: CategoryStat) { Column( @@ -190,14 +208,14 @@ fun CategoryStatItem(stat: CategoryStat) { verticalAlignment = Alignment.CenterVertically ) { LinearProgressIndicator( - progress = stat.percentage.toFloat() / 100f, + progress = { stat.percentage.toFloat() / 100f }, modifier = Modifier .weight(1f) .height(8.dp) .background( MaterialTheme.colorScheme.surfaceVariant, RoundedCornerShape(4.dp) - ) + ), ) Spacer(modifier = Modifier.width(8.dp))