Add pull-to-refresh for chat
This commit is contained in:
1 parent
7a0f745442
commit
1764e03263
2 files changed
+37
-29
No files matched your search
+36
-29
@@ -19,6 +19,7 @@ import androidx.compose.material3.CardDefaults
|
|||||||
import androidx.compose.material3.CircularProgressIndicator
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
|
import androidx.compose.material3.PullToRefreshBox
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TextButton
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@@ -88,10 +89,15 @@ fun ChatScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
PullToRefreshBox(
|
||||||
modifier = modifier.padding(16.dp),
|
isRefreshing = isLoading,
|
||||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
onRefresh = onRetry,
|
||||||
|
modifier = modifier,
|
||||||
) {
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.padding(16.dp),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||||
|
) {
|
||||||
if (topStatus.visible) {
|
if (topStatus.visible) {
|
||||||
ChatStatusBanner(topStatus = topStatus)
|
ChatStatusBanner(topStatus = topStatus)
|
||||||
}
|
}
|
||||||
@@ -145,33 +151,34 @@ fun ChatScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Card(modifier = Modifier.fillMaxWidth()) {
|
Card(modifier = Modifier.fillMaxWidth()) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(horizontal = 10.dp, vertical = 10.dp),
|
.padding(horizontal = 10.dp, vertical = 10.dp),
|
||||||
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||||
verticalAlignment = Alignment.Bottom,
|
verticalAlignment = Alignment.Bottom,
|
||||||
) {
|
|
||||||
OutlinedTextField(
|
|
||||||
value = input,
|
|
||||||
onValueChange = { input = it },
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
label = { Text("输入消息") },
|
|
||||||
placeholder = { Text("给 $sessionTitle 发一句话") },
|
|
||||||
maxLines = 3,
|
|
||||||
enabled = !isSending,
|
|
||||||
)
|
|
||||||
Button(
|
|
||||||
onClick = {
|
|
||||||
if (input.isNotBlank() && !isSending) {
|
|
||||||
onSend(input.trim())
|
|
||||||
input = ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
enabled = !isSending,
|
|
||||||
) {
|
) {
|
||||||
if (isSending) CircularProgressIndicator() else Text("发送")
|
OutlinedTextField(
|
||||||
|
value = input,
|
||||||
|
onValueChange = { input = it },
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
label = { Text("输入消息") },
|
||||||
|
placeholder = { Text("给 $sessionTitle 发一句话") },
|
||||||
|
maxLines = 3,
|
||||||
|
enabled = !isSending,
|
||||||
|
)
|
||||||
|
Button(
|
||||||
|
onClick = {
|
||||||
|
if (input.isNotBlank() && !isSending) {
|
||||||
|
onSend(input.trim())
|
||||||
|
input = ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
enabled = !isSending,
|
||||||
|
) {
|
||||||
|
if (isSending) CircularProgressIndicator() else Text("发送")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -459,3 +459,4 @@ Android/iOS App
|
|||||||
- 2026-03-07:继续细化聊天时间线层级:system notice 改成更轻的窄条样式,thinking 去掉大 pill 改为更轻的 loading 行,tool error 文案收成“执行失败”并统一到更明显的错误容器语义,让过渡态 / 系统态 / 错误态和正式聊天消息的层级更清楚。
|
- 2026-03-07:继续细化聊天时间线层级:system notice 改成更轻的窄条样式,thinking 去掉大 pill 改为更轻的 loading 行,tool error 文案收成“执行失败”并统一到更明显的错误容器语义,让过渡态 / 系统态 / 错误态和正式聊天消息的层级更清楚。
|
||||||
- 2026-03-07:开始补主动自救能力:会话页新增常驻“刷新”入口,不再只有报错卡里才有重试;设置页新增“立即同步”入口,让用户能主动拉取状态 / agents / 会话列表,而不是只能等后台轮询或进详情页触发刷新。
|
- 2026-03-07:开始补主动自救能力:会话页新增常驻“刷新”入口,不再只有报错卡里才有重试;设置页新增“立即同步”入口,让用户能主动拉取状态 / agents / 会话列表,而不是只能等后台轮询或进详情页触发刷新。
|
||||||
- 2026-03-07:会话页补上真正的下拉刷新:基于 Material3 `PullToRefreshBox` 接 `onRetry`,让列表页除了常驻“刷新”按钮外,也支持更符合移动端习惯的手势刷新。
|
- 2026-03-07:会话页补上真正的下拉刷新:基于 Material3 `PullToRefreshBox` 接 `onRetry`,让列表页除了常驻“刷新”按钮外,也支持更符合移动端习惯的手势刷新。
|
||||||
|
- 2026-03-07:聊天页也补上下拉刷新:沿用同一套 `PullToRefreshBox + onRetry` 机制,让会话详情除了顶栏刷新/重连外,也支持直接下拉拉取最新消息与状态。
|
||||||
Reference in new issue
Block a user