Restore detail navigation behavior
This commit is contained in:
1 parent
3ebcf9761b
commit
6543f83b3a
8 files changed
+104
-50
No files matched your search
+9
@@ -0,0 +1,9 @@
|
||||
package cn.xiaobai.openclawapp.platform
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
actual fun PlatformBackHandler(enabled: Boolean, onBack: () -> Unit) {
|
||||
BackHandler(enabled = enabled, onBack = onBack)
|
||||
}
|
||||
@@ -170,6 +170,7 @@ private fun OpenClawRoot(appState: OpenClawAppState) {
|
||||
when {
|
||||
activeSession != null -> ChatScreen(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
sessionTitle = activeSession.title,
|
||||
messages = appState.repository.messagesFor(activeSession.id),
|
||||
isSending = appState.sendingSessionId == activeSession.id,
|
||||
isLoading = appState.isSyncing,
|
||||
|
||||
+69
-50
@@ -38,6 +38,7 @@ import cn.xiaobai.openclawapp.data.LocalMessagePhase
|
||||
import cn.xiaobai.openclawapp.data.MessageKind
|
||||
import cn.xiaobai.openclawapp.data.MessageRole
|
||||
import cn.xiaobai.openclawapp.data.localMessagePhase
|
||||
import cn.xiaobai.openclawapp.platform.PlatformBackHandler
|
||||
import cn.xiaobai.openclawapp.ui.EmptyStateCard
|
||||
import cn.xiaobai.openclawapp.ui.StatusPill
|
||||
import cn.xiaobai.openclawapp.ui.StatusPillTone
|
||||
@@ -46,6 +47,7 @@ import kotlinx.coroutines.delay
|
||||
@Composable
|
||||
fun ChatScreen(
|
||||
modifier: Modifier = Modifier,
|
||||
sessionTitle: String,
|
||||
messages: List<ChatMessage>,
|
||||
isSending: Boolean,
|
||||
isLoading: Boolean,
|
||||
@@ -63,6 +65,8 @@ fun ChatScreen(
|
||||
onOpenAttachment: (String) -> Unit,
|
||||
onDownloadAttachment: (String) -> Unit,
|
||||
) {
|
||||
PlatformBackHandler(onBack = onBack)
|
||||
|
||||
var input by remember { mutableStateOf("") }
|
||||
val listState = rememberLazyListState()
|
||||
|
||||
@@ -88,6 +92,7 @@ fun ChatScreen(
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
ChatHeader(
|
||||
sessionTitle = sessionTitle,
|
||||
topStatus = topStatus,
|
||||
onBack = onBack,
|
||||
onRetry = onRetry,
|
||||
@@ -265,74 +270,88 @@ private fun buildChatTopStatus(
|
||||
|
||||
@Composable
|
||||
private fun ChatHeader(
|
||||
sessionTitle: String,
|
||||
topStatus: ChatTopStatus,
|
||||
onBack: () -> Unit,
|
||||
onRetry: () -> Unit,
|
||||
onSendAttachmentStub: () -> Unit,
|
||||
) {
|
||||
Column(
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceContainerLow,
|
||||
),
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
TextButton(onClick = onBack) { Text("返回") }
|
||||
TextButton(onClick = onRetry) {
|
||||
Text(topStatus.actionLabel)
|
||||
}
|
||||
TextButton(onClick = onSendAttachmentStub) {
|
||||
Text("附件")
|
||||
}
|
||||
}
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = when (topStatus.tone) {
|
||||
StatusPillTone.Error -> MaterialTheme.colorScheme.errorContainer
|
||||
StatusPillTone.Warning -> MaterialTheme.colorScheme.tertiaryContainer.copy(alpha = 0.55f)
|
||||
StatusPillTone.Success -> MaterialTheme.colorScheme.secondaryContainer.copy(alpha = 0.55f)
|
||||
StatusPillTone.Info -> MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.5f)
|
||||
StatusPillTone.Neutral -> MaterialTheme.colorScheme.surfaceContainerHigh
|
||||
},
|
||||
),
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(12.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp),
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 12.dp, vertical = 10.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
StatusPill(
|
||||
text = when (topStatus.tone) {
|
||||
StatusPillTone.Error -> "需处理"
|
||||
StatusPillTone.Warning -> "处理中"
|
||||
StatusPillTone.Success -> "在线"
|
||||
StatusPillTone.Info -> "同步中"
|
||||
StatusPillTone.Neutral -> "提示"
|
||||
},
|
||||
tone = topStatus.tone,
|
||||
)
|
||||
TextButton(onClick = onBack) { Text("返回") }
|
||||
Text(
|
||||
text = topStatus.text,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = when (topStatus.tone) {
|
||||
StatusPillTone.Error -> MaterialTheme.colorScheme.onErrorContainer
|
||||
StatusPillTone.Warning -> MaterialTheme.colorScheme.onTertiaryContainer
|
||||
StatusPillTone.Success -> MaterialTheme.colorScheme.onSecondaryContainer
|
||||
StatusPillTone.Info -> MaterialTheme.colorScheme.onPrimaryContainer
|
||||
StatusPillTone.Neutral -> MaterialTheme.colorScheme.onSurfaceVariant
|
||||
},
|
||||
text = sessionTitle,
|
||||
modifier = Modifier.weight(1f),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
TextButton(onClick = onSendAttachmentStub) {
|
||||
Text("附件")
|
||||
}
|
||||
TextButton(onClick = onRetry) {
|
||||
Text(topStatus.actionLabel)
|
||||
}
|
||||
}
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = when (topStatus.tone) {
|
||||
StatusPillTone.Error -> MaterialTheme.colorScheme.errorContainer
|
||||
StatusPillTone.Warning -> MaterialTheme.colorScheme.tertiaryContainer.copy(alpha = 0.55f)
|
||||
StatusPillTone.Success -> MaterialTheme.colorScheme.secondaryContainer.copy(alpha = 0.55f)
|
||||
StatusPillTone.Info -> MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.5f)
|
||||
StatusPillTone.Neutral -> MaterialTheme.colorScheme.surfaceContainerHigh
|
||||
},
|
||||
),
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 12.dp, vertical = 10.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
StatusPill(
|
||||
text = when (topStatus.tone) {
|
||||
StatusPillTone.Error -> "需处理"
|
||||
StatusPillTone.Warning -> "处理中"
|
||||
StatusPillTone.Success -> "在线"
|
||||
StatusPillTone.Info -> "同步中"
|
||||
StatusPillTone.Neutral -> "提示"
|
||||
},
|
||||
tone = topStatus.tone,
|
||||
)
|
||||
Text(
|
||||
text = topStatus.text,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = when (topStatus.tone) {
|
||||
StatusPillTone.Error -> MaterialTheme.colorScheme.onErrorContainer
|
||||
StatusPillTone.Warning -> MaterialTheme.colorScheme.onTertiaryContainer
|
||||
StatusPillTone.Success -> MaterialTheme.colorScheme.onSecondaryContainer
|
||||
StatusPillTone.Info -> MaterialTheme.colorScheme.onPrimaryContainer
|
||||
StatusPillTone.Neutral -> MaterialTheme.colorScheme.onSurfaceVariant
|
||||
},
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package cn.xiaobai.openclawapp.platform
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
expect fun PlatformBackHandler(enabled: Boolean = true, onBack: () -> Unit)
|
||||
@@ -0,0 +1,6 @@
|
||||
package cn.xiaobai.openclawapp.platform
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
actual fun PlatformBackHandler(enabled: Boolean, onBack: () -> Unit) = Unit
|
||||
@@ -0,0 +1,6 @@
|
||||
package cn.xiaobai.openclawapp.platform
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
actual fun PlatformBackHandler(enabled: Boolean, onBack: () -> Unit) = Unit
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package cn.xiaobai.openclawapp.platform
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
actual fun PlatformBackHandler(enabled: Boolean, onBack: () -> Unit) = Unit
|
||||
Reference in new issue
Block a user