fix: 修复光标bug;移除输入框表情按钮;修复章节回退动画;部分页面大字模式优化
This commit is contained in:
@@ -38,6 +38,7 @@ import androidx.compose.ui.graphics.SolidColor
|
|||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.layout.SubcomposeLayout
|
import androidx.compose.ui.layout.SubcomposeLayout
|
||||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||||
|
import androidx.compose.ui.text.input.TextFieldValue
|
||||||
import androidx.compose.ui.semantics.Role
|
import androidx.compose.ui.semantics.Role
|
||||||
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
|
||||||
@@ -72,7 +73,6 @@ fun ChatInputField(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
placeholder: String = "输入消息...",
|
placeholder: String = "输入消息...",
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
onEmojiClick: () -> Unit = {},
|
|
||||||
onAddClick: () -> Unit = {},
|
onAddClick: () -> Unit = {},
|
||||||
onStartRecording: () -> Unit = {},
|
onStartRecording: () -> Unit = {},
|
||||||
onStopRecording: () -> 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) {
|
when (layoutPresentation.trailingAction) {
|
||||||
ChatInputTrailingAction.ADD -> {
|
ChatInputTrailingAction.ADD -> {
|
||||||
RoundIconAction(
|
RoundIconAction(
|
||||||
@@ -319,9 +310,18 @@ private fun TextInputContent(
|
|||||||
enabled: Boolean,
|
enabled: Boolean,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
|
var textFieldValue by remember { mutableStateOf(TextFieldValue(value)) }
|
||||||
|
LaunchedEffect(value) {
|
||||||
|
if (value != textFieldValue.text) {
|
||||||
|
textFieldValue = TextFieldValue(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
BasicTextField(
|
BasicTextField(
|
||||||
value = value,
|
value = textFieldValue,
|
||||||
onValueChange = onValueChange,
|
onValueChange = {
|
||||||
|
textFieldValue = it
|
||||||
|
onValueChange(it.text)
|
||||||
|
},
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
textStyle = MaterialTheme.typography.bodyLarge.copy(
|
textStyle = MaterialTheme.typography.bodyLarge.copy(
|
||||||
fontSize = AppTypography.titleMedium,
|
fontSize = AppTypography.titleMedium,
|
||||||
@@ -341,7 +341,7 @@ private fun TextInputContent(
|
|||||||
CenterAreaShell(
|
CenterAreaShell(
|
||||||
backgroundColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.14f),
|
backgroundColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.14f),
|
||||||
) {
|
) {
|
||||||
if (value.isEmpty()) {
|
if (textFieldValue.text.isEmpty()) {
|
||||||
Text(
|
Text(
|
||||||
text = placeholder,
|
text = placeholder,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ enum class ChatInputTrailingAction {
|
|||||||
|
|
||||||
data class ChatInputLayoutPresentation(
|
data class ChatInputLayoutPresentation(
|
||||||
val leadingAction: ChatInputLeadingAction,
|
val leadingAction: ChatInputLeadingAction,
|
||||||
val showEmojiAction: Boolean,
|
|
||||||
val trailingAction: ChatInputTrailingAction,
|
val trailingAction: ChatInputTrailingAction,
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
@@ -44,7 +43,6 @@ data class ChatInputLayoutPresentation(
|
|||||||
return when (inputMode) {
|
return when (inputMode) {
|
||||||
InputMode.TEXT -> ChatInputLayoutPresentation(
|
InputMode.TEXT -> ChatInputLayoutPresentation(
|
||||||
leadingAction = ChatInputLeadingAction.SWITCH_TO_VOICE,
|
leadingAction = ChatInputLeadingAction.SWITCH_TO_VOICE,
|
||||||
showEmojiAction = true,
|
|
||||||
trailingAction = if (hasText) {
|
trailingAction = if (hasText) {
|
||||||
ChatInputTrailingAction.SEND
|
ChatInputTrailingAction.SEND
|
||||||
} else {
|
} else {
|
||||||
@@ -54,7 +52,6 @@ data class ChatInputLayoutPresentation(
|
|||||||
|
|
||||||
InputMode.VOICE -> ChatInputLayoutPresentation(
|
InputMode.VOICE -> ChatInputLayoutPresentation(
|
||||||
leadingAction = ChatInputLeadingAction.SWITCH_TO_TEXT,
|
leadingAction = ChatInputLeadingAction.SWITCH_TO_TEXT,
|
||||||
showEmojiAction = !isRecording,
|
|
||||||
trailingAction = if (isRecording) {
|
trailingAction = if (isRecording) {
|
||||||
ChatInputTrailingAction.CANCEL
|
ChatInputTrailingAction.CANCEL
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import androidx.compose.ui.Alignment
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
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 com.huaga.life_echo.network.models.FAQDto
|
import com.huaga.life_echo.network.models.FAQDto
|
||||||
import com.huaga.life_echo.ui.icons.AppIcons
|
import com.huaga.life_echo.ui.icons.AppIcons
|
||||||
import com.huaga.life_echo.ui.theme.AppTypography
|
import com.huaga.life_echo.ui.theme.AppTypography
|
||||||
@@ -67,8 +66,8 @@ fun FAQItem(
|
|||||||
Text(
|
Text(
|
||||||
text = faq.answer,
|
text = faq.answer,
|
||||||
fontSize = AppTypography.bodyMedium,
|
fontSize = AppTypography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
lineHeight = AppTypography.lineHeightNormal,
|
||||||
lineHeight = 20.sp
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,38 +232,63 @@ fun AccountManagementScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 登出当前设备确认对话框
|
// 登出当前设备确认对话框(跟随大字模式)
|
||||||
if (showLogoutDialog) {
|
if (showLogoutDialog) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = { showLogoutDialog = false },
|
onDismissRequest = { showLogoutDialog = false },
|
||||||
title = { Text("确认登出") },
|
title = {
|
||||||
text = { Text("确定要登出当前设备吗?") },
|
Text(
|
||||||
|
text = "确认登出",
|
||||||
|
fontSize = AppTypography.titleMedium,
|
||||||
|
fontWeight = FontWeight.SemiBold
|
||||||
|
)
|
||||||
|
},
|
||||||
|
text = {
|
||||||
|
Text(
|
||||||
|
text = "确定要登出当前设备吗?",
|
||||||
|
fontSize = AppTypography.bodyMedium,
|
||||||
|
lineHeight = AppTypography.lineHeightNormal
|
||||||
|
)
|
||||||
|
},
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(
|
TextButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
viewModel.logout()
|
viewModel.logout()
|
||||||
showLogoutDialog = false
|
showLogoutDialog = false
|
||||||
onLogoutSuccess()
|
onLogoutSuccess()
|
||||||
}
|
},
|
||||||
|
colors = ButtonDefaults.textButtonColors(
|
||||||
|
contentColor = MaterialTheme.colorScheme.error
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
Text("确认", color = MaterialTheme.colorScheme.error)
|
Text("确认", fontSize = AppTypography.bodyMedium)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dismissButton = {
|
dismissButton = {
|
||||||
TextButton(onClick = { showLogoutDialog = false }) {
|
TextButton(onClick = { showLogoutDialog = false }) {
|
||||||
Text("取消")
|
Text("取消", fontSize = AppTypography.bodyMedium)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 登出所有设备确认对话框
|
// 登出所有设备确认对话框(跟随大字模式)
|
||||||
if (showLogoutAllDialog) {
|
if (showLogoutAllDialog) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = { showLogoutAllDialog = false },
|
onDismissRequest = { showLogoutAllDialog = false },
|
||||||
title = { Text("确认登出所有设备") },
|
title = {
|
||||||
|
Text(
|
||||||
|
text = "确认登出所有设备",
|
||||||
|
fontSize = AppTypography.titleMedium,
|
||||||
|
fontWeight = FontWeight.SemiBold
|
||||||
|
)
|
||||||
|
},
|
||||||
text = {
|
text = {
|
||||||
Text("确定要登出所有设备吗?这将使您在所有设备上的登录状态失效,需要重新登录。")
|
Text(
|
||||||
|
text = "确定要登出所有设备吗?这将使您在所有设备上的登录状态失效,需要重新登录。",
|
||||||
|
fontSize = AppTypography.bodyMedium,
|
||||||
|
lineHeight = AppTypography.lineHeightNormal
|
||||||
|
)
|
||||||
},
|
},
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(
|
TextButton(
|
||||||
@@ -272,14 +297,17 @@ fun AccountManagementScreen(
|
|||||||
showLogoutAllDialog = false
|
showLogoutAllDialog = false
|
||||||
onLogoutSuccess()
|
onLogoutSuccess()
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
colors = ButtonDefaults.textButtonColors(
|
||||||
|
contentColor = MaterialTheme.colorScheme.error
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
Text("确认登出", color = MaterialTheme.colorScheme.error)
|
Text("确认登出", fontSize = AppTypography.bodyMedium)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dismissButton = {
|
dismissButton = {
|
||||||
TextButton(onClick = { showLogoutAllDialog = false }) {
|
TextButton(onClick = { showLogoutAllDialog = false }) {
|
||||||
Text("取消")
|
Text("取消", fontSize = AppTypography.bodyMedium)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -168,6 +168,8 @@ fun MyMemoirScreen(
|
|||||||
AnimatedContent(
|
AnimatedContent(
|
||||||
targetState = showFullTextReading || selectedChapter != null,
|
targetState = showFullTextReading || selectedChapter != null,
|
||||||
transitionSpec = {
|
transitionSpec = {
|
||||||
|
if (targetState) {
|
||||||
|
// 进入章节/阅读:新内容从右侧滑入,目录向左滑出
|
||||||
slideInHorizontally(
|
slideInHorizontally(
|
||||||
initialOffsetX = { it },
|
initialOffsetX = { it },
|
||||||
animationSpec = tween(300)
|
animationSpec = tween(300)
|
||||||
@@ -175,6 +177,16 @@ fun MyMemoirScreen(
|
|||||||
targetOffsetX = { -it },
|
targetOffsetX = { -it },
|
||||||
animationSpec = tween(300)
|
animationSpec = tween(300)
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
// 返回目录:目录从左侧滑入,章节向右滑出
|
||||||
|
slideInHorizontally(
|
||||||
|
initialOffsetX = { -it },
|
||||||
|
animationSpec = tween(300)
|
||||||
|
) togetherWith slideOutHorizontally(
|
||||||
|
targetOffsetX = { it },
|
||||||
|
animationSpec = tween(300)
|
||||||
|
)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
label = "memoir_navigation"
|
label = "memoir_navigation"
|
||||||
) { isReading ->
|
) { isReading ->
|
||||||
@@ -230,18 +242,23 @@ fun MyMemoirScreen(
|
|||||||
// 清除回忆确认弹窗状态
|
// 清除回忆确认弹窗状态
|
||||||
var showClearDialog by remember { mutableStateOf(false) }
|
var showClearDialog by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
// 清除回忆确认弹窗
|
// 清除回忆确认弹窗(跟随大字模式)
|
||||||
if (showClearDialog) {
|
if (showClearDialog) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = { showClearDialog = false },
|
onDismissRequest = { showClearDialog = false },
|
||||||
title = {
|
title = {
|
||||||
Text(
|
Text(
|
||||||
text = "清除回忆",
|
text = "清除回忆",
|
||||||
|
fontSize = AppTypography.titleMedium,
|
||||||
fontWeight = FontWeight.SemiBold
|
fontWeight = FontWeight.SemiBold
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
text = {
|
text = {
|
||||||
Text("清除回忆会完全清除当前章节的内容,确定继续吗?")
|
Text(
|
||||||
|
"清除回忆会完全清除当前章节的内容,确定继续吗?",
|
||||||
|
fontSize = AppTypography.bodyMedium,
|
||||||
|
lineHeight = AppTypography.lineHeightNormal
|
||||||
|
)
|
||||||
},
|
},
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(
|
TextButton(
|
||||||
@@ -255,12 +272,12 @@ fun MyMemoirScreen(
|
|||||||
contentColor = MaterialTheme.colorScheme.error
|
contentColor = MaterialTheme.colorScheme.error
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
Text("确定清除")
|
Text("确定清除", fontSize = AppTypography.bodyMedium)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dismissButton = {
|
dismissButton = {
|
||||||
TextButton(onClick = { showClearDialog = false }) {
|
TextButton(onClick = { showClearDialog = false }) {
|
||||||
Text("取消")
|
Text("取消", fontSize = AppTypography.bodyMedium)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user