@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
|
@@ -22,13 +22,15 @@ import {
|
|
|
22
22
|
MessageCategoryConstants,
|
|
23
23
|
MessageOptionConstants,
|
|
24
24
|
MessageTypeConstants,
|
|
25
|
+
ReceiverTypeConstants,
|
|
25
26
|
} from "../constants/UIKitConstants";
|
|
26
27
|
import { CometChatUiKitConstants } from "../index";
|
|
27
28
|
import { CometChatMessageComposerAction } from "../helper/types";
|
|
28
|
-
import { Icon } from "../icons/Icon";
|
|
29
|
+
import { Icon, IconName } from "../icons/Icon";
|
|
30
|
+
import { getMessagePreviewInternal } from "../utils/MessageUtils";
|
|
29
31
|
import { CometChatMessageOption } from "../modals/CometChatMessageOption";
|
|
30
32
|
import { CometChatMessageTemplate } from "../modals/CometChatMessageTemplate";
|
|
31
|
-
import { CometChatConversationUtils } from "../utils/conversationUtils";
|
|
33
|
+
import { CometChatConversationUtils, attachmentCountLabel } from "../utils/conversationUtils";
|
|
32
34
|
import { CometChatAudioBubble } from "../views/CometChatAudioBubble";
|
|
33
35
|
import { CometChatDeletedBubble } from "../views/CometChatDeletedBubble";
|
|
34
36
|
import { CometChatFileBubble } from "../views/CometChatFileBubble";
|
|
@@ -42,10 +44,17 @@ import { CometChatCardBubble } from "../views/CometChatCardBubble";
|
|
|
42
44
|
import { ChatConfigurator } from "./ChatConfigurator";
|
|
43
45
|
import { DataSource } from "./DataSource";
|
|
44
46
|
import { CommonUtils } from "../utils/CommonUtils";
|
|
45
|
-
import { DimensionValue, TouchableOpacity, ViewStyle, View, Text, Platform } from "react-native";
|
|
47
|
+
import { DimensionValue, Modal, NativeModules, StyleSheet, TouchableOpacity, ViewStyle, View, Text, Platform } from "react-native";
|
|
48
|
+
const { FileManager } = NativeModules;
|
|
49
|
+
// Multiple Attachment Support — U9
|
|
50
|
+
import { groupAttachments, isGalleryMessage } from "../utils/groupAttachments";
|
|
51
|
+
import { CometChatImagesBubble } from "../views/CometChatImagesBubble";
|
|
52
|
+
import { CometChatVideosBubble } from "../views/CometChatVideosBubble";
|
|
53
|
+
import { CometChatFilesBubble } from "../views/CometChatFilesBubble";
|
|
54
|
+
import { CometChatAudiosBubble } from "../views/CometChatAudiosBubble";
|
|
55
|
+
import { CometChatVoiceNoteBubble } from "../views/CometChatVoiceNoteBubble";
|
|
46
56
|
import Clipboard from "@react-native-clipboard/clipboard";
|
|
47
57
|
import { getCometChatTranslation } from "../resources/CometChatLocalizeNew/LocalizationManager";
|
|
48
|
-
import { CometChatMessageEvents } from "../events/CometChatMessageEvents";
|
|
49
58
|
|
|
50
59
|
const t = getCometChatTranslation();
|
|
51
60
|
|
|
@@ -97,6 +106,72 @@ function isDeletedMessage(message: CometChat.BaseMessage): boolean {
|
|
|
97
106
|
return message.getDeletedBy() != null;
|
|
98
107
|
}
|
|
99
108
|
|
|
109
|
+
// Kind-specific icon + "N Photos/Videos/Audios/Files" label for a conversation-list preview, keyed by
|
|
110
|
+
// the message TYPE. Files are the default (documents + everything else). Never a generic "attachments".
|
|
111
|
+
function kindPreview(type: string, count: number): { icon: IconName; label: string } {
|
|
112
|
+
const label = attachmentCountLabel(type, count); // shared "N Files/Photos/…" label
|
|
113
|
+
switch (type) {
|
|
114
|
+
case MessageTypeConstants.image: return { icon: 'photo-fill', label };
|
|
115
|
+
case MessageTypeConstants.video: return { icon: 'videocam-fill', label };
|
|
116
|
+
case MessageTypeConstants.audio: return { icon: 'mic-fill', label };
|
|
117
|
+
default: return { icon: 'description-fill', label };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// U10 — Conversation list subtitle for multi-attachment messages (design doc §17.2)
|
|
122
|
+
function buildMultiAttachmentSubtitle(
|
|
123
|
+
mediaAttachments: CometChat.Attachment[],
|
|
124
|
+
audioAttachments: CometChat.Attachment[],
|
|
125
|
+
fileAttachments: CometChat.Attachment[],
|
|
126
|
+
message: CometChat.MediaMessage
|
|
127
|
+
): string {
|
|
128
|
+
const caption = (message.getCaption() ?? '').trim();
|
|
129
|
+
const imageCount = mediaAttachments.filter(a =>
|
|
130
|
+
a.getMimeType().startsWith('image/')
|
|
131
|
+
).length;
|
|
132
|
+
const videoCount = mediaAttachments.filter(a =>
|
|
133
|
+
a.getMimeType().startsWith('video/')
|
|
134
|
+
).length;
|
|
135
|
+
const mediaCount = mediaAttachments.length;
|
|
136
|
+
const audioCount = audioAttachments.length;
|
|
137
|
+
const fileCount = fileAttachments.length;
|
|
138
|
+
const totalCount = mediaCount + audioCount + fileCount;
|
|
139
|
+
|
|
140
|
+
// Mixed kinds → generic label
|
|
141
|
+
const kindCount = [mediaCount > 0, audioCount > 0, fileCount > 0].filter(Boolean).length;
|
|
142
|
+
if (kindCount > 1) {
|
|
143
|
+
return t('ATTACHMENT_COUNT').replace('{count}', String(totalCount));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Audio only
|
|
147
|
+
if (audioCount > 0) {
|
|
148
|
+
return t('PREVIEW_AUDIOS_COUNT').replace('{count}', String(audioCount));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Files only
|
|
152
|
+
if (fileCount > 0) {
|
|
153
|
+
return t('PREVIEW_FILES_COUNT').replace('{count}', String(fileCount));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Media only — caption takes priority over image/video breakdown
|
|
157
|
+
if (caption) {
|
|
158
|
+
const truncated = caption.length > 40 ? caption.substring(0, 40) + '…' : caption;
|
|
159
|
+
const mediaLabel = imageCount > 0 && videoCount === 0
|
|
160
|
+
? t('PREVIEW_PHOTOS_COUNT').replace('{count}', String(imageCount))
|
|
161
|
+
: videoCount > 0 && imageCount === 0
|
|
162
|
+
? t('PREVIEW_VIDEOS_COUNT').replace('{count}', String(videoCount))
|
|
163
|
+
: `📷 ${mediaCount} media`;
|
|
164
|
+
return `${mediaLabel} · ${truncated}`;
|
|
165
|
+
}
|
|
166
|
+
if (imageCount > 0 && videoCount === 0) {
|
|
167
|
+
return t('PREVIEW_PHOTOS_COUNT').replace('{count}', String(imageCount));
|
|
168
|
+
}
|
|
169
|
+
if (videoCount > 0 && imageCount === 0) {
|
|
170
|
+
return t('PREVIEW_VIDEOS_COUNT').replace('{count}', String(videoCount));
|
|
171
|
+
}
|
|
172
|
+
return `${t('PREVIEW_PHOTOS_COUNT').replace('{count}', String(imageCount))} & ${t('PREVIEW_VIDEOS_COUNT').replace('{count}', String(videoCount))}`;
|
|
173
|
+
}
|
|
174
|
+
|
|
100
175
|
export class MessageDataSource implements DataSource {
|
|
101
176
|
|
|
102
177
|
// --- AI/Tool/Stream Bubble Implementations ---
|
|
@@ -131,18 +206,29 @@ export class MessageDataSource implements DataSource {
|
|
|
131
206
|
};
|
|
132
207
|
|
|
133
208
|
|
|
134
|
-
getAgentAssistantMessageTemplate(
|
|
209
|
+
getAgentAssistantMessageTemplate(
|
|
210
|
+
theme: CometChatTheme,
|
|
211
|
+
additionalParams?: AdditionalParams
|
|
212
|
+
): CometChatMessageTemplate {
|
|
135
213
|
return new CometChatMessageTemplate({
|
|
136
214
|
type: 'assistant',
|
|
137
215
|
category: 'agentic',
|
|
138
|
-
ContentView: (message: CometChat.BaseMessage) =>
|
|
216
|
+
ContentView: (message: CometChat.BaseMessage) =>
|
|
139
217
|
this.getAgentAssistantMessageBubble(message, theme),
|
|
218
|
+
ReplyView: (message: CometChat.BaseMessage, _alignment: MessageBubbleAlignmentType) => {
|
|
219
|
+
if (message.getReceiverType() !== ReceiverTypeConstants.group) {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
const replyView = ChatConfigurator.dataSource.getReplyView?.(message, theme, additionalParams) || null;
|
|
223
|
+
if (!replyView) return null;
|
|
224
|
+
return <View style={{ marginTop: 2, marginBottom: 6 }}>{replyView}</View>;
|
|
225
|
+
},
|
|
140
226
|
|
|
141
227
|
options: undefined,
|
|
142
228
|
|
|
143
229
|
FooterView: (message: CometChat.BaseMessage) => (
|
|
144
230
|
<TouchableOpacity onPress={() => this.handleCopy(message as CometChat.AIAssistantMessage)}>
|
|
145
|
-
<Icon name="ai-copy-option" width={24} height={24} containerStyle={
|
|
231
|
+
<Icon name="ai-copy-option" width={24} height={24} containerStyle={styles.aiCopyIcon} color={theme.color.textSecondary} />
|
|
146
232
|
</TouchableOpacity>
|
|
147
233
|
),
|
|
148
234
|
});
|
|
@@ -513,7 +599,7 @@ export class MessageDataSource implements DataSource {
|
|
|
513
599
|
additionalParams?: AdditionalParams
|
|
514
600
|
): CometChatMessageOption[] {
|
|
515
601
|
let optionsList: Array<CometChatMessageOption> = [];
|
|
516
|
-
if (!isDeletedMessage(messageObject))
|
|
602
|
+
if (!isDeletedMessage(messageObject)) {
|
|
517
603
|
optionsList.push(
|
|
518
604
|
...ChatConfigurator.dataSource.getCommonOptions(
|
|
519
605
|
loggedInUser,
|
|
@@ -523,8 +609,64 @@ export class MessageDataSource implements DataSource {
|
|
|
523
609
|
additionalParams
|
|
524
610
|
)
|
|
525
611
|
);
|
|
612
|
+
this.pushCaptionEditOption(
|
|
613
|
+
optionsList,
|
|
614
|
+
loggedInUser,
|
|
615
|
+
messageObject,
|
|
616
|
+
theme,
|
|
617
|
+
group,
|
|
618
|
+
additionalParams
|
|
619
|
+
);
|
|
620
|
+
}
|
|
526
621
|
return optionsList;
|
|
527
622
|
}
|
|
623
|
+
/** §8.5 — Download all attachments sequentially via FileManager.checkAndDownload. */
|
|
624
|
+
getDownloadAllOption(theme: CometChatTheme): CometChatMessageOption {
|
|
625
|
+
return {
|
|
626
|
+
id: MessageOptionConstants.downloadAll,
|
|
627
|
+
title: t('ATTACHMENT_DOWNLOAD_ALL') ?? 'Download all',
|
|
628
|
+
onPress: (message: CometChat.BaseMessage) => {
|
|
629
|
+
const mediaMsg = message as CometChat.MediaMessage;
|
|
630
|
+
const attachments = mediaMsg.getAttachments?.() ?? [];
|
|
631
|
+
attachments.forEach((att) => {
|
|
632
|
+
FileManager?.checkAndDownload(att.getUrl(), att.getName(), () => {});
|
|
633
|
+
});
|
|
634
|
+
},
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Media messages get an Edit option only when they carry a caption — you edit the
|
|
640
|
+
* caption of a media attachment, not the file. Inserted before Delete to mirror text ordering.
|
|
641
|
+
*/
|
|
642
|
+
private pushCaptionEditOption(
|
|
643
|
+
optionsList: CometChatMessageOption[],
|
|
644
|
+
loggedInUser: CometChat.User,
|
|
645
|
+
messageObject: CometChat.BaseMessage,
|
|
646
|
+
theme: CometChatTheme,
|
|
647
|
+
group?: CometChat.Group,
|
|
648
|
+
additionalParams?: AdditionalParams
|
|
649
|
+
) {
|
|
650
|
+
const caption = ((messageObject as CometChat.MediaMessage).getCaption?.() ?? '').trim();
|
|
651
|
+
if (!caption.length) return;
|
|
652
|
+
if (
|
|
653
|
+
!this.validateOption(
|
|
654
|
+
loggedInUser,
|
|
655
|
+
messageObject,
|
|
656
|
+
MessageOptionConstants.editMessage,
|
|
657
|
+
group,
|
|
658
|
+
additionalParams
|
|
659
|
+
)
|
|
660
|
+
)
|
|
661
|
+
return;
|
|
662
|
+
const editOption = this.getEditOption(theme);
|
|
663
|
+
const deleteIdx = optionsList.findIndex(
|
|
664
|
+
(o) => o.id === MessageOptionConstants.deleteMessage
|
|
665
|
+
);
|
|
666
|
+
if (deleteIdx >= 0) optionsList.splice(deleteIdx, 0, editOption);
|
|
667
|
+
else optionsList.push(editOption);
|
|
668
|
+
}
|
|
669
|
+
|
|
528
670
|
getVideoMessageOptions(
|
|
529
671
|
loggedInUser: CometChat.User,
|
|
530
672
|
messageObject: CometChat.BaseMessage,
|
|
@@ -533,7 +675,7 @@ export class MessageDataSource implements DataSource {
|
|
|
533
675
|
additionalParams?: AdditionalParams
|
|
534
676
|
): CometChatMessageOption[] {
|
|
535
677
|
let optionsList: Array<CometChatMessageOption> = [];
|
|
536
|
-
if (!isDeletedMessage(messageObject))
|
|
678
|
+
if (!isDeletedMessage(messageObject)) {
|
|
537
679
|
optionsList.push(
|
|
538
680
|
...ChatConfigurator.dataSource.getCommonOptions(
|
|
539
681
|
loggedInUser,
|
|
@@ -543,6 +685,15 @@ export class MessageDataSource implements DataSource {
|
|
|
543
685
|
additionalParams
|
|
544
686
|
)
|
|
545
687
|
);
|
|
688
|
+
this.pushCaptionEditOption(
|
|
689
|
+
optionsList,
|
|
690
|
+
loggedInUser,
|
|
691
|
+
messageObject,
|
|
692
|
+
theme,
|
|
693
|
+
group,
|
|
694
|
+
additionalParams
|
|
695
|
+
);
|
|
696
|
+
}
|
|
546
697
|
return optionsList;
|
|
547
698
|
}
|
|
548
699
|
getImageMessageOptions(
|
|
@@ -553,7 +704,7 @@ export class MessageDataSource implements DataSource {
|
|
|
553
704
|
additionalParams?: AdditionalParams
|
|
554
705
|
): CometChatMessageOption[] {
|
|
555
706
|
let optionsList: Array<CometChatMessageOption> = [];
|
|
556
|
-
if (!isDeletedMessage(messageObject))
|
|
707
|
+
if (!isDeletedMessage(messageObject)) {
|
|
557
708
|
optionsList.push(
|
|
558
709
|
...ChatConfigurator.dataSource.getCommonOptions(
|
|
559
710
|
loggedInUser,
|
|
@@ -563,6 +714,15 @@ export class MessageDataSource implements DataSource {
|
|
|
563
714
|
additionalParams
|
|
564
715
|
)
|
|
565
716
|
);
|
|
717
|
+
this.pushCaptionEditOption(
|
|
718
|
+
optionsList,
|
|
719
|
+
loggedInUser,
|
|
720
|
+
messageObject,
|
|
721
|
+
theme,
|
|
722
|
+
group,
|
|
723
|
+
additionalParams
|
|
724
|
+
);
|
|
725
|
+
}
|
|
566
726
|
return optionsList;
|
|
567
727
|
}
|
|
568
728
|
getFileMessageOptions(
|
|
@@ -573,7 +733,7 @@ export class MessageDataSource implements DataSource {
|
|
|
573
733
|
additionalParams?: AdditionalParams
|
|
574
734
|
): CometChatMessageOption[] {
|
|
575
735
|
let optionsList: Array<CometChatMessageOption> = [];
|
|
576
|
-
if (!isDeletedMessage(messageObject))
|
|
736
|
+
if (!isDeletedMessage(messageObject)) {
|
|
577
737
|
optionsList.push(
|
|
578
738
|
...ChatConfigurator.dataSource.getCommonOptions(
|
|
579
739
|
loggedInUser,
|
|
@@ -583,6 +743,15 @@ export class MessageDataSource implements DataSource {
|
|
|
583
743
|
additionalParams
|
|
584
744
|
)
|
|
585
745
|
);
|
|
746
|
+
this.pushCaptionEditOption(
|
|
747
|
+
optionsList,
|
|
748
|
+
loggedInUser,
|
|
749
|
+
messageObject,
|
|
750
|
+
theme,
|
|
751
|
+
group,
|
|
752
|
+
additionalParams
|
|
753
|
+
);
|
|
754
|
+
}
|
|
586
755
|
return optionsList;
|
|
587
756
|
}
|
|
588
757
|
getMessageOptions(
|
|
@@ -1021,19 +1190,24 @@ export class MessageDataSource implements DataSource {
|
|
|
1021
1190
|
theme: CometChatTheme,
|
|
1022
1191
|
additionalParams?: AdditionalParams
|
|
1023
1192
|
): JSX.Element | null {
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1193
|
+
// A quoted message can arrive method-less (raw data, no prototype — same symlinked-SDK issue as
|
|
1194
|
+
// the conversation list). Every accessor below is guarded, and the whole builder is wrapped in
|
|
1195
|
+
// try/catch: a bad quoted message must, at worst, hide the reply preview — NEVER throw and blank
|
|
1196
|
+
// the entire message bubble (which is what made replies-to-attachments vanish from the list).
|
|
1197
|
+
try {
|
|
1198
|
+
const hasQuotedMessage = message.getQuotedMessage?.();
|
|
1199
|
+
|
|
1200
|
+
if (!hasQuotedMessage ||
|
|
1201
|
+
message instanceof CometChat.Action ||
|
|
1202
|
+
message.getDeletedAt?.()) {
|
|
1029
1203
|
return null;
|
|
1030
1204
|
}
|
|
1031
1205
|
|
|
1032
1206
|
// Check if the original message is outgoing to determine styling
|
|
1033
1207
|
const loggedInUser = CometChatUIKit.loggedInUser;
|
|
1034
|
-
const isOutgoingMessage = loggedInUser && message.getSender()?.getUid() === loggedInUser?.getUid();
|
|
1035
|
-
|
|
1036
|
-
const isQuotedMessageDeleted = hasQuotedMessage.getDeletedBy() != null;
|
|
1208
|
+
const isOutgoingMessage = loggedInUser && message.getSender?.()?.getUid?.() === loggedInUser?.getUid?.();
|
|
1209
|
+
|
|
1210
|
+
const isQuotedMessageDeleted = ((hasQuotedMessage as any).getDeletedBy?.() ?? null) != null;
|
|
1037
1211
|
|
|
1038
1212
|
// Create custom theme with overridden colors for reply view
|
|
1039
1213
|
const replyTheme = {
|
|
@@ -1048,7 +1222,7 @@ export class MessageDataSource implements DataSource {
|
|
|
1048
1222
|
// Handle click to navigate to quoted message
|
|
1049
1223
|
const handleReplyClick = () => {
|
|
1050
1224
|
if (!isQuotedMessageDeleted) {
|
|
1051
|
-
const messageId = String(hasQuotedMessage.getId());
|
|
1225
|
+
const messageId = String((hasQuotedMessage as any).getId?.() ?? '');
|
|
1052
1226
|
if (additionalParams?.onReplyClick) {
|
|
1053
1227
|
additionalParams.onReplyClick(messageId);
|
|
1054
1228
|
}
|
|
@@ -1087,13 +1261,18 @@ export class MessageDataSource implements DataSource {
|
|
|
1087
1261
|
if (additionalParams?.onReplyClick && !isQuotedMessageDeleted) {
|
|
1088
1262
|
const replyTouchableStyle = { padding: theme.spacing.padding.p0_5 };
|
|
1089
1263
|
return (
|
|
1090
|
-
<TouchableOpacity onPress={handleReplyClick} activeOpacity={0.7} style={replyTouchableStyle}>
|
|
1264
|
+
<TouchableOpacity testID="bubble-quoted-reply" onPress={handleReplyClick} activeOpacity={0.7} style={replyTouchableStyle}>
|
|
1091
1265
|
{previewComponent}
|
|
1092
1266
|
</TouchableOpacity>
|
|
1093
1267
|
);
|
|
1094
1268
|
}
|
|
1095
1269
|
|
|
1096
|
-
return previewComponent
|
|
1270
|
+
return <View testID="bubble-quoted-reply">{previewComponent}</View>;
|
|
1271
|
+
} catch (e) {
|
|
1272
|
+
// A malformed quoted message must not crash the whole list — degrade gracefully by
|
|
1273
|
+
// hiding just the reply preview; the message bubble itself still renders.
|
|
1274
|
+
return null;
|
|
1275
|
+
}
|
|
1097
1276
|
}
|
|
1098
1277
|
|
|
1099
1278
|
getDeleteMessageBubble(message: CometChat.BaseMessage, theme: CometChatTheme): JSX.Element {
|
|
@@ -1311,12 +1490,24 @@ export class MessageDataSource implements DataSource {
|
|
|
1311
1490
|
): JSX.Element {
|
|
1312
1491
|
let loggedInUser = CometChatUIKit.loggedInUser;
|
|
1313
1492
|
if (isImageMessage(message)) {
|
|
1314
|
-
const
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1493
|
+
const isSentByMe = message.getSender()?.getUid() === loggedInUser?.getUid();
|
|
1494
|
+
const _style = isSentByMe
|
|
1495
|
+
? theme.messageListStyles.outgoingMessageBubbleStyles?.imageBubbleStyles
|
|
1496
|
+
: theme.messageListStyles.incomingMessageBubbleStyles?.imageBubbleStyles;
|
|
1318
1497
|
|
|
1319
|
-
return
|
|
1498
|
+
return (
|
|
1499
|
+
<View>
|
|
1500
|
+
<CometChatImageBubble imageUrl={{ uri: imageUrl }} style={_style?.imageStyle} />
|
|
1501
|
+
{Boolean(caption) && (
|
|
1502
|
+
<Text style={{
|
|
1503
|
+
color: isSentByMe ? theme.color.staticWhite : theme.color.neutral900,
|
|
1504
|
+
paddingHorizontal: 8,
|
|
1505
|
+
paddingTop: 6,
|
|
1506
|
+
paddingBottom: 4,
|
|
1507
|
+
}}>{caption}</Text>
|
|
1508
|
+
)}
|
|
1509
|
+
</View>
|
|
1510
|
+
);
|
|
1320
1511
|
}
|
|
1321
1512
|
return <></>;
|
|
1322
1513
|
}
|
|
@@ -1431,9 +1622,35 @@ export class MessageDataSource implements DataSource {
|
|
|
1431
1622
|
getAudioMessageContentView(
|
|
1432
1623
|
message: CometChat.MediaMessage,
|
|
1433
1624
|
alignment: MessageBubbleAlignmentType,
|
|
1434
|
-
theme: CometChatTheme
|
|
1625
|
+
theme: CometChatTheme,
|
|
1626
|
+
additionalParams?: AdditionalParams
|
|
1435
1627
|
): JSX.Element {
|
|
1436
|
-
|
|
1628
|
+
// DD §9 — enableMultipleAttachments=false on the message list → deprecated single-attachment bubble.
|
|
1629
|
+
if (additionalParams?.enableMultipleAttachments === false) {
|
|
1630
|
+
const attachment = message.getAttachment();
|
|
1631
|
+
return ChatConfigurator.dataSource.getAudioMessageBubble(
|
|
1632
|
+
attachment.getUrl(), attachment.getName(), {}, message, theme
|
|
1633
|
+
);
|
|
1634
|
+
}
|
|
1635
|
+
// §8.1a — audio rendering matches WhatsApp:
|
|
1636
|
+
// • SHARED / picked audio file (no audioType) → the headphone-chip + filename player
|
|
1637
|
+
// (CometChatAudiosBubble), single or multiple.
|
|
1638
|
+
// • RECORDED voice note (metadata.audioType === "voice_note") → the WAVEFORM player
|
|
1639
|
+
// (CometChatVoiceNoteBubble for a stack; the single-audio CometChatAudioBubble for one).
|
|
1640
|
+
// An AUDIO message ALWAYS renders the audio bubble — no fallback to a file list. Any attachment
|
|
1641
|
+
// that isn't a playable audio file (unsupported audio format, or a non-audio image/video/doc)
|
|
1642
|
+
// shows a "no preview" file card (icon + name + Download) inside the bubble (see CometChatAudiosBubble).
|
|
1643
|
+
const audioType = (message.getMetadata?.() as Record<string, any> | undefined)?.audioType;
|
|
1644
|
+
if (audioType !== "voice_note") {
|
|
1645
|
+
// shared/picked audio file(s) → headphone + filename cards
|
|
1646
|
+
return <CometChatAudiosBubble message={message} theme={theme} />;
|
|
1647
|
+
}
|
|
1648
|
+
// DD §8.1a — recorded voice note → waveform: a STACK (2+) uses CometChatVoiceNoteBubble; a SINGLE
|
|
1649
|
+
// recording (the usual case — voice notes are recorded one at a time) uses the single-audio bubble.
|
|
1650
|
+
if (isGalleryMessage(message)) {
|
|
1651
|
+
return <CometChatVoiceNoteBubble message={message} theme={theme} />;
|
|
1652
|
+
}
|
|
1653
|
+
const attachment = message.getAttachment();
|
|
1437
1654
|
return ChatConfigurator.dataSource.getAudioMessageBubble(
|
|
1438
1655
|
attachment.getUrl(),
|
|
1439
1656
|
attachment.getName(),
|
|
@@ -1445,45 +1662,55 @@ export class MessageDataSource implements DataSource {
|
|
|
1445
1662
|
getVideoMessageContentView(
|
|
1446
1663
|
message: CometChat.MediaMessage,
|
|
1447
1664
|
alignment: MessageBubbleAlignmentType,
|
|
1448
|
-
theme: CometChatTheme
|
|
1665
|
+
theme: CometChatTheme,
|
|
1666
|
+
additionalParams?: AdditionalParams
|
|
1449
1667
|
): JSX.Element | null {
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
attachment.
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1668
|
+
// DD §9 — enableMultipleAttachments=false → deprecated single-attachment video bubble.
|
|
1669
|
+
if (additionalParams?.enableMultipleAttachments === false) {
|
|
1670
|
+
const attachment = message.getAttachment();
|
|
1671
|
+
return ChatConfigurator.dataSource.getVideoMessageBubble(
|
|
1672
|
+
attachment.getUrl(), attachment.getUrl(), message, theme
|
|
1673
|
+
);
|
|
1674
|
+
}
|
|
1675
|
+
// A VIDEO message ALWAYS renders the video grid — no fallback to a file list. Any attachment that
|
|
1676
|
+
// isn't a video (image / audio / file) shows a "no preview" placeholder cell inside the grid, and
|
|
1677
|
+
// a "No preview available" fullscreen on tap (see CometChatVideosBubble + CometChatMediaViewer).
|
|
1678
|
+
return <CometChatVideosBubble message={message} theme={theme} />;
|
|
1457
1679
|
}
|
|
1458
1680
|
getImageMessageContentView(
|
|
1459
1681
|
message: CometChat.MediaMessage,
|
|
1460
1682
|
alignment: MessageBubbleAlignmentType,
|
|
1461
|
-
theme: CometChatTheme
|
|
1683
|
+
theme: CometChatTheme,
|
|
1684
|
+
additionalParams?: AdditionalParams
|
|
1462
1685
|
): JSX.Element | null {
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
if (
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
)
|
|
1686
|
+
const caption = message.getCaption() ?? '';
|
|
1687
|
+
// DD §9 — enableMultipleAttachments=false → deprecated single-attachment image bubble.
|
|
1688
|
+
if (additionalParams?.enableMultipleAttachments === false) {
|
|
1689
|
+
const attachment = message.getAttachment();
|
|
1690
|
+
return ChatConfigurator.dataSource.getImageMessageBubble(
|
|
1691
|
+
attachment.getUrl(), caption, message, theme
|
|
1692
|
+
);
|
|
1693
|
+
}
|
|
1694
|
+
// An IMAGE message ALWAYS renders the image grid — no fallback to a file list. Any attachment that
|
|
1695
|
+
// can't be previewed (unsupported format / load error) shows a "no preview" placeholder cell inside
|
|
1696
|
+
// the grid instead (see CometChatImagesBubble's ImageCell).
|
|
1697
|
+
return <CometChatImagesBubble message={message} theme={theme} />;
|
|
1473
1698
|
}
|
|
1474
1699
|
getFileMessageContentView(
|
|
1475
1700
|
message: CometChat.MediaMessage,
|
|
1476
1701
|
alignment: MessageBubbleAlignmentType,
|
|
1477
|
-
theme: CometChatTheme
|
|
1702
|
+
theme: CometChatTheme,
|
|
1703
|
+
additionalParams?: AdditionalParams
|
|
1478
1704
|
): JSX.Element {
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
attachment.
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
)
|
|
1705
|
+
// DD §9 — enableMultipleAttachments=false → deprecated single-attachment file bubble.
|
|
1706
|
+
if (additionalParams?.enableMultipleAttachments === false) {
|
|
1707
|
+
const attachment = message.getAttachment();
|
|
1708
|
+
return ChatConfigurator.dataSource.getFileMessageBubble(
|
|
1709
|
+
attachment.getUrl(), attachment.getName(), {}, message, theme
|
|
1710
|
+
);
|
|
1711
|
+
}
|
|
1712
|
+
// DD §9 (flag=true, default): the new FilesBubble renders 1..N — including a single file.
|
|
1713
|
+
return <CometChatFilesBubble message={message} theme={theme} />;
|
|
1487
1714
|
}
|
|
1488
1715
|
|
|
1489
1716
|
getTextMessageTemplate(
|
|
@@ -1534,7 +1761,7 @@ export class MessageDataSource implements DataSource {
|
|
|
1534
1761
|
if (isDeletedMessage(message)) {
|
|
1535
1762
|
return ChatConfigurator.dataSource.getDeleteMessageBubble(message, theme);
|
|
1536
1763
|
} else
|
|
1537
|
-
return ChatConfigurator.dataSource.getAudioMessageContentView(message, alignment, theme);
|
|
1764
|
+
return ChatConfigurator.dataSource.getAudioMessageContentView(message, alignment, theme, additionalParams);
|
|
1538
1765
|
},
|
|
1539
1766
|
options: (loggedInuser, message, theme, group) =>
|
|
1540
1767
|
ChatConfigurator.dataSource.getAudioMessageOptions(
|
|
@@ -1563,7 +1790,7 @@ export class MessageDataSource implements DataSource {
|
|
|
1563
1790
|
if (isDeletedMessage(message)) {
|
|
1564
1791
|
return ChatConfigurator.dataSource.getDeleteMessageBubble(message, theme);
|
|
1565
1792
|
} else
|
|
1566
|
-
return ChatConfigurator.dataSource.getVideoMessageContentView(message, alignment, theme);
|
|
1793
|
+
return ChatConfigurator.dataSource.getVideoMessageContentView(message, alignment, theme, additionalParams);
|
|
1567
1794
|
},
|
|
1568
1795
|
options: (loggedInuser, message, theme, group) =>
|
|
1569
1796
|
ChatConfigurator.dataSource.getVideoMessageOptions(
|
|
@@ -1592,7 +1819,7 @@ export class MessageDataSource implements DataSource {
|
|
|
1592
1819
|
if (isDeletedMessage(message)) {
|
|
1593
1820
|
return ChatConfigurator.dataSource.getDeleteMessageBubble(message, theme);
|
|
1594
1821
|
} else
|
|
1595
|
-
return ChatConfigurator.dataSource.getImageMessageContentView(message, alignment, theme);
|
|
1822
|
+
return ChatConfigurator.dataSource.getImageMessageContentView(message, alignment, theme, additionalParams);
|
|
1596
1823
|
},
|
|
1597
1824
|
options: (loggedInuser, message, theme, group) =>
|
|
1598
1825
|
ChatConfigurator.dataSource.getImageMessageOptions(
|
|
@@ -1621,7 +1848,7 @@ export class MessageDataSource implements DataSource {
|
|
|
1621
1848
|
if (isDeletedMessage(message)) {
|
|
1622
1849
|
return ChatConfigurator.dataSource.getDeleteMessageBubble(message, theme);
|
|
1623
1850
|
} else
|
|
1624
|
-
return ChatConfigurator.dataSource.getFileMessageContentView(message, alignment, theme);
|
|
1851
|
+
return ChatConfigurator.dataSource.getFileMessageContentView(message, alignment, theme, additionalParams);
|
|
1625
1852
|
},
|
|
1626
1853
|
options: (loggedInuser, message, theme, group) =>
|
|
1627
1854
|
ChatConfigurator.dataSource.getFileMessageOptions(
|
|
@@ -2207,6 +2434,27 @@ export class MessageDataSource implements DataSource {
|
|
|
2207
2434
|
const actionMsg = this.getActionMessage(lastMessage);
|
|
2208
2435
|
if (actionMsg) return actionMsg;
|
|
2209
2436
|
}
|
|
2437
|
+
// Multi-attachment subtitle (design doc §17.2 / §8.4). Drive the label + icon off the message's
|
|
2438
|
+
// COARSE TYPE (image/video/audio/file) — NOT per-attachment mime. A file message can carry a file
|
|
2439
|
+
// whose mime is image/* (e.g. "image (1).png" sent as a document); classifying by mime would split
|
|
2440
|
+
// it and mislabel a files-only message as a mixed "N attachments". The coarse type is single-kind.
|
|
2441
|
+
if (lastMessage instanceof CometChat.MediaMessage) {
|
|
2442
|
+
// §8.4 — batch-aware: a multi-KIND batch is fanned out into N messages, each single-kind. Prefer
|
|
2443
|
+
// the batch total (stamped on every member's metadata) so the row summarizes the whole send.
|
|
2444
|
+
const md = lastMessage.getMetadata?.() as any;
|
|
2445
|
+
const batchSize = md?.batchSize;
|
|
2446
|
+
const batchTotalCount = md?.batchTotalCount;
|
|
2447
|
+
const isBatch =
|
|
2448
|
+
md?.batchId != null &&
|
|
2449
|
+
typeof batchSize === "number" && batchSize > 1 &&
|
|
2450
|
+
typeof batchTotalCount === "number" && batchTotalCount > 1;
|
|
2451
|
+
const count = isBatch ? batchTotalCount : (lastMessage.getAttachments?.() ?? []).length;
|
|
2452
|
+
if (count > 1) {
|
|
2453
|
+
const { icon, label } = kindPreview(lastMessage.getType(), count);
|
|
2454
|
+
const caption = (lastMessage.getCaption?.() ?? '').trim();
|
|
2455
|
+
return getMessagePreviewInternal(icon, caption ? `${label} · ${caption}` : label, { theme });
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2210
2458
|
return CometChatConversationUtils.getMessagePreview(lastMessage, theme);
|
|
2211
2459
|
}
|
|
2212
2460
|
|
|
@@ -2235,6 +2483,10 @@ export class MessageDataSource implements DataSource {
|
|
|
2235
2483
|
if (message instanceof CometChat.TextMessage) {
|
|
2236
2484
|
return message.getText() || "";
|
|
2237
2485
|
} else if (message instanceof CometChat.MediaMessage) {
|
|
2486
|
+
if (isGalleryMessage(message)) {
|
|
2487
|
+
const { mediaAttachments, audioAttachments, fileAttachments } = groupAttachments(message);
|
|
2488
|
+
return buildMultiAttachmentSubtitle(mediaAttachments, audioAttachments, fileAttachments, message);
|
|
2489
|
+
}
|
|
2238
2490
|
const data = message.getData() as any;
|
|
2239
2491
|
return data?.name || message.getType() || "";
|
|
2240
2492
|
} else if (message.getType() === "groupMember") {
|
|
@@ -2244,4 +2496,11 @@ export class MessageDataSource implements DataSource {
|
|
|
2244
2496
|
}
|
|
2245
2497
|
}
|
|
2246
2498
|
//for internal use only
|
|
2247
|
-
export const internalMessageDataSource = new MessageDataSource();
|
|
2499
|
+
export const internalMessageDataSource = new MessageDataSource();
|
|
2500
|
+
|
|
2501
|
+
const styles = StyleSheet.create({
|
|
2502
|
+
aiCopyIcon: {
|
|
2503
|
+
marginLeft: 10,
|
|
2504
|
+
marginBottom: -20,
|
|
2505
|
+
},
|
|
2506
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Toast } from './Toast';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Lightweight controller for the shared `Toast` component — the app's default
|
|
6
|
+
* lightweight notification (used instead of a native `Alert`). Returns a
|
|
7
|
+
* `showToast(message)` action and the `ToastElement` to drop into the render tree.
|
|
8
|
+
*/
|
|
9
|
+
export function useToast(durationMs = 3000) {
|
|
10
|
+
const [message, setMessage] = useState<string | null>(null);
|
|
11
|
+
const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
12
|
+
|
|
13
|
+
const showToast = useCallback(
|
|
14
|
+
(msg: string) => {
|
|
15
|
+
setMessage(msg);
|
|
16
|
+
if (timer.current) clearTimeout(timer.current);
|
|
17
|
+
timer.current = setTimeout(() => setMessage(null), durationMs);
|
|
18
|
+
},
|
|
19
|
+
[durationMs]
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
useEffect(() => () => {
|
|
23
|
+
if (timer.current) clearTimeout(timer.current);
|
|
24
|
+
}, []);
|
|
25
|
+
|
|
26
|
+
const ToastElement = message ? <Toast message={message} /> : null;
|
|
27
|
+
|
|
28
|
+
return { showToast, ToastElement };
|
|
29
|
+
}
|
|
@@ -1,30 +1,19 @@
|
|
|
1
|
-
import Svg, { Path,
|
|
1
|
+
import Svg, { Path, Defs, LinearGradient, Stop } from "react-native-svg";
|
|
2
2
|
/* SVGR has dropped some elements not supported by react-native-svg: filter */
|
|
3
3
|
import type { SvgProps } from "react-native-svg";
|
|
4
4
|
const SvgComponent = ({ height, width, color }: SvgProps) => (
|
|
5
|
-
<Svg width={width} height={height} fill='none' viewBox='0 0
|
|
6
|
-
<Path fill='#
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
fillRule='evenodd'
|
|
11
|
-
d='M7.333 2.667A2.133 2.133 0 0 0 5.199 4.8v22.4c0 1.178.955 2.134 2.134 2.134h17.333a2.133 2.133 0 0 0 2.133-2.134V9.333l-6.666-6.666z'
|
|
12
|
-
clipRule='evenodd'
|
|
13
|
-
/>
|
|
14
|
-
</G>
|
|
15
|
-
<Path
|
|
16
|
-
fill='#fff'
|
|
17
|
-
d='M21.62 15.974a1.5 1.5 0 0 1-.229.55c-.09.139-.183.231-.275.184-.091 0-.139-.597-.183-.69q-.106-.241-.137-.505c-.046-.367-.184-.691-.415-.828q-.343-.276-.962-.415a3 3 0 0 1-1.24-.55c-.366-.277-.779-.507-1.008-.783-.23-.23-.414-.277-.505-.23-.138.046-.183.184-.183.322v8.555c0 .23-.046.506-.138.782-.091.277-.138.552-.367.827-.23.277-.55.46-.963.645-.414.184-.918.277-1.47.322a3.3 3.3 0 0 1-1.65-.322 3.3 3.3 0 0 1-1.147-.874c-.276-.368-.414-.736-.414-1.197 0-.413.185-.827.597-1.195.367-.367.78-.644 1.24-.782.457-.139.871-.23 1.284-.23s1.055 0 1.376.093c.32.091.551.138.734.184v-8.142c0-.277.091-.505.23-.689.137-.184.366-.276.595-.322q.345-.069.552.138c.138.092 0 .277.182.46q.207.275.552.69c.23.276.504.506.87.735.322.23.598.368.827.507.23.09.46.184.643.276.183.091.413.183.596.321s.414.322.642.599c.23.277.366.505.413.781 0 .277 0 .552-.047.782z'
|
|
18
|
-
/>
|
|
19
|
-
<Path fill='url(#prefix__b)' d='M26.176 8.708H20.76L26.8 14.75V9.333z' />
|
|
20
|
-
<Path fill='#F9C499' d='M22.267 9.333h4.534l-6.667-6.667V7.2c0 1.178.955 2.133 2.133 2.133' />
|
|
5
|
+
<Svg width={width} height={height} fill='none' viewBox='0 0 22 27'>
|
|
6
|
+
<Path fill='#F16C00' d='M15.1328 0.000610352L21.7988 6.66663V24.5338C21.7988 25.712 20.8442 26.6675 19.666 26.6676H2.33301C1.1548 26.6676 0.199219 25.712 0.199219 24.5338V2.1344C0.199219 0.956192 1.1548 0.000610352 2.33301 0.000610352H15.1328Z' />
|
|
7
|
+
<Path fill='#fff' d='M16.6205 13.308C16.5809 13.5048 16.5031 13.6918 16.3913 13.8585C16.3003 13.9969 16.208 14.0895 16.1155 14.0425C16.0245 14.0425 15.9775 13.445 15.9333 13.3524C15.8628 13.1917 15.8164 13.0216 15.7955 12.8474C15.7498 12.4797 15.612 12.156 15.3815 12.019C15.1525 11.8352 14.8325 11.6969 14.4187 11.604C13.9693 11.5168 13.5457 11.3286 13.1797 11.0537C12.8128 10.777 12.4003 10.5475 12.1713 10.2709C11.9408 10.0414 11.7573 9.9942 11.6663 10.0414C11.5283 10.087 11.4828 10.2254 11.4828 10.3635V18.9177C11.4828 19.1487 11.4373 19.4239 11.3448 19.7005C11.2538 19.9772 11.2068 20.2522 10.9778 20.5275C10.7488 20.8042 10.4275 20.988 10.015 21.172C9.60098 21.356 9.09748 21.4487 8.54565 21.4942C7.97669 21.5301 7.40806 21.4192 6.89432 21.172C6.45227 20.9689 6.06071 20.6704 5.74782 20.2979C5.47198 19.93 5.33398 19.5622 5.33398 19.1015C5.33398 18.6882 5.51898 18.2745 5.93132 17.9065C6.29832 17.5387 6.71082 17.2622 7.17015 17.1239C7.62832 16.9855 8.04215 16.8944 8.45465 16.8944C8.86849 16.8944 9.50998 16.8944 9.83132 16.9869C10.1515 17.0782 10.382 17.1252 10.5653 17.1709V9.0292C10.5653 8.75254 10.6565 8.5242 10.7945 8.34037C10.9323 8.15637 11.1613 8.0637 11.3903 8.0182C11.6208 7.97254 11.8043 8.0182 11.9422 8.15654C12.0802 8.2477 11.9422 8.43304 12.1243 8.61554C12.2623 8.79954 12.4458 9.03054 12.6762 9.3057C12.9052 9.58237 13.1797 9.81187 13.5467 10.0415C13.8682 10.271 14.144 10.4094 14.373 10.5477C14.6022 10.639 14.8325 10.7317 15.016 10.8244C15.1993 10.9155 15.4285 11.0069 15.612 11.1452C15.7953 11.2835 16.0258 11.4674 16.2535 11.744C16.4838 12.0207 16.6205 12.2489 16.6673 12.5254C16.6673 12.802 16.6673 13.0772 16.6205 13.3069V13.3082V13.308Z' />
|
|
8
|
+
<Path fill='url(#prefix__audio-file-type_b)' d='M21.176 6.04163L15.7598 6.04163L21.8014 12.0833L21.8014 6.66663L21.176 6.04163Z' />
|
|
9
|
+
<Path fill='#F9C499' d='M17.2674 6.66663L21.8008 6.66663L15.1341 -4.06371e-05L15.1341 4.53329C15.1341 5.7115 16.0892 6.66663 17.2674 6.66663Z' />
|
|
21
10
|
<Defs>
|
|
22
11
|
<LinearGradient
|
|
23
|
-
id='
|
|
24
|
-
x1={
|
|
25
|
-
x2={
|
|
26
|
-
y1={
|
|
27
|
-
y2={
|
|
12
|
+
id='prefix__audio-file-type_b'
|
|
13
|
+
x1={17.1139}
|
|
14
|
+
x2={23.1556}
|
|
15
|
+
y1={4.68746}
|
|
16
|
+
y2={10.7291}
|
|
28
17
|
gradientUnits='userSpaceOnUse'
|
|
29
18
|
>
|
|
30
19
|
<Stop stopOpacity={0.2} />
|