@cometchat/chat-uikit-react-native 5.2.2 → 5.2.4

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.
Files changed (79) hide show
  1. package/package.json +1 -1
  2. package/src/CometChatConversations/CometChatConversations.tsx +170 -91
  3. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +312 -116
  4. package/src/CometChatMessageComposer/styles.tsx +2 -1
  5. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +83 -17
  6. package/src/CometChatMessageList/CometChatMessageList.tsx +603 -65
  7. package/src/CometChatMessageList/style.ts +47 -2
  8. package/src/CometChatSearch/CometChatSearch.tsx +1718 -0
  9. package/src/CometChatSearch/SearchConstants.ts +46 -0
  10. package/src/CometChatSearch/Skeleton.tsx +192 -0
  11. package/src/CometChatSearch/index.ts +1 -0
  12. package/src/CometChatSearch/style.ts +414 -0
  13. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +43 -7
  14. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +45 -7
  15. package/src/extensions/Polls/Polls.tsx +36 -2
  16. package/src/extensions/Polls/PollsBubble.tsx +13 -9
  17. package/src/extensions/Polls/PollsDecorator.tsx +13 -1
  18. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +50 -11
  19. package/src/extensions/Stickers/style.ts +0 -1
  20. package/src/index.ts +5 -0
  21. package/src/shared/base/Types.ts +8 -0
  22. package/src/shared/constants/UIKitConstants.ts +2 -0
  23. package/src/shared/events/CometChatMessageEvents/index.ts +8 -7
  24. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +3 -0
  25. package/src/shared/events/CometChatUIEventHandler/Listener.ts +8 -0
  26. package/src/shared/events/ListenerInitializer.ts +3 -0
  27. package/src/shared/events/messages.ts +1 -0
  28. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +158 -27
  29. package/src/shared/framework/DataSource.ts +7 -0
  30. package/src/shared/framework/DataSourceDecorator.tsx +12 -0
  31. package/src/shared/framework/MessageDataSource.tsx +182 -1
  32. package/src/shared/helper/functions.js +0 -67
  33. package/src/shared/helper/helperFunctions.ts +73 -0
  34. package/src/shared/icons/components/documents.tsx +23 -0
  35. package/src/shared/icons/components/empty-search.tsx +52 -0
  36. package/src/shared/icons/components/message-blocked.tsx +32 -0
  37. package/src/shared/icons/components/unread.tsx +29 -0
  38. package/src/shared/icons/icon-mapping.tsx +9 -0
  39. package/src/shared/index.ts +2 -1
  40. package/src/shared/modals/CometChatMessageTemplate.ts +23 -0
  41. package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +4 -4
  42. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +22 -4
  43. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +75 -36
  44. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +65 -27
  45. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +42 -4
  46. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +66 -27
  47. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +42 -4
  48. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +43 -4
  49. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +43 -4
  50. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +43 -4
  51. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +45 -7
  52. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +42 -4
  53. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +43 -4
  54. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +42 -4
  55. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +42 -4
  56. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +43 -5
  57. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +43 -4
  58. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +42 -4
  59. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +45 -7
  60. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +274 -23
  61. package/src/shared/utils/MessageReceiptUtils.ts +32 -0
  62. package/src/shared/utils/MessageUtils.tsx +106 -4
  63. package/src/shared/views/CometChatAudioBubble/style.ts +0 -2
  64. package/src/shared/views/CometChatFileBubble/style.ts +0 -4
  65. package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +1 -0
  66. package/src/shared/views/CometChatList/CometChatList.tsx +12 -0
  67. package/src/shared/views/CometChatList/Header.tsx +79 -49
  68. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +14 -4
  69. package/src/shared/views/CometChatReportDialog/CometChatReportDialog.tsx +390 -0
  70. package/src/shared/views/CometChatReportDialog/index.ts +3 -0
  71. package/src/shared/views/CometChatReportDialog/style.ts +164 -0
  72. package/src/shared/views/CometChatStatusIndicator/private.png +0 -0
  73. package/src/shared/views/CometChatStatusIndicator/protected.png +0 -0
  74. package/src/shared/views/CometChatStatusIndicator/styles.ts +2 -2
  75. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +18 -2
  76. package/src/shared/views/index.ts +6 -0
  77. package/src/theme/default/default.ts +3 -0
  78. package/src/theme/provider.tsx +7 -5
  79. package/src/theme/type.ts +21 -1
@@ -17,6 +17,8 @@
17
17
  "ADMINISTRATOR": "管理員",
18
18
  "AI": "艾",
