From 70e79ec584ac521f2bdd3684f12d177c41c96aa4 Mon Sep 17 00:00:00 2001 From: yovinchen Date: Thu, 28 Nov 2024 23:25:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=96=87=E5=AD=97?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF=20=E6=94=B9=E8=BF=9B?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E8=AF=AD=E5=8F=A5=E5=92=8CUI=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/screen/CategoryDetailScreen.kt | 32 +++++++++++++---- .../ui/screen/MemberDetailScreen.kt | 35 ++++++++++++++----- 2 files changed, 52 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/yovinchen/bookkeeping/ui/screen/CategoryDetailScreen.kt b/app/src/main/java/com/yovinchen/bookkeeping/ui/screen/CategoryDetailScreen.kt index 2460a98..2f6f2be 100644 --- a/app/src/main/java/com/yovinchen/bookkeeping/ui/screen/CategoryDetailScreen.kt +++ b/app/src/main/java/com/yovinchen/bookkeeping/ui/screen/CategoryDetailScreen.kt @@ -1,12 +1,30 @@ package com.yovinchen.bookkeeping.ui.screen -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.lazy.LazyColumn -import androidx.compose.foundation.lazy.items import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack -import androidx.compose.material3.* -import androidx.compose.runtime.* +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext @@ -15,6 +33,7 @@ import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel import com.yovinchen.bookkeeping.data.BookkeepingDatabase import com.yovinchen.bookkeeping.model.BookkeepingRecord +import com.yovinchen.bookkeeping.model.TransactionType import com.yovinchen.bookkeeping.ui.components.CategoryPieChart import com.yovinchen.bookkeeping.ui.components.RecordItem import com.yovinchen.bookkeeping.viewmodel.CategoryDetailViewModel @@ -22,8 +41,7 @@ import com.yovinchen.bookkeeping.viewmodel.CategoryDetailViewModelFactory import java.text.NumberFormat import java.text.SimpleDateFormat import java.time.YearMonth -import java.time.format.DateTimeFormatter -import java.util.* +import java.util.Locale @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -76,7 +94,7 @@ fun CategoryDetailScreen( horizontalAlignment = Alignment.CenterHorizontally ) { Text( - text = "总支出", + text = if (records.isNotEmpty() && records.first().type == TransactionType.INCOME) "总收入" else "总支出", style = MaterialTheme.typography.titleMedium ) Spacer(modifier = Modifier.height(8.dp)) diff --git a/app/src/main/java/com/yovinchen/bookkeeping/ui/screen/MemberDetailScreen.kt b/app/src/main/java/com/yovinchen/bookkeeping/ui/screen/MemberDetailScreen.kt index 77574aa..896a86f 100644 --- a/app/src/main/java/com/yovinchen/bookkeeping/ui/screen/MemberDetailScreen.kt +++ b/app/src/main/java/com/yovinchen/bookkeeping/ui/screen/MemberDetailScreen.kt @@ -1,24 +1,43 @@ package com.yovinchen.bookkeeping.ui.screen -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.lazy.LazyColumn import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack -import androidx.compose.material3.* -import androidx.compose.runtime.* +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel import com.yovinchen.bookkeeping.data.Record +import com.yovinchen.bookkeeping.model.TransactionType import com.yovinchen.bookkeeping.ui.components.RecordItem import com.yovinchen.bookkeeping.viewmodel.MemberDetailViewModel import java.text.NumberFormat import java.text.SimpleDateFormat import java.time.YearMonth -import java.time.format.DateTimeFormatter -import java.util.* +import java.util.Locale @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -50,7 +69,7 @@ fun MemberDetailScreen( }, navigationIcon = { IconButton(onClick = onNavigateBack) { - Icon(Icons.Default.ArrowBack, "返回") + Icon(Icons.AutoMirrored.Filled.ArrowBack, "返回") } } ) @@ -75,7 +94,7 @@ fun MemberDetailScreen( horizontalAlignment = Alignment.CenterHorizontally ) { Text( - text = "总支出", + text = if (records.isNotEmpty() && records.first().type == TransactionType.INCOME) "总收入" else "总支出", style = MaterialTheme.typography.titleMedium ) Spacer(modifier = Modifier.height(8.dp))