@cometchat/chat-uikit-react-native 5.3.10 → 5.4.0

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 (138) hide show
  1. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  3. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  4. package/android/.gradle/7.4/gc.properties +0 -0
  5. package/android/.gradle/vcs-1/gc.properties +0 -0
  6. package/android/src/main/java/com/reactnativecometchatuikit/CometChatClipboardModule.kt +52 -0
  7. package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +1 -0
  8. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +95 -8
  9. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +237 -6
  10. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorViewManager.kt +2 -1
  11. package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +85 -47
  12. package/ios/CometChatClipboardModule.m +11 -0
  13. package/ios/CometChatClipboardModule.swift +41 -0
  14. package/ios/FileManager.m +201 -39
  15. package/ios/RichTextEditorView.swift +312 -4
  16. package/ios/RichTextEditorViewManager.m +1 -0
  17. package/ios/SoundPlayer.m +18 -6
  18. package/package.json +9 -7
  19. package/react-native-cometchat-ui-kit.podspec +1 -0
  20. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +692 -107
  21. package/src/CometChatConversations/CometChatConversations.tsx +19 -6
  22. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +649 -49
  23. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +23 -4
  24. package/src/CometChatMessageList/CometChatMessageList.tsx +463 -54
  25. package/src/CometChatMessageList/MANUAL_TEST_CASES.md +154 -0
  26. package/src/CometChatMessageList/components/MessageListItem.tsx +30 -17
  27. package/src/CometChatMessageList/style.ts +33 -5
  28. package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +13 -0
  29. package/src/CometChatRichTextEditor/index.tsx +25 -0
  30. package/src/CometChatSearch/CometChatSearch.tsx +296 -154
  31. package/src/calls/CallingExtension.tsx +19 -13
  32. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +20 -1
  33. package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +20 -9
  34. package/src/index.ts +39 -0
  35. package/src/shared/CometChatUiKit/CometChatUIKit.ts +40 -34
  36. package/src/shared/base/Types.ts +3 -0
  37. package/src/shared/constants/UIKitConstants.ts +15 -1
  38. package/src/shared/framework/DataSource.ts +14 -4
  39. package/src/shared/framework/DataSourceDecorator.tsx +17 -8
  40. package/src/shared/framework/MessageDataSource.tsx +307 -60
  41. package/src/shared/helper/useToast.tsx +29 -0
  42. package/src/shared/icons/components/audio-file-type.tsx +11 -22
  43. package/src/shared/icons/components/document-file-type.tsx +11 -24
  44. package/src/shared/icons/components/image-file-type.tsx +12 -21
  45. package/src/shared/icons/components/link-file-type.tsx +25 -0
  46. package/src/shared/icons/components/pdf-file-type.tsx +11 -22
  47. package/src/shared/icons/components/presentation-file-type.tsx +11 -24
  48. package/src/shared/icons/components/spreadsheet-file-type.tsx +11 -24
  49. package/src/shared/icons/components/text-file-type.tsx +11 -21
  50. package/src/shared/icons/components/unknown-file-type.tsx +21 -25
  51. package/src/shared/icons/components/video-file-type.tsx +11 -24
  52. package/src/shared/icons/components/zip-file-type.tsx +11 -24
  53. package/src/shared/icons/icon-mapping.tsx +2 -0
  54. package/src/shared/index.ts +28 -0
  55. package/src/shared/modals/AttachmentPickerConfiguration.ts +13 -0
  56. package/src/shared/modals/SelectedAttachment.ts +65 -0
  57. package/src/shared/modals/UploadState.ts +10 -0
  58. package/src/shared/modals/index.ts +4 -0
  59. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +42 -1
  60. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +42 -1
  61. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +43 -2
  62. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +43 -2
  63. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +43 -2
  64. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +43 -2
  65. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +43 -2
  66. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +43 -2
  67. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +43 -2
  68. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +43 -2
  69. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +43 -2
  70. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +43 -2
  71. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +43 -2
  72. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +43 -2
  73. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +43 -2
  74. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +43 -2
  75. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +43 -2
  76. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +43 -2
  77. package/src/shared/services/UploadQueueService.ts +145 -0
  78. package/src/shared/services/index.ts +2 -0
  79. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +42 -18
  80. package/src/shared/utils/MessageUtils.tsx +13 -4
  81. package/src/shared/utils/attachmentLimits.ts +156 -0
  82. package/src/shared/utils/audioPlaybackCoordinator.ts +28 -0
  83. package/src/shared/utils/batchMediaContext.tsx +30 -0
  84. package/src/shared/utils/conversationUtils.ts +26 -4
  85. package/src/shared/utils/groupAttachments.ts +93 -0
  86. package/src/shared/utils/index.ts +8 -0
  87. package/src/shared/utils/openMultiFileChooser.ts +123 -0
  88. package/src/shared/utils/partitionAttachmentsByKind.ts +44 -0
  89. package/src/shared/views/ClipboardPasteHandler/ClipboardPasteHandler.ts +28 -0
  90. package/src/shared/views/ClipboardPasteHandler/NativeCometChatClipboardModule.ts +16 -0
  91. package/src/shared/views/ClipboardPasteHandler/index.ts +2 -0
  92. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -0
  93. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.style.ts +32 -0
  94. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.tsx +90 -0
  95. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreviewItem.tsx +276 -0
  96. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +827 -0
  97. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTray.tsx +110 -0
  98. package/src/shared/views/CometChatAttachmentPreview/StagedVideoDurationProbe.tsx +53 -0
  99. package/src/shared/views/CometChatAttachmentPreview/index.ts +8 -0
  100. package/src/shared/views/CometChatAttachmentViewer/CometChatAttachmentViewer.tsx +305 -0
  101. package/src/shared/views/CometChatAttachmentViewer/index.ts +2 -0
  102. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +71 -74
  103. package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +587 -0
  104. package/src/shared/views/CometChatAudiosBubble/index.ts +2 -0
  105. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +5 -7
  106. package/src/shared/views/CometChatCaptionText/CometChatCaptionText.tsx +182 -0
  107. package/src/shared/views/CometChatCaptionText/index.ts +2 -0
  108. package/src/shared/views/CometChatComposerErrorBanner.tsx +83 -0
  109. package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +141 -0
  110. package/src/shared/views/CometChatConversationStarter/index.ts +2 -0
  111. package/src/shared/views/CometChatConversationSummary/CometChatConversationSummary.tsx +155 -0
  112. package/src/shared/views/CometChatConversationSummary/index.ts +2 -0
  113. package/src/shared/views/CometChatFileBubble/style.ts +6 -4
  114. package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +316 -0
  115. package/src/shared/views/CometChatFilesBubble/index.ts +2 -0
  116. package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +323 -0
  117. package/src/shared/views/CometChatImagesBubble/index.ts +2 -0
  118. package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +425 -0
  119. package/src/shared/views/CometChatMediaViewer/index.ts +2 -0
  120. package/src/shared/views/CometChatMediaViewer/mediaViewerUtils.ts +30 -0
  121. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +14 -4
  122. package/src/shared/views/CometChatSendButtonView/CometChatSendButtonView.tsx +1 -0
  123. package/src/shared/views/CometChatSmartReplies/CometChatSmartReplies.tsx +172 -0
  124. package/src/shared/views/CometChatSmartReplies/index.ts +2 -0
  125. package/src/shared/views/CometChatVideoBubble/style.ts +3 -3
  126. package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +441 -0
  127. package/src/shared/views/CometChatVideosBubble/index.ts +2 -0
  128. package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +78 -0
  129. package/src/shared/views/CometChatVoiceNoteBubble/index.ts +2 -0
  130. package/src/shared/views/index.ts +37 -1
  131. package/src/theme/CometChatThemeHelper.ts +8 -0
  132. package/src/theme/default/color/dark.ts +9 -0
  133. package/src/theme/default/color/light.ts +10 -0
  134. package/src/theme/type.ts +73 -0
  135. package/src/CometChatMessageList/PERFORMANCE_ARCHITECTURE.md +0 -478
  136. package/src/CometChatMessageList/SEARCH_NAV_PERF_PLAN.md +0 -613
  137. package/src/shared/CometChatUiKit/CometChatUIKit.changes.md +0 -76
  138. package/src/shared/CometChatUiKit/checkAuthSettings-review.md +0 -211