19
19
  "ALL": "全部",
20
+ "MESSAGE_COMPOSER_MENTION_ALL": "全部",
21
+ "MESSAGE_COMPOSER_MENTION_NOTIFY_EVERYONE_LABEL": "通知此群組中的所有人",
20
22
  "AND": "一個",
21
23
  "ANIMALES_NATURE": "動物與自然",
22
24
  "ANSWER": "答案",
@@ -454,14 +456,50 @@
454
456
  "YOU_INITIATED_GROUP_AUDIO_CALL": "您已啟動音訊通話",
455
457
  "YOU_INITIATED_GROUP_VIDEO_CALL": "您已啟動視訊通話",
456
458
  "meeting": "會議",
459
+ "Flag_Message_Title": "檢舉訊息",
460
+ "Flag_Message_Subtitle": "若此對話違反我們的社群規範,請檢舉。我們不會告知該帳戶您已檢舉他們。",
461
+ "Flag_Message_Remark_Label": "理由",
462
+ "Flag_Message_Remark_Optional": "選填",
463
+ "Flag_Message_Remark_Placeholder": "為您的檢舉提供更多說明…",
464
+ "Flag_Message_Confirm_Yes": "檢舉",
465
+ "Flag_Message_Confirm_No": "取消",
466
+ "Flag_Message_Reason_Id_Spam": "垃圾訊息/不想要的內容",
467
+ "Flag_Message_Reason_Id_Sexual": "露骨或不當內容",
468
+ "Flag_Message_Reason_Id_Harassment": "侮辱或威脅行為",
469
+ "Message_List_Option_Flag_Message": "檢舉",
470
+ "Flag_Error_Text":"發生錯誤。請檢查後再試一次。",
471
+ "Flag_Empty_Submit_Text":"無法提交。請在回報此訊息前選擇一個原因。",
472
+ "START_REPORTING": "開始報告",
473
+ "LOGOUT": "登出",
474
+ "AI_ASSISTANTS": "AI 助手",
475
+ "CREATE_CONVERSATION": "建立對話",
476
+ "EDIT_MODERATION": "編輯失敗。您的訊息因為管理政策被封鎖。",
477
+ "BLOCKED_MODERATION": "您的訊息因為管理政策被封鎖。",
457
478
  "NO_CONVERSATION_HISTORY_FOUND": "找不到對話歷史",
458
- "SOMETHING_WENT_WRONG_ON_OUR_END": "我們這邊出了點問題,請重試",
459
- "START_A_CHAT": "點擊“新聊天”按鈕開始聊天",
479
+ "SOMETHING_WENT_WRONG_ON_OUR_END": "我們這邊出了點問題,請重試",
480
+ "START_A_CHAT": "點擊“新聊天”按鈕開始聊天",
460
481
  "CHAT_HISTORY": "聊天記錄",
461
482
  "ASK_ANYTHING": "提問任何問題...",
462
483
  "AI_ASSISTANT": "AI 助手",
463
- "START_REPORTING": "開始報告",
464
- "LOGOUT": "登出",
465
- "AI_ASSISTANTS": "AI 助手",
466
- "CREATE_CONVERSATION": "建立對話"
467
- }
484
+ "SEARCH_PLACEHOLDER": "搜尋...",
485
+ "SEARCH_NO_RESULTS_TITLE": "沒有結果",
486
+ "SEARCH_NO_RESULTS_SUBTITLE": "開始輸入以搜尋訊息和對話",
487
+ "SEARCH_NO_RESULTS_FOUND_TITLE": "未找到結果",
488
+ "SEARCH_NO_RESULTS_FOUND_SUBTITLE": "找不到任何相符項目。請嘗試其他關鍵字。",
489
+ "SEARCH_ERROR_LOADING_CONVERSATIONS": "載入對話時發生錯誤",
490
+ "SEARCH_ERROR_LOADING_MESSAGES": "載入訊息時發生錯誤",
491
+ "SEARCH_TRY_AGAIN": "請稍後再試",
492
+ "SEARCH_SEE_MORE": "查看更多",
493
+ "SEARCH_LOADING": "載入中...",
494
+ "SEARCH_FILTER_UNREAD": "未讀",
495
+ "SEARCH_FILTER_GROUPS": "群組",
496
+ "SEARCH_FILTER_PHOTOS": "照片",
497
+ "SEARCH_FILTER_VIDEOS": "影片",
498
+ "SEARCH_FILTER_LINKS": "連結",
499
+ "SEARCH_FILTER_DOCUMENTS": "文件",
500
+ "SEARCH_FILTER_AUDIO": "音訊",
501
+ "SEARCH_FILTER_CONVERSATIONS": "對話",
502
+ "SEARCH_FILTER_MESSAGES": "訊息",
503
+ "SEARCH_NO_MESSAGES": "沒有訊息",
504
+ "MESSAGE_REPORTED": "訊息已回報"
505
+ }
@@ -1,40 +1,291 @@
1
- import React from "react";
2
- import { View, Text, TouchableOpacity, Image } from "react-native";
1
+ import React, { JSX } from "react";
2
+ import { View, Text, TouchableOpacity, Image, StyleProp, ViewStyle } from "react-native";
3
+ import { CometChat } from "@cometchat/chat-sdk-react-native";
3
4
  import closeIcon from "./resources/close.png";
