@cometchat/chat-uikit-react-native 5.3.9 → 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.
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/src/main/java/com/reactnativecometchatuikit/CometChatClipboardModule.kt +52 -0
- package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +1 -0
- package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +95 -8
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +237 -6
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorViewManager.kt +2 -1
- package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +85 -47
- package/ios/CometChatClipboardModule.m +11 -0
- package/ios/CometChatClipboardModule.swift +41 -0
- package/ios/FileManager.m +201 -39
- package/ios/RichTextEditorView.swift +312 -4
- package/ios/RichTextEditorViewManager.m +1 -0
- package/ios/SoundPlayer.m +18 -6
- package/package.json +9 -7
- package/react-native-cometchat-ui-kit.podspec +1 -0
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +692 -107
- package/src/CometChatConversations/CometChatConversations.tsx +28 -6
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +649 -49
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +23 -4
- package/src/CometChatMessageList/CometChatMessageList.tsx +530 -58
- package/src/CometChatMessageList/MANUAL_TEST_CASES.md +154 -0
- package/src/CometChatMessageList/components/MessageListItem.tsx +30 -17
- package/src/CometChatMessageList/style.ts +33 -5
- package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +13 -0
- package/src/CometChatRichTextEditor/index.tsx +25 -0
- package/src/CometChatSearch/CometChatSearch.tsx +296 -154
- package/src/calls/CallingExtension.tsx +19 -13
- package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +20 -1
- package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +20 -9
- package/src/index.ts +39 -0
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +40 -34
- package/src/shared/base/Types.ts +3 -0
- package/src/shared/constants/UIKitConstants.ts +15 -1
- package/src/shared/framework/DataSource.ts +14 -4
- package/src/shared/framework/DataSourceDecorator.tsx +17 -8
- package/src/shared/framework/MessageDataSource.tsx +321 -62
- package/src/shared/helper/useToast.tsx +29 -0
- package/src/shared/icons/components/audio-file-type.tsx +11 -22
- package/src/shared/icons/components/document-file-type.tsx +11 -24
- package/src/shared/icons/components/image-file-type.tsx +12 -21
- package/src/shared/icons/components/link-file-type.tsx +25 -0
- package/src/shared/icons/components/pdf-file-type.tsx +11 -22
- package/src/shared/icons/components/presentation-file-type.tsx +11 -24
- package/src/shared/icons/components/spreadsheet-file-type.tsx +11 -24
- package/src/shared/icons/components/text-file-type.tsx +11 -21
- package/src/shared/icons/components/unknown-file-type.tsx +21 -25
- package/src/shared/icons/components/video-file-type.tsx +11 -24
- package/src/shared/icons/components/zip-file-type.tsx +11 -24
- package/src/shared/icons/icon-mapping.tsx +2 -0
- package/src/shared/index.ts +28 -0
- package/src/shared/modals/AttachmentPickerConfiguration.ts +13 -0
- package/src/shared/modals/SelectedAttachment.ts +65 -0
- package/src/shared/modals/UploadState.ts +10 -0
- package/src/shared/modals/index.ts +4 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +43 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +43 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +44 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +44 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +44 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +44 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +44 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +44 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +44 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +44 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +44 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +44 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +44 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +44 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +44 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +44 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +44 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +44 -2
- package/src/shared/services/UploadQueueService.ts +145 -0
- package/src/shared/services/index.ts +2 -0
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +42 -18
- package/src/shared/utils/MessageUtils.tsx +13 -4
- package/src/shared/utils/attachmentLimits.ts +156 -0
- package/src/shared/utils/audioPlaybackCoordinator.ts +28 -0
- package/src/shared/utils/batchMediaContext.tsx +30 -0
- package/src/shared/utils/conversationUtils.ts +44 -4
- package/src/shared/utils/groupAttachments.ts +93 -0
- package/src/shared/utils/index.ts +8 -0
- package/src/shared/utils/openMultiFileChooser.ts +123 -0
- package/src/shared/utils/partitionAttachmentsByKind.ts +44 -0
- package/src/shared/views/ClipboardPasteHandler/ClipboardPasteHandler.ts +28 -0
- package/src/shared/views/ClipboardPasteHandler/NativeCometChatClipboardModule.ts +16 -0
- package/src/shared/views/ClipboardPasteHandler/index.ts +2 -0
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -0
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.style.ts +32 -0
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.tsx +90 -0
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreviewItem.tsx +276 -0
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +827 -0
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTray.tsx +110 -0
- package/src/shared/views/CometChatAttachmentPreview/StagedVideoDurationProbe.tsx +53 -0
- package/src/shared/views/CometChatAttachmentPreview/index.ts +8 -0
- package/src/shared/views/CometChatAttachmentViewer/CometChatAttachmentViewer.tsx +305 -0
- package/src/shared/views/CometChatAttachmentViewer/index.ts +2 -0
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +71 -74
- package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +587 -0
- package/src/shared/views/CometChatAudiosBubble/index.ts +2 -0
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +5 -7
- package/src/shared/views/CometChatCaptionText/CometChatCaptionText.tsx +182 -0
- package/src/shared/views/CometChatCaptionText/index.ts +2 -0
- package/src/shared/views/CometChatComposerErrorBanner.tsx +83 -0
- package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +141 -0
- package/src/shared/views/CometChatConversationStarter/index.ts +2 -0
- package/src/shared/views/CometChatConversationSummary/CometChatConversationSummary.tsx +155 -0
- package/src/shared/views/CometChatConversationSummary/index.ts +2 -0
- package/src/shared/views/CometChatFileBubble/style.ts +6 -4
- package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +316 -0
- package/src/shared/views/CometChatFilesBubble/index.ts +2 -0
- package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +323 -0
- package/src/shared/views/CometChatImagesBubble/index.ts +2 -0
- package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +425 -0
- package/src/shared/views/CometChatMediaViewer/index.ts +2 -0
- package/src/shared/views/CometChatMediaViewer/mediaViewerUtils.ts +30 -0
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +14 -4
- package/src/shared/views/CometChatSendButtonView/CometChatSendButtonView.tsx +1 -0
- package/src/shared/views/CometChatSmartReplies/CometChatSmartReplies.tsx +172 -0
- package/src/shared/views/CometChatSmartReplies/index.ts +2 -0
- package/src/shared/views/CometChatVideoBubble/style.ts +3 -3
- package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +441 -0
- package/src/shared/views/CometChatVideosBubble/index.ts +2 -0
- package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +78 -0
- package/src/shared/views/CometChatVoiceNoteBubble/index.ts +2 -0
- package/src/shared/views/index.ts +37 -1
- package/src/theme/CometChatThemeHelper.ts +8 -0
- package/src/theme/default/color/dark.ts +9 -0
- package/src/theme/default/color/light.ts +10 -0
- package/src/theme/type.ts +73 -0
- package/src/CometChatMessageList/PERFORMANCE_ARCHITECTURE.md +0 -478
- package/src/CometChatMessageList/SEARCH_NAV_PERF_PLAN.md +0 -613
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ActivityIndicator,
|
|
4
|
+
NativeEventEmitter,
|
|
5
|
+
NativeModules,
|
|
6
|
+
Platform,
|
|
7
|
+
Text,
|
|
8
|
+
TouchableOpacity,
|
|
9
|
+
View,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import { CometChat } from '@cometchat/chat-sdk-react-native';
|
|
12
|
+
import { CometChatTheme } from '../../../theme/type';
|
|
13
|
+
import { deepMerge } from '../../helper/helperFunctions';
|
|
14
|
+
import { useCompTheme } from '../../../theme/hook';
|
|
15
|
+
import { Icon } from '../../icons/Icon';
|
|
16
|
+
import { getFileTypeIcon, ATTACHMENT_COLLAPSED_LIMIT } from '../../constants/UIKitConstants';
|
|
17
|
+
import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
|
|
18
|
+
import { groupAttachments } from '../../utils/groupAttachments';
|
|
19
|
+
import { CometChatUIKit } from '../../CometChatUiKit';
|
|
20
|
+
import { CometChatCaptionText } from '../CometChatCaptionText';
|
|
21
|
+
|
|
22
|
+
const { FileManager } = NativeModules;
|
|
23
|
+
const fileEventEmitter = new NativeEventEmitter(FileManager);
|
|
24
|
+
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
// Design doc §8.6 — the "FilesBubble": renders a single-kind file message
|
|
27
|
+
// (all non-media file attachments, after the §7 fan-out) as a downloadable
|
|
28
|
+
// card-list. A SINGLE file renders as a plain row; MULTIPLE files (a collection)
|
|
29
|
+
// each get their own lighter, rounded card — the SAME treatment as the audio
|
|
30
|
+
// collection bubble (CometChatAudiosBubble): extendedPrimary800/neutral100 card,
|
|
31
|
+
// radius.r3, padding.p3, margin.m2 gap. (Renders what was the files section of the
|
|
32
|
+
// now-retired multi-section gallery bubble.)
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
type DownloadState = 'IDLE' | 'DOWNLOADING' | 'DONE' | 'FAILED';
|
|
36
|
+
|
|
37
|
+
function formatFileSize(bytes?: number): string {
|
|
38
|
+
// Missing/invalid size (e.g. an attachment reconstructed without a size field) → no label,
|
|
39
|
+
// so the row shows just the extension instead of "undefined B".
|
|
40
|
+
if (typeof bytes !== 'number' || !isFinite(bytes) || bytes <= 0) return '';
|
|
41
|
+
if (bytes >= 1_048_576) return `${(bytes / 1_048_576).toFixed(1)} MB`;
|
|
42
|
+
if (bytes >= 1_024) return `${Math.round(bytes / 1_024)} KB`;
|
|
43
|
+
return `${bytes} B`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getExtension(name: string): string {
|
|
47
|
+
return (name.split('.').pop() ?? '').toUpperCase();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface CometChatFilesBubbleProps {
|
|
51
|
+
message: CometChat.MediaMessage;
|
|
52
|
+
theme: CometChatTheme;
|
|
53
|
+
/** Per-instance style overrides (applied over the tokenized defaults) — same pattern as the
|
|
54
|
+
* other bubbles (e.g. CometChatAudioBubble / CometChatFileBubble). */
|
|
55
|
+
style?: CometChatTheme["filesBubbleStyles"];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Renders a single-kind file message (all files, after the §7 fan-out) as a
|
|
60
|
+
* vertical list of downloadable rows, with a caption on the message. One file =
|
|
61
|
+
* plain row; two or more = one lighter card per file (matches the audio bubble).
|
|
62
|
+
*/
|
|
63
|
+
export function CometChatFilesBubble({
|
|
64
|
+
message,
|
|
65
|
+
theme,
|
|
66
|
+
style,
|
|
67
|
+
}: CometChatFilesBubbleProps) {
|
|
68
|
+
const { t } = useCometChatTranslation();
|
|
69
|
+
const compTheme = useCompTheme();
|
|
70
|
+
const mergedStyle = deepMerge(
|
|
71
|
+
theme.filesBubbleStyles ?? {},
|
|
72
|
+
compTheme.filesBubbleStyles ?? {},
|
|
73
|
+
style ?? {}
|
|
74
|
+
);
|
|
75
|
+
const [expanded, setExpanded] = useState(false);
|
|
76
|
+
const [downloadStates, setDownloadStates] = useState<Record<string, DownloadState>>({});
|
|
77
|
+
// Android's DownloadManager is async — map each downloadId to the file to OPEN once its
|
|
78
|
+
// `downloadComplete` event fires (iOS resolves synchronously in the checkAndDownload callback).
|
|
79
|
+
const pendingOpensRef = useRef<Record<string, { url: string; name: string; key: string }>>({});
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (Platform.OS !== 'android') return;
|
|
82
|
+
const sub = fileEventEmitter.addListener('downloadComplete', (data: { downloadId: number }) => {
|
|
83
|
+
const pending = pendingOpensRef.current[String(data?.downloadId)];
|
|
84
|
+
if (pending) {
|
|
85
|
+
FileManager?.openFile?.(pending.url, pending.name, () => {});
|
|
86
|
+
setDownloadStates(prev => ({ ...prev, [pending.key]: 'DONE' }));
|
|
87
|
+
delete pendingOpensRef.current[String(data.downloadId)];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return () => sub.remove();
|
|
91
|
+
}, []);
|
|
92
|
+
|
|
93
|
+
// A `file`-type message can carry media attachments too: web sends a MIXED batch as ONE `file`
|
|
94
|
+
// message (video + image + docs together) instead of fanning out per kind the way this app does.
|
|
95
|
+
// Its intent is a file/download LIST of every attachment — so recombine all of groupAttachments'
|
|
96
|
+
// kind-split groups here. Using only `fileAttachments` would silently drop the video/image and
|
|
97
|
+
// render an empty bubble. (App-native `file` messages carry only real files, so this is a no-op
|
|
98
|
+
// for them.)
|
|
99
|
+
const { mediaAttachments, audioAttachments, fileAttachments } = groupAttachments(message);
|
|
100
|
+
const files = [...mediaAttachments, ...audioAttachments, ...fileAttachments];
|
|
101
|
+
const caption = message.getCaption() ?? '';
|
|
102
|
+
const isSentByMe = message.getSender()?.getUid() === CometChatUIKit.loggedInUser?.getUid();
|
|
103
|
+
|
|
104
|
+
if (files.length === 0) return null;
|
|
105
|
+
|
|
106
|
+
// 2+ files → each file sits in its own lighter card (like the audio collection); a single file
|
|
107
|
+
// stays a plain row on the message bubble.
|
|
108
|
+
const isCollection = files.length > 1;
|
|
109
|
+
const visibleFiles =
|
|
110
|
+
expanded || files.length <= ATTACHMENT_COLLAPSED_LIMIT
|
|
111
|
+
? files
|
|
112
|
+
: files.slice(0, ATTACHMENT_COLLAPSED_LIMIT);
|
|
113
|
+
|
|
114
|
+
const hiddenCount = files.length - ATTACHMENT_COLLAPSED_LIMIT;
|
|
115
|
+
const showExpandButton = files.length > ATTACHMENT_COLLAPSED_LIMIT;
|
|
116
|
+
|
|
117
|
+
const handleDownload = (file: CometChat.Attachment) => {
|
|
118
|
+
const url = file.getUrl();
|
|
119
|
+
const name = file.getName();
|
|
120
|
+
const key = url;
|
|
121
|
+
if ((downloadStates[key] ?? 'IDLE') === 'DOWNLOADING') return;
|
|
122
|
+
|
|
123
|
+
// Tap = OPEN the document (mirror CometChatFileBubble — the multi bubble previously only
|
|
124
|
+
// downloaded and never opened, so multi-doc messages "didn't open" after sending). If a local
|
|
125
|
+
// copy already exists, open it immediately; otherwise download first, then open on completion.
|
|
126
|
+
FileManager?.doesFileExist?.(name, (existResult: string) => {
|
|
127
|
+
let exists = false;
|
|
128
|
+
try { exists = !!JSON.parse(existResult)?.exists; } catch {}
|
|
129
|
+
if (exists) {
|
|
130
|
+
FileManager?.openFile?.(url, name, () => {});
|
|
131
|
+
setDownloadStates(prev => ({ ...prev, [key]: 'DONE' }));
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
setDownloadStates(prev => ({ ...prev, [key]: 'DOWNLOADING' }));
|
|
136
|
+
FileManager?.checkAndDownload?.(url, name, (result: string) => {
|
|
137
|
+
try {
|
|
138
|
+
const parsed = JSON.parse(result);
|
|
139
|
+
if (Platform.OS === 'ios') {
|
|
140
|
+
// iOS resolves the download in this callback — open on success.
|
|
141
|
+
if (parsed.success) {
|
|
142
|
+
FileManager?.openFile?.(url, name, () => {});
|
|
143
|
+
setDownloadStates(prev => ({ ...prev, [key]: 'DONE' }));
|
|
144
|
+
} else {
|
|
145
|
+
setDownloadStates(prev => ({ ...prev, [key]: 'FAILED' }));
|
|
146
|
+
}
|
|
147
|
+
} else if (parsed.downloadId != null) {
|
|
148
|
+
// Android: DownloadManager is async — the downloadComplete listener opens it.
|
|
149
|
+
pendingOpensRef.current[String(parsed.downloadId)] = { url, name, key };
|
|
150
|
+
} else {
|
|
151
|
+
setDownloadStates(prev => ({ ...prev, [key]: 'FAILED' }));
|
|
152
|
+
}
|
|
153
|
+
} catch {
|
|
154
|
+
setDownloadStates(prev => ({ ...prev, [key]: 'FAILED' }));
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const S = theme.spacing;
|
|
161
|
+
const textColor = isSentByMe ? theme.color.sendBubbleText : theme.color.receiveBubbleText;
|
|
162
|
+
const subtextColor = isSentByMe ? theme.color.sendBubbleTimestamp : theme.color.receiveBubbleTimestamp;
|
|
163
|
+
// Card surface: a lighter purple on the sent (purple) bubble; on received, a shade DARKER than the
|
|
164
|
+
// grey bubble (neutral400 vs the neutral300 bubble) so cards read as grey-on-lighter — not the
|
|
165
|
+
// near-white (lighter-than-bubble) cards, which inverted the design.
|
|
166
|
+
const cardBg = isSentByMe ? theme.color.extendedPrimary800 : theme.color.neutral400;
|
|
167
|
+
// Accent for the download icon + "Show more": white on the sent (purple) bubble, primary on received.
|
|
168
|
+
const accentColor = isSentByMe ? theme.color.staticWhite : theme.color.primary;
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
// Size to content like the AudiosBubble (no fixed minWidth floor) so the message-bubble wrapper's
|
|
172
|
+
// horizontal padding stays symmetric — a screen-% floor could exceed the wrapper's content area and
|
|
173
|
+
// push the cards past the right padding, making L/R padding look uneven.
|
|
174
|
+
<View testID="bubble-file" style={[{ width: '100%' }, mergedStyle.containerStyle]}>
|
|
175
|
+
{visibleFiles.map((file, index) => {
|
|
176
|
+
const key = file.getUrl();
|
|
177
|
+
const dlState = downloadStates[key] ?? 'IDLE';
|
|
178
|
+
const ext = getExtension(file.getName());
|
|
179
|
+
// Join only the parts we actually have → "1.2 MB • PDF", "PDF", or "" — never "undefined B".
|
|
180
|
+
const sizeLabel = [formatFileSize(file.getSize()), ext].filter(Boolean).join(' • ');
|
|
181
|
+
|
|
182
|
+
const row = (
|
|
183
|
+
<TouchableOpacity
|
|
184
|
+
onPress={() => handleDownload(file)}
|
|
185
|
+
activeOpacity={0.7}
|
|
186
|
+
style={{
|
|
187
|
+
flexDirection: 'row',
|
|
188
|
+
alignItems: 'center',
|
|
189
|
+
gap: S.spacing.s2,
|
|
190
|
+
// In collection mode the card supplies the padding (p3); a single row pads itself.
|
|
191
|
+
...(isCollection
|
|
192
|
+
? null
|
|
193
|
+
: { paddingVertical: S.padding.p3, paddingHorizontal: S.padding.p3 }),
|
|
194
|
+
}}
|
|
195
|
+
accessibilityRole="button"
|
|
196
|
+
accessibilityLabel={`Download ${file.getName()}`}
|
|
197
|
+
>
|
|
198
|
+
{/* Colored file type icon */}
|
|
199
|
+
<Icon name={getFileTypeIcon(file.getName())} size={S.spacing.s8} />
|
|
200
|
+
|
|
201
|
+
{/* Name + size•ext. minWidth:0 lets the Texts truncate cleanly inside the flex row instead
|
|
202
|
+
of forcing the row wider / wrapping (Android). */}
|
|
203
|
+
<View style={{ flex: 1, minWidth: 0 }}>
|
|
204
|
+
<Text
|
|
205
|
+
numberOfLines={1}
|
|
206
|
+
ellipsizeMode="middle"
|
|
207
|
+
style={[{ ...theme.typography.body.medium, color: textColor }, mergedStyle.fileNameStyle]}
|
|
208
|
+
>
|
|
209
|
+
{file.getName()}
|
|
210
|
+
</Text>
|
|
211
|
+
<Text
|
|
212
|
+
numberOfLines={1}
|
|
213
|
+
ellipsizeMode="tail"
|
|
214
|
+
style={[{ ...theme.typography.caption1.regular, color: subtextColor, marginTop: S.margin.m0_5 }, mergedStyle.fileSizeTextStyle]}
|
|
215
|
+
>
|
|
216
|
+
{sizeLabel}
|
|
217
|
+
</Text>
|
|
218
|
+
{dlState === 'FAILED' && (
|
|
219
|
+
<Text
|
|
220
|
+
style={{ ...theme.typography.caption2.regular, color: theme.color.error, marginTop: S.margin.m0_5 }}
|
|
221
|
+
>
|
|
222
|
+
{t('DOWNLOAD_FAILED') ?? 'Download failed'}
|
|
223
|
+
</Text>
|
|
224
|
+
)}
|
|
225
|
+
</View>
|
|
226
|
+
|
|
227
|
+
{/* Download state indicator. flex-end (not center) so the icon sits flush against the card's
|
|
228
|
+
right padding — matching the file icon flush against the left padding → symmetric L/R. */}
|
|
229
|
+
<View style={{ width: S.spacing.s6, alignItems: 'flex-end' }}>
|
|
230
|
+
{dlState === 'DOWNLOADING' ? (
|
|
231
|
+
<ActivityIndicator
|
|
232
|
+
size="small"
|
|
233
|
+
color={isSentByMe ? theme.color.staticWhite : theme.color.primary}
|
|
234
|
+
/>
|
|
235
|
+
) : dlState === 'DONE' ? (
|
|
236
|
+
<Icon name="check-fill" size={S.spacing.s5} color={theme.color.primary} />
|
|
237
|
+
) : (
|
|
238
|
+
<Icon name="download" size={S.spacing.s5} color={accentColor as string} imageStyle={mergedStyle.downloadIconStyle} />
|
|
239
|
+
)}
|
|
240
|
+
</View>
|
|
241
|
+
</TouchableOpacity>
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
// 2+ files → wrap each row in its own lighter card, with a gap between cards (and before
|
|
245
|
+
// the expand button). Single file → plain row, no card.
|
|
246
|
+
if (isCollection) {
|
|
247
|
+
const notLastCard = index < visibleFiles.length - 1 || showExpandButton;
|
|
248
|
+
return (
|
|
249
|
+
<View
|
|
250
|
+
key={key}
|
|
251
|
+
style={[{
|
|
252
|
+
backgroundColor: cardBg,
|
|
253
|
+
borderRadius: S.radius.r3,
|
|
254
|
+
padding: S.padding.p3,
|
|
255
|
+
marginBottom: notLastCard ? S.margin.m2 : 0,
|
|
256
|
+
}, mergedStyle.cardStyle]}
|
|
257
|
+
>
|
|
258
|
+
{row}
|
|
259
|
+
</View>
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
return <View key={key}>{row}</View>;
|
|
263
|
+
})}
|
|
264
|
+
|
|
265
|
+
{/* Expand / Collapse — a filled button matching the file cards: "⌄ Show N more" / "⌃ Show less",
|
|
266
|
+
chevron first, on the card surface. */}
|
|
267
|
+
{showExpandButton && (
|
|
268
|
+
<TouchableOpacity
|
|
269
|
+
testID="file-list-expand"
|
|
270
|
+
onPress={() => setExpanded(e => !e)}
|
|
271
|
+
activeOpacity={0.7}
|
|
272
|
+
style={{
|
|
273
|
+
flexDirection: 'row',
|
|
274
|
+
alignItems: 'center',
|
|
275
|
+
justifyContent: 'center',
|
|
276
|
+
gap: S.spacing.s1,
|
|
277
|
+
backgroundColor: cardBg,
|
|
278
|
+
borderRadius: S.radius.r3,
|
|
279
|
+
paddingVertical: S.padding.p3,
|
|
280
|
+
paddingHorizontal: S.padding.p3,
|
|
281
|
+
}}
|
|
282
|
+
accessibilityRole="button"
|
|
283
|
+
>
|
|
284
|
+
<Icon
|
|
285
|
+
name={expanded ? 'keyboard-arrow-up' : 'keyboard-arrow-down'}
|
|
286
|
+
size={S.spacing.s5}
|
|
287
|
+
color={accentColor as string}
|
|
288
|
+
/>
|
|
289
|
+
<Text style={[{ ...theme.typography.body.medium, color: accentColor }, mergedStyle.expandButtonTextStyle]}>
|
|
290
|
+
{expanded
|
|
291
|
+
? (t('FILE_LIST_SHOW_LESS') ?? 'Show less')
|
|
292
|
+
: (t('FILE_LIST_SHOW_MORE') ?? `Show ${hiddenCount} more`).replace('{count}', String(hiddenCount))}
|
|
293
|
+
</Text>
|
|
294
|
+
</TouchableOpacity>
|
|
295
|
+
)}
|
|
296
|
+
|
|
297
|
+
{/* §7 — caption rides on the (last) message of the batch */}
|
|
298
|
+
{Boolean(caption) && (
|
|
299
|
+
<CometChatCaptionText
|
|
300
|
+
message={message}
|
|
301
|
+
caption={caption}
|
|
302
|
+
theme={theme}
|
|
303
|
+
containerStyle={{
|
|
304
|
+
paddingHorizontal: S.padding.p3,
|
|
305
|
+
paddingTop: S.padding.p2,
|
|
306
|
+
paddingBottom: S.padding.p1,
|
|
307
|
+
}}
|
|
308
|
+
textStyle={[{
|
|
309
|
+
...theme.typography.body.regular,
|
|
310
|
+
color: textColor,
|
|
311
|
+
}, mergedStyle.captionStyle]}
|
|
312
|
+
/>
|
|
313
|
+
)}
|
|
314
|
+
</View>
|
|
315
|
+
);
|
|
316
|
+
}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { Image, 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 { CometChatUIKit } from '../../CometChatUiKit';
|
|
9
|
+
import { CometChatMessageEvents } from '../../events/CometChatMessageEvents';
|
|
10
|
+
import { CometChatMediaViewer } from '../CometChatMediaViewer';
|
|
11
|
+
import { CometChatCaptionText } from '../CometChatCaptionText';
|
|
12
|
+
import { Icon } from '../../icons/Icon';
|
|
13
|
+
import { isImageMime } from '../CometChatMediaViewer/mediaViewerUtils';
|
|
14
|
+
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Design doc §8.1 — ImagesBubble: renders a single-kind IMAGE message (all images after the §7 fan-out)
|
|
17
|
+
// as a WhatsApp-style collage grid + a batch-spanning fullscreen viewer. Independent of the
|
|
18
|
+
// VideosBubble — image cells only (no video scrim / play button / duration chip / server thumbnails).
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
interface BorderRadii {
|
|
22
|
+
topLeft?: number;
|
|
23
|
+
topRight?: number;
|
|
24
|
+
bottomLeft?: number;
|
|
25
|
+
bottomRight?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ---- Cell ----------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
interface ImageCellProps {
|
|
31
|
+
attachment: CometChat.Attachment;
|
|
32
|
+
aspectRatio?: number;
|
|
33
|
+
radii: BorderRadii;
|
|
34
|
+
onPress?: () => void;
|
|
35
|
+
testID?: string;
|
|
36
|
+
overflowCount?: number;
|
|
37
|
+
cellStyle?: StyleProp<ViewStyle>;
|
|
38
|
+
overflowOverlayStyle?: StyleProp<ViewStyle>;
|
|
39
|
+
overflowTextStyle?: TextStyle;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const ImageCell = ({
|
|
43
|
+
attachment,
|
|
44
|
+
aspectRatio = 1,
|
|
45
|
+
radii,
|
|
46
|
+
onPress,
|
|
47
|
+
testID,
|
|
48
|
+
overflowCount,
|
|
49
|
+
cellStyle,
|
|
50
|
+
overflowOverlayStyle,
|
|
51
|
+
overflowTextStyle,
|
|
52
|
+
}: ImageCellProps) => {
|
|
53
|
+
const theme = useTheme();
|
|
54
|
+
// An IMAGE bubble previews images only. A non-image attachment (video/audio/file) OR an image that
|
|
55
|
+
// can't be decoded (unsupported format / dead URL → onError) shows a "no preview" placeholder cell
|
|
56
|
+
// instead of a broken/blank tile.
|
|
57
|
+
const [failed, setFailed] = useState(false);
|
|
58
|
+
const mime = attachment.getMimeType?.() ?? '';
|
|
59
|
+
// Placeholder only for a KNOWN non-image kind (a proper "type/subtype" mime that isn't image/*) or a
|
|
60
|
+
// genuine decode failure (onError). An empty / bare-extension mime — e.g. an optimistic OUTGOING
|
|
61
|
+
// attachment the instant you press send, before the confirmed message resolves — is treated as an
|
|
62
|
+
// image so a valid image never flashes the "no preview" placeholder for a frame before it loads.
|
|
63
|
+
const showPlaceholder = (mime.includes('/') && !isImageMime(mime)) || failed;
|
|
64
|
+
const borderStyle = {
|
|
65
|
+
borderTopLeftRadius: radii.topLeft ?? 0,
|
|
66
|
+
borderTopRightRadius: radii.topRight ?? 0,
|
|
67
|
+
borderBottomLeftRadius: radii.bottomLeft ?? 0,
|
|
68
|
+
borderBottomRightRadius: radii.bottomRight ?? 0,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<TouchableOpacity
|
|
73
|
+
testID={testID}
|
|
74
|
+
onPress={onPress}
|
|
75
|
+
activeOpacity={0.85}
|
|
76
|
+
style={[{ flex: 1, aspectRatio, overflow: 'hidden' }, borderStyle, cellStyle]}
|
|
77
|
+
accessibilityRole="button"
|
|
78
|
+
accessibilityLabel={attachment.getName()}
|
|
79
|
+
>
|
|
80
|
+
{showPlaceholder ? (
|
|
81
|
+
<View
|
|
82
|
+
testID="grid-cell-nopreview"
|
|
83
|
+
style={[StyleSheet.absoluteFillObject, borderStyle, { backgroundColor: theme.color.neutral200, justifyContent: 'center', alignItems: 'center' }]}
|
|
84
|
+
>
|
|
85
|
+
<Icon name="unknown-file-type" size={theme.spacing.spacing.s12} />
|
|
86
|
+
</View>
|
|
87
|
+
) : (
|
|
88
|
+
<Image
|
|
89
|
+
source={{ uri: attachment.getUrl() }}
|
|
90
|
+
style={[StyleSheet.absoluteFillObject, borderStyle]}
|
|
91
|
+
resizeMode="cover"
|
|
92
|
+
onError={() => setFailed(true)}
|
|
93
|
+
/>
|
|
94
|
+
)}
|
|
95
|
+
|
|
96
|
+
{overflowCount != null && overflowCount > 0 && (
|
|
97
|
+
<View
|
|
98
|
+
testID="grid-overflow"
|
|
99
|
+
pointerEvents="none"
|
|
100
|
+
style={[StyleSheet.absoluteFillObject, { backgroundColor: theme.color.mediaOverlay, justifyContent: 'center', alignItems: 'center' }, overflowOverlayStyle]}
|
|
101
|
+
>
|
|
102
|
+
{/* heading1.bold = { fontSize: 24, fontWeight: '700' }; letterSpacing -0.5 is a micro-adjust. */}
|
|
103
|
+
<Text style={[{ ...theme.typography.heading1.bold, color: theme.color.staticWhite, letterSpacing: -0.5 }, overflowTextStyle]}>{`+${overflowCount}`}</Text>
|
|
104
|
+
</View>
|
|
105
|
+
)}
|
|
106
|
+
</TouchableOpacity>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// ---- Grid layout (by count) ----------------------------------------------
|
|
111
|
+
|
|
112
|
+
const ImageGrid = ({
|
|
113
|
+
attachments,
|
|
114
|
+
onAttachmentPress,
|
|
115
|
+
containerStyle,
|
|
116
|
+
cellStyle,
|
|
117
|
+
overflowOverlayStyle,
|
|
118
|
+
overflowTextStyle,
|
|
119
|
+
}: {
|
|
120
|
+
attachments: CometChat.Attachment[];
|
|
121
|
+
onAttachmentPress: (attachment: CometChat.Attachment, index: number) => void;
|
|
122
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
123
|
+
cellStyle?: StyleProp<ViewStyle>;
|
|
124
|
+
overflowOverlayStyle?: StyleProp<ViewStyle>;
|
|
125
|
+
overflowTextStyle?: TextStyle;
|
|
126
|
+
}) => {
|
|
127
|
+
const theme = useTheme();
|
|
128
|
+
const GAP = theme.spacing.spacing.s0_5; // 2 — inter-tile gutter
|
|
129
|
+
const CORNER = theme.spacing.radius.r2; // tiles nest at radius_2 (8)
|
|
130
|
+
const count = attachments.length;
|
|
131
|
+
if (count === 0) return null;
|
|
132
|
+
|
|
133
|
+
const cell = (i: number, radii: BorderRadii, aspectRatio?: number, overflowCount?: number) => (
|
|
134
|
+
<ImageCell
|
|
135
|
+
testID={`grid-cell-${i}`}
|
|
136
|
+
attachment={attachments[i]}
|
|
137
|
+
aspectRatio={aspectRatio}
|
|
138
|
+
radii={radii}
|
|
139
|
+
overflowCount={overflowCount}
|
|
140
|
+
onPress={() => onAttachmentPress(attachments[i], i)}
|
|
141
|
+
cellStyle={cellStyle}
|
|
142
|
+
overflowOverlayStyle={overflowOverlayStyle}
|
|
143
|
+
overflowTextStyle={overflowTextStyle}
|
|
144
|
+
/>
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
const renderLayout = () => {
|
|
148
|
+
if (count === 1) {
|
|
149
|
+
return (
|
|
150
|
+
<View style={{ flexDirection: 'row' }}>
|
|
151
|
+
{cell(0, { topLeft: CORNER, topRight: CORNER, bottomLeft: CORNER, bottomRight: CORNER }, 4 / 3)}
|
|
152
|
+
</View>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
if (count === 2) {
|
|
156
|
+
return (
|
|
157
|
+
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
158
|
+
{cell(0, { topLeft: CORNER, bottomLeft: CORNER })}
|
|
159
|
+
{cell(1, { topRight: CORNER, bottomRight: CORNER })}
|
|
160
|
+
</View>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
if (count === 3) {
|
|
164
|
+
return (
|
|
165
|
+
<View style={{ gap: GAP }}>
|
|
166
|
+
<View style={{ flexDirection: 'row' }}>{cell(0, { topLeft: CORNER, topRight: CORNER }, 4 / 3)}</View>
|
|
167
|
+
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
168
|
+
{cell(1, { bottomLeft: CORNER })}
|
|
169
|
+
{cell(2, { bottomRight: CORNER })}
|
|
170
|
+
</View>
|
|
171
|
+
</View>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
if (count === 4) {
|
|
175
|
+
return (
|
|
176
|
+
<View style={{ gap: GAP }}>
|
|
177
|
+
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
178
|
+
{cell(0, { topLeft: CORNER })}
|
|
179
|
+
{cell(1, { topRight: CORNER })}
|
|
180
|
+
</View>
|
|
181
|
+
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
182
|
+
{cell(2, { bottomLeft: CORNER })}
|
|
183
|
+
{cell(3, { bottomRight: CORNER })}
|
|
184
|
+
</View>
|
|
185
|
+
</View>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
// 5+ → 2×2 with a "+N" overlay on the 4th slot
|
|
189
|
+
const overflowCount = count - 4;
|
|
190
|
+
return (
|
|
191
|
+
<View style={{ gap: GAP }}>
|
|
192
|
+
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
193
|
+
{cell(0, { topLeft: CORNER })}
|
|
194
|
+
{cell(1, { topRight: CORNER })}
|
|
195
|
+
</View>
|
|
196
|
+
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
197
|
+
{cell(2, { bottomLeft: CORNER })}
|
|
198
|
+
{cell(3, { bottomRight: CORNER }, undefined, overflowCount)}
|
|
199
|
+
</View>
|
|
200
|
+
</View>
|
|
201
|
+
);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
return <View style={[styles.gridContainer, containerStyle]}>{renderLayout()}</View>;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// ---- Bubble --------------------------------------------------------------
|
|
208
|
+
|
|
209
|
+
export interface CometChatImagesBubbleProps {
|
|
210
|
+
message: CometChat.MediaMessage;
|
|
211
|
+
theme: CometChatTheme;
|
|
212
|
+
/** Per-instance style overrides — shares the `mediaGridBubbleStyles` theme key with VideosBubble. */
|
|
213
|
+
style?: CometChatTheme["mediaGridBubbleStyles"];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Renders a single-kind IMAGE message (all images, after the §7 fan-out) as a grid, with a
|
|
218
|
+
* batch-spanning fullscreen pager on tap. Fully independent of CometChatVideosBubble.
|
|
219
|
+
*/
|
|
220
|
+
export function CometChatImagesBubble({
|
|
221
|
+
message: initialMessage,
|
|
222
|
+
theme,
|
|
223
|
+
style,
|
|
224
|
+
}: CometChatImagesBubbleProps) {
|
|
225
|
+
const compTheme = useCompTheme();
|
|
226
|
+
const s = deepMerge(theme.mediaGridBubbleStyles ?? {}, compTheme.mediaGridBubbleStyles ?? {}, style ?? {});
|
|
227
|
+
const [viewerVisible, setViewerVisible] = useState(false);
|
|
228
|
+
const [viewerInitialIndex, setViewerInitialIndex] = useState(0);
|
|
229
|
+
// §8.2 — the media set fed to the fullscreen pager (batch-spanning union when the list provides it).
|
|
230
|
+
const [viewerItems, setViewerItems] = useState<CometChat.Attachment[]>([]);
|
|
231
|
+
// §8.7 — local copy so onMessageEdited can refresh a caption edit.
|
|
232
|
+
const [message, setMessage] = useState<CometChat.MediaMessage>(initialMessage);
|
|
233
|
+
|
|
234
|
+
// An IMAGE message renders ALL its attachments; off-kind ones (video/audio/file) show a "no preview"
|
|
235
|
+
// placeholder cell + a "No preview available" fullscreen. getAttachments() preserves pick order.
|
|
236
|
+
const allAttachments = useMemo(
|
|
237
|
+
() => (message.getAttachments?.() ?? []).filter((a) => a != null && typeof a.getUrl === 'function'),
|
|
238
|
+
[message]
|
|
239
|
+
);
|
|
240
|
+
const caption = message.getCaption() ?? '';
|
|
241
|
+
const isSentByMe = message.getSender()?.getUid() === CometChatUIKit.loggedInUser?.getUid();
|
|
242
|
+
|
|
243
|
+
// §8.7 — refresh the local copy when the server edits the message in.
|
|
244
|
+
useEffect(() => {
|
|
245
|
+
const listenerId = `ImagesBubble_${message.getId?.() ?? message.getMuid?.() ?? Date.now()}`;
|
|
246
|
+
CometChatMessageEvents.addListener(
|
|
247
|
+
CometChatMessageEvents.messageEdited,
|
|
248
|
+
listenerId,
|
|
249
|
+
(edited: CometChat.BaseMessage) => {
|
|
250
|
+
const editedId = edited.getId?.();
|
|
251
|
+
const editedMuid = edited.getMuid?.();
|
|
252
|
+
const myId = message.getId?.();
|
|
253
|
+
const myMuid = message.getMuid?.();
|
|
254
|
+
if (
|
|
255
|
+
edited instanceof CometChat.MediaMessage &&
|
|
256
|
+
((myId && editedId && myId === editedId) || (myMuid && editedMuid && myMuid === editedMuid))
|
|
257
|
+
) {
|
|
258
|
+
setMessage(edited);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
return () => CometChatMessageEvents.removeListener(CometChatMessageEvents.messageEdited, listenerId);
|
|
263
|
+
}, []);
|
|
264
|
+
|
|
265
|
+
useEffect(() => {
|
|
266
|
+
setMessage(initialMessage);
|
|
267
|
+
}, [initialMessage]);
|
|
268
|
+
|
|
269
|
+
if (allAttachments.length === 0) return null;
|
|
270
|
+
|
|
271
|
+
return (
|
|
272
|
+
<View testID="bubble-image">
|
|
273
|
+
<ImageGrid
|
|
274
|
+
attachments={allAttachments}
|
|
275
|
+
containerStyle={s.containerStyle}
|
|
276
|
+
cellStyle={s.cellStyle}
|
|
277
|
+
overflowOverlayStyle={s.overflowOverlayStyle}
|
|
278
|
+
overflowTextStyle={s.overflowTextStyle}
|
|
279
|
+
onAttachmentPress={(_, index) => {
|
|
280
|
+
// Page THIS message's attachments (grid & viewer share the same list → index aligns).
|
|
281
|
+
// The viewer renders off-kind items (non-image) as "No preview available".
|
|
282
|
+
setViewerItems(allAttachments);
|
|
283
|
+
setViewerInitialIndex(index);
|
|
284
|
+
setViewerVisible(true);
|
|
285
|
+
}}
|
|
286
|
+
/>
|
|
287
|
+
{Boolean(caption) && (
|
|
288
|
+
<CometChatCaptionText
|
|
289
|
+
message={message}
|
|
290
|
+
caption={caption}
|
|
291
|
+
theme={theme}
|
|
292
|
+
containerStyle={{
|
|
293
|
+
paddingHorizontal: theme.spacing.padding.p3,
|
|
294
|
+
paddingTop: theme.spacing.padding.p2,
|
|
295
|
+
paddingBottom: theme.spacing.padding.p1,
|
|
296
|
+
}}
|
|
297
|
+
textStyle={{
|
|
298
|
+
...theme.typography.body.regular,
|
|
299
|
+
color: isSentByMe ? theme.color.staticWhite : theme.color.neutral900,
|
|
300
|
+
}}
|
|
301
|
+
/>
|
|
302
|
+
)}
|
|
303
|
+
<CometChatMediaViewer
|
|
304
|
+
mediaItems={viewerItems.length > 0 ? viewerItems : allAttachments}
|
|
305
|
+
canPreview={(att) => isImageMime(att.getMimeType?.() ?? '')}
|
|
306
|
+
startIndex={viewerInitialIndex}
|
|
307
|
+
visible={viewerVisible}
|
|
308
|
+
message={message}
|
|
309
|
+
onClose={() => setViewerVisible(false)}
|
|
310
|
+
/>
|
|
311
|
+
</View>
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const styles = StyleSheet.create({
|
|
316
|
+
// Standard media footprint (240 − 4 − 4 padding) as the grid's MIN width; alignSelf:'stretch' lets it
|
|
317
|
+
// grow to fill a wider sibling, maxWidth:'100%' clamps it in a narrower one.
|
|
318
|
+
gridContainer: {
|
|
319
|
+
alignSelf: 'stretch',
|
|
320
|
+
minWidth: 232,
|
|
321
|
+
maxWidth: '100%',
|
|
322
|
+
},
|
|
323
|
+
});
|