refactor: UI界面和代码重构
1. 简化 AnalysisViewModel 使用 Flow 组合 2. 改进 AnalysisScreen 的布局结构 3. 优化 CategoryDetailScreen 的视觉层次 4. 修复统计中成员名称的处理
This commit is contained in:
parent
94fc7b2a7e
commit
37b91ded7f
@ -62,27 +62,74 @@ fun CategoryDetailScreen(
|
|||||||
.padding(padding),
|
.padding(padding),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
|
// 第一部分:总支出
|
||||||
item {
|
item {
|
||||||
|
Card(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp),
|
||||||
|
elevation = CardDefaults.cardElevation(defaultElevation = 4.dp)
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(16.dp),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "总支出",
|
||||||
|
style = MaterialTheme.typography.titleMedium
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
Text(
|
Text(
|
||||||
text = NumberFormat.getCurrencyInstance(Locale.CHINA).format(total),
|
text = NumberFormat.getCurrencyInstance(Locale.CHINA).format(total),
|
||||||
style = MaterialTheme.typography.headlineMedium,
|
style = MaterialTheme.typography.headlineMedium,
|
||||||
modifier = Modifier.padding(16.dp)
|
fontWeight = FontWeight.Bold
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 第二部分:扇形图
|
||||||
item {
|
item {
|
||||||
|
Card(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||||
|
elevation = CardDefaults.cardElevation(defaultElevation = 4.dp)
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(16.dp),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "成员分布",
|
||||||
|
style = MaterialTheme.typography.titleMedium,
|
||||||
|
modifier = Modifier.padding(bottom = 16.dp)
|
||||||
|
)
|
||||||
CategoryPieChart(
|
CategoryPieChart(
|
||||||
categoryData = memberStats.map { Pair(it.category, it.percentage.toFloat()) },
|
categoryData = memberStats.map { Pair(it.category, it.percentage.toFloat()) },
|
||||||
memberData = emptyList(),
|
memberData = emptyList(),
|
||||||
currentViewMode = false,
|
currentViewMode = false,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(16.dp),
|
.height(200.dp),
|
||||||
onCategoryClick = { memberName -> onNavigateToMemberDetail(memberName) }
|
onCategoryClick = { memberName -> onNavigateToMemberDetail(memberName) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 按日期分组记录
|
// 第三部分:详细信息
|
||||||
|
item {
|
||||||
|
Text(
|
||||||
|
text = "详细记录",
|
||||||
|
style = MaterialTheme.typography.titleMedium,
|
||||||
|
modifier = Modifier.padding(16.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按日期分组的记录列表
|
||||||
val groupedRecords = records.groupBy { record ->
|
val groupedRecords = records.groupBy { record ->
|
||||||
SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(record.date)
|
SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(record.date)
|
||||||
}.toSortedMap(compareByDescending { it })
|
}.toSortedMap(compareByDescending { it })
|
||||||
|
@ -75,7 +75,7 @@ fun MemberDetailScreen(
|
|||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = "当前分类总支出",
|
text = "总支出",
|
||||||
style = MaterialTheme.typography.titleMedium
|
style = MaterialTheme.typography.titleMedium
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
Loading…
Reference in New Issue
Block a user