4
5
  import { useTheme } from "../../../theme";
5
6
  import { Styles } from "./style";
7
+ import { getCometChatTranslation } from "../../resources/CometChatLocalizeNew/LocalizationManager";
8
+ import { Icon } from "../../icons/Icon";
9
+ import { CometChatUIKit } from "../../CometChatUiKit";
10
+
11
+ const t = getCometChatTranslation();
12
+
13
+ /**
14
+ * Props for CometChatMessagePreview component
15
+ */
16
+ interface CometChatMessagePreviewProps {
17
+ // Old interface (for backward compatibility)
18
+ messagePreviewTitle?: string;
19
+ messagePreviewSubtitle?: string;
20
+ closeIconURL?: any;
21
+ onCloseClick?: () => void;
22
+
23
+ // New interface (message-based)
24
+ message?: CometChat.BaseMessage;
25
+ theme?: any;
26
+ showCloseIcon?: boolean;
27
+ style?: StyleProp<ViewStyle>;
28
+
29
+ // Icon support
30
+ subtitleIcon?: JSX.Element;
31
+
32
+ // Title style override
33
+ titleStyle?: any;
34
+
35
+ // Deleted message indicator
36
+ isDeletedMessage?: boolean;
37
+ }
6
38
 
7
39
  /**
8
40
  *
9
41
  * CometChatMessagePreview
10
42
  *
11
43
  */
