@cometchat/chat-uikit-react-native 5.2.3 → 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.
- package/package.json +1 -1
- package/src/CometChatConversations/CometChatConversations.tsx +167 -86
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +312 -116
- package/src/CometChatMessageComposer/styles.tsx +2 -1
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +83 -17
- package/src/CometChatMessageList/CometChatMessageList.tsx +549 -70
- package/src/CometChatMessageList/style.ts +4 -2
- package/src/CometChatSearch/CometChatSearch.tsx +1718 -0
- package/src/CometChatSearch/SearchConstants.ts +46 -0
- package/src/CometChatSearch/Skeleton.tsx +192 -0
- package/src/CometChatSearch/index.ts +1 -0
- package/src/CometChatSearch/style.ts +414 -0
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +43 -7
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +45 -7
- package/src/extensions/Polls/Polls.tsx +36 -2
- package/src/extensions/Polls/PollsBubble.tsx +13 -9
- package/src/extensions/Polls/PollsDecorator.tsx +13 -1
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +50 -11
- package/src/extensions/Stickers/style.ts +0 -1
- package/src/index.ts +5 -0
- package/src/shared/base/Types.ts +8 -0
- package/src/shared/constants/UIKitConstants.ts +2 -0
- package/src/shared/events/CometChatMessageEvents/index.ts +8 -7
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +4 -0
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +158 -27
- package/src/shared/framework/DataSource.ts +7 -0
- package/src/shared/framework/DataSourceDecorator.tsx +12 -0
- package/src/shared/framework/MessageDataSource.tsx +182 -1
- package/src/shared/helper/functions.js +0 -67
- package/src/shared/helper/helperFunctions.ts +73 -0
- package/src/shared/icons/components/documents.tsx +23 -0
- package/src/shared/icons/components/empty-search.tsx +52 -0
- package/src/shared/icons/components/message-blocked.tsx +1 -1
- package/src/shared/icons/components/unread.tsx +29 -0
- package/src/shared/icons/icon-mapping.tsx +7 -0
- package/src/shared/index.ts +2 -1
- package/src/shared/modals/CometChatMessageTemplate.ts +23 -0
- package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +4 -4
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +17 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +70 -34
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +60 -24
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +60 -24
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +40 -4
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +38 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +40 -4
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +274 -23
- package/src/shared/utils/MessageUtils.tsx +0 -1
- package/src/shared/views/CometChatAudioBubble/style.ts +0 -2
- package/src/shared/views/CometChatFileBubble/style.ts +0 -4
- package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +1 -0
- package/src/shared/views/CometChatList/CometChatList.tsx +12 -0
- package/src/shared/views/CometChatList/Header.tsx +79 -49
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +14 -4
- package/src/shared/views/CometChatReportDialog/CometChatReportDialog.tsx +390 -0
- package/src/shared/views/CometChatReportDialog/index.ts +3 -0
- package/src/shared/views/CometChatReportDialog/style.ts +164 -0
- package/src/shared/views/CometChatStatusIndicator/private.png +0 -0
- package/src/shared/views/CometChatStatusIndicator/protected.png +0 -0
- package/src/shared/views/CometChatStatusIndicator/styles.ts +2 -2
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +18 -2
- package/src/shared/views/index.ts +6 -0
- package/src/theme/default/default.ts +3 -0
- package/src/theme/provider.tsx +7 -5
- package/src/theme/type.ts +2 -0
|
@@ -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:
|
|
13
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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={
|
|
25
|
-
{/* <View style={Styles(
|
|
26
|
-
<View style={Styles(
|
|
27
|
-
<Text style={Styles(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
};
|
|
@@ -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 ? (
|
|
@@ -126,6 +126,14 @@ interface HeaderProps {
|
|
|
126
126
|
* If true, hides the entire header.
|
|
127
127
|
*/
|
|
128
128
|
hideHeader?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Custom search view component to display instead of the default search input.
|
|
131
|
+
*/
|
|
132
|
+
SearchView?: () => JSX.Element;
|
|
133
|
+
/**
|
|
134
|
+
* Callback triggered when the search bar is clicked or focused.
|
|
135
|
+
*/
|
|
136
|
+
onSearchBarClicked?: () => void;
|
|
129
137
|
}
|
|
130
138
|
|
|
131
139
|
/**
|
|
@@ -161,13 +169,16 @@ export default function Header({
|
|
|
161
169
|
searchStyle,
|
|
162
170
|
hideHeader = false,
|
|
163
171
|
backButtonIconContainerStyle = { marginLeft: 10 },
|
|
172
|
+
SearchView,
|
|
173
|
+
onSearchBarClicked,
|
|
164
174
|
}: HeaderProps) {
|
|
165
175
|
const theme = useTheme();
|
|
166
176
|
const inputRef = useRef<TextInput>(null);
|
|
167
177
|
return (
|
|
168
|
-
<View style={[styles.listBaseHeaderStyle,
|
|
178
|
+
<View style={[styles.listBaseHeaderStyle, { width: '100%' }]}>
|
|
179
|
+
{/* Header section with border */}
|
|
169
180
|
{!hideHeader && (
|
|
170
|
-
<View style={styles.upperContainer}>
|
|
181
|
+
<View style={[styles.upperContainer, containerStyle]}>
|
|
171
182
|
<View style={{ flexDirection: "row", ...titleSeparatorStyle }}>
|
|
172
183
|
{/* Render back button and title if not in selection mode */}
|
|
173
184
|
{!shouldSelect && (!hideBackButton || title.length !== 0) && (
|
|
@@ -250,54 +261,73 @@ export default function Header({
|
|
|
250
261
|
</View>
|
|
251
262
|
)}
|
|
252
263
|
|
|
253
|
-
{/* Render search box */}
|
|
264
|
+
{/* Render search box without border */}
|
|
254
265
|
{!hideSearch && (
|
|
255
|
-
<View
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
266
|
+
<View style={{
|
|
267
|
+
alignSelf: 'stretch',
|
|
268
|
+
width: '100%',
|
|
269
|
+
paddingVertical: theme.spacing.spacing.s3
|
|
270
|
+
}}>
|
|
271
|
+
{SearchView ? (
|
|
272
|
+
<View >
|
|
273
|
+
<SearchView />
|
|
274
|
+
</View>
|
|
275
|
+
) : (
|
|
276
|
+
<View
|
|
277
|
+
style={[
|
|
278
|
+
{
|
|
279
|
+
backgroundColor: theme.color.background3,
|
|
280
|
+
borderRadius: theme.spacing.radius.max,
|
|
281
|
+
paddingHorizontal: theme.spacing.spacing.s3,
|
|
282
|
+
paddingVertical: theme.spacing.spacing.s3,
|
|
283
|
+
marginTop: theme.spacing.spacing.s2,
|
|
284
|
+
flexDirection: 'row' as const,
|
|
285
|
+
alignItems: 'center' as const,
|
|
286
|
+
gap: theme.spacing.spacing.s2,
|
|
287
|
+
height: 48,
|
|
288
|
+
alignSelf: 'stretch',
|
|
289
|
+
},
|
|
290
|
+
searchStyle?.containerStyle,
|
|
291
|
+
]}
|
|
292
|
+
>
|
|
293
|
+
<Icon
|
|
294
|
+
name='search-fill'
|
|
295
|
+
size={searchStyle?.iconStyle?.width || 24}
|
|
296
|
+
height={searchStyle?.iconStyle?.height || 24}
|
|
297
|
+
width={searchStyle?.iconStyle?.width || 24}
|
|
298
|
+
color={searchStyle?.iconStyle?.tintColor || theme.color.iconSecondary}
|
|
299
|
+
icon={searchStyle?.icon}
|
|
300
|
+
imageStyle={searchStyle?.iconStyle}
|
|
301
|
+
/>
|
|
302
|
+
<TextInput
|
|
303
|
+
ref={inputRef}
|
|
304
|
+
placeholder={searchPlaceholderText}
|
|
305
|
+
placeholderTextColor={
|
|
306
|
+
searchStyle?.placehodlerTextStyle?.color || theme.color.textTertiary
|
|
307
|
+
}
|
|
308
|
+
onChangeText={searchHandler}
|
|
309
|
+
onFocus={onSearchBarClicked}
|
|
310
|
+
returnKeyType='search'
|
|
311
|
+
value={searchInput}
|
|
312
|
+
onSubmitEditing={() => {
|
|
313
|
+
onSubmitEditing?.();
|
|
314
|
+
inputRef.current?.focus();
|
|
315
|
+
}}
|
|
316
|
+
submitBehavior='submit'
|
|
317
|
+
numberOfLines={1}
|
|
318
|
+
style={[
|
|
319
|
+
{
|
|
320
|
+
flex: 1,
|
|
321
|
+
color: theme.color.textPrimary,
|
|
322
|
+
fontSize: 16,
|
|
323
|
+
paddingVertical: 4,
|
|
324
|
+
...theme.typography.heading4.regular,
|
|
325
|
+
},
|
|
326
|
+
searchStyle?.textStyle,
|
|
327
|
+
]}
|
|
328
|
+
/>
|
|
329
|
+
</View>
|
|
330
|
+
)}
|
|
301
331
|
</View>
|
|
302
332
|
)}
|
|
303
333
|
</View>
|
|
@@ -130,11 +130,21 @@ export const CometChatMessageBubble = memo(
|
|
|
130
130
|
{LeadingView && LeadingView}
|
|
131
131
|
<View style={{ marginStart: 4, maxWidth: "80%" } as ViewProps}>
|
|
132
132
|
{HeaderView && HeaderView}
|
|
133
|
-
<View style={{ ...style?.containerStyle }} onLayout={handleLayout}>
|
|
133
|
+
<View style={{ ...style?.containerStyle, padding: 0, paddingHorizontal: 0, paddingVertical: 0, paddingTop: 0, paddingBottom: 0, paddingLeft: 0, paddingRight: 0 }} onLayout={handleLayout}>
|
|
134
134
|
{ReplyView && ReplyView}
|
|
135
|
-
{
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
<View style={{
|
|
136
|
+
padding: style?.containerStyle?.padding,
|
|
137
|
+
paddingHorizontal: style?.containerStyle?.paddingHorizontal,
|
|
138
|
+
paddingVertical: style?.containerStyle?.paddingVertical,
|
|
139
|
+
paddingTop: style?.containerStyle?.paddingTop,
|
|
140
|
+
paddingBottom: style?.containerStyle?.paddingBottom,
|
|
141
|
+
paddingLeft: style?.containerStyle?.paddingLeft,
|
|
142
|
+
paddingRight: style?.containerStyle?.paddingRight
|
|
143
|
+
}}>
|
|
144
|
+
{ContentView && ContentView}
|
|
145
|
+
{StatusInfoView && StatusInfoView}
|
|
146
|
+
{BottomView && BottomView}
|
|
147
|
+
</View>
|
|
138
148
|
</View>
|
|
139
149
|
{_width && (
|
|
140
150
|
<View style={{ maxWidth: _width }}>
|