Skip to content

Commit b81a5e0

Browse files
committed
update
1 parent 500d0d9 commit b81a5e0

2 files changed

Lines changed: 23 additions & 14 deletions

File tree

app/src/main/java/com/ai/assistance/operit/ui/features/chat/components/style/bubble/BubbleStyleChatMessage.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ fun BubbleStyleChatMessage(
3030
BubbleUserMessageComposable(
3131
message = message,
3232
backgroundColor = userMessageColor,
33-
textColor = userTextColor
33+
textColor = userTextColor,
34+
enableDialogs = enableDialogs
3435
)
3536
}
3637
"ai" -> {

app/src/main/java/com/ai/assistance/operit/ui/features/chat/components/style/bubble/BubbleUserMessageComposable.kt

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ import kotlinx.coroutines.withContext
6060
fun BubbleUserMessageComposable(
6161
message: ChatMessage,
6262
backgroundColor: Color,
63-
textColor: Color
63+
textColor: Color,
64+
enableDialogs: Boolean = true
6465
) {
6566
val context = LocalContext.current
6667
val preferencesManager = remember { UserPreferencesManager.getInstance(context) }
@@ -164,7 +165,7 @@ fun BubbleUserMessageComposable(
164165
Card(
165166
modifier = Modifier
166167
.size(120.dp)
167-
.clickable {
168+
.clickable(enabled = enableDialogs) {
168169
selectedImageBitmap.value = bitmap
169170
showImagePreview.value = true
170171
},
@@ -189,7 +190,8 @@ fun BubbleUserMessageComposable(
189190
content = ""
190191
),
191192
textColor = textColor,
192-
backgroundColor = backgroundColor
193+
backgroundColor = backgroundColor,
194+
enabled = enableDialogs
193195
)
194196
}
195197
}
@@ -209,7 +211,9 @@ fun BubbleUserMessageComposable(
209211
attachment = attachment,
210212
textColor = textColor,
211213
backgroundColor = backgroundColor,
214+
enabled = enableDialogs,
212215
onClick = { attachmentData ->
216+
if (!enableDialogs) return@AttachmentTag
213217
selectedChatAttachment.value =
214218
ChatAttachment(
215219
id = attachmentData.id,
@@ -293,7 +297,7 @@ fun BubbleUserMessageComposable(
293297
}
294298

295299
// 内容预览对话框
296-
if (showContentPreview.value) {
300+
if (enableDialogs && showContentPreview.value) {
297301
AttachmentViewerDialog(
298302
visible = true,
299303
attachment = selectedChatAttachment.value,
@@ -302,7 +306,7 @@ fun BubbleUserMessageComposable(
302306
}
303307

304308
// 图片预览对话框
305-
if (showImagePreview.value && selectedImageBitmap.value != null) {
309+
if (enableDialogs && showImagePreview.value && selectedImageBitmap.value != null) {
306310
Dialog(onDismissRequest = { showImagePreview.value = false }) {
307311
Surface(
308312
modifier = Modifier
@@ -334,7 +338,7 @@ fun BubbleUserMessageComposable(
334338
color = MaterialTheme.colorScheme.onSurface
335339
)
336340
}
337-
341+
338342
IconButton(onClick = { showImagePreview.value = false }) {
339343
Icon(
340344
imageVector = Icons.Default.Close,
@@ -628,6 +632,7 @@ private fun AttachmentTag(
628632
attachment: AttachmentData,
629633
textColor: Color,
630634
backgroundColor: Color,
635+
enabled: Boolean = true,
631636
onClick: (AttachmentData) -> Unit = {}
632637
) {
633638
val context = LocalContext.current
@@ -657,12 +662,15 @@ private fun AttachmentTag(
657662
.padding(vertical = 2.dp)
658663
.clickable(
659664
enabled =
660-
attachment.content.isNotEmpty() ||
661-
attachment.id.startsWith("/") ||
662-
attachment.id.startsWith("content://") ||
663-
attachment.id.startsWith("file://") ||
664-
attachment.id.startsWith("media_pool:") ||
665-
attachment.type.startsWith("image/"),
665+
enabled &&
666+
(
667+
attachment.content.isNotEmpty() ||
668+
attachment.id.startsWith("/") ||
669+
attachment.id.startsWith("content://") ||
670+
attachment.id.startsWith("file://") ||
671+
attachment.id.startsWith("media_pool:") ||
672+
attachment.type.startsWith("image/")
673+
),
666674
onClick = { onClick(attachment) }
667675
),
668676
shape = RoundedCornerShape(12.dp),
@@ -691,4 +699,4 @@ private fun AttachmentTag(
691699
)
692700
}
693701
}
694-
}
702+
}

0 commit comments

Comments
 (0)