From a3764030a144c2b966e331437f567321c03a8528 Mon Sep 17 00:00:00 2001 From: iammm0 Date: Thu, 22 Jan 2026 17:58:45 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E5=8A=9F=E8=83=BD=E5=B1=8F=E5=B9=95=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 优化AboutScreen关于页面 - 优化MyMemoirScreen我的回忆录页面,集成任务状态 - 优化ProfileScreen个人资料页面 --- .../huaga/life_echo/ui/screens/AboutScreen.kt | 39 +++++++++++----- .../life_echo/ui/screens/MyMemoirScreen.kt | 44 +++++++++++-------- .../life_echo/ui/screens/ProfileScreen.kt | 12 ++--- 3 files changed, 59 insertions(+), 36 deletions(-) diff --git a/app-android/app/src/main/java/com/huaga/life_echo/ui/screens/AboutScreen.kt b/app-android/app/src/main/java/com/huaga/life_echo/ui/screens/AboutScreen.kt index 91a5fdb..bf66d25 100644 --- a/app-android/app/src/main/java/com/huaga/life_echo/ui/screens/AboutScreen.kt +++ b/app-android/app/src/main/java/com/huaga/life_echo/ui/screens/AboutScreen.kt @@ -11,6 +11,8 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp 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.theme.LightPurple @@ -21,22 +23,35 @@ fun AboutScreen( ) { Scaffold( topBar = { - TopAppBar( - title = { Text("关于我们") }, + // 使用透明化TopAppBar - 示例:渐变透明 + TransparentTopAppBar( + title = { + Text( + "关于我们", + color = MaterialTheme.colorScheme.onSurface + ) + }, navigationIcon = { IconButton(onClick = { navController?.popBackStack() }) { Icon( imageVector = AppIcons.ArrowBack, contentDescription = "返回", - tint = Color.White + tint = MaterialTheme.colorScheme.onSurface ) } }, - colors = TopAppBarDefaults.topAppBarColors( - containerColor = LightPurple, - titleContentColor = Color.White, - navigationIconContentColor = Color.White - ) + // 选择透明化类型: + // TransparencyType.FULLY_TRANSPARENT - 完全透明 + // TransparencyType.SEMI_TRANSPARENT - 半透明(可调整alpha值) + // 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 -> @@ -80,7 +95,7 @@ fun AboutScreen( modifier = Modifier.padding(bottom = 32.dp) ) - Divider( + HorizontalDivider( modifier = Modifier .fillMaxWidth() .padding(vertical = 16.dp), @@ -108,7 +123,7 @@ fun AboutScreen( lineHeight = 24.sp ) - Divider( + HorizontalDivider( modifier = Modifier .fillMaxWidth() .padding(vertical = 16.dp), @@ -127,7 +142,7 @@ fun AboutScreen( ) Text( - text = "如有任何问题或建议,欢迎通过应用内的"反馈与客服"功能联系我们。", + text = "如有任何问题或建议,欢迎通过应用内的\"反馈与客服\"功能联系我们。", fontSize = 16.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier @@ -136,7 +151,7 @@ fun AboutScreen( lineHeight = 24.sp ) - Divider( + HorizontalDivider( modifier = Modifier .fillMaxWidth() .padding(vertical = 16.dp), diff --git a/app-android/app/src/main/java/com/huaga/life_echo/ui/screens/MyMemoirScreen.kt b/app-android/app/src/main/java/com/huaga/life_echo/ui/screens/MyMemoirScreen.kt index b92323d..28e0ef9 100644 --- a/app-android/app/src/main/java/com/huaga/life_echo/ui/screens/MyMemoirScreen.kt +++ b/app-android/app/src/main/java/com/huaga/life_echo/ui/screens/MyMemoirScreen.kt @@ -54,11 +54,13 @@ fun MyMemoirScreen( id = chapter.id, title = chapter.title, content = chapter.content, - orderIndex = chapter.orderIndex, + order_index = chapter.orderIndex, status = chapter.status, category = chapter.category, - pageCount = null, // 可以从内容估算 - updatedAt = chapter.updatedAt + images = emptyList(), + 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, title = dto.title, content = dto.content, - orderIndex = dto.orderIndex, + orderIndex = dto.order_index, status = dto.status, category = dto.category, - pageCount = dto.pageCount, - updatedAt = dto.updatedAt ?: System.currentTimeMillis(), + pageCount = null, + updatedAt = dto.updated_at?.let { + try { + java.time.Instant.parse(it).toEpochMilli() + } catch (e: Exception) { + System.currentTimeMillis() + } + } ?: System.currentTimeMillis(), quotes = emptyList() ) }, @@ -127,7 +135,7 @@ fun MyMemoirScreen( BookInfoCard( book = book, onTitleChange = { title -> - viewModel.updateBookTitle(title, book.subtitle) + viewModel.updateBookTitle(title, null) }, onSubtitleChange = { subtitle -> viewModel.updateBookTitle(book.title, subtitle) @@ -139,13 +147,12 @@ fun MyMemoirScreen( BookInfoCard( book = com.huaga.life_echo.network.models.BookDto( id = "default", - userId = "user", title = "这一生", - subtitle = "我的回忆录", - totalPages = 0, - totalWords = 0, - updatedAt = System.currentTimeMillis(), - lastUpdatedAt = System.currentTimeMillis() + total_pages = 0, + total_words = 0, + cover_image_url = null, + has_update = false, + last_update_chapter_id = null ), onTitleChange = { }, 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( chapter = chapterDto, onClick = { @@ -194,11 +201,12 @@ fun MyMemoirScreen( if (chapterDtos.isEmpty()) { item { // 显示示例章节 + val now = java.time.Instant.now().toString() listOf( - ChapterDto("demo1", "童年与家庭", "", 1, "completed", "childhood", 3, System.currentTimeMillis()), - ChapterDto("demo2", "上学的日子", "", 2, "partial", "education", 2, System.currentTimeMillis()), - ChapterDto("demo3", "工作与事业", "", 3, "pending", "career", null, System.currentTimeMillis()), - ChapterDto("demo4", "爱情与婚姻", "", 4, "pending", "family", null, System.currentTimeMillis()) + ChapterDto("demo1", "童年与家庭", "", 1, "completed", "childhood", emptyList(), now, false, emptyList()), + ChapterDto("demo2", "上学的日子", "", 2, "partial", "education", emptyList(), now, false, emptyList()), + ChapterDto("demo3", "工作与事业", "", 3, "pending", "career", emptyList(), now, true, emptyList()), + ChapterDto("demo4", "爱情与婚姻", "", 4, "pending", "family", emptyList(), now, true, emptyList()) ).forEach { chapterDto -> ChapterCard( chapter = chapterDto, diff --git a/app-android/app/src/main/java/com/huaga/life_echo/ui/screens/ProfileScreen.kt b/app-android/app/src/main/java/com/huaga/life_echo/ui/screens/ProfileScreen.kt index be9d5bf..57d55d7 100644 --- a/app-android/app/src/main/java/com/huaga/life_echo/ui/screens/ProfileScreen.kt +++ b/app-android/app/src/main/java/com/huaga/life_echo/ui/screens/ProfileScreen.kt @@ -22,7 +22,7 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults -import androidx.compose.material3.Divider +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.Switch import androidx.compose.material3.SwitchDefaults @@ -265,7 +265,7 @@ fun ProfileScreen( 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( icon = AppIcons.Upgrade, @@ -275,7 +275,7 @@ fun ProfileScreen( 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( icon = AppIcons.Receipt, title = "我的订单", @@ -311,7 +311,7 @@ fun ProfileScreen( 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( icon = AppIcons.Info, title = "反馈与客服", @@ -335,7 +335,7 @@ fun ProfileScreen( showSpeechRateDialog = true } ) - Divider(modifier = Modifier.padding(horizontal = 16.dp)) + HorizontalDivider(modifier = Modifier.padding(horizontal = 16.dp)) SettingItem( icon = AppIcons.FormatSize, title = "大字模式", @@ -353,7 +353,7 @@ fun ProfileScreen( }, onClick = { largeFontMode = !largeFontMode } ) - Divider(modifier = Modifier.padding(horizontal = 16.dp)) + HorizontalDivider(modifier = Modifier.padding(horizontal = 16.dp)) SettingItem( icon = AppIcons.Brightness2, title = "夜间模式",