@@ -59,14 +59,14 @@ export const getVideoBubbleStylesLight = (
59
59
  padding: spacing.padding.p1,
60
60
  paddingBottom: spacing.padding.p0,
61
61
  borderRadius: spacing.radius.r3,
62
- alignSelf: "flex-start",
63
- justifyContent: 'center',
62
+ overflow: "hidden",
64
63
  },
65
64
  imageStyle: {
66
65
  borderRadius: spacing.radius.r2,
67
66
  backgroundColor: color.background3,
68
67
  height: 140,
69
- width: 232,
68
+ width: '100%',
69
+ minWidth: 232,
70
70
  overflow: 'hidden'
71
71
  },
72
72
  playIconStyle: {
@@ -0,0 +1,441 @@
1
+ import React, { useEffect, useMemo, useState } from 'react';
2
+ import { Image, ImageStyle, StyleProp, StyleSheet, Text, TextStyle, TouchableOpacity, View, ViewStyle } from 'react-native';
3
+ import { CometChat } from '@cometchat/chat-sdk-react-native';
4
+ import { CometChatTheme } from '../../../theme/type';
5
+ import { useTheme } from '../../../theme';
6
+ import { useCompTheme } from '../../../theme/hook';
7
+ import { deepMerge } from '../../helper/helperFunctions';
8
+ import { Icon } from '../../icons/Icon';
9
+ import { getExtensionData } from '../../../extensions/ExtensionModerator';
10
+ import { CometChatUIKit } from '../../CometChatUiKit';
11
+ import { CometChatMessageEvents } from '../../events/CometChatMessageEvents';
12
+ import { CometChatMediaViewer } from '../CometChatMediaViewer';
13
+ import { CometChatCaptionText } from '../CometChatCaptionText';
14
+ import { isVideoMime } from '../CometChatMediaViewer/mediaViewerUtils';
15
+
16
+ // ---------------------------------------------------------------------------
17
+ // Design doc §8.1 — VideosBubble: renders a single-kind VIDEO message (all videos after the §7 fan-out)
18
+ // as a WhatsApp-style collage grid + a batch-spanning fullscreen viewer. Independent of the
19
+ // ImagesBubble — video cells add a dark scrim, a server thumbnail, a centered play button and a
20
+ // duration chip; the grid layout + viewer are otherwise the same.
21
+ // ---------------------------------------------------------------------------
22
+
23
+ interface BorderRadii {
24
+ topLeft?: number;
25
+ topRight?: number;
26
+ bottomLeft?: number;
27
+ bottomRight?: number;
28
+ }
29
+
30
+ function formatDurationSecs(secs: number): string {
31
+ const m = Math.floor(secs / 60);
32
+ const s = Math.floor(secs % 60);
33
+ return `${m}:${s.toString().padStart(2, '0')}`;
34
+ }
35
+
36
+ function getDuration(attachment: CometChat.Attachment): string | undefined {
37
+ try {
38
+ const meta = attachment.getMetadata?.() as Record<string, unknown> | undefined;
39
+ const raw = meta?.duration ?? meta?.video_duration;
40
+ if (typeof raw === 'number' && raw > 0) return formatDurationSecs(raw);
41
+ if (typeof raw === 'string' && raw.length > 0) return raw;
42
+ } catch {}
43
+ return undefined;
44
+ }
45
+
46
+ // ---- Cell ----------------------------------------------------------------
47
+
48
+ interface VideoCellProps {
49
+ attachment: CometChat.Attachment;
50
+ aspectRatio?: number;
51
+ radii: BorderRadii;
52
+ onPress?: () => void;
53
+ testID?: string;
54
+ overflowCount?: number;
55
+ thumbnailUrl?: string;
56
+ cellStyle?: StyleProp<ViewStyle>;
57
+ playButtonStyle?: StyleProp<ViewStyle>;
58
+ playIconStyle?: ImageStyle;
59
+ durationChipStyle?: StyleProp<ViewStyle>;
60
+ durationTextStyle?: TextStyle;
61
+ overflowOverlayStyle?: StyleProp<ViewStyle>;
62
+ overflowTextStyle?: TextStyle;
63
+ }
64
+
65
+ const VideoCell = ({
66
+ attachment,
67
+ aspectRatio = 1,
68
+ radii,
69
+ onPress,
70
+ testID,
71
+ overflowCount,
72
+ thumbnailUrl,
73
+ cellStyle,
74
+ playButtonStyle,
75
+ playIconStyle,
76
+ durationChipStyle,
77
+ durationTextStyle,
78
+ overflowOverlayStyle,
79
+ overflowTextStyle,
80
+ }: VideoCellProps) => {
81
+ const theme = useTheme();
82
+ const duration = getDuration(attachment);
83
+ // A VIDEO bubble previews videos only. Anything else (image / audio / file) is unsupported here →
84
+ // a "no preview" placeholder cell (tapping it opens the "No preview available" fullscreen). Gate on a
85
+ // KNOWN non-video kind (a proper "type/subtype" mime that isn't video/*): an empty / bare-extension
86
+ // mime — e.g. an optimistic OUTGOING attachment mid-send — is treated as a video so the placeholder
87
+ // doesn't flash for a frame before the thumbnail loads.
88
+ const mime = attachment.getMimeType?.() ?? '';
89
+ const unsupported = mime.includes('/') && !isVideoMime(mime);
90
+
91
+ const borderStyle = {
92
+ borderTopLeftRadius: radii.topLeft ?? 0,
93
+ borderTopRightRadius: radii.topRight ?? 0,
94
+ borderBottomLeftRadius: radii.bottomLeft ?? 0,
95
+ borderBottomRightRadius: radii.bottomRight ?? 0,
96
+ };
97
+
98
+ if (unsupported) {
99
+ return (
100
+ <TouchableOpacity
101
+ testID={testID}
102
+ onPress={onPress}
103
+ activeOpacity={0.85}
104
+ style={[{ flex: 1, aspectRatio, overflow: 'hidden' }, borderStyle, cellStyle]}
105
+ accessibilityRole="button"
106
+ accessibilityLabel={attachment.getName()}
107
+ >
108
+ <View
109
+ testID="grid-cell-nopreview"
110
+ style={[StyleSheet.absoluteFillObject, borderStyle, { backgroundColor: theme.color.neutral200, justifyContent: 'center', alignItems: 'center' }]}
111
+ >
112
+ <Icon name="unknown-file-type" size={theme.spacing.spacing.s12} />
113
+ </View>
114
+ {overflowCount != null && overflowCount > 0 && (
115
+ <View
116
+ testID="grid-overflow"
117
+ pointerEvents="none"
118
+ style={[StyleSheet.absoluteFillObject, { backgroundColor: theme.color.mediaOverlay, justifyContent: 'center', alignItems: 'center' }, overflowOverlayStyle]}
119
+ >
120
+ <Text style={[{ ...theme.typography.heading1.bold, color: theme.color.staticWhite, letterSpacing: -0.5 }, overflowTextStyle]}>{`+${overflowCount}`}</Text>
121
+ </View>
122
+ )}
123
+ </TouchableOpacity>
124
+ );
125
+ }
126
+
127
+ return (
128
+ <TouchableOpacity
129
+ testID={testID}
130
+ onPress={onPress}
131
+ activeOpacity={0.85}
132
+ style={[{ flex: 1, aspectRatio, overflow: 'hidden' }, borderStyle, cellStyle]}
133
+ accessibilityRole="button"
134
+ accessibilityLabel={attachment.getName()}
135
+ >
136
+ <View style={[StyleSheet.absoluteFillObject, { backgroundColor: theme.color.mediaScrim }, borderStyle]} />
137
+ {thumbnailUrl ? (
138
+ <Image source={{ uri: thumbnailUrl }} style={[StyleSheet.absoluteFillObject, borderStyle]} resizeMode="cover" />
139
+ ) : null}
140
+
141
+ {!overflowCount && (
142
+ <View pointerEvents="none" style={StyleSheet.absoluteFillObject}>
143
+ <View style={styles.centerFill}>
144
+ <View
145
+ style={[{
146
+ width: theme.spacing.spacing.s11,
147
+ height: theme.spacing.spacing.s11,
148
+ // r6 (24), not r5 (20): on the 44px (s11) box RN clamps the radius to half the box (22),
149
+ // so r6 renders a perfect circle while r5 would give a rounded square.
150
+ borderRadius: theme.spacing.radius.r6,
151
+ backgroundColor: theme.color.mediaOverlay,
152
+ justifyContent: 'center',
153
+ alignItems: 'center',
154
+ }, playButtonStyle]}
155
+ >
156
+ <Icon name="play-arrow-fill" size={theme.spacing.spacing.s6} color={theme.color.staticWhite} imageStyle={playIconStyle} />
157
+ </View>
158
+ </View>
159
+ </View>
160
+ )}
161
+
162
+ {!overflowCount && duration && (
163
+ <View
164
+ pointerEvents="none"
165
+ style={[{
166
+ position: 'absolute',
167
+ bottom: theme.spacing.spacing.s2,
168
+ left: theme.spacing.spacing.s2,
169
+ backgroundColor: theme.color.mediaDurationChip,
170
+ borderRadius: theme.spacing.radius.r1,
171
+ paddingHorizontal: theme.spacing.padding.p1,
172
+ paddingVertical: theme.spacing.padding.p0_5,
173
+ }, durationChipStyle]}
174
+ >
175
+ {/* fontSize 11 / fontWeight '600' kept inline: no typography token matches. */}
176
+ <Text style={[{ color: theme.color.staticWhite, fontSize: 11, fontWeight: '600' }, durationTextStyle]}>{duration}</Text>
177
+ </View>
178
+ )}
179
+
180
+ {overflowCount != null && overflowCount > 0 && (
181
+ <View
182
+ testID="grid-overflow"
183
+ pointerEvents="none"
184
+ style={[StyleSheet.absoluteFillObject, { backgroundColor: theme.color.mediaOverlay, justifyContent: 'center', alignItems: 'center' }, overflowOverlayStyle]}
185
+ >
186
+ <Text style={[{ ...theme.typography.heading1.bold, color: theme.color.staticWhite, letterSpacing: -0.5 }, overflowTextStyle]}>{`+${overflowCount}`}</Text>
187
+ </View>
188
+ )}
189
+ </TouchableOpacity>
190
+ );
191
+ };
192
+
193
+ // ---- Grid layout (by count) ----------------------------------------------
194
+
195
+ const VideoGrid = ({
196
+ attachments,
197
+ thumbnailUrls,
198
+ onAttachmentPress,
199
+ containerStyle,
200
+ cellStyle,
201
+ playButtonStyle,
202
+ playIconStyle,
203
+ durationChipStyle,
204
+ durationTextStyle,
205
+ overflowOverlayStyle,
206
+ overflowTextStyle,
207
+ }: {
208
+ attachments: CometChat.Attachment[];
209
+ thumbnailUrls?: string[];
210
+ onAttachmentPress: (attachment: CometChat.Attachment, index: number) => void;
211
+ containerStyle?: StyleProp<ViewStyle>;
212
+ cellStyle?: StyleProp<ViewStyle>;
213
+ playButtonStyle?: StyleProp<ViewStyle>;
214
+ playIconStyle?: ImageStyle;
215
+ durationChipStyle?: StyleProp<ViewStyle>;
216
+ durationTextStyle?: TextStyle;
217
+ overflowOverlayStyle?: StyleProp<ViewStyle>;
218
+ overflowTextStyle?: TextStyle;
219
+ }) => {
220
+ const theme = useTheme();
221
+ const GAP = theme.spacing.spacing.s0_5; // 2 — inter-tile gutter
222
+ const CORNER = theme.spacing.radius.r2; // tiles nest at radius_2 (8)
223
+ const count = attachments.length;
224
+ if (count === 0) return null;
225
+
226
+ const cell = (i: number, radii: BorderRadii, aspectRatio?: number, overflowCount?: number) => (
227
+ <VideoCell
228
+ testID={`grid-cell-${i}`}
229
+ attachment={attachments[i]}
230
+ aspectRatio={aspectRatio}
231
+ radii={radii}
232
+ overflowCount={overflowCount}
233
+ thumbnailUrl={thumbnailUrls?.[i]}
234
+ onPress={() => onAttachmentPress(attachments[i], i)}
235
+ cellStyle={cellStyle}
236
+ playButtonStyle={playButtonStyle}
237
+ playIconStyle={playIconStyle}
238
+ durationChipStyle={durationChipStyle}
239
+ durationTextStyle={durationTextStyle}
240
+ overflowOverlayStyle={overflowOverlayStyle}
241
+ overflowTextStyle={overflowTextStyle}
242
+ />
243
+ );
244
+
245
+ const renderLayout = () => {
246
+ if (count === 1) {
247
+ return (
248
+ <View style={{ flexDirection: 'row' }}>
249
+ {cell(0, { topLeft: CORNER, topRight: CORNER, bottomLeft: CORNER, bottomRight: CORNER }, 4 / 3)}
250
+ </View>
251
+ );
252
+ }
253
+ if (count === 2) {
254
+ return (
255
+ <View style={{ flexDirection: 'row', gap: GAP }}>
256
+ {cell(0, { topLeft: CORNER, bottomLeft: CORNER })}
257
+ {cell(1, { topRight: CORNER, bottomRight: CORNER })}
258
+ </View>
259
+ );
260
+ }
261
+ if (count === 3) {
262
+ return (
263
+ <View style={{ gap: GAP }}>
264
+ <View style={{ flexDirection: 'row' }}>{cell(0, { topLeft: CORNER, topRight: CORNER }, 4 / 3)}</View>
265
+ <View style={{ flexDirection: 'row', gap: GAP }}>
266
+ {cell(1, { bottomLeft: CORNER })}
267
+ {cell(2, { bottomRight: CORNER })}
268
+ </View>
269
+ </View>
270
+ );
271
+ }
272
+ if (count === 4) {
273
+ return (
274
+ <View style={{ gap: GAP }}>
275
+ <View style={{ flexDirection: 'row', gap: GAP }}>
276
+ {cell(0, { topLeft: CORNER })}
277
+ {cell(1, { topRight: CORNER })}
278
+ </View>
279
+ <View style={{ flexDirection: 'row', gap: GAP }}>
280
+ {cell(2, { bottomLeft: CORNER })}
281
+ {cell(3, { bottomRight: CORNER })}
282
+ </View>
283
+ </View>
284
+ );
285
+ }
286
+ // 5+ → 2×2 with a "+N" overlay on the 4th slot
287
+ const overflowCount = count - 4;
288
+ return (
289
+ <View style={{ gap: GAP }}>
290
+ <View style={{ flexDirection: 'row', gap: GAP }}>
291
+ {cell(0, { topLeft: CORNER })}
292
+ {cell(1, { topRight: CORNER })}
293
+ </View>
294
+ <View style={{ flexDirection: 'row', gap: GAP }}>
295
+ {cell(2, { bottomLeft: CORNER })}
296
+ {cell(3, { bottomRight: CORNER }, undefined, overflowCount)}
297
+ </View>
298
+ </View>
299
+ );
300
+ };
301
+
302
+ return <View style={[styles.gridContainer, containerStyle]}>{renderLayout()}</View>;
303
+ };
304
+
305
+ // ---- Bubble --------------------------------------------------------------
306
+
307
+ export interface CometChatVideosBubbleProps {
308
+ message: CometChat.MediaMessage;
309
+ theme: CometChatTheme;
310
+ /** Per-instance style overrides — shares the `mediaGridBubbleStyles` theme key with ImagesBubble. */
311
+ style?: CometChatTheme["mediaGridBubbleStyles"];
312
+ }
313
+
314
+ /**
315
+ * Renders a single-kind VIDEO message (all videos, after the §7 fan-out) as a grid, with a
316
+ * batch-spanning fullscreen pager on tap. Fully independent of CometChatImagesBubble.
317
+ */
318
+ export function CometChatVideosBubble({
319
+ message: initialMessage,
320
+ theme,
321
+ style,
322
+ }: CometChatVideosBubbleProps) {
323
+ const compTheme = useCompTheme();
324
+ const s = deepMerge(theme.mediaGridBubbleStyles ?? {}, compTheme.mediaGridBubbleStyles ?? {}, style ?? {});
325
+ const [viewerVisible, setViewerVisible] = useState(false);
326
+ const [viewerInitialIndex, setViewerInitialIndex] = useState(0);
327
+ // §8.2 — the media set fed to the fullscreen pager (batch-spanning union when the list provides it).
328
+ const [viewerItems, setViewerItems] = useState<CometChat.Attachment[]>([]);
329
+ // §8.7 — local copy so onMessageEdited can refresh server-generated thumbnails / a caption edit.
330
+ const [message, setMessage] = useState<CometChat.MediaMessage>(initialMessage);
331
+
332
+ // A VIDEO message renders ALL its attachments; off-kind ones (image/audio/file) show a "no preview"
333
+ // placeholder cell + a "No preview available" fullscreen. getAttachments() preserves pick order.
334
+ const allAttachments = useMemo(
335
+ () => (message.getAttachments?.() ?? []).filter((a) => a != null && typeof a.getUrl === 'function'),
336
+ [message]
337
+ );
338
+ const caption = message.getCaption() ?? '';
339
+ const isSentByMe = message.getSender()?.getUid() === CometChatUIKit.loggedInUser?.getUid();
340
+
341
+ // §8.7 — server-generated video thumbnails, re-derived when the message updates.
342
+ const thumbnailUrls: string[] = useMemo(() => {
343
+ const thumbnailData = getExtensionData(message, 'thumbnail-generation');
344
+ const attachmentData: any[] = thumbnailData?.attachments ?? [];
345
+ return allAttachments.map((_, i) => {
346
+ const entry = attachmentData[i];
347
+ if (!entry || entry['error']) return '';
348
+ const thumbnails = entry?.data?.thumbnails ?? {};
349
+ return thumbnails['url_large'] ?? thumbnails['url_medium'] ?? thumbnails['url_small'] ?? '';
350
+ });
351
+ }, [message, allAttachments]);
352
+
353
+ // §8.7 — refresh the local copy when the server edits the message in (async thumbnails).
354
+ useEffect(() => {
355
+ const listenerId = `VideosBubble_${message.getId?.() ?? message.getMuid?.() ?? Date.now()}`;
356
+ CometChatMessageEvents.addListener(
357
+ CometChatMessageEvents.messageEdited,
358
+ listenerId,
359
+ (edited: CometChat.BaseMessage) => {
360
+ const editedId = edited.getId?.();
361
+ const editedMuid = edited.getMuid?.();
362
+ const myId = message.getId?.();
363
+ const myMuid = message.getMuid?.();
364
+ if (
365
+ edited instanceof CometChat.MediaMessage &&
366
+ ((myId && editedId && myId === editedId) || (myMuid && editedMuid && myMuid === editedMuid))
367
+ ) {
368
+ setMessage(edited);
369
+ }
370
+ }
371
+ );
372
+ return () => CometChatMessageEvents.removeListener(CometChatMessageEvents.messageEdited, listenerId);
373
+ }, []);
374
+
375
+ useEffect(() => {
376
+ setMessage(initialMessage);
377
+ }, [initialMessage]);
378
+
379
+ if (allAttachments.length === 0) return null;
380
+
381
+ return (
382
+ <View testID="bubble-video">
383
+ <VideoGrid
384
+ attachments={allAttachments}
385
+ thumbnailUrls={thumbnailUrls}
386
+ containerStyle={s.containerStyle}
387
+ cellStyle={s.cellStyle}
388
+ playButtonStyle={s.playButtonStyle}
389
+ playIconStyle={s.playIconStyle}
390
+ durationChipStyle={s.durationChipStyle}
391
+ durationTextStyle={s.durationTextStyle}
392
+ overflowOverlayStyle={s.overflowOverlayStyle}
393
+ overflowTextStyle={s.overflowTextStyle}
394
+ onAttachmentPress={(_, index) => {
395
+ // Page THIS message's attachments (grid & viewer share the same list → index aligns).
396
+ // The viewer renders off-kind items (non-video) as "No preview available".
397
+ setViewerItems(allAttachments);
398
+ setViewerInitialIndex(index);
399
+ setViewerVisible(true);
400
+ }}
401
+ />
402
+ {Boolean(caption) && (
403
+ <CometChatCaptionText
404
+ message={message}
405
+ caption={caption}
406
+ theme={theme}
407
+ containerStyle={{
408
+ paddingHorizontal: theme.spacing.padding.p3,
409
+ paddingTop: theme.spacing.padding.p2,
410
+ paddingBottom: theme.spacing.padding.p1,
411
+ }}
412
+ textStyle={{
413
+ ...theme.typography.body.regular,
414
+ color: isSentByMe ? theme.color.staticWhite : theme.color.neutral900,
415
+ }}
416
+ />
417
+ )}
418
+ <CometChatMediaViewer
419
+ mediaItems={viewerItems.length > 0 ? viewerItems : allAttachments}
420
+ canPreview={(att) => isVideoMime(att.getMimeType?.() ?? '')}
421
+ startIndex={viewerInitialIndex}
422
+ visible={viewerVisible}
423
+ message={message}
424
+ onClose={() => setViewerVisible(false)}
425
+ />
426
+ </View>
427
+ );
428
+ }
429
+
430
+ const styles = StyleSheet.create({
431
+ gridContainer: {
432
+ alignSelf: 'stretch',
433
+ minWidth: 232,
434
+ maxWidth: '100%',
435
+ },
436
+ centerFill: {
437
+ flex: 1,
438
+ justifyContent: 'center',
439
+ alignItems: 'center',
440
+ },
441
+ });
@@ -0,0 +1,2 @@
1
+ export { CometChatVideosBubble } from './CometChatVideosBubble';
2
+ export type { CometChatVideosBubbleProps } from './CometChatVideosBubble';
@@ -0,0 +1,78 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { CometChat } from '@cometchat/chat-sdk-react-native';
4
+ import { CometChatTheme } from '../../../theme/type';
5
+ import { groupAttachments } from '../../utils/groupAttachments';
6
+ import { CometChatUIKit } from '../../CometChatUiKit';
7
+ import { CometChatAudioBubble } from '../CometChatAudioBubble';
8
+ import { CometChatCaptionText } from '../CometChatCaptionText';
9
+ import { deepMerge } from '../../helper/helperFunctions';
10
+ import { useCompTheme } from '../../../theme/hook';
11
+
12
+ // ---------------------------------------------------------------------------
13
+ // Design doc §8.1a — the "VoiceNoteBubble": renders a RECORDED voice-note message
14
+ // (metadata.audioType === "voice_note") with the WAVEFORM player — reusing the
15
+ // existing single-audio primitive (CometChatAudioBubble) unchanged, one per item.
16
+ // Voice notes are normally a single recording; a stack is rendered if there were
17
+ // several. Shared/picked audio FILES use CometChatAudiosBubble (headphone+filename)
18
+ // instead. Tap → play inline; audio is never part of the fullscreen pager (§8.2).
19
+ // ---------------------------------------------------------------------------
20
+
21
+ export interface CometChatVoiceNoteBubbleProps {
22
+ message: CometChat.MediaMessage;
23
+ theme: CometChatTheme;
24
+ /** Per-instance style overrides (same pattern as the other bubbles). */
25
+ style?: CometChatTheme["voiceNoteBubbleStyles"];
26
+ }
27
+
28
+ /**
29
+ * Renders a recorded voice-note message as the waveform player (CometChatAudioBubble),
30
+ * with a caption on the message.
31
+ */
32
+ export function CometChatVoiceNoteBubble({
33
+ message,
34
+ theme,
35
+ style,
36
+ }: CometChatVoiceNoteBubbleProps) {
37
+ const compTheme = useCompTheme();
38
+ const s = deepMerge(theme.voiceNoteBubbleStyles ?? {}, compTheme.voiceNoteBubbleStyles ?? {}, style ?? {});
39
+ const { audioAttachments } = groupAttachments(message);
40
+ const caption = message.getCaption() ?? '';
41
+ const isSentByMe = message.getSender()?.getUid() === CometChatUIKit.loggedInUser?.getUid();
42
+
43
+ if (audioAttachments.length === 0) return null;
44
+
45
+ return (
46
+ <View style={[{ width: '100%' }, s.containerStyle]}>
47
+ {audioAttachments.map((att, i) => (
48
+ <CometChatAudioBubble
49
+ key={att.getUrl() ?? String(i)}
50
+ audioUrl={att.getUrl()}
51
+ playViewContainerStyle={s.playViewContainerStyle}
52
+ playIconStyle={s.playIconStyle}
53
+ playIconContainerStyle={s.playIconContainerStyle}
54
+ waveStyle={s.waveStyle}
55
+ waveContainerStyle={s.waveContainerStyle}
56
+ playProgressTextStyle={s.playProgressTextStyle}
57
+ />
58
+ ))}
59
+ {/* §7 — caption rides on the (last) message of the batch */}
60
+ {Boolean(caption) && (
61
+ <CometChatCaptionText
62
+ message={message}
63
+ caption={caption}
64
+ theme={theme}
65
+ containerStyle={{
66
+ paddingHorizontal: theme.spacing.padding.p3,
67
+ paddingTop: theme.spacing.padding.p2,
68
+ paddingBottom: theme.spacing.padding.p1,
69
+ }}
70
+ textStyle={[{
71
+ ...theme.typography.body.regular,
72
+ color: isSentByMe ? theme.color.staticWhite : theme.color.neutral900,
73
+ }, s.captionStyle]}
74
+ />
75
+ )}
76
+ </View>
77
+ );
78
+ }
@@ -0,0 +1,2 @@
1
+ export { CometChatVoiceNoteBubble } from './CometChatVoiceNoteBubble';
2
+ export type { CometChatVoiceNoteBubbleProps } from './CometChatVoiceNoteBubble';
@@ -196,4 +196,40 @@ export type {
196
196
  DateStyle,
197
197
  MenuItemInterface,
198
198
  NewMessageIndicatorStyle,
199
- };
199
+ };
200
+
201
+ // Multiple Attachment Support — U4 (§5.0 canonical names)
202
+ export {
203
+ CometChatAttachmentTray,
204
+ CometChatAttachmentTile,
205
+ CometChatAttachmentPreview, // backward-compat alias
206
+ CometChatAttachmentPreviewItem, // backward-compat alias
207
+ getAttachmentPreviewStyle,
208
+ } from './CometChatAttachmentPreview';
209
+ export type {
210
+ CometChatAttachmentTrayProps,
211
+ CometChatAttachmentTileProps,
212
+ CometChatAttachmentPreviewProps,
213
+ CometChatAttachmentPreviewItemProps,
214
+ } from './CometChatAttachmentPreview';
215
+
216
+ // Design doc §8.0 — five per-type multi-attachment bubbles (no single "GalleryBubble").
217
+ // §8.1 — image/video share one media-grid renderer.
218
+ export { CometChatImagesBubble } from './CometChatImagesBubble';
219
+ export { CometChatVideosBubble } from './CometChatVideosBubble';
220
+ // §8.6 — per-type files bubble (vertical file-card list)
221
+ export { CometChatFilesBubble } from './CometChatFilesBubble';
222
+ export type { CometChatFilesBubbleProps } from './CometChatFilesBubble';
223
+ // §8.1a — shared/picked audio-file bubble (WhatsApp-style headphone chip + filename + seek bar)
224
+ export { CometChatAudiosBubble } from './CometChatAudiosBubble';
225
+ export type { CometChatAudiosBubbleProps } from './CometChatAudiosBubble';
226
+ // §8.1a — recorded voice-note bubble (waveform player, built on the existing CometChatAudioBubble)
227
+ export { CometChatVoiceNoteBubble } from './CometChatVoiceNoteBubble';
228
+ export type { CometChatVoiceNoteBubbleProps } from './CometChatVoiceNoteBubble';
229
+
230
+ // §8.2.1 — unified image+video pager (supersedes CometChatAttachmentViewer for multi-attachment)
231
+ export { CometChatMediaViewer } from './CometChatMediaViewer';
232
+ export type { CometChatMediaViewerProps } from './CometChatMediaViewer';
233
+
234
+ export { CometChatAttachmentViewer } from './CometChatAttachmentViewer';
235
+ export type { CometChatAttachmentViewerProps } from './CometChatAttachmentViewer';
@@ -276,6 +276,14 @@ export class CometChatThemeHelper {
276
276
  color.previewCodeBlockBorder =
277
277
  color.previewCodeBlockBorder === undefined ? defaultColor.previewCodeBlockBorder : color.previewCodeBlockBorder;
278
278
 
279
+ // Media overlays — so a custom (partial) theme still gets the dark scrims for media/attachments.
280
+ color.mediaScrim = color.mediaScrim === undefined ? defaultColor.mediaScrim : color.mediaScrim;
281
+ color.mediaOverlay = color.mediaOverlay === undefined ? defaultColor.mediaOverlay : color.mediaOverlay;
282
+ color.mediaDurationChip =
283
+ color.mediaDurationChip === undefined ? defaultColor.mediaDurationChip : color.mediaDurationChip;
284
+ color.mediaErrorOverlay =
285
+ color.mediaErrorOverlay === undefined ? defaultColor.mediaErrorOverlay : color.mediaErrorOverlay;
286
+
279
287
  return color;
280
288
  }
