@cometchat/chat-uikit-react-native 5.2.9 → 5.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +23 -10
- package/src/CometChatMessageList/CometChatMessageList.tsx +25 -42
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +71 -14
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +4 -3
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cometchat/chat-uikit-react-native",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.10",
|
|
4
4
|
"description": "Ready-to-use Chat UI Components for React Native",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"module": "src/index",
|
|
@@ -120,4 +120,4 @@
|
|
|
120
120
|
"node_modules/",
|
|
121
121
|
"lib/"
|
|
122
122
|
]
|
|
123
|
-
}
|
|
123
|
+
}
|
|
@@ -2076,16 +2076,29 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
2076
2076
|
trackingCharacter: activeCharacter.current,
|
|
2077
2077
|
});
|
|
2078
2078
|
mentionMap.current = updatedMap;
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2079
|
+
|
|
2080
|
+
// Calculate cursor position after the mention + space
|
|
2081
|
+
// Add 1 to account for the space character added after the mention
|
|
2082
|
+
const newCursorPosition =
|
|
2083
|
+
selectionPosition.start -
|
|
2084
|
+
(searchStringRef.current.length + 1) +
|
|
2085
|
+
(item.promptText?.length ?? 0) +
|
|
2086
|
+
1; // +1 for the space after mention
|
|
2087
|
+
|
|
2088
|
+
// On iOS, use InteractionManager to ensure selection is applied after UI updates
|
|
2089
|
+
if (Platform.OS === "ios") {
|
|
2090
|
+
InteractionManager.runAfterInteractions(() => {
|
|
2091
|
+
setSelectionPosition({
|
|
2092
|
+
start: newCursorPosition,
|
|
2093
|
+
end: newCursorPosition,
|
|
2094
|
+
});
|
|
2095
|
+
});
|
|
2096
|
+
} else {
|
|
2097
|
+
setSelectionPosition({
|
|
2098
|
+
start: newCursorPosition,
|
|
2099
|
+
end: newCursorPosition,
|
|
2100
|
+
});
|
|
2101
|
+
}
|
|
2089
2102
|
setFormattedInputMessage();
|
|
2090
2103
|
};
|
|
2091
2104
|
|
|
@@ -632,7 +632,7 @@ export const CometChatMessageList = memo(
|
|
|
632
632
|
const hideMarkAsUnreadOption = (isAgenticUser || !!parentMessageId) ? true : !showMarkAsUnreadOption;//hide for threads and agentic users
|
|
633
633
|
|
|
634
634
|
const callListenerId = "call_" + new Date().getTime();
|
|
635
|
-
const effectiveHideModeration =
|
|
635
|
+
const effectiveHideModeration = hideModerationStatus;
|
|
636
636
|
const groupListenerId = "group_" + new Date().getTime();
|
|
637
637
|
const uiEventListener = "uiEvent_" + new Date().getTime();
|
|
638
638
|
const callEventListener = "callEvent_" + new Date().getTime();
|
|
@@ -1073,7 +1073,10 @@ export const CometChatMessageList = memo(
|
|
|
1073
1073
|
const oldestMessage = previousMessagesFetched[previousMessagesFetched.length];
|
|
1074
1074
|
|
|
1075
1075
|
if (oldestMessage) {
|
|
1076
|
-
|
|
1076
|
+
const msgId = safeGetId(oldestMessage);
|
|
1077
|
+
if (msgId !== undefined) {
|
|
1078
|
+
setNewMessageIndicatorId(String(msgId));
|
|
1079
|
+
}
|
|
1077
1080
|
}
|
|
1078
1081
|
}
|
|
1079
1082
|
|
|
@@ -1383,7 +1386,6 @@ export const CometChatMessageList = memo(
|
|
|
1383
1386
|
// Center the message: place it at middle of the screen
|
|
1384
1387
|
// In inverted list: offset = message.y - (screenHeight/2 - messageHeight/2)
|
|
1385
1388
|
const centeredOffset = Math.max(0, position.y - (screenHeight / 2) + (position.height / 2));
|
|
1386
|
-
console.log({centeredOffset});
|
|
1387
1389
|
|
|
1388
1390
|
// console.log(`📍 Scrolling to position-based offset ${centeredOffset.toFixed(1)}px for message ${messageId}`);
|
|
1389
1391
|
messageListRef.current?.scrollToOffset({
|
|
@@ -1715,8 +1717,8 @@ export const CometChatMessageList = memo(
|
|
|
1715
1717
|
(response: any) => {
|
|
1716
1718
|
setShowMessageOptions([]);
|
|
1717
1719
|
setHasManuallyMarkedUnread(true);
|
|
1718
|
-
let convId:string = "";
|
|
1719
|
-
let conversationType:string = "";
|
|
1720
|
+
let convId: string = "";
|
|
1721
|
+
let conversationType: string = "";
|
|
1720
1722
|
if (user) {
|
|
1721
1723
|
convId = user?.getUid();
|
|
1722
1724
|
conversationType = CometChat.RECEIVER_TYPE.USER;
|
|
@@ -1727,12 +1729,10 @@ export const CometChatMessageList = memo(
|
|
|
1727
1729
|
//getting convesation using conversationId=Uid and conversationType
|
|
1728
1730
|
CometChat.getConversation(convId, conversationType).then((conversation) => {
|
|
1729
1731
|
// Emitting conversation update event
|
|
1730
|
-
console.log("Emitting ccUpdateConversation event for mark as unread", conversation);
|
|
1731
1732
|
CometChatUIEventHandler.emitConversationEvent(
|
|
1732
1733
|
CometChatConversationEvents.ccUpdateConversation,
|
|
1733
1734
|
{ conversation }
|
|
1734
1735
|
);
|
|
1735
|
-
console.log("latest",conversation.getUnreadMessageCount());
|
|
1736
1736
|
setUnreadCount(conversation.getUnreadMessageCount());
|
|
1737
1737
|
setNewMessageIndicatorId(message.getId().toString());
|
|
1738
1738
|
}).catch((error) => {
|
|
@@ -2184,12 +2184,11 @@ export const CometChatMessageList = memo(
|
|
|
2184
2184
|
.catch((rej: any) => {
|
|
2185
2185
|
deleteItem.current = undefined;
|
|
2186
2186
|
setShowDeleteModal(false);
|
|
2187
|
-
console.log(rej);
|
|
2188
2187
|
onError && onError(rej);
|
|
2189
2188
|
});
|
|
2190
2189
|
};
|
|
2191
2190
|
|
|
2192
|
-
const createActionMessage = () => {};
|
|
2191
|
+
const createActionMessage = () => { };
|
|
2193
2192
|
|
|
2194
2193
|
const updateMessageReceipt = (receipt: any) => {
|
|
2195
2194
|
if (
|
|
@@ -2262,8 +2261,6 @@ export const CometChatMessageList = memo(
|
|
|
2262
2261
|
});
|
|
2263
2262
|
CometChat.getLoggedinUser()
|
|
2264
2263
|
.then(async (u: any) => {
|
|
2265
|
-
console.log({startFromUnreadMessages});
|
|
2266
|
-
|
|
2267
2264
|
loggedInUser.current = u;
|
|
2268
2265
|
if (isAgenticUser && !parentMessageId) {
|
|
2269
2266
|
messageRequest.current = null;
|
|
@@ -2289,8 +2286,6 @@ export const CometChatMessageList = memo(
|
|
|
2289
2286
|
convId,
|
|
2290
2287
|
conversationType
|
|
2291
2288
|
);
|
|
2292
|
-
console.log({convId,conversationType,user,group,conversation,getUnreadMessageCount:conversation.getUnreadMessageCount()});
|
|
2293
|
-
// console.log("lower", conversation);
|
|
2294
2289
|
if (conversation.getUnreadMessageCount() > 0) {
|
|
2295
2290
|
setUnreadCount(conversation.getUnreadMessageCount());
|
|
2296
2291
|
const lastReadMessageId = conversation.getLastReadMessageId();
|
|
@@ -2430,33 +2425,32 @@ export const CometChatMessageList = memo(
|
|
|
2430
2425
|
(aiAssistantMessage, aiToolResultMessage, aiToolArgumentMessage) => {
|
|
2431
2426
|
const replacement = aiAssistantMessage || aiToolResultMessage || aiToolArgumentMessage;
|
|
2432
2427
|
if (!replacement) return;
|
|
2433
|
-
console.log("replacement", replacement);
|
|
2434
2428
|
|
|
2435
2429
|
const replacementId = typeof (replacement as any)?.getId === 'function' ? (replacement as any).getId() : (replacement as any)?.id;
|
|
2436
2430
|
const replacementRunId = (replacement as any)?.data?.runId;
|
|
2437
|
-
|
|
2438
|
-
if(messagesContentListRef.current?.[0]?.isStreamMessage && messagesContentListRef.current?.[0]?.targetMessageId === runId){
|
|
2431
|
+
|
|
2432
|
+
if (messagesContentListRef.current?.[0]?.isStreamMessage && messagesContentListRef.current?.[0]?.targetMessageId === runId) {
|
|
2439
2433
|
latestMessageRef.current = replacement;
|
|
2440
2434
|
}
|
|
2441
|
-
|
|
2435
|
+
|
|
2442
2436
|
const list = messagesContentListRef.current;
|
|
2443
2437
|
let updatedList: any[];
|
|
2444
|
-
|
|
2438
|
+
|
|
2445
2439
|
// Find indices in one pass
|
|
2446
2440
|
const existingIndex = list.findIndex((msg) => {
|
|
2447
2441
|
const msgId = typeof (msg as any)?.getId === 'function' ? (msg as any).getId() : (msg as any)?.id;
|
|
2448
2442
|
return msgId && String(msgId) === String(replacementId);
|
|
2449
2443
|
});
|
|
2450
|
-
|
|
2451
|
-
const streamIndex = existingIndex === -1 ? list.findIndex((msg) =>
|
|
2444
|
+
|
|
2445
|
+
const streamIndex = existingIndex === -1 ? list.findIndex((msg) =>
|
|
2452
2446
|
(msg as any).isStreamMessage === true && (msg as any).targetMessageId === runId
|
|
2453
2447
|
) : -1;
|
|
2454
|
-
|
|
2448
|
+
|
|
2455
2449
|
const matchingIndex = (existingIndex === -1 && streamIndex === -1) ? list.findIndex((msg) => {
|
|
2456
2450
|
const msgRunId = (msg as any)?.data?.runId;
|
|
2457
2451
|
return msgRunId && String(msgRunId) === String(replacementRunId);
|
|
2458
2452
|
}) : -1;
|
|
2459
|
-
|
|
2453
|
+
|
|
2460
2454
|
// Update list based on what we found
|
|
2461
2455
|
if (existingIndex !== -1) {
|
|
2462
2456
|
// Update existing message
|
|
@@ -2472,8 +2466,7 @@ export const CometChatMessageList = memo(
|
|
|
2472
2466
|
// Add at beginning
|
|
2473
2467
|
updatedList = [replacement, ...list];
|
|
2474
2468
|
}
|
|
2475
|
-
|
|
2476
|
-
console.log("updatedList", updatedList);
|
|
2469
|
+
|
|
2477
2470
|
messagesContentListRef.current = updatedList;
|
|
2478
2471
|
setMessagesList(updatedList);
|
|
2479
2472
|
onLoad && onLoad([...updatedList].reverse());
|
|
@@ -2783,15 +2776,13 @@ export const CometChatMessageList = memo(
|
|
|
2783
2776
|
connectionListenerId,
|
|
2784
2777
|
new CometChat.ConnectionListener({
|
|
2785
2778
|
onConnected: () => {
|
|
2786
|
-
console.log("CONNECTED...");
|
|
2787
2779
|
streamOnConnected();
|
|
2788
2780
|
if (lastID.current) {
|
|
2789
2781
|
getUpdatedPreviousMessages();
|
|
2790
2782
|
}
|
|
2791
2783
|
},
|
|
2792
|
-
inConnecting: () => {},
|
|
2784
|
+
inConnecting: () => { },
|
|
2793
2785
|
onDisconnected: () => {
|
|
2794
|
-
console.log("DISCONNECTED...");
|
|
2795
2786
|
streamOnDisconnected();
|
|
2796
2787
|
if (!messagesList[0].id) {
|
|
2797
2788
|
for (let i = 0; i < messagesList.length; i++) {
|
|
@@ -3356,8 +3347,7 @@ export const CometChatMessageList = memo(
|
|
|
3356
3347
|
|
|
3357
3348
|
<Text
|
|
3358
3349
|
style={_style.threadedMessageStyles?.indicatorTextStyle}
|
|
3359
|
-
>{`${item.getReplyCount()} ${
|
|
3360
|
-
item.getReplyCount() > 1 ? t("REPLIES") : t("REPLY")
|
|
3350
|
+
>{`${item.getReplyCount()} ${item.getReplyCount() > 1 ? t("REPLIES") : t("REPLY")
|
|
3361
3351
|
}`}</Text>
|
|
3362
3352
|
<CometChatBadge
|
|
3363
3353
|
style={{
|
|
@@ -3376,7 +3366,6 @@ export const CometChatMessageList = memo(
|
|
|
3376
3366
|
setShowMessageOptions([]);
|
|
3377
3367
|
CometChat.getUser(item.getSender().getUid())
|
|
3378
3368
|
.then((user: any) => {
|
|
3379
|
-
console.log({ user });
|
|
3380
3369
|
CometChatUIEventHandler.emitUIEvent("openChat", { user });
|
|
3381
3370
|
})
|
|
3382
3371
|
.catch((e: any) => {
|
|
@@ -3407,13 +3396,11 @@ export const CometChatMessageList = memo(
|
|
|
3407
3396
|
};
|
|
3408
3397
|
|
|
3409
3398
|
NativeModules.FileManager.shareMessage(shareObj, (callback: any) => {
|
|
3410
|
-
console.log("shareMessage Callback", callback);
|
|
3411
3399
|
});
|
|
3412
3400
|
};
|
|
3413
3401
|
|
|
3414
3402
|
const openOptionsForMessage = useCallback(
|
|
3415
3403
|
(item: CometChat.BaseMessage | any, template: CometChatMessageTemplate) => {
|
|
3416
|
-
console.log("Opening options for message:", item);
|
|
3417
3404
|
let options = template?.options
|
|
3418
3405
|
? loggedInUser.current
|
|
3419
3406
|
? template.options(loggedInUser.current, item, mergedTheme, group)
|
|
@@ -3868,32 +3855,32 @@ export const CometChatMessageList = memo(
|
|
|
3868
3855
|
const id = typeof item?.getId === 'function' ? item.getId() : item?.id;
|
|
3869
3856
|
const muid = typeof item?.getMuid === 'function' ? item.getMuid() : item?.muid;
|
|
3870
3857
|
|
|
3871
|
-
|
|
3858
|
+
|
|
3872
3859
|
// For stream messages in agentic mode, use a unique combination
|
|
3873
3860
|
// to prevent duplicate keys when navigating between chat and history
|
|
3874
3861
|
if (item?.isStreamMessage) {
|
|
3875
3862
|
const targetId = item?.targetMessageId || '';
|
|
3876
3863
|
return `stream_${id}_${targetId}_${index}`;
|
|
3877
3864
|
}
|
|
3878
|
-
|
|
3865
|
+
|
|
3879
3866
|
// Use id + muid if both exist
|
|
3880
3867
|
if (id && muid) {
|
|
3881
3868
|
return `${id}_${muid}`;
|
|
3882
3869
|
}
|
|
3883
3870
|
|
|
3884
|
-
|
|
3871
|
+
|
|
3885
3872
|
// Use muid if id doesn't exist (pending message)
|
|
3886
3873
|
if (muid) {
|
|
3887
3874
|
return `muid_${muid}`;
|
|
3888
3875
|
}
|
|
3889
3876
|
|
|
3890
|
-
|
|
3877
|
+
|
|
3891
3878
|
// Use id if muid doesn't exist
|
|
3892
3879
|
if (id) {
|
|
3893
3880
|
return `id_${id}`;
|
|
3894
3881
|
}
|
|
3895
3882
|
|
|
3896
|
-
|
|
3883
|
+
|
|
3897
3884
|
// Fallback to index if neither exist (should not happen, but prevents duplicates)
|
|
3898
3885
|
if (__DEV__) {
|
|
3899
3886
|
console.warn('[MessageList] Message without id or muid at index:', index, item);
|
|
@@ -4454,7 +4441,7 @@ export const CometChatMessageList = memo(
|
|
|
4454
4441
|
)}
|
|
4455
4442
|
|
|
4456
4443
|
{/* Navigation loading for far message fetching and scroll operations */}
|
|
4457
|
-
{navigationLoading&& (getLoadingStateView())}
|
|
4444
|
+
{navigationLoading && (getLoadingStateView())}
|
|
4458
4445
|
<FlatList
|
|
4459
4446
|
showsVerticalScrollIndicator={false}
|
|
4460
4447
|
ref={messageListRef}
|
|
@@ -4551,10 +4538,6 @@ export const CometChatMessageList = memo(
|
|
|
4551
4538
|
reportedMessageRef.current = null;
|
|
4552
4539
|
}}
|
|
4553
4540
|
onReportSubmit={(payload) => {
|
|
4554
|
-
console.log("Report submitted", {
|
|
4555
|
-
messageId: payload.message?.getId?.(),
|
|
4556
|
-
payload,
|
|
4557
|
-
});
|
|
4558
4541
|
setShowReportDialog(false);
|
|
4559
4542
|
reportedMessageRef.current = null;
|
|
4560
4543
|
}}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
2
2
|
import React, { JSX } from "react";
|
|
3
|
-
import { ColorValue, StyleProp, Text, TextStyle } from "react-native";
|
|
3
|
+
import { ColorValue, StyleProp, Text, TextStyle, View } from "react-native";
|
|
4
4
|
import { CometChatUIKit } from "../../CometChatUiKit";
|
|
5
5
|
import {
|
|
6
6
|
MentionsTargetElement,
|
|
@@ -25,6 +25,8 @@ const t = getCometChatTranslation();
|
|
|
25
25
|
type MentionsSubStyle = {
|
|
26
26
|
textStyle?: TextStyle;
|
|
27
27
|
selfTextStyle?: TextStyle;
|
|
28
|
+
backgroundColor?: ColorValue;
|
|
29
|
+
selfBackgroundColor?: ColorValue;
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
type MentionContext = "composer" | "conversation" | "incoming" | "outgoing";
|
|
@@ -71,7 +73,7 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
|
|
|
71
73
|
private incomingBubbleStyle: MentionsSubStyle;
|
|
72
74
|
private outgoingBubbleStyle: MentionsSubStyle;
|
|
73
75
|
private currentContext: MentionContext = "incoming";
|
|
74
|
-
private resolveStyle(isSelf: boolean): TextStyle {
|
|
76
|
+
private resolveStyle(isSelf: boolean): { textStyle: TextStyle; backgroundColor: ColorValue | undefined } {
|
|
75
77
|
let style: MentionsSubStyle;
|
|
76
78
|
switch (this.currentContext) {
|
|
77
79
|
case "composer":
|
|
@@ -86,7 +88,9 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
|
|
|
86
88
|
default:
|
|
87
89
|
style = this.incomingBubbleStyle;
|
|
88
90
|
}
|
|
89
|
-
|
|
91
|
+
const textStyle = isSelf ? (style.selfTextStyle ?? {}) : (style.textStyle ?? {});
|
|
92
|
+
const backgroundColor = isSelf ? style.selfBackgroundColor : style.backgroundColor;
|
|
93
|
+
return { textStyle, backgroundColor };
|
|
90
94
|
}
|
|
91
95
|
|
|
92
96
|
/**
|
|
@@ -132,22 +136,64 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
|
|
|
132
136
|
? loggedInUser
|
|
133
137
|
: (themeOrUser as CometChat.User | undefined);
|
|
134
138
|
|
|
135
|
-
|
|
139
|
+
// Incoming bubble style - purple/blue text with purple background
|
|
140
|
+
const incomingFallback: MentionsSubStyle = {
|
|
136
141
|
textStyle: { fontWeight: "700", fontSize: 14, lineHeight: 19.6, color: "#6852D6" },
|
|
137
142
|
selfTextStyle: { fontWeight: "700", fontSize: 14, lineHeight: 19.6, color: "#FFAB00" },
|
|
143
|
+
backgroundColor: "rgba(104, 82, 214, 0.15)", // Purple/blue matching text color
|
|
144
|
+
selfBackgroundColor: "rgba(255, 171, 0, 0.2)", // Yellow/warning for @all
|
|
138
145
|
};
|
|
139
146
|
|
|
140
|
-
|
|
147
|
+
// Outgoing bubble style - white text with white background
|
|
148
|
+
const outgoingFallback: MentionsSubStyle = {
|
|
149
|
+
textStyle: { fontWeight: "700", fontSize: 14, lineHeight: 19.6, color: "#FFFFFF" },
|
|
150
|
+
selfTextStyle: { fontWeight: "700", fontSize: 14, lineHeight: 19.6, color: "#FFAB00" },
|
|
151
|
+
backgroundColor: "rgba(255, 255, 255, 0.2)", // White matching text color
|
|
152
|
+
selfBackgroundColor: "rgba(255, 171, 0, 0.2)", // Yellow/warning for @all
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const incomingFromTheme = (c: ColorValue): MentionsSubStyle => {
|
|
141
156
|
const baseStyle = theme?.typography?.body?.bold || {};
|
|
142
157
|
return {
|
|
143
158
|
textStyle: { ...baseStyle, color: c },
|
|
144
159
|
selfTextStyle: { ...baseStyle, color: theme?.color?.warning || "#FFAB00" },
|
|
160
|
+
backgroundColor: "rgba(104, 82, 214, 0.15)", // Purple/blue matching primary color
|
|
161
|
+
selfBackgroundColor: "rgba(255, 171, 0, 0.2)", // Yellow/warning for @all
|
|
145
162
|
};
|
|
146
163
|
};
|
|
147
164
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
165
|
+
const outgoingFromTheme = (c: ColorValue): MentionsSubStyle => {
|
|
166
|
+
const baseStyle = theme?.typography?.body?.bold || {};
|
|
167
|
+
return {
|
|
168
|
+
textStyle: { ...baseStyle, color: c },
|
|
169
|
+
selfTextStyle: { ...baseStyle, color: theme?.color?.warning || "#FFAB00" },
|
|
170
|
+
backgroundColor: "rgba(255, 255, 255, 0.2)", // White matching outgoing text color
|
|
171
|
+
selfBackgroundColor: "rgba(255, 171, 0, 0.2)", // Yellow/warning for @all
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// Composer-specific style with purple/blue background matching the text color
|
|
176
|
+
const composerFallback: MentionsSubStyle = {
|
|
177
|
+
textStyle: { fontWeight: "700", fontSize: 14, lineHeight: 19.6, color: "#6852D6" },
|
|
178
|
+
selfTextStyle: { fontWeight: "700", fontSize: 14, lineHeight: 19.6, color: "#FFAB00" },
|
|
179
|
+
backgroundColor: "rgba(104, 82, 214, 0.15)", // Purple/blue matching text color
|
|
180
|
+
selfBackgroundColor: "rgba(255, 171, 0, 0.2)", // Yellow/warning for @all
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const composerFromTheme = (): MentionsSubStyle => {
|
|
184
|
+
const baseStyle = theme?.typography?.body?.bold || {};
|
|
185
|
+
const primaryColor = theme?.color?.primary || "#6852D6";
|
|
186
|
+
return {
|
|
187
|
+
textStyle: { ...baseStyle, color: primaryColor },
|
|
188
|
+
selfTextStyle: { ...baseStyle, color: theme?.color?.warning || "#FFAB00" },
|
|
189
|
+
backgroundColor: "rgba(104, 82, 214, 0.15)", // Purple/blue background
|
|
190
|
+
selfBackgroundColor: "rgba(255, 171, 0, 0.2)", // Yellow/warning for @all
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
this.incomingBubbleStyle = theme ? incomingFromTheme(theme.color.receiveBubbleTextHighlight) : incomingFallback;
|
|
195
|
+
this.outgoingBubbleStyle = theme ? outgoingFromTheme(theme.color.sendBubbleTextHighlight) : outgoingFallback;
|
|
196
|
+
this.composerStyle = theme ? composerFromTheme() : composerFallback;
|
|
151
197
|
this.conversationStyle = this.incomingBubbleStyle;
|
|
152
198
|
}
|
|
153
199
|
|
|
@@ -584,23 +630,29 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
|
|
|
584
630
|
this.setContext(isOutgoing ? "outgoing" : "incoming");
|
|
585
631
|
}
|
|
586
632
|
|
|
587
|
-
const textStyle = this.resolveStyle(isSelf);
|
|
633
|
+
const { textStyle, backgroundColor } = this.resolveStyle(isSelf);
|
|
588
634
|
|
|
589
635
|
let onPressProp =
|
|
590
636
|
this.temp && !isAlias
|
|
591
637
|
? { onPress: (event: any) => this.onMentionClick(event, segment) }
|
|
592
638
|
: {}; // still suppress click for alias
|
|
593
639
|
|
|
640
|
+
const mentionContainerStyle = backgroundColor ? {
|
|
641
|
+
backgroundColor,
|
|
642
|
+
borderRadius: 4,
|
|
643
|
+
paddingHorizontal: 2,
|
|
644
|
+
} : {};
|
|
645
|
+
|
|
594
646
|
if (this.target === MentionsTargetElement.textbubble) {
|
|
595
647
|
return (
|
|
596
|
-
<Text suppressHighlighting={true} key={index} {...onPressProp} style={[textStyle]}>
|
|
648
|
+
<Text suppressHighlighting={true} key={index} {...onPressProp} style={[textStyle, mentionContainerStyle]}>
|
|
597
649
|
{userRegistry[segment]}
|
|
598
650
|
</Text>
|
|
599
651
|
);
|
|
600
652
|
}
|
|
601
653
|
|
|
602
654
|
return (
|
|
603
|
-
<Text suppressHighlighting={true} key={index} {...onPressProp} style={[textStyle]}>
|
|
655
|
+
<Text suppressHighlighting={true} key={index} {...onPressProp} style={[textStyle, mentionContainerStyle]}>
|
|
604
656
|
{userRegistry[segment]}
|
|
605
657
|
</Text>
|
|
606
658
|
);
|
|
@@ -610,11 +662,16 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
|
|
|
610
662
|
(it) => it.underlyingText === `<@all:${segment}>`
|
|
611
663
|
);
|
|
612
664
|
if (aliasItem) {
|
|
613
|
-
const styleResolved = this.resolveStyle(true);
|
|
665
|
+
const { textStyle: styleResolved, backgroundColor } = this.resolveStyle(true);
|
|
666
|
+
const mentionContainerStyle = backgroundColor ? {
|
|
667
|
+
backgroundColor,
|
|
668
|
+
borderRadius: 4,
|
|
669
|
+
paddingHorizontal: 2,
|
|
670
|
+
} : {};
|
|
614
671
|
// If context is 'conversation', render @all and description inline
|
|
615
672
|
if (this.currentContext === "conversation") {
|
|
616
673
|
return (
|
|
617
|
-
<Text suppressHighlighting={true} key={index} style={[styleResolved]}>
|
|
674
|
+
<Text suppressHighlighting={true} key={index} style={[styleResolved, mentionContainerStyle]}>
|
|
618
675
|
<Text style={[styleResolved, { fontWeight: "700" }]}>
|
|
619
676
|
@{aliasItem.promptText}
|
|
620
677
|
</Text>
|
|
@@ -626,7 +683,7 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
|
|
|
626
683
|
);
|
|
627
684
|
}
|
|
628
685
|
return (
|
|
629
|
-
<Text suppressHighlighting={true} key={index} style={[styleResolved]}>
|
|
686
|
+
<Text suppressHighlighting={true} key={index} style={[styleResolved, mentionContainerStyle]}>
|
|
630
687
|
{aliasItem.promptText}
|
|
631
688
|
</Text>
|
|
632
689
|
);
|
|
@@ -105,7 +105,7 @@ export interface CometChatMessageInputInterface {
|
|
|
105
105
|
*/
|
|
106
106
|
export const CometChatMessageInput = (props: CometChatMessageInputInterface) => {
|
|
107
107
|
const theme = useTheme();
|
|
108
|
-
const {t}= useCometChatTranslation()
|
|
108
|
+
const { t } = useCometChatTranslation()
|
|
109
109
|
const {
|
|
110
110
|
text = "",
|
|
111
111
|
placeHolderText = t("ENTER_YOUR_MESSAGE_HERE"),
|
|
@@ -133,14 +133,15 @@ export const CometChatMessageInput = (props: CometChatMessageInputInterface) =>
|
|
|
133
133
|
placeholder={placeHolderText}
|
|
134
134
|
onSelectionChange={onSelectionChange}
|
|
135
135
|
selection={selection}
|
|
136
|
-
value={text}
|
|
137
136
|
onFocus={() => {
|
|
138
137
|
CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, {
|
|
139
138
|
alignment: ViewAlignment.composerBottom,
|
|
140
139
|
child: () => null, // Hide the panel content.
|
|
141
140
|
});
|
|
142
141
|
}}
|
|
143
|
-
|
|
142
|
+
>
|
|
143
|
+
{text}
|
|
144
|
+
</TextInput>
|
|
144
145
|
<View style={style?.dividerStyle as ViewStyle} />
|
|
145
146
|
<View
|
|
146
147
|
style={{
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|