fix: 修复光标bug;移除输入框表情按钮;修复章节回退动画;部分页面大字模式优化

This commit is contained in:
yangshilin
2026-03-10 15:24:48 +08:00
parent 462880960e
commit c700b7a67c
5 changed files with 84 additions and 43 deletions

View File

@@ -38,6 +38,7 @@ import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.SubcomposeLayout
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
@@ -72,7 +73,6 @@ fun ChatInputField(
modifier: Modifier = Modifier,
placeholder: String = "输入消息...",
enabled: Boolean = true,
onEmojiClick: () -> Unit = {},
onAddClick: () -> Unit = {},
onStartRecording: () -> Unit = {},
onStopRecording: () -> Unit = {},
@@ -167,15 +167,6 @@ fun ChatInputField(
}
}
if (layoutPresentation.showEmojiAction) {
RoundIconAction(
icon = AppIcons.SentimentSatisfied,
contentDescription = "表情",
enabled = enabled && !isRecording,
onClick = onEmojiClick,
)
}
when (layoutPresentation.trailingAction) {
ChatInputTrailingAction.ADD -> {
RoundIconAction(
@@ -319,9 +310,18 @@ private fun TextInputContent(
enabled: Boolean,
modifier: Modifier = Modifier,
) {
var textFieldValue by remember { mutableStateOf(TextFieldValue(value)) }
LaunchedEffect(value) {
if (value != textFieldValue.text) {
textFieldValue = TextFieldValue(value)
}
}
BasicTextField(
value = value,
onValueChange = onValueChange,
value = textFieldValue,
onValueChange = {
textFieldValue = it
onValueChange(it.text)
},
modifier = modifier,
textStyle = MaterialTheme.typography.bodyLarge.copy(
fontSize = AppTypography.titleMedium,
@@ -341,7 +341,7 @@ private fun TextInputContent(
CenterAreaShell(
backgroundColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.14f),
) {
if (value.isEmpty()) {
if (textFieldValue.text.isEmpty()) {
Text(
text = placeholder,
color = MaterialTheme.colorScheme.onSurfaceVariant,

View File

@@ -32,7 +32,6 @@ enum class ChatInputTrailingAction {
data class ChatInputLayoutPresentation(
val leadingAction: ChatInputLeadingAction,
val showEmojiAction: Boolean,
val trailingAction: ChatInputTrailingAction,
) {
companion object {
@@ -44,7 +43,6 @@ data class ChatInputLayoutPresentation(
return when (inputMode) {
InputMode.TEXT -> ChatInputLayoutPresentation(
leadingAction = ChatInputLeadingAction.SWITCH_TO_VOICE,
showEmojiAction = true,
trailingAction = if (hasText) {
ChatInputTrailingAction.SEND
} else {
@@ -54,7 +52,6 @@ data class ChatInputLayoutPresentation(
InputMode.VOICE -> ChatInputLayoutPresentation(
leadingAction = ChatInputLeadingAction.SWITCH_TO_TEXT,
showEmojiAction = !isRecording,
trailingAction = if (isRecording) {
ChatInputTrailingAction.CANCEL
} else {

View File

@@ -13,7 +13,6 @@ 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.compose.ui.unit.sp
import com.huaga.life_echo.network.models.FAQDto
import com.huaga.life_echo.ui.icons.AppIcons
import com.huaga.life_echo.ui.theme.AppTypography
@@ -67,8 +66,8 @@ fun FAQItem(
Text(
text = faq.answer,
fontSize = AppTypography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
lineHeight = 20.sp
lineHeight = AppTypography.lineHeightNormal,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}

View File

@@ -232,38 +232,63 @@ fun AccountManagementScreen(
)
}
// 登出当前设备确认对话框
// 登出当前设备确认对话框(跟随大字模式)
if (showLogoutDialog) {
AlertDialog(
onDismissRequest = { showLogoutDialog = false },
title = { Text("确认登出") },
text = { Text("确定要登出当前设备吗?") },
title = {
Text(
text = "确认登出",
fontSize = AppTypography.titleMedium,
fontWeight = FontWeight.SemiBold
)
},
text = {
Text(
text = "确定要登出当前设备吗?",
fontSize = AppTypography.bodyMedium,
lineHeight = AppTypography.lineHeightNormal
)
},
confirmButton = {
TextButton(
onClick = {
viewModel.logout()
showLogoutDialog = false
onLogoutSuccess()
}
},
colors = ButtonDefaults.textButtonColors(
contentColor = MaterialTheme.colorScheme.error
)
) {
Text("确认", color = MaterialTheme.colorScheme.error)
Text("确认", fontSize = AppTypography.bodyMedium)
}
},
dismissButton = {
TextButton(onClick = { showLogoutDialog = false }) {
Text("取消")
Text("取消", fontSize = AppTypography.bodyMedium)
}
}
)
}
// 登出所有设备确认对话框
// 登出所有设备确认对话框(跟随大字模式)
if (showLogoutAllDialog) {
AlertDialog(
onDismissRequest = { showLogoutAllDialog = false },
title = { Text("确认登出所有设备") },
text = {
Text("定要登出所有设备吗?这将使您在所有设备上的登录状态失效,需要重新登录。")
title = {
Text(
text = "登出所有设备",
fontSize = AppTypography.titleMedium,
fontWeight = FontWeight.SemiBold
)
},
text = {
Text(
text = "确定要登出所有设备吗?这将使您在所有设备上的登录状态失效,需要重新登录。",
fontSize = AppTypography.bodyMedium,
lineHeight = AppTypography.lineHeightNormal
)
},
confirmButton = {
TextButton(
@@ -272,14 +297,17 @@ fun AccountManagementScreen(
showLogoutAllDialog = false
onLogoutSuccess()
}
}
},
colors = ButtonDefaults.textButtonColors(
contentColor = MaterialTheme.colorScheme.error
)
) {
Text("确认登出", color = MaterialTheme.colorScheme.error)
Text("确认登出", fontSize = AppTypography.bodyMedium)
}
},
dismissButton = {
TextButton(onClick = { showLogoutAllDialog = false }) {
Text("取消")
Text("取消", fontSize = AppTypography.bodyMedium)
}
}
)

View File

@@ -168,13 +168,25 @@ fun MyMemoirScreen(
AnimatedContent(
targetState = showFullTextReading || selectedChapter != null,
transitionSpec = {
slideInHorizontally(
initialOffsetX = { it },
animationSpec = tween(300)
) togetherWith slideOutHorizontally(
targetOffsetX = { -it },
animationSpec = tween(300)
)
if (targetState) {
// 进入章节/阅读:新内容从右侧滑入,目录向左滑出
slideInHorizontally(
initialOffsetX = { it },
animationSpec = tween(300)
) togetherWith slideOutHorizontally(
targetOffsetX = { -it },
animationSpec = tween(300)
)
} else {
// 返回目录:目录从左侧滑入,章节向右滑出
slideInHorizontally(
initialOffsetX = { -it },
animationSpec = tween(300)
) togetherWith slideOutHorizontally(
targetOffsetX = { it },
animationSpec = tween(300)
)
}
},
label = "memoir_navigation"
) { isReading ->
@@ -230,18 +242,23 @@ fun MyMemoirScreen(
// 清除回忆确认弹窗状态
var showClearDialog by remember { mutableStateOf(false) }
// 清除回忆确认弹窗
// 清除回忆确认弹窗(跟随大字模式)
if (showClearDialog) {
AlertDialog(
onDismissRequest = { showClearDialog = false },
title = {
Text(
text = "清除回忆",
fontSize = AppTypography.titleMedium,
fontWeight = FontWeight.SemiBold
)
},
text = {
Text("清除回忆会完全清除当前章节的内容,确定继续吗?")
Text(
"清除回忆会完全清除当前章节的内容,确定继续吗?",
fontSize = AppTypography.bodyMedium,
lineHeight = AppTypography.lineHeightNormal
)
},
confirmButton = {
TextButton(
@@ -255,12 +272,12 @@ fun MyMemoirScreen(
contentColor = MaterialTheme.colorScheme.error
)
) {
Text("确定清除")
Text("确定清除", fontSize = AppTypography.bodyMedium)
}
},
dismissButton = {
TextButton(onClick = { showClearDialog = false }) {
Text("取消")
Text("取消", fontSize = AppTypography.bodyMedium)
}
}
)