Skip to content

Commit 6190ca8

Browse files
committed
feat(chat): add message animation and improve context menu
- Integrate AnimatedVisibility with slide, fade, and expand animations for message items - Enhance dropdown menu UI with updated icons, colors, and sizing - Refactor message item composition for better readability and structure - Adjust loading indicator appearance and behavior in both chat styles - Improve XML tag cleaning logic for message content sanitization
1 parent 083fa6d commit 6190ca8

File tree

13 files changed

+3080
-2502
lines changed

13 files changed

+3080
-2502
lines changed

app/src/main/java/com/ai/assistance/operit/ui/features/chat/components/ChatArea.kt

Lines changed: 429 additions & 425 deletions
Large diffs are not rendered by default.

app/src/main/java/com/ai/assistance/operit/ui/features/chat/components/ChatInputSection.kt

Lines changed: 582 additions & 526 deletions
Large diffs are not rendered by default.

app/src/main/java/com/ai/assistance/operit/ui/features/chat/components/part/CustomXmlRenderer.kt

Lines changed: 259 additions & 182 deletions
Large diffs are not rendered by default.

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

Lines changed: 291 additions & 221 deletions
Large diffs are not rendered by default.

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

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,58 @@
1-
21
package com.ai.assistance.operit.ui.features.chat.components.style.bubble
32

43
import androidx.compose.runtime.Composable
54
import androidx.compose.ui.graphics.Color
65
import com.ai.assistance.operit.data.model.ChatMessage
76
import com.ai.assistance.operit.ui.features.chat.components.style.cursor.SummaryMessageComposable
8-
import com.ai.assistance.operit.util.stream.Stream
97

108
/**
11-
* A composable function that renders chat messages in a bubble chat style.
12-
* Delegates to specialized composables based on message type.
9+
* A composable function that renders chat messages in a bubble chat style. Delegates to specialized
10+
* composables based on message type.
1311
*/
1412
@Composable
1513
fun BubbleStyleChatMessage(
16-
message: ChatMessage,
17-
userMessageColor: Color,
18-
aiMessageColor: Color,
19-
userTextColor: Color,
20-
aiTextColor: Color,
21-
systemMessageColor: Color,
22-
systemTextColor: Color,
23-
isHidden: Boolean = false,
24-
onDeleteMessage: ((Int) -> Unit)? = null,
25-
index: Int = -1,
26-
enableDialogs: Boolean = true // 新增参数:是否启用弹窗功能,默认启用
14+
message: ChatMessage,
15+
userMessageColor: Color,
16+
aiMessageColor: Color,
17+
userTextColor: Color,
18+
aiTextColor: Color,
19+
systemMessageColor: Color,
20+
systemTextColor: Color,
21+
isHidden: Boolean = false,
22+
onDeleteMessage: ((Int) -> Unit)? = null,
23+
index: Int = -1,
24+
enableDialogs: Boolean = true // 新增参数:是否启用弹窗功能,默认启用
2725
) {
2826
when (message.sender) {
2927
"user" -> {
3028
BubbleUserMessageComposable(
31-
message = message,
32-
backgroundColor = userMessageColor,
33-
textColor = userTextColor
29+
message = message,
30+
backgroundColor = userMessageColor,
31+
textColor = userTextColor
3432
)
3533
}
3634
"ai" -> {
3735
BubbleAiMessageComposable(
38-
message = message,
39-
backgroundColor = aiMessageColor,
40-
textColor = aiTextColor,
41-
isHidden = isHidden
36+
message = message,
37+
backgroundColor = aiMessageColor,
38+
textColor = aiTextColor,
39+
thinkingBackgroundColor =
40+
Color.Gray.copy(alpha = 0.1f), // Default or passed value
41+
thinkingTextColor = Color.Gray, // Default or passed value
42+
isHidden = isHidden
4243
)
4344
}
4445
"summary" -> {
4546
SummaryMessageComposable(
46-
message = message,
47-
backgroundColor = systemMessageColor.copy(alpha = 0.7f),
48-
textColor = systemTextColor,
49-
onDelete = {
50-
if (index != -1) {
51-
onDeleteMessage?.invoke(index)
52-
}
53-
},
54-
enableDialog = enableDialogs // 传递弹窗启用状态
47+
message = message,
48+
backgroundColor = systemMessageColor.copy(alpha = 0.7f),
49+
textColor = systemTextColor,
50+
onDelete = {
51+
if (index != -1) {
52+
onDeleteMessage?.invoke(index)
53+
}
54+
},
55+
enableDialog = enableDialogs // 传递弹窗启用状态
5556
)
5657
}
5758
}

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

Lines changed: 832 additions & 622 deletions
Large diffs are not rendered by default.

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@ fun CursorStyleChatMessage(
2525
overrideStream: Stream<String>? = null,
2626
onDeleteMessage: ((Int) -> Unit)? = null,
2727
index: Int = -1,
28-
enableDialogs: Boolean = true // 新增参数:是否启用弹窗功能,默认启用
28+
onSpeakMessage: ((String) -> Unit)? = null,
29+
enableDialogs: Boolean = true // 新增参数:是否启用弹窗功能,默认启用
2930
) {
3031
when (message.sender) {
3132
"user" -> {
3233
UserMessageComposable(
3334
message = message,
3435
backgroundColor = userMessageColor,
35-
textColor = userTextColor
36+
textColor = userTextColor,
37+
onSpeakMessage = onSpeakMessage
3638
)
3739
}
3840
"ai" -> {
@@ -41,7 +43,7 @@ fun CursorStyleChatMessage(
4143
backgroundColor = aiMessageColor,
4244
textColor = aiTextColor,
4345
overrideStream = overrideStream,
44-
enableDialogs = enableDialogs // 传递弹窗启用状态
46+
enableDialogs = enableDialogs // 传递弹窗启用状态
4547
)
4648
}
4749
"summary" -> {
@@ -54,7 +56,7 @@ fun CursorStyleChatMessage(
5456
onDeleteMessage?.invoke(index)
5557
}
5658
},
57-
enableDialog = enableDialogs // 传递弹窗启用状态
59+
enableDialog = enableDialogs // 传递弹窗启用状态
5860
)
5961
}
6062
}

0 commit comments

Comments
 (0)