12
- const CometChatMessagePreview = (props: any) => {
13
- let messageText = props?.messagePreviewSubtitle ?? "";
44
+ const CometChatMessagePreview = (props: CometChatMessagePreviewProps) => {
45
+ const {
46
+ messagePreviewTitle,
47
+ messagePreviewSubtitle,
48
+ closeIconURL,
49
+ onCloseClick,
50
+ message,
51
+ theme: propTheme,
52
+ showCloseIcon = false,
53
+ style,
54
+ subtitleIcon,
55
+ titleStyle,
56
+ isDeletedMessage = false
57
+ } = props;
58
+
14
59
  const theme = useTheme();
60
+ const finalTheme = propTheme || theme;
61
+
62
+ // Helper function to get message preview title (sender name)
63
+ const getMessagePreviewTitle = (): string => {
64
+ if (messagePreviewTitle) return messagePreviewTitle;
65
+
66
+ if (!message) return "";
67
+
68
+ try {
69
+ if (message && typeof message.getSender === 'function') {
70
+ const sender = message.getSender();
71
+ if (sender && typeof sender.getName === 'function') {
72
+ return sender.getName() || "";
73
+ }
74
+ }
75
+ // Fallback for cases where getSender is not available
76
+ if (message && (message as any).sender && (message as any).sender.name) {
77
+ return (message as any).sender.name;
78
+ }
79
+ } catch (error) {
80
+ console.warn("Error getting message sender:", error);
81
+ }
82
+ return "";
83
+ };
84
+
85
+ // Helper function to get message preview subtitle/content
86
+ const getMessagePreviewSubtitle = (): string => {
87
+ if (messagePreviewSubtitle) return messagePreviewSubtitle;
88
+
89
+ if (!message) return "";
90
+
91
+
92
+ if (props.isDeletedMessage) {
93
+ return t("MESSAGE_IS_DELETED") || "Message deleted";
94
+ }
95
+
96
+ try {
97
+ const messageType = typeof message.getType === 'function' ? message.getType() : (message as any).type;
98
+ const messageCategory = typeof message.getCategory === 'function' ? message.getCategory() : (message as any).category;
15
99
 
16
- let imageSource;
17
- if (props?.closeIconURL) {
18
- if (typeof props?.closeIconURL === "string" && props?.closeIconURL.length > 0)
19
- imageSource = { uri: props?.closeIconURL };
20
- else imageSource = closeIcon;
21
- }
100
+ if (messageCategory === CometChat.CATEGORY_MESSAGE) {
101
+ switch (messageType) {
102
+ case CometChat.MESSAGE_TYPE.TEXT:
103
+ const textMessage = message as CometChat.TextMessage;
104
+ let text = (typeof textMessage.getText === 'function' ? textMessage.getText() : (textMessage as any).text) || "";
105
+ try {
106
+ if (textMessage.getMentionedUsers && textMessage.getMentionedUsers().length > 0) {
107
+ const mentionedUsers = textMessage.getMentionedUsers();
108
+ const uidMap = new Map();
109
+ mentionedUsers.forEach(user => {
110
+ uidMap.set(user.getUid(), user.getName());
111
+ });
112
+ text = text.replace(/<@uid:(.*?)>/g, (match: string, uid: string): string => {
113
+ if (uidMap.has(uid)) {
114
+ return `@${uidMap.get(uid)}`;
115
+ }
116
+ return match;
117
+ });
118
+ }
119
+ text = text.replace(/<@all:(.*?)>/g, (match: string, alias: string): string => {
120
+ return `@${alias}`;
121
+ });
122
+
123
+ } catch (e) {
124
+ console.warn("Error formatting mentions in preview:", e);
125
+ }
126
+
127
+ // Truncate long text messages
128
+ return text.length > 50 ? `${text.substring(0, 50)}...` : text;
129
+
130
+ case CometChat.MESSAGE_TYPE.IMAGE:
131
+ const imageMessage = message as CometChat.MediaMessage;
132
+ const imageAttachment = typeof imageMessage.getAttachment === 'function' ? imageMessage.getAttachment() : (imageMessage as any).attachment;
133
+ return imageAttachment?.getName?.() || imageAttachment?.name || t("MESSAGE_IMAGE") || "Image";
134
+
135
+ case CometChat.MESSAGE_TYPE.VIDEO:
136
+ const videoMessage = message as CometChat.MediaMessage;
137
+ const videoAttachment = typeof videoMessage.getAttachment === 'function' ? videoMessage.getAttachment() : (videoMessage as any).attachment;
138
+ return videoAttachment?.getName?.() || videoAttachment?.name || t("MESSAGE_VIDEO") || "Video";
139
+
140
+ case CometChat.MESSAGE_TYPE.AUDIO:
141
+ const audioMessage = message as CometChat.MediaMessage;
142
+ const audioAttachment = typeof audioMessage.getAttachment === 'function' ? audioMessage.getAttachment() : (audioMessage as any).attachment;
143
+ return audioAttachment?.getName?.() || audioAttachment?.name || t("MESSAGE_AUDIO") || "Audio";
144
+
145
+ case CometChat.MESSAGE_TYPE.FILE:
146
+ const fileMessage = message as CometChat.MediaMessage;
147
+ const fileAttachment = typeof fileMessage.getAttachment === 'function' ? fileMessage.getAttachment() : (fileMessage as any).attachment;
148
+ return fileAttachment?.getName?.() || fileAttachment?.name || t("MESSAGE_FILE") || "File";
149
+
150
+ default:
151
+ return messageType || t("MESSAGE") || "Message";
152
+ }
153
+ } else if (messageCategory === CometChat.CATEGORY_CUSTOM) {
154
+ // Handle custom message types with proper formatting
155
+
156
+ if (messageType === "extension_sticker") {
157
+ return "Sticker";
158
+ } else if (messageType === "extension_collaborative_whiteboard" || messageType === "extension_whiteboard") {
159
+ return "Collaborative Whiteboard";
160
+ } else if (messageType === "extension_document") {
161
+ return "Document";
162
+ } else if (messageType === "extension_poll") {
163
+ return "Poll";
164
+ } else if (messageType === "meeting") {
165
+ return "Meeting";
166
+ } else if (messageType === "extension_location") {
167
+ return "Location";
168
+ } else {
169
+ // Convert snake_case or camelCase to Title Case, but remove "extension_" prefix
170
+ if (messageType) {
171
+ let formattedType = messageType;
172
+
173
+ // Remove "extension_" prefix if present
174
+ if (formattedType.startsWith('extension_')) {
175
+ formattedType = formattedType.replace('extension_', '');
176
+ }
177
+
178
+ return formattedType
179
+ .replace(/[_-]/g, ' ')
180
+ .replace(/([a-z])([A-Z])/g, '$1 $2')
181
+ .split(' ')
182
+ .map((word: string) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
183
+ .join(' ');
184
+ }
185
+ return t("CUSTOM_MESSAGE") || "Custom Message";
186
+ }
187
+ } else if (messageCategory === CometChat.CATEGORY_ACTION) {
188
+ return t("ACTION_MESSAGE") || "Action";
189
+ }
190
+
191
+ return t("MESSAGE") || "Message";
192
+ } catch (error) {
193
+ console.warn("Error getting message preview subtitle:", error);
194
+ return t("MESSAGE") || "Message";
195
+ }
196
+ };
197
+
198
+ // Helper function to get auto-generated icon for attachment types
199
+ const getAutoIcon = (): JSX.Element | null => {
200
+ if (subtitleIcon) return null; // Don't auto-generate if icon is manually provided
201
+ if (!message) {
202
+ return null;
203
+ }
204
+
205
+ try {
206
+ const messageType = typeof message.getType === 'function' ? message.getType() : (message as any).type;
207
+ const messageCategory = typeof message.getCategory === 'function' ? message.getCategory() : (message as any).category;
208
+
209
+ // Use theme colors safely
210
+ const iconColor = finalTheme?.palette?.getAccent600?.() ||
211
+ finalTheme?.color?.iconSecondary ||
212
+ finalTheme?.colors?.accent ||
213
+ "#666666"; // fallback color
214
+
215
+ if (messageCategory === CometChat.CATEGORY_MESSAGE) {
216
+ switch (messageType) {
217
+ case CometChat.MESSAGE_TYPE.IMAGE:
218
+ return <Icon name="photo-fill" width={16} height={16} color={iconColor} />;
219
+ case CometChat.MESSAGE_TYPE.VIDEO:
220
+ return <Icon name="videocam-fill" width={16} height={16} color={iconColor} />;
221
+ case CometChat.MESSAGE_TYPE.AUDIO:
222
+ return <Icon name="play-circle-fill" width={16} height={16} color={iconColor} />;
223
+ case CometChat.MESSAGE_TYPE.FILE:
224
+ return <Icon name="description-fill" width={16} height={16} color={iconColor} />;
225
+ default:
226
+ }
227
+ } else if (messageCategory === CometChat.CATEGORY_CUSTOM) {
228
+ // Handle custom message types with appropriate icons
229
+ let iconMessageType = messageType;
230
+
231
+ // Normalize the message type by removing "extension_" prefix if present
232
+ if (iconMessageType && iconMessageType.startsWith('extension_')) {
233
+ iconMessageType = iconMessageType.replace('extension_', '');
234
+ }
235
+
236
+ switch (iconMessageType) {
237
+ case "sticker":
238
+ return <Icon name="sticker-fill" width={16} height={16} color={iconColor} />;
239
+ case "collaborative_whiteboard":
240
+ case "whiteboard":
241
+ return <Icon name="collaborative-whiteboard-fill" width={16} height={16} color={iconColor} />;
242
+ case "document":
243
+ return <Icon name="collaborative-document-fill" width={16} height={16} color={iconColor} />;
244
+ case "poll":
245
+ return <Icon name="poll-fill" width={16} height={16} color={iconColor} />;
246
+ case "meeting":
247
+ return <Icon name="videocam-fill" width={16} height={16} color={iconColor} />;
248
+ case "location":
249
+ return <Icon name="location-on-fill" width={16} height={16} color={iconColor} />;
250
+ default:
251
+ return <Icon name="chat-fill" width={16} height={16} color={iconColor} />;
252
+ }
253
+ }
254
+ } catch (error) {
255
+ console.warn("Error getting auto icon:", error);
256
+ }
257
+
258
+ return null;
259
+ };
260
+
261
+ let messageText = getMessagePreviewSubtitle();
262
+ let title = getMessagePreviewTitle();
263
+ let autoIcon = getAutoIcon();
264
+
265
+ const shouldShowClose = showCloseIcon || onCloseClick;
266
+ const containerStyle = style ? [Styles(finalTheme).editPreviewContainerStyle, style] : Styles(finalTheme).editPreviewContainerStyle;
267
+ const iconToShow = subtitleIcon || autoIcon;
22
268
 
23
269
  return (
24
- <View style={Styles(theme).editPreviewContainerStyle}>
25
- {/* <View style={Styles(theme).leftBar} /> */}
26
- <View style={Styles(theme).previewHeadingStyle}>
27
- <Text style={Styles(theme).previewTitleStyle}>{props?.messagePreviewTitle ?? ""}</Text>
28
- <TouchableOpacity
29
- style={Styles(theme).previewCloseStyle}
30
- onPress={props?.onCloseClick ?? (() => {})}
31
- >
32
- <Image style={Styles(theme).previewCloseIconStyle} source={imageSource} />
33
- </TouchableOpacity>
270
+ <View style={containerStyle}>
271
+ {/* <View style={Styles(finalTheme).leftBar} /> */}
272
+ <View style={Styles(finalTheme).previewHeadingStyle}>
273
+ <Text style={[Styles(finalTheme).previewTitleStyle, titleStyle]}>{title}</Text>
274
+ {shouldShowClose && (
275
+ <TouchableOpacity
276
+ style={Styles(finalTheme).previewCloseStyle}
277
+ onPress={onCloseClick ?? (() => {})}
278
+ >
279
+ <Icon name='close' width={16} height={16} color={finalTheme.color.textPrimary} />
280
+ </TouchableOpacity>
281
+ )}
282
+ </View>
283
+ <View style={{ flexDirection: 'row', alignItems: 'flex-start', gap: finalTheme?.spacing?.padding?.p1}}>
284
+ {iconToShow && <View>{iconToShow}</View>}
285
+ <Text numberOfLines={1} ellipsizeMode='tail' style={[Styles(finalTheme).previewSubTitleStyle, { flex: 1 }]}>
286
+ {messageText}
287
+ </Text>
34
288
  </View>
35
- <Text numberOfLines={1} ellipsizeMode='tail' style={Styles(theme).previewSubTitleStyle}>
36
- {messageText}
37
- </Text>
38
289
  </View>
39
290
  );
40
291
  };
@@ -0,0 +1,32 @@
1
+ import { MessageReceipt } from "../constants/UIKitConstants";
2
+ import { CometChat } from "@cometchat/chat-sdk-react-native";
3
+ import { getModerationStatus } from "./MessageUtils";
4
+
5
+ /**
6
+ * Utility helper for deriving a message receipt status from a BaseMessage instance.
7
+ */
8
+ export const MessageReceiptUtils = {
9
+ getReceiptStatus(message: CometChat.BaseMessage | undefined): MessageReceipt {
10
+ if (!message) return MessageReceipt.WAIT;
11
+
12
+ // Moderation status (if available)
13
+ const moderationStatus = getModerationStatus(message);
14
+ if (moderationStatus === "disapproved") return MessageReceipt.ERROR;
15
+ if (moderationStatus === "pending") return MessageReceipt.WAIT;
16
+
17
+ // Explicit error markers
18
+ const hasError = (message as any)?.error || (message as any)?.metadata?.error;
19
+ if (hasError) return MessageReceipt.ERROR;
20
+
21
+ // Deleted messages treated as error for receipts
22
+ if ((message as any)?.deletedAt) return MessageReceipt.ERROR;
23
+
24
+ if ((message as any)?.readAt) return MessageReceipt.READ;
25
+ if ((message as any)?.deliveredAt) return MessageReceipt.DELIVERED;
26
+ if ((message as any)?.sentAt) return MessageReceipt.SENT;
27
+
28
+ return MessageReceipt.WAIT;
29
+ },
30
+ };
31
+
32
+ export default MessageReceiptUtils;
@@ -12,11 +12,13 @@ import { ChatConfigurator } from "../framework";
12
12
  import { Icon, IconName } from "../icons/Icon";
13
13
  import { CometChatMessageTemplate } from "../modals";
14
14
  import { CometChatMessageBubble } from "../views/CometChatMessageBubble";
15
- import { BubbleStyles, CometChatTheme } from "../../theme/type";
15
+ import { BubbleStyles, CometChatTheme, OutgoingBubbleStyles } from "../../theme/type";
16
16
  import { CometChatUIKit } from "../CometChatUiKit";
17
17
  import { deepMerge } from "../helper/helperFunctions";
18
18
  import { CometChatDate } from "../views/CometChatDate";
19
19
  import { CometChatAvatar, CometChatReceipt } from "../views";
20
+ import { useCometChatTranslation } from "../resources/CometChatLocalizeNew";
21
+ import { useTheme } from "../../theme";
20
22
 
21
23
  type MessageViewParamsType = {
22
24
  message: CometChat.BaseMessage;
@@ -282,6 +284,8 @@ export const MessageUtils = {
282
284
  avatarVisibility,
283
285
  } = params;
284
286
  const templatesMap = getTemplatesMap(templates!);
287
+ const baseStyle = getBubbleStyle(message, theme);
288
+
285
289
  let hasTemplate = templatesMap.get(`${message.getCategory()}_${message.getType()}`);
286
290
  if (templates!.length > 0) {
287
291
  let customTemplate = templates!.find(
@@ -291,7 +295,24 @@ export const MessageUtils = {
291
295
  if (customTemplate) hasTemplate = customTemplate;
292
296
  }
293
297
 
294
- const style = getBubbleStyle(message, theme);
298
+ // Only show moderation bottom view for outgoing disapproved messages
299
+ const moderationStatus = getModerationStatus(message);
300
+ const isOutgoing = message.getSender()?.getUid() === CometChatUIKit.loggedInUser?.getUid();
301
+ const styleForThisMessage =
302
+ isOutgoing && moderationStatus === "disapproved"
303
+ ? deepMerge(baseStyle, {
304
+ containerStyle: {
305
+ borderBottomLeftRadius: 0,
306
+ borderBottomRightRadius: 0,
307
+ overflow: "hidden",
308
+ },
309
+ })
310
+ : baseStyle;
311
+
312
+ const DefaultModerationBottomView =
313
+ isOutgoing && moderationStatus === "disapproved" ? (
314
+ <ModerationBottomView status={moderationStatus} />
315
+ ) : undefined;
295
316
 
296
317
  return (
297
318
  <CometChatMessageBubble
@@ -309,12 +330,15 @@ export const MessageUtils = {
309
330
  HeaderView={
310
331
  message.getReceiverType() === "group" ? getHeaderView(message, theme) : undefined
311
332
  }
312
- BottomView={hasTemplate?.BottomView && hasTemplate?.BottomView(message, alignment!)}
333
+ BottomView={
334
+ DefaultModerationBottomView ||
335
+ (hasTemplate?.BottomView && hasTemplate?.BottomView(message, alignment!))
336
+ }
313
337
  StatusInfoView={
314
338
  (hasTemplate?.StatusInfoView && hasTemplate!.StatusInfoView(message, alignment!)) ||
315
339
  getStatusInfoView(message, theme, receiptsVisibility, datePattern)
316
340
  }
317
- style={style}
341
+ style={styleForThisMessage}
318
342
  />
319
343
  );
320
344
  },
@@ -349,3 +373,81 @@ export const getMessagePreviewInternal = (
349
373
  </>
350
374
  );
351
375
  };
376
+
377
+ export const getModerationStatus = (message: CometChat.BaseMessage | any): string => {
378
+ if (message?.getModerationStatus) {
379
+ try {
380
+ return message.getModerationStatus();
381
+ } catch (e) {
382
+ console.log("🚀 ~ getModerationStatus ~ e:", e);
383
+ }
384
+ }
385
+ const rawStatus =
386
+ message?.getData?.()?.moderation?.status ||
387
+ message?.getData?.()?.metaData?.moderation?.status ||
388
+ message?.data?.moderation?.status ||
389
+ message?.data?.metaData?.moderation?.status ||
390
+ message?.moderationStatus;
391
+ if (!rawStatus) return "unmoderated";
392
+ return String(rawStatus);
393
+ };
394
+
395
+ export const ModerationBottomView = ({
396
+ status,
397
+ moderationStyle,
398
+ }: {
399
+ status: string;
400
+ moderationStyle?: OutgoingBubbleStyles["moderationStyle"];
401
+ }) => {
402
+ const { t } = useCometChatTranslation();
403
+ const theme = useTheme();
404
+ if (status !== "disapproved") return null;
405
+
406
+ const bubblePadH =
407
+ theme.messageListStyles.outgoingMessageBubbleStyles?.containerStyle?.paddingHorizontal ??
408
+ theme.spacing?.spacing?.s3 ?? 12;
409
+
410
+ const bubblePadB =
411
+ theme.messageListStyles.outgoingMessageBubbleStyles?.containerStyle?.paddingBottom ?? 0;
412
+
413
+ const bubbleRadius =
414
+ theme.messageListStyles.outgoingMessageBubbleStyles?.containerStyle?.borderRadius ?? 8;
415
+
416
+ const themeModerationStyle =
417
+ theme.messageListStyles.outgoingMessageBubbleStyles.moderationStyle || {};
418
+
419
+ const effective = deepMerge(themeModerationStyle, moderationStyle || {});
420
+
421
+ return (
422
+ <View
423
+ style={[
424
+ {
425
+ marginHorizontal: -bubblePadH,
426
+ marginBottom: -bubblePadB,
427
+ borderTopLeftRadius: 0,
428
+ borderTopRightRadius: 0,
429
+ borderBottomLeftRadius: bubbleRadius,
430
+ borderBottomRightRadius: bubbleRadius,
431
+ flexDirection: "row",
432
+ alignItems: "center",
433
+ },
434
+ effective?.containerStyle,
435
+ ]}
436
+ >
437
+ <Icon
438
+ name="message-blocked"
439
+ color={effective?.iconTintColor}
440
+ containerStyle={{ paddingLeft: 12, paddingRight: 4, alignSelf: "stretch" }}
441
+ />
442
+ <Text
443
+ style={[
444
+ effective?.textStyle,
445
+ ]}
446
+ >
447
+ {t("BLOCKED_MODERATION")}
448
+ </Text>
449
+ </View>
450
+ );
451
+ };
452
+
453
+
@@ -15,7 +15,6 @@ export const getAudioBubbleStyleLight = (
15
15
  paddingBottom: spacing.padding.p0,
16
16
  borderRadius: spacing.radius.r3,
17
17
  alignSelf: "flex-start",
18
- height: 74,
19
18
  width: 240,
20
19
  },
21
20
  playViewContainerStyle: {
@@ -118,7 +117,6 @@ export const getAudioBubbleStyleDark = (
118
117
  paddingBottom: spacing.padding.p0,
119
118
  borderRadius: spacing.radius.r3,
120
119
  alignSelf: "flex-start",
121
- height: 74,
122
120
  width: 240,
123
121
  },
124
122
  playViewContainerStyle: {
@@ -16,7 +16,6 @@ export const getFileBubbleStyleLight = (
16
16
  paddingBottom: spacing.padding.p0,
17
17
  borderRadius: spacing.radius.r3,
18
18
  alignSelf: "flex-start",
19
- height: 74,
20
19
  width: 240,
21
20
  },
22
21
  titleStyle: {
@@ -40,7 +39,6 @@ export const getFileBubbleStyleLight = (
40
39
  paddingTop: spacing.padding.p3,
41
40
  paddingHorizontal: spacing.padding.p2,
42
41
  borderRadius: spacing.radius.r3,
43
- height: 74,
44
42
  width: 240,
45
43
  },
46
44
  titleStyle: {
@@ -78,7 +76,6 @@ export const getFileBubbleStyleDark = (
78
76
  paddingBottom: spacing.padding.p0,
79
77
  borderRadius: spacing.radius.r3,
80
78
  alignSelf: "flex-start",
81
- height: 74,
82
79
  width: 240,
83
80
  },
84
81
  titleStyle: {
@@ -102,7 +99,6 @@ export const getFileBubbleStyleDark = (
102
99
  paddingTop: spacing.padding.p3,
103
100
  paddingHorizontal: spacing.padding.p2,
104
101
  borderRadius: spacing.radius.r3,
105
- height: 74,
106
102
  width: 240,
107
103
  },
108
104
  titleStyle: {
@@ -146,6 +146,7 @@ export const CometChatImageLoader = (props: CometChatImageLoaderPropType) => {
146
146
  alignItems: "center",
147
147
  height: style?.height,
148
148
  width: style?.width,
149
+ minWidth: style?.minWidth,
149
150
  }}
150
151
  >
151
152
  {/* Render the image. It is initially hidden until loaded. */}
@@ -135,6 +135,14 @@ export interface CometChatListProps {
135
135
  * Returns the final array of items currently in the list.
136
136
  */
137
137
  onListFetched?: (fetchedList: any[]) => void;
138
+ /**
139
+ * Custom search view component to display instead of the default search input.
140
+ */
141
+ SearchView?: () => JSX.Element;
142
+ /**
143
+ * Callback triggered when the search bar is clicked or focused.
144
+ */
145
+ onSearchBarClicked?: () => void;
138
146
  }
139
147
 
140
148
  let lastCall: any;
@@ -189,6 +197,8 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
189
197
  hideSubmitButton,
190
198
  statusIndicatorType,
191
199
  hideStickyHeader = false,
200
+ SearchView,
201
+ onSearchBarClicked,
192
202
  } = props;
193
203
 
194
204
  // functions which can be accessed by parents
@@ -799,6 +809,8 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
799
809
  confirmSelectionStyle={listStyle?.confirmSelectionStyle}
800
810
  searchStyle={listStyle?.searchStyle}
801
811
  selectedCount={selectedCount}
812
+ SearchView={SearchView}
813
+ onSearchBarClicked={onSearchBarClicked}
802
814
  />
803
815
  <View style={styles.container}>{getMessageContainer()}</View>
804
816
  {list.length === 0 && dataLoadingStatus.toLowerCase() === LOADING ? (