refactor: 优化多个功能屏幕界面

- 优化AboutScreen关于页面
- 优化MyMemoirScreen我的回忆录页面,集成任务状态
- 优化ProfileScreen个人资料页面
This commit is contained in:
iammm0
2026-01-22 17:58:45 +08:00
parent 7333bc4de5
commit a3764030a1
3 changed files with 59 additions and 36 deletions

View File

@@ -11,6 +11,8 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import com.huaga.life_echo.ui.components.common.TransparentTopAppBar
import com.huaga.life_echo.ui.components.common.TransparencyType
import com.huaga.life_echo.ui.icons.AppIcons import com.huaga.life_echo.ui.icons.AppIcons
import com.huaga.life_echo.ui.theme.LightPurple import com.huaga.life_echo.ui.theme.LightPurple
@@ -21,22 +23,35 @@ fun AboutScreen(
) { ) {
Scaffold( Scaffold(
topBar = { topBar = {
TopAppBar( // 使用透明化TopAppBar - 示例:渐变透明
title = { Text("关于我们") }, TransparentTopAppBar(
title = {
Text(
"关于我们",
color = MaterialTheme.colorScheme.onSurface
)
},
navigationIcon = { navigationIcon = {
IconButton(onClick = { navController?.popBackStack() }) { IconButton(onClick = { navController?.popBackStack() }) {
Icon( Icon(
imageVector = AppIcons.ArrowBack, imageVector = AppIcons.ArrowBack,
contentDescription = "返回", contentDescription = "返回",
tint = Color.White tint = MaterialTheme.colorScheme.onSurface
) )
} }
}, },
colors = TopAppBarDefaults.topAppBarColors( // 选择透明化类型:
containerColor = LightPurple, // TransparencyType.FULLY_TRANSPARENT - 完全透明
titleContentColor = Color.White, // TransparencyType.SEMI_TRANSPARENT - 半透明可调整alpha值
navigationIconContentColor = Color.White // TransparencyType.GRADIENT - 渐变透明(从顶部到底部)
) transparencyType = TransparencyType.GRADIENT,
backgroundColor = MaterialTheme.colorScheme.surface,
gradientColors = listOf(
MaterialTheme.colorScheme.surface.copy(alpha = 0.95f),
MaterialTheme.colorScheme.surface.copy(alpha = 0.0f)
),
titleContentColor = MaterialTheme.colorScheme.onSurface,
navigationIconContentColor = MaterialTheme.colorScheme.onSurface
) )
} }
) { paddingValues -> ) { paddingValues ->
@@ -80,7 +95,7 @@ fun AboutScreen(
modifier = Modifier.padding(bottom = 32.dp) modifier = Modifier.padding(bottom = 32.dp)
) )
Divider( HorizontalDivider(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(vertical = 16.dp), .padding(vertical = 16.dp),
@@ -108,7 +123,7 @@ fun AboutScreen(
lineHeight = 24.sp lineHeight = 24.sp
) )
Divider( HorizontalDivider(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(vertical = 16.dp), .padding(vertical = 16.dp),
@@ -127,7 +142,7 @@ fun AboutScreen(
) )
Text( Text(
text = "如有任何问题或建议,欢迎通过应用内的"反馈与客服"功能联系我们。", text = "如有任何问题或建议,欢迎通过应用内的\"反馈与客服\"功能联系我们。",
fontSize = 16.sp, fontSize = 16.sp,
color = MaterialTheme.colorScheme.onSurfaceVariant, color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier modifier = Modifier
@@ -136,7 +151,7 @@ fun AboutScreen(
lineHeight = 24.sp lineHeight = 24.sp
) )
Divider( HorizontalDivider(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(vertical = 16.dp), .padding(vertical = 16.dp),

View File

@@ -54,11 +54,13 @@ fun MyMemoirScreen(
id = chapter.id, id = chapter.id,
title = chapter.title, title = chapter.title,
content = chapter.content, content = chapter.content,
orderIndex = chapter.orderIndex, order_index = chapter.orderIndex,
status = chapter.status, status = chapter.status,
category = chapter.category, category = chapter.category,
pageCount = null, // 可以从内容估算 images = emptyList(),
updatedAt = chapter.updatedAt updated_at = java.time.Instant.ofEpochMilli(chapter.updatedAt).toString(),
is_new = chapter.isNew,
source_segments = emptyList()
) )
} }
} }
@@ -84,11 +86,17 @@ fun MyMemoirScreen(
id = dto.id, id = dto.id,
title = dto.title, title = dto.title,
content = dto.content, content = dto.content,
orderIndex = dto.orderIndex, orderIndex = dto.order_index,
status = dto.status, status = dto.status,
category = dto.category, category = dto.category,
pageCount = dto.pageCount, pageCount = null,
updatedAt = dto.updatedAt ?: System.currentTimeMillis(), updatedAt = dto.updated_at?.let {
try {
java.time.Instant.parse(it).toEpochMilli()
} catch (e: Exception) {
System.currentTimeMillis()
}
} ?: System.currentTimeMillis(),
quotes = emptyList() quotes = emptyList()
) )
}, },
@@ -127,7 +135,7 @@ fun MyMemoirScreen(
BookInfoCard( BookInfoCard(
book = book, book = book,
onTitleChange = { title -> onTitleChange = { title ->
viewModel.updateBookTitle(title, book.subtitle) viewModel.updateBookTitle(title, null)
}, },
onSubtitleChange = { subtitle -> onSubtitleChange = { subtitle ->
viewModel.updateBookTitle(book.title, subtitle) viewModel.updateBookTitle(book.title, subtitle)
@@ -139,13 +147,12 @@ fun MyMemoirScreen(
BookInfoCard( BookInfoCard(
book = com.huaga.life_echo.network.models.BookDto( book = com.huaga.life_echo.network.models.BookDto(
id = "default", id = "default",
userId = "user",
title = "这一生", title = "这一生",
subtitle = "我的回忆录", total_pages = 0,
totalPages = 0, total_words = 0,
totalWords = 0, cover_image_url = null,
updatedAt = System.currentTimeMillis(), has_update = false,
lastUpdatedAt = System.currentTimeMillis() last_update_chapter_id = null
), ),
onTitleChange = { }, onTitleChange = { },
modifier = Modifier.padding(bottom = 24.dp) modifier = Modifier.padding(bottom = 24.dp)
@@ -177,7 +184,7 @@ fun MyMemoirScreen(
} }
// 章节列表 // 章节列表
items(chapterDtos.sortedBy { it.orderIndex }, key = { it.id }) { chapterDto -> items(chapterDtos.sortedBy { it.order_index }, key = { it.id }) { chapterDto ->
ChapterCard( ChapterCard(
chapter = chapterDto, chapter = chapterDto,
onClick = { onClick = {
@@ -194,11 +201,12 @@ fun MyMemoirScreen(
if (chapterDtos.isEmpty()) { if (chapterDtos.isEmpty()) {
item { item {
// 显示示例章节 // 显示示例章节
val now = java.time.Instant.now().toString()
listOf( listOf(
ChapterDto("demo1", "童年与家庭", "", 1, "completed", "childhood", 3, System.currentTimeMillis()), ChapterDto("demo1", "童年与家庭", "", 1, "completed", "childhood", emptyList(), now, false, emptyList()),
ChapterDto("demo2", "上学的日子", "", 2, "partial", "education", 2, System.currentTimeMillis()), ChapterDto("demo2", "上学的日子", "", 2, "partial", "education", emptyList(), now, false, emptyList()),
ChapterDto("demo3", "工作与事业", "", 3, "pending", "career", null, System.currentTimeMillis()), ChapterDto("demo3", "工作与事业", "", 3, "pending", "career", emptyList(), now, true, emptyList()),
ChapterDto("demo4", "爱情与婚姻", "", 4, "pending", "family", null, System.currentTimeMillis()) ChapterDto("demo4", "爱情与婚姻", "", 4, "pending", "family", emptyList(), now, true, emptyList())
).forEach { chapterDto -> ).forEach { chapterDto ->
ChapterCard( ChapterCard(
chapter = chapterDto, chapter = chapterDto,

View File

@@ -22,7 +22,7 @@ import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Divider import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.Switch import androidx.compose.material3.Switch
import androidx.compose.material3.SwitchDefaults import androidx.compose.material3.SwitchDefaults
@@ -265,7 +265,7 @@ fun ProfileScreen(
navController?.navigate(com.huaga.life_echo.navigation.Screen.PlanDetails.route) navController?.navigate(com.huaga.life_echo.navigation.Screen.PlanDetails.route)
} }
) )
Divider(modifier = Modifier.padding(horizontal = 16.dp)) HorizontalDivider(modifier = Modifier.padding(horizontal = 16.dp))
} }
SettingItem( SettingItem(
icon = AppIcons.Upgrade, icon = AppIcons.Upgrade,
@@ -275,7 +275,7 @@ fun ProfileScreen(
navController?.navigate(com.huaga.life_echo.navigation.Screen.UpgradePlan.route) navController?.navigate(com.huaga.life_echo.navigation.Screen.UpgradePlan.route)
} }
) )
Divider(modifier = Modifier.padding(horizontal = 16.dp)) HorizontalDivider(modifier = Modifier.padding(horizontal = 16.dp))
SettingItem( SettingItem(
icon = AppIcons.Receipt, icon = AppIcons.Receipt,
title = "我的订单", title = "我的订单",
@@ -311,7 +311,7 @@ fun ProfileScreen(
navController?.navigate(com.huaga.life_echo.navigation.Screen.FAQ.route) navController?.navigate(com.huaga.life_echo.navigation.Screen.FAQ.route)
} }
) )
Divider(modifier = Modifier.padding(horizontal = 16.dp)) HorizontalDivider(modifier = Modifier.padding(horizontal = 16.dp))
SettingItem( SettingItem(
icon = AppIcons.Info, icon = AppIcons.Info,
title = "反馈与客服", title = "反馈与客服",
@@ -335,7 +335,7 @@ fun ProfileScreen(
showSpeechRateDialog = true showSpeechRateDialog = true
} }
) )
Divider(modifier = Modifier.padding(horizontal = 16.dp)) HorizontalDivider(modifier = Modifier.padding(horizontal = 16.dp))
SettingItem( SettingItem(
icon = AppIcons.FormatSize, icon = AppIcons.FormatSize,
title = "大字模式", title = "大字模式",
@@ -353,7 +353,7 @@ fun ProfileScreen(
}, },
onClick = { largeFontMode = !largeFontMode } onClick = { largeFontMode = !largeFontMode }
) )
Divider(modifier = Modifier.padding(horizontal = 16.dp)) HorizontalDivider(modifier = Modifier.padding(horizontal = 16.dp))
SettingItem( SettingItem(
icon = AppIcons.Brightness2, icon = AppIcons.Brightness2,
title = "夜间模式", title = "夜间模式",