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.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.PullToRefreshBox
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -88,10 +89,15 @@ fun ChatScreen(
|
||||
)
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier = modifier.padding(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||
PullToRefreshBox(
|
||||
isRefreshing = isLoading,
|
||||
onRefresh = onRetry,
|
||||
modifier = modifier,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.padding(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
if (topStatus.visible) {
|
||||
ChatStatusBanner(topStatus = topStatus)
|
||||
}
|
||||
@@ -145,33 +151,34 @@ fun ChatScreen(
|
||||
}
|
||||
}
|
||||
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 10.dp, vertical = 10.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
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,
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 10.dp, vertical = 10.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
verticalAlignment = Alignment.Bottom,
|
||||
) {
|
||||
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("发送")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user