feat: refine mobile UI layout and empty states
This commit is contained in:
1 parent
9bc9b0f318
commit
5c2ae565c8
6 files changed
+195
-74
No files matched your search
+42
-24
@@ -27,6 +27,7 @@ import androidx.compose.ui.draw.clip
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import cn.xiaobai.openclawapp.data.ChatMessage
|
import cn.xiaobai.openclawapp.data.ChatMessage
|
||||||
import cn.xiaobai.openclawapp.data.MessageRole
|
import cn.xiaobai.openclawapp.data.MessageRole
|
||||||
|
import cn.xiaobai.openclawapp.ui.EmptyStateCard
|
||||||
import cn.xiaobai.openclawapp.ui.StatusPill
|
import cn.xiaobai.openclawapp.ui.StatusPill
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -69,40 +70,57 @@ fun ChatScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LazyColumn(
|
if (messages.isEmpty()) {
|
||||||
modifier = Modifier.weight(1f).fillMaxWidth(),
|
EmptyStateCard(
|
||||||
verticalArrangement = Arrangement.spacedBy(10.dp),
|
title = "还没有消息",
|
||||||
) {
|
subtitle = "这里以后会展示真实的会话历史、流式回复和工具执行状态。",
|
||||||
items(messages, key = { it.id }) { message ->
|
)
|
||||||
MessageBubble(message)
|
} else {
|
||||||
|
LazyColumn(
|
||||||
|
modifier = Modifier.weight(1f).fillMaxWidth(),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(10.dp),
|
||||||
|
) {
|
||||||
|
items(messages, key = { it.id }) { message ->
|
||||||
|
MessageBubble(message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Card(modifier = Modifier.fillMaxWidth()) {
|
Card(modifier = Modifier.fillMaxWidth()) {
|
||||||
Row(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(12.dp),
|
.padding(12.dp),
|
||||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
verticalArrangement = Arrangement.spacedBy(10.dp),
|
||||||
verticalAlignment = Alignment.Bottom,
|
|
||||||
) {
|
) {
|
||||||
OutlinedTextField(
|
Text(
|
||||||
value = input,
|
"直接发一条消息给当前会话",
|
||||||
onValueChange = { input = it },
|
style = MaterialTheme.typography.labelLarge,
|
||||||
modifier = Modifier.weight(1f),
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
label = { Text("输入消息") },
|
|
||||||
placeholder = { Text("给 OpenClaw 发一句话") },
|
|
||||||
maxLines = 4,
|
|
||||||
)
|
)
|
||||||
Button(
|
Row(
|
||||||
onClick = {
|
modifier = Modifier.fillMaxWidth(),
|
||||||
if (input.isNotBlank()) {
|
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||||
onSend(input.trim())
|
verticalAlignment = Alignment.Bottom,
|
||||||
input = ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
) {
|
) {
|
||||||
Text("发送")
|
OutlinedTextField(
|
||||||
|
value = input,
|
||||||
|
onValueChange = { input = it },
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
label = { Text("输入消息") },
|
||||||
|
placeholder = { Text("给 OpenClaw 发一句话") },
|
||||||
|
maxLines = 4,
|
||||||
|
)
|
||||||
|
Button(
|
||||||
|
onClick = {
|
||||||
|
if (input.isNotBlank()) {
|
||||||
|
onSend(input.trim())
|
||||||
|
input = ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
Text("发送")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -15,7 +15,7 @@ import androidx.compose.material3.Text
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import cn.xiaobai.openclawapp.ui.SectionHeader
|
import cn.xiaobai.openclawapp.ui.HeroCard
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ServerConfigScreen(
|
fun ServerConfigScreen(
|
||||||
@@ -34,9 +34,10 @@ fun ServerConfigScreen(
|
|||||||
.padding(20.dp),
|
.padding(20.dp),
|
||||||
verticalArrangement = Arrangement.spacedBy(18.dp),
|
verticalArrangement = Arrangement.spacedBy(18.dp),
|
||||||
) {
|
) {
|
||||||
SectionHeader(
|
HeroCard(
|
||||||
title = "连接 OpenClaw",
|
title = "连接 OpenClaw",
|
||||||
subtitle = "第一版先连接你自己的 Mobile Gateway / BFF。等接口稳定后,再无缝切到真实 OpenClaw。",
|
subtitle = "第一版先连接你自己的 Mobile Gateway / BFF。等接口稳定后,再无缝切到真实 OpenClaw。",
|
||||||
|
badge = "Setup",
|
||||||
)
|
)
|
||||||
|
|
||||||
Card(modifier = Modifier.fillMaxWidth()) {
|
Card(modifier = Modifier.fillMaxWidth()) {
|
||||||
|
|||||||
+71
-36
@@ -11,14 +11,20 @@ import androidx.compose.foundation.lazy.items
|
|||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.CardDefaults
|
import androidx.compose.material3.CardDefaults
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.OutlinedTextField
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import cn.xiaobai.openclawapp.data.SessionSummary
|
import cn.xiaobai.openclawapp.data.SessionSummary
|
||||||
|
import cn.xiaobai.openclawapp.ui.EmptyStateCard
|
||||||
|
import cn.xiaobai.openclawapp.ui.HeroCard
|
||||||
import cn.xiaobai.openclawapp.ui.MetricCard
|
import cn.xiaobai.openclawapp.ui.MetricCard
|
||||||
import cn.xiaobai.openclawapp.ui.SectionHeader
|
|
||||||
import cn.xiaobai.openclawapp.ui.StatusPill
|
import cn.xiaobai.openclawapp.ui.StatusPill
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -27,61 +33,90 @@ fun SessionListScreen(
|
|||||||
sessions: List<SessionSummary>,
|
sessions: List<SessionSummary>,
|
||||||
onOpenSession: (String) -> Unit,
|
onOpenSession: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
|
var query by remember { mutableStateOf("") }
|
||||||
|
val filteredSessions = sessions.filter {
|
||||||
|
query.isBlank() ||
|
||||||
|
it.title.contains(query, ignoreCase = true) ||
|
||||||
|
it.id.contains(query, ignoreCase = true) ||
|
||||||
|
it.lastMessage.contains(query, ignoreCase = true)
|
||||||
|
}
|
||||||
|
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = modifier.padding(16.dp),
|
modifier = modifier.padding(16.dp),
|
||||||
verticalArrangement = Arrangement.spacedBy(14.dp),
|
verticalArrangement = Arrangement.spacedBy(14.dp),
|
||||||
) {
|
) {
|
||||||
item {
|
item {
|
||||||
SectionHeader(
|
HeroCard(
|
||||||
title = "会话",
|
title = "OpenClaw Mobile",
|
||||||
subtitle = "先用 Mock 数据把体验打磨好,下一步再接真实 OpenClaw 会话流。",
|
subtitle = "先把会话体验打磨得像个真正可用的 App,再接真实消息流。这样后面联调会轻松很多。",
|
||||||
|
badge = "Mock Mode",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
item {
|
item {
|
||||||
Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
|
Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
|
||||||
MetricCard(title = "总会话", value = sessions.size.toString(), modifier = Modifier.weight(1f))
|
MetricCard(title = "总会话", value = sessions.size.toString(), modifier = Modifier.weight(1f))
|
||||||
MetricCard(title = "在线入口", value = "1", modifier = Modifier.weight(1f))
|
MetricCard(title = "筛选结果", value = filteredSessions.size.toString(), modifier = Modifier.weight(1f))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
items(sessions, key = { it.id }) { session ->
|
item {
|
||||||
Card(
|
OutlinedTextField(
|
||||||
modifier = Modifier
|
value = query,
|
||||||
.fillMaxWidth()
|
onValueChange = { query = it },
|
||||||
.clickable { onOpenSession(session.id) },
|
modifier = Modifier.fillMaxWidth(),
|
||||||
colors = CardDefaults.cardColors(
|
singleLine = true,
|
||||||
containerColor = MaterialTheme.colorScheme.surfaceContainerLow,
|
label = { Text("搜索会话") },
|
||||||
),
|
placeholder = { Text("按标题、ID 或最后一条消息搜索") },
|
||||||
) {
|
)
|
||||||
Column(
|
}
|
||||||
|
|
||||||
|
if (filteredSessions.isEmpty()) {
|
||||||
|
item {
|
||||||
|
EmptyStateCard(
|
||||||
|
title = "没有匹配的会话",
|
||||||
|
subtitle = "现在还只是本地 Mock 数据。后面接入真实接口后,这里会变成真正的会话检索入口。",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
items(filteredSessions, key = { it.id }) { session ->
|
||||||
|
Card(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(16.dp),
|
.clickable { onOpenSession(session.id) },
|
||||||
verticalArrangement = Arrangement.spacedBy(10.dp),
|
colors = CardDefaults.cardColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.surfaceContainerLow,
|
||||||
|
),
|
||||||
) {
|
) {
|
||||||
Row(
|
Column(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(10.dp),
|
||||||
) {
|
) {
|
||||||
Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
Row(
|
||||||
Text(
|
modifier = Modifier.fillMaxWidth(),
|
||||||
text = session.title,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
style = MaterialTheme.typography.titleMedium,
|
) {
|
||||||
)
|
Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||||
Text(
|
Text(
|
||||||
text = session.id,
|
text = session.title,
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.titleMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
)
|
||||||
)
|
Text(
|
||||||
|
text = session.id,
|
||||||
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
StatusPill(text = session.updatedAt, highlighted = true)
|
||||||
}
|
}
|
||||||
StatusPill(text = session.updatedAt, highlighted = true)
|
Text(
|
||||||
|
text = session.lastMessage,
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Text(
|
|
||||||
text = session.lastMessage,
|
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-5
@@ -12,8 +12,8 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import cn.xiaobai.openclawapp.data.ServerConfig
|
import cn.xiaobai.openclawapp.data.ServerConfig
|
||||||
|
import cn.xiaobai.openclawapp.ui.HeroCard
|
||||||
import cn.xiaobai.openclawapp.ui.LabelValueCard
|
import cn.xiaobai.openclawapp.ui.LabelValueCard
|
||||||
import cn.xiaobai.openclawapp.ui.SectionHeader
|
|
||||||
import cn.xiaobai.openclawapp.ui.SelectableRowCard
|
import cn.xiaobai.openclawapp.ui.SelectableRowCard
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -30,9 +30,10 @@ fun SettingsScreen(
|
|||||||
verticalArrangement = Arrangement.spacedBy(14.dp),
|
verticalArrangement = Arrangement.spacedBy(14.dp),
|
||||||
) {
|
) {
|
||||||
item {
|
item {
|
||||||
SectionHeader(
|
HeroCard(
|
||||||
title = "设置",
|
title = "连接配置",
|
||||||
subtitle = "先把连接配置、模型信息和默认 Agent 放在一起。后面再拆成账号、通知、实验功能等模块。",
|
subtitle = "这里先承载服务器地址、token 状态和默认 Agent。等网络层接入后,再往下拆成账号、通知和实验功能。",
|
||||||
|
badge = "Settings",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ fun SettingsScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
item {
|
item {
|
||||||
Text("切换默认 Agent")
|
Text("切换默认 Agent", style = androidx.compose.material3.MaterialTheme.typography.titleMedium)
|
||||||
}
|
}
|
||||||
|
|
||||||
items(availableAgents) { agent ->
|
items(availableAgents) { agent ->
|
||||||
|
|||||||
+7
-7
@@ -2,7 +2,6 @@ package cn.xiaobai.openclawapp.feature.status
|
|||||||
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
@@ -11,9 +10,9 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import cn.xiaobai.openclawapp.data.ServerStatus
|
import cn.xiaobai.openclawapp.data.ServerStatus
|
||||||
|
import cn.xiaobai.openclawapp.ui.HeroCard
|
||||||
import cn.xiaobai.openclawapp.ui.LabelValueCard
|
import cn.xiaobai.openclawapp.ui.LabelValueCard
|
||||||
import cn.xiaobai.openclawapp.ui.MetricCard
|
import cn.xiaobai.openclawapp.ui.MetricCard
|
||||||
import cn.xiaobai.openclawapp.ui.SectionHeader
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun StatusScreen(
|
fun StatusScreen(
|
||||||
@@ -25,9 +24,10 @@ fun StatusScreen(
|
|||||||
verticalArrangement = Arrangement.spacedBy(14.dp),
|
verticalArrangement = Arrangement.spacedBy(14.dp),
|
||||||
) {
|
) {
|
||||||
item {
|
item {
|
||||||
SectionHeader(
|
HeroCard(
|
||||||
title = "运行状态",
|
title = if (status.online) "链路正常" else "连接异常",
|
||||||
subtitle = "这里以后会扩展成 OpenClaw、BFF、消息流、推送链路的统一状态面板。",
|
subtitle = "状态页后面会扩展成 OpenClaw、BFF、消息流和推送链路的统一面板。现在先把最关键的几个信号放清楚。",
|
||||||
|
badge = if (status.online) "Online" else "Offline",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ fun StatusScreen(
|
|||||||
LabelValueCard(
|
LabelValueCard(
|
||||||
label = "当前模型",
|
label = "当前模型",
|
||||||
value = status.currentModel,
|
value = status.currentModel,
|
||||||
supporting = "后续这里可以增加模型切换、provider 状态、限额与延迟数据。",
|
supporting = "后续这里可以增加 provider 状态、模型切换、额度与响应时延。",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
item {
|
item {
|
||||||
@@ -67,7 +67,7 @@ fun StatusScreen(
|
|||||||
}
|
}
|
||||||
item {
|
item {
|
||||||
Text(
|
Text(
|
||||||
"V1 阶段先把结构留好,不急着一口气塞太多信息。状态页最重要的是清晰,不是热闹。",
|
"状态页最忌讳一上来塞满技术细节。先把在线性、模型和 agent 放稳,后面再扩展统计和事件流。",
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -41,6 +41,43 @@ fun SectionHeader(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun HeroCard(
|
||||||
|
title: String,
|
||||||
|
subtitle: String,
|
||||||
|
badge: String? = null,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
|
Card(
|
||||||
|
modifier = modifier.fillMaxWidth(),
|
||||||
|
shape = RoundedCornerShape(24.dp),
|
||||||
|
colors = CardDefaults.cardColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
||||||
|
),
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(18.dp),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(10.dp),
|
||||||
|
) {
|
||||||
|
if (!badge.isNullOrBlank()) {
|
||||||
|
StatusPill(text = badge, highlighted = true)
|
||||||
|
}
|
||||||
|
Text(
|
||||||
|
title,
|
||||||
|
style = MaterialTheme.typography.headlineSmall,
|
||||||
|
color = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
subtitle,
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
color = MaterialTheme.colorScheme.onPrimaryContainer.copy(alpha = 0.85f),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun LabelValueCard(
|
fun LabelValueCard(
|
||||||
label: String,
|
label: String,
|
||||||
@@ -177,3 +214,32 @@ fun SelectableRowCard(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun EmptyStateCard(
|
||||||
|
title: String,
|
||||||
|
subtitle: String,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
|
Card(
|
||||||
|
modifier = modifier.fillMaxWidth(),
|
||||||
|
shape = RoundedCornerShape(22.dp),
|
||||||
|
colors = CardDefaults.cardColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.surfaceContainerLow,
|
||||||
|
),
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(20.dp),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
|
) {
|
||||||
|
Text(title, style = MaterialTheme.typography.titleMedium)
|
||||||
|
Text(
|
||||||
|
subtitle,
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user