281
289
 
@@ -38,6 +38,7 @@ const alertColors = {
38
38
  const staticColors = {
39
39
  staticBlack: "#141414",
40
40
  staticWhite: "#FFFFFF",
41
+ staticWhite35: "rgba(255, 255, 255, 0.35)", // staticWhite @ 35% (color-mix(staticWhite 35%, transparent))
41
42
  };
42
43
 
43
44
  const overlayColors = {
@@ -95,6 +96,7 @@ export const defaultColorDark: Color = {
95
96
  sendBubbleLink: staticColors.staticWhite,
96
97
  sendBubbleTimestamp: staticColors.staticWhite,
97
98
  sendBubbleIcon: staticColors.staticWhite,
99
+ sendBubbleTrack: staticColors.staticWhite35, // unfilled seek-bar track on the send bubble
98
100
 
99
101
  receiveBubbleBackground: neutralColors.neutral300,
100
102
  receiveBubbleText: neutralColors.neutral900,
@@ -109,4 +111,11 @@ export const defaultColorDark: Color = {
109
111
  previewCodeBlockBackground: overlayColors.overlayCodeBlock,
110
112
  // Reply preview code block border
111
113
  previewCodeBlockBorder: overlayColors.overlayCodeBlockBorder,
114
+
115
+ // Media overlays — dark scrims that sit ON TOP of image/video content, so they stay dark in BOTH
116
+ // themes (a light scrim over media reads wrong). Same values as light for that reason.
117
+ mediaScrim: "#0D0D0D", // opaque fill behind a video cell / poster
118
+ mediaOverlay: "rgba(0, 0, 0, 0.6)", // play-button circle, "+N" overflow scrim, batch-count overlay
119
+ mediaDurationChip: "rgba(0, 0, 0, 0.72)", // duration pill (darker for text legibility)
120
+ mediaErrorOverlay: "rgba(0, 0, 0, 0.45)", // dim for an errored media tile
112
121
  };
@@ -38,6 +38,7 @@ const alertColors = {
38
38
  const staticColors = {
39
39
  staticBlack: "#141414",
40
40
  staticWhite: "#FFFFFF",
41
+ staticWhite35: "rgba(255, 255, 255, 0.35)", // staticWhite @ 35% (color-mix(staticWhite 35%, transparent))
41
42
  };
42
43
 
43
44
  const overlayColors = {
@@ -95,6 +96,7 @@ export const defaultColorLight = {
95
96
  sendBubbleLink: staticColors.staticWhite,
96
97
  sendBubbleTimestamp: staticColors.staticWhite,
97
98
  sendBubbleIcon: staticColors.staticWhite,
99
+ sendBubbleTrack: staticColors.staticWhite35, // unfilled seek-bar track on the send bubble
98
100
 
99
101
  receiveBubbleBackground: neutralColors.neutral300,
100
102
  receiveBubbleText: neutralColors.neutral900,
@@ -109,6 +111,14 @@ export const defaultColorLight = {
109
111
  previewCodeBlockBackground: overlayColors.overlayCodeBlock,
110
112
  // Reply preview code block border
111
113
  previewCodeBlockBorder: overlayColors.overlayCodeBlockBorder,
114
+
115
+ // Media overlays — dark scrims that sit ON TOP of image/video content, so they stay dark in BOTH
116
+ // themes (a light scrim over media reads wrong). Tokenized here so every media/attachment surface
117
+ // pulls the same values instead of hardcoding them per component.
118
+ mediaScrim: "#0D0D0D", // opaque fill behind a video cell / poster
119
+ mediaOverlay: "rgba(0, 0, 0, 0.6)", // play-button circle, "+N" overflow scrim, batch-count overlay
120
+ mediaDurationChip: "rgba(0, 0, 0, 0.72)", // duration pill (darker for text legibility)
121
+ mediaErrorOverlay: "rgba(0, 0, 0, 0.45)", // dim for an errored media tile
112
122
  };
113
123
  type EachColorValue<T extends typeof defaultColorLight> = {
114
124
  [P in keyof T]: ColorValue;