@cometchat/chat-uikit-react-native 5.5.4 → 5.7.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/src/main/java/com/reactnativecometchatuikit/CometChatKeyboardModule.kt +101 -0
- package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +1 -0
- package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +78 -3
- package/android/src/main/java/com/reactnativecometchatuikit/KeyboardDirectionWatcher.kt +64 -0
- package/android/src/main/java/com/reactnativecometchatuikit/KeyboardLanguageDirection.kt +44 -0
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +287 -49
- package/android/src/main/java/com/reactnativecometchatuikit/SafeFileName.java +78 -0
- package/ios/CCLocalFileGuard.h +19 -0
- package/ios/CCLocalFileGuard.m +34 -0
- package/ios/CometChatKeyboardModule.m +9 -0
- package/ios/CometChatKeyboardModule.swift +71 -0
- package/ios/FileManager.m +70 -6
- package/ios/KeyboardLanguageDirection.swift +24 -0
- package/ios/RichTextEditorView.swift +253 -51
- package/ios/RichTextEditorViewManager.m +1 -0
- package/ios/VideoManager.m +1 -1
- package/package.json +18 -3
- package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +41 -57
- package/src/CometChatAIAssistantChatHistory/Skeleton.tsx +4 -1
- package/src/CometChatAIAssistantChatHistory/style.ts +5 -2
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +145 -63
- package/src/CometChatCompactMessageComposer/styles.ts +7 -7
- package/src/CometChatConversations/CometChatConversations.tsx +276 -147
- package/src/CometChatConversations/Skeleton.tsx +4 -1
- package/src/CometChatConversations/style.ts +1 -1
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +39 -18
- package/src/CometChatGroupMembers/Skeleton.tsx +4 -1
- package/src/CometChatGroupMembers/style.ts +6 -4
- package/src/CometChatGroups/CometChatGroups.tsx +74 -58
- package/src/CometChatGroups/GroupsStyle.ts +1 -1
- package/src/CometChatGroups/Skeleton.tsx +4 -1
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +190 -96
- package/src/CometChatMessageComposer/styles.tsx +1 -1
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +28 -15
- package/src/CometChatMessageHeader/listners.ts +76 -56
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +8 -1
- package/src/CometChatMessageInformation/Skeleton.tsx +4 -1
- package/src/CometChatMessageList/CometChatMessageList.tsx +1465 -313
- package/src/CometChatMessageList/SwipeToReplyView.tsx +61 -0
- package/src/CometChatMessageList/style.ts +32 -32
- package/src/CometChatMessageList/swipeToReply.ts +25 -0
- package/src/CometChatNotificationFeed/CometChatNotificationFeed.tsx +81 -10
- package/src/CometChatNotificationFeed/style.ts +1 -1
- package/src/CometChatNotificationFeed/utils.ts +17 -18
- package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +82 -3
- package/src/CometChatPinnedMessages/style.ts +5 -5
- package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +2 -0
- package/src/CometChatRichTextEditor/index.tsx +3 -0
- package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +83 -15
- package/src/CometChatSavedMessages/style.ts +3 -3
- package/src/CometChatSearch/CometChatSearch.tsx +391 -136
- package/src/CometChatSearch/Skeleton.tsx +4 -1
- package/src/CometChatSearch/searchLabels.ts +26 -0
- package/src/CometChatSearch/style.ts +7 -7
- package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +34 -8
- package/src/CometChatThreadHeader/Header.tsx +2 -2
- package/src/CometChatUsers/CometChatUsers.tsx +10 -1
- package/src/CometChatUsers/Skeleton.tsx +4 -1
- package/src/CometChatUsers/style.ts +1 -1
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +27 -1
- package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +16 -4
- package/src/calls/CometChatCallLogs/Skeleton.tsx +4 -1
- package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +11 -3
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +10 -2
- package/src/extensions/CollaborativeBubble/style.ts +4 -4
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +1 -1
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +1 -1
- package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +11 -6
- package/src/extensions/LinkPreview/style.ts +6 -6
- package/src/extensions/Polls/Header.tsx +1 -1
- package/src/extensions/Polls/Polls.tsx +25 -12
- package/src/extensions/Polls/PollsBubble.tsx +10 -6
- package/src/extensions/Polls/style.ts +4 -4
- package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +2 -2
- package/src/extensions/Stickers/CometChatStickerKeyboard/Skeleton.tsx +1 -1
- package/src/extensions/Stickers/CometChatStickerKeyboard/style.ts +1 -1
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +4 -2
- package/src/index.ts +11 -1
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +102 -2
- package/src/shared/CometChatUiKit/UIKitSettings.ts +28 -0
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +10 -0
- package/src/shared/events/index.ts +4 -0
- package/src/shared/events/offline.ts +28 -0
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +18 -13
- package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +15 -7
- package/src/shared/formatters/CometChatTextFormatter.ts +11 -0
- package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +7 -4
- package/src/shared/framework/MessageDataSource.tsx +51 -108
- package/src/shared/helper/LocalizedDateHelper.ts +64 -4
- package/src/shared/helper/helperFunctions.ts +71 -4
- package/src/shared/helper/keyboardDirection.ts +54 -0
- package/src/shared/helper/layoutDirection.ts +205 -0
- package/src/shared/helper/pluralRules.ts +67 -0
- package/src/shared/helper/textDirection.ts +118 -0
- package/src/shared/icons/Icon.tsx +37 -2
- package/src/shared/icons/components/format-list-numbered-rtl.tsx +15 -0
- package/src/shared/index.ts +2 -0
- package/src/shared/offline/OfflineHub.ts +651 -0
- package/src/shared/offline/OfflineMediaBubble.tsx +49 -0
- package/src/shared/offline/OfflineViews.tsx +222 -0
- package/src/shared/offline/conversationPins.ts +137 -0
- package/src/shared/offline/conversations.ts +325 -0
- package/src/shared/offline/frameProbe.ts +24 -0
- package/src/shared/offline/gate.ts +94 -0
- package/src/shared/offline/groupActions.ts +81 -0
- package/src/shared/offline/identity.ts +162 -0
- package/src/shared/offline/index.ts +76 -0
- package/src/shared/offline/media.ts +247 -0
- package/src/shared/offline/notices.ts +84 -0
- package/src/shared/offline/reconcile.ts +296 -0
- package/src/shared/offline/searchOutcome.ts +62 -0
- package/src/shared/offline/send.ts +430 -0
- package/src/shared/offline/stateContract.ts +85 -0
- package/src/shared/offline/threadReplies.ts +125 -0
- package/src/shared/offline/twoPhase.ts +372 -0
- package/src/shared/offline/unsentActions.ts +168 -0
- package/src/shared/offline/useOfflineMediaUri.ts +87 -0
- package/src/shared/offline/useOfflineReconnect.ts +25 -0
- package/src/shared/offline/useOfflineSessionEnded.ts +22 -0
- package/src/shared/offline/useOfflineUploadTray.ts +76 -0
- package/src/shared/offline/usePresenceHidden.ts +33 -0
- package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +2 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/ar/translation.json +720 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +75 -4
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +75 -4
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +82 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +90 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +74 -3
- package/src/shared/services/UploadQueueService.ts +106 -1
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +13 -12
- package/src/shared/utils/CometChatMessagePreview/style.ts +1 -1
- package/src/shared/utils/MessageReceiptUtils.ts +8 -0
- package/src/shared/utils/MessageUtils.tsx +14 -14
- package/src/shared/utils/PermissionUtil.ts +16 -5
- package/src/shared/utils/SavedMessagesHelper.ts +18 -1
- package/src/shared/utils/attachmentLimits.ts +3 -2
- package/src/shared/utils/catchUpCursor.ts +36 -0
- package/src/shared/utils/conversationUtils.ts +3 -5
- package/src/shared/utils/failedMessageRetry.ts +73 -0
- package/src/shared/utils/fileIconFontSize.ts +10 -0
- package/src/shared/utils/fileSizeLabel.ts +16 -0
- package/src/shared/utils/groupActionText.ts +75 -0
- package/src/shared/utils/messageIdentity.ts +38 -0
- package/src/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.tsx +12 -8
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.style.ts +1 -1
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreviewItem.tsx +5 -3
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +22 -17
- package/src/shared/views/CometChatAttachmentViewer/CometChatAttachmentViewer.tsx +45 -12
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +16 -10
- package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +20 -8
- package/src/shared/views/CometChatBadge/CometChatBadge.tsx +8 -4
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +6 -2
- package/src/shared/views/CometChatComposerErrorBanner.tsx +3 -1
- package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +8 -3
- package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +2 -2
- package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +5 -3
- package/src/shared/views/CometChatEmojiKeyboard/emojis.ts +8 -8
- package/src/shared/views/CometChatEmojiKeyboard/style.ts +2 -2
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +13 -27
- package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +65 -15
- package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +7 -3
- package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +56 -25
- package/src/shared/views/CometChatInlineAudioRecorder/CometChatInlineAudioRecorder.tsx +41 -21
- package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +7 -3
- package/src/shared/views/CometChatLinkConfirmPopup/CometChatLinkConfirmPopup.tsx +7 -3
- package/src/shared/views/CometChatList/CometChatList.tsx +478 -21
- package/src/shared/views/CometChatList/Header.tsx +5 -2
- package/src/shared/views/CometChatList/sectionLetter.ts +44 -0
- package/src/shared/views/CometChatList/styles.ts +7 -7
- package/src/shared/views/CometChatListItem/CometChatListItem.tsx +6 -4
- package/src/shared/views/CometChatMediaRecorder/CometChatAudioPlayer.tsx +16 -10
- package/src/shared/views/CometChatMediaRecorder/Timer.tsx +5 -1
- package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +43 -16
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +24 -4
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +19 -2
- package/src/shared/views/CometChatNewMessageIndicator/CometChatNewMessageIndicator.tsx +3 -2
- package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +59 -12
- package/src/shared/views/CometChatReactionList/ReactionListStyle.tsx +2 -2
- package/src/shared/views/CometChatReactionList/Skeleton.tsx +4 -1
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +6 -2
- package/src/shared/views/CometChatReportDialog/CometChatReportDialog.tsx +7 -3
- package/src/shared/views/CometChatReportDialog/style.ts +1 -1
- package/src/shared/views/CometChatSmartReplies/CometChatSmartReplies.tsx +1 -1
- package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +4 -0
- package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +20 -13
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +3 -2
- package/src/shared/views/CometChatSuggestionList/Skeleton.tsx +1 -1
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +29 -3
- package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +20 -30
- package/src/shared/views/CometChatTooltipMenu/tooltipPosition.ts +43 -0
- package/src/shared/views/CometChatVideoBubble/style.ts +2 -2
- package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +4 -1
- package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +58 -24
- package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +24 -12
- package/src/shared/views/SenderLabel.tsx +41 -0
- package/src/theme/default/default.ts +1 -1
- package/src/theme/type.ts +17 -0
- 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
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Gap from the screen edge, and from the touch point when the menu opens beside it.
|
|
2
|
+
const EDGE = 12;
|
|
3
|
+
const TOUCH_GAP = 10;
|
|
4
|
+
|
|
5
|
+
export type TooltipPosition = {
|
|
6
|
+
start?: number;
|
|
7
|
+
end?: number;
|
|
8
|
+
top?: number;
|
|
9
|
+
bottom?: number;
|
|
10
|
+
maxWidth?: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Where the menu sits for a touch at (x, y). Horizontal placement is in start/end terms: x is a
|
|
15
|
+
* physical page coordinate, but React Native swaps absolute `left`/`right` in RTL, so a trigger
|
|
16
|
+
* at the left edge opened its menu at the right (ENG-41389). Near the start edge the menu opens
|
|
17
|
+
* just past the touch; otherwise it hugs the end edge — so it stays on screen at both edges.
|
|
18
|
+
*/
|
|
19
|
+
export function tooltipPosition(
|
|
20
|
+
x: number,
|
|
21
|
+
y: number,
|
|
22
|
+
width: number,
|
|
23
|
+
height: number,
|
|
24
|
+
isRTL: boolean
|
|
25
|
+
): TooltipPosition {
|
|
26
|
+
const position: TooltipPosition = {};
|
|
27
|
+
// Clamped: a touch outside the window (stale size, multi-window) still lands on screen.
|
|
28
|
+
const fromStart = Math.min(Math.max(isRTL ? width - x : x, 0), width);
|
|
29
|
+
if (fromStart <= width / 3) {
|
|
30
|
+
position.start = fromStart + TOUCH_GAP;
|
|
31
|
+
// Long or translated labels wrap instead of running past the end edge.
|
|
32
|
+
position.maxWidth = width - position.start - EDGE;
|
|
33
|
+
} else {
|
|
34
|
+
position.end = EDGE;
|
|
35
|
+
position.maxWidth = width - 2 * EDGE;
|
|
36
|
+
}
|
|
37
|
+
if (y <= height / 2) {
|
|
38
|
+
position.top = y + 20;
|
|
39
|
+
} else {
|
|
40
|
+
position.bottom = Math.max(height - y + 10, 40);
|
|
41
|
+
}
|
|
42
|
+
return position;
|
|
43
|
+
}
|
|
@@ -51,7 +51,7 @@ export const getVideoBubbleStylesLight = (
|
|
|
51
51
|
top: 50
|
|
52
52
|
},
|
|
53
53
|
dateReceiptContainerStyle: {
|
|
54
|
-
|
|
54
|
+
paddingEnd: spacing.padding.p1
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
outgoingBubbleStyle: {
|
|
@@ -88,7 +88,7 @@ export const getVideoBubbleStylesLight = (
|
|
|
88
88
|
top: 50
|
|
89
89
|
},
|
|
90
90
|
dateReceiptContainerStyle: {
|
|
91
|
-
|
|
91
|
+
paddingEnd: spacing.padding.p1
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
};
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "react-native";
|
|
11
11
|
import Video from "react-native-video";
|
|
12
12
|
import { Icon } from "../../icons/Icon";
|
|
13
|
+
import { directionStyle, useComponentLayoutDirection } from "../../helper/layoutDirection";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Props for the CometChatVideoPlayer component.
|
|
@@ -39,6 +40,8 @@ export interface CometChatVideoPlayerProps {
|
|
|
39
40
|
|
|
40
41
|
export const CometChatVideoPlayer = (props: CometChatVideoPlayerProps) => {
|
|
41
42
|
const { videoUri, isVisible, onClose, onLoad, loadingIconColor } = props;
|
|
43
|
+
// Modal content is a new native root: give it the opener's direction (ENG-41333, §4.7).
|
|
44
|
+
const direction = useComponentLayoutDirection();
|
|
42
45
|
const [isPaused, setPaused] = useState(false);
|
|
43
46
|
const [isLoading, setIsLoading] = useState(true);
|
|
44
47
|
const [showCloseButton, setShowCloseButton] = useState(true);
|
|
@@ -112,7 +115,7 @@ export const CometChatVideoPlayer = (props: CometChatVideoPlayerProps) => {
|
|
|
112
115
|
visible={isVisible}
|
|
113
116
|
onRequestClose={handleClose}
|
|
114
117
|
>
|
|
115
|
-
<View style={styles.modalBackground}>
|
|
118
|
+
<View style={[styles.modalBackground, directionStyle(direction)]}>
|
|
116
119
|
<TouchableWithoutFeedback onPress={handleVideoTap}>
|
|
117
120
|
<View style={styles.playerContainer}>
|
|
118
121
|
<Video
|
|
@@ -2,6 +2,10 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
|
2
2
|
import { Image, ImageStyle, StyleProp, StyleSheet, Text, TextStyle, TouchableOpacity, View, ViewStyle } from 'react-native';
|
|
3
3
|
import { CometChat } from '@cometchat/chat-sdk-react-native';
|
|
4
4
|
import { CometChatTheme } from '../../../theme/type';
|
|
5
|
+
import { isOfflineUnsent } from '../../offline/identity';
|
|
6
|
+
import { isMediaOutOfReach, requestMediaDownload } from '../../offline/media';
|
|
7
|
+
import { MediaOutOfReachNote } from '../../offline/OfflineMediaBubble';
|
|
8
|
+
import { useMediaOutOfReach } from '../../offline/useOfflineMediaUri';
|
|
5
9
|
import { useTheme } from '../../../theme';
|
|
6
10
|
import { useCompTheme } from '../../../theme/hook';
|
|
7
11
|
import { deepMerge } from '../../helper/helperFunctions';
|
|
@@ -22,10 +26,10 @@ import { AdditionalParams } from "../../base/Types";
|
|
|
22
26
|
// ---------------------------------------------------------------------------
|
|
23
27
|
|
|
24
28
|
interface BorderRadii {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
topStart?: number;
|
|
30
|
+
topEnd?: number;
|
|
31
|
+
bottomStart?: number;
|
|
32
|
+
bottomEnd?: number;
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
function formatDurationSecs(secs: number): string {
|
|
@@ -54,6 +58,8 @@ interface VideoCellProps {
|
|
|
54
58
|
testID?: string;
|
|
55
59
|
overflowCount?: number;
|
|
56
60
|
thumbnailUrl?: string;
|
|
61
|
+
/** Own message the server has not acked (offline queue): no server thumbnail can exist yet. */
|
|
62
|
+
unsent?: boolean;
|
|
57
63
|
/** Retry a failed server thumbnail — only for a just-sent message, whose thumbnail may not exist yet. */
|
|
58
64
|
retryThumbnail?: boolean;
|
|
59
65
|
cellStyle?: StyleProp<ViewStyle>;
|
|
@@ -73,6 +79,8 @@ interface VideoCellProps {
|
|
|
73
79
|
const THUMBNAIL_RETRY_DELAYS_MS = [1000, 2000, 4000, 8000, 15000];
|
|
74
80
|
const THUMBNAIL_RETRY_WINDOW_SECS = 120;
|
|
75
81
|
|
|
82
|
+
const isRemoteUrl = (url?: string) => /^https?:\/\//i.test(url ?? '');
|
|
83
|
+
|
|
76
84
|
const VideoCell = ({
|
|
77
85
|
attachment,
|
|
78
86
|
aspectRatio = 1,
|
|
@@ -81,6 +89,7 @@ const VideoCell = ({
|
|
|
81
89
|
testID,
|
|
82
90
|
overflowCount,
|
|
83
91
|
thumbnailUrl,
|
|
92
|
+
unsent,
|
|
84
93
|
retryThumbnail,
|
|
85
94
|
cellStyle,
|
|
86
95
|
playButtonStyle,
|
|
@@ -94,7 +103,14 @@ const VideoCell = ({
|
|
|
94
103
|
const duration = getDuration(attachment);
|
|
95
104
|
// Only stand in for a server thumbnail that is on its way: no `thumbnailUrl` means the Thumbnail
|
|
96
105
|
// Generation extension is off in the dashboard (or failed for this file), and then no thumbnail shows.
|
|
97
|
-
|
|
106
|
+
// The exception is an own message still queued/sending (offline): it has no `thumbnailUrl` yet, and
|
|
107
|
+
// its video is a local file (or an upload this device linked), so the local frame stands in until it is acked.
|
|
108
|
+
const attachmentUrl = attachment.getUrl?.();
|
|
109
|
+
const localThumbnail = useLocalVideoThumbnail(
|
|
110
|
+
unsent
|
|
111
|
+
? { localUri: isRemoteUrl(attachmentUrl) ? undefined : attachmentUrl || undefined, remoteUrl: attachmentUrl }
|
|
112
|
+
: { remoteUrl: thumbnailUrl ? attachmentUrl : undefined }
|
|
113
|
+
);
|
|
98
114
|
// Bumped once a retried thumbnail is fetched, to remount the <Image> onto the now-cached file.
|
|
99
115
|
const [thumbnailKey, setThumbnailKey] = useState(0);
|
|
100
116
|
const retry = useRef<{ attempt: number; timer?: ReturnType<typeof setTimeout> }>({ attempt: 0 });
|
|
@@ -124,10 +140,18 @@ const VideoCell = ({
|
|
|
124
140
|
const unsupported = mime.includes('/') && !isVideoMime(mime);
|
|
125
141
|
|
|
126
142
|
const borderStyle = {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
143
|
+
borderTopStartRadius: radii.topStart ?? 0,
|
|
144
|
+
borderTopEndRadius: radii.topEnd ?? 0,
|
|
145
|
+
borderBottomStartRadius: radii.bottomStart ?? 0,
|
|
146
|
+
borderBottomEndRadius: radii.bottomEnd ?? 0,
|
|
147
|
+
};
|
|
148
|
+
const outOfReach = useMediaOutOfReach(attachment);
|
|
149
|
+
const handlePress = () => {
|
|
150
|
+
// Offline ON: no copy on the device and no connection, so the player has nothing to play.
|
|
151
|
+
if (isMediaOutOfReach(attachment)) return;
|
|
152
|
+
// Online with no copy: ask the SDK for one; the viewer streams the URL meanwhile (AC-12.3).
|
|
153
|
+
requestMediaDownload(attachment);
|
|
154
|
+
onPress?.();
|
|
131
155
|
};
|
|
132
156
|
|
|
133
157
|
if (unsupported) {
|
|
@@ -162,7 +186,7 @@ const VideoCell = ({
|
|
|
162
186
|
return (
|
|
163
187
|
<TouchableOpacity
|
|
164
188
|
testID={testID}
|
|
165
|
-
onPress={
|
|
189
|
+
onPress={handlePress}
|
|
166
190
|
activeOpacity={0.85}
|
|
167
191
|
style={[{ flex: 1, aspectRatio, overflow: 'hidden' }, borderStyle, cellStyle]}
|
|
168
192
|
accessibilityRole="button"
|
|
@@ -205,6 +229,12 @@ const VideoCell = ({
|
|
|
205
229
|
</View>
|
|
206
230
|
)}
|
|
207
231
|
|
|
232
|
+
{outOfReach && !overflowCount ? (
|
|
233
|
+
<View pointerEvents="none" style={{ position: 'absolute', top: theme.spacing.spacing.s2, left: theme.spacing.spacing.s2, right: theme.spacing.spacing.s2 }}>
|
|
234
|
+
<MediaOutOfReachNote attachment={attachment} color={theme.color.staticWhite} />
|
|
235
|
+
</View>
|
|
236
|
+
) : null}
|
|
237
|
+
|
|
208
238
|
{!overflowCount && duration && (
|
|
209
239
|
<View
|
|
210
240
|
pointerEvents="none"
|
|
@@ -241,6 +271,7 @@ const VideoCell = ({
|
|
|
241
271
|
const VideoGrid = ({
|
|
242
272
|
attachments,
|
|
243
273
|
thumbnailUrls,
|
|
274
|
+
unsent,
|
|
244
275
|
retryThumbnail,
|
|
245
276
|
onAttachmentPress,
|
|
246
277
|
containerStyle,
|
|
@@ -254,6 +285,7 @@ const VideoGrid = ({
|
|
|
254
285
|
}: {
|
|
255
286
|
attachments: CometChat.Attachment[];
|
|
256
287
|
thumbnailUrls?: string[];
|
|
288
|
+
unsent?: boolean;
|
|
257
289
|
retryThumbnail?: boolean;
|
|
258
290
|
onAttachmentPress: (attachment: CometChat.Attachment, index: number) => void;
|
|
259
291
|
containerStyle?: StyleProp<ViewStyle>;
|
|
@@ -279,6 +311,7 @@ const VideoGrid = ({
|
|
|
279
311
|
radii={radii}
|
|
280
312
|
overflowCount={overflowCount}
|
|
281
313
|
thumbnailUrl={thumbnailUrls?.[i]}
|
|
314
|
+
unsent={unsent}
|
|
282
315
|
retryThumbnail={retryThumbnail}
|
|
283
316
|
onPress={() => onAttachmentPress(attachments[i], i)}
|
|
284
317
|
cellStyle={cellStyle}
|
|
@@ -295,25 +328,25 @@ const VideoGrid = ({
|
|
|
295
328
|
if (count === 1) {
|
|
296
329
|
return (
|
|
297
330
|
<View style={{ flexDirection: 'row' }}>
|
|
298
|
-
{cell(0, {
|
|
331
|
+
{cell(0, { topStart: CORNER, topEnd: CORNER, bottomStart: CORNER, bottomEnd: CORNER }, 4 / 3)}
|
|
299
332
|
</View>
|
|
300
333
|
);
|
|
301
334
|
}
|
|
302
335
|
if (count === 2) {
|
|
303
336
|
return (
|
|
304
337
|
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
305
|
-
{cell(0, {
|
|
306
|
-
{cell(1, {
|
|
338
|
+
{cell(0, { topStart: CORNER, bottomStart: CORNER })}
|
|
339
|
+
{cell(1, { topEnd: CORNER, bottomEnd: CORNER })}
|
|
307
340
|
</View>
|
|
308
341
|
);
|
|
309
342
|
}
|
|
310
343
|
if (count === 3) {
|
|
311
344
|
return (
|
|
312
345
|
<View style={{ gap: GAP }}>
|
|
313
|
-
<View style={{ flexDirection: 'row' }}>{cell(0, {
|
|
346
|
+
<View style={{ flexDirection: 'row' }}>{cell(0, { topStart: CORNER, topEnd: CORNER }, 4 / 3)}</View>
|
|
314
347
|
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
315
|
-
{cell(1, {
|
|
316
|
-
{cell(2, {
|
|
348
|
+
{cell(1, { bottomStart: CORNER })}
|
|
349
|
+
{cell(2, { bottomEnd: CORNER })}
|
|
317
350
|
</View>
|
|
318
351
|
</View>
|
|
319
352
|
);
|
|
@@ -322,12 +355,12 @@ const VideoGrid = ({
|
|
|
322
355
|
return (
|
|
323
356
|
<View style={{ gap: GAP }}>
|
|
324
357
|
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
325
|
-
{cell(0, {
|
|
326
|
-
{cell(1, {
|
|
358
|
+
{cell(0, { topStart: CORNER })}
|
|
359
|
+
{cell(1, { topEnd: CORNER })}
|
|
327
360
|
</View>
|
|
328
361
|
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
329
|
-
{cell(2, {
|
|
330
|
-
{cell(3, {
|
|
362
|
+
{cell(2, { bottomStart: CORNER })}
|
|
363
|
+
{cell(3, { bottomEnd: CORNER })}
|
|
331
364
|
</View>
|
|
332
365
|
</View>
|
|
333
366
|
);
|
|
@@ -337,12 +370,12 @@ const VideoGrid = ({
|
|
|
337
370
|
return (
|
|
338
371
|
<View style={{ gap: GAP }}>
|
|
339
372
|
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
340
|
-
{cell(0, {
|
|
341
|
-
{cell(1, {
|
|
373
|
+
{cell(0, { topStart: CORNER })}
|
|
374
|
+
{cell(1, { topEnd: CORNER })}
|
|
342
375
|
</View>
|
|
343
376
|
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
344
|
-
{cell(2, {
|
|
345
|
-
{cell(3, {
|
|
377
|
+
{cell(2, { bottomStart: CORNER })}
|
|
378
|
+
{cell(3, { bottomEnd: CORNER }, undefined, overflowCount)}
|
|
346
379
|
</View>
|
|
347
380
|
</View>
|
|
348
381
|
);
|
|
@@ -413,6 +446,7 @@ export function CometChatVideosBubble({
|
|
|
413
446
|
<VideoGrid
|
|
414
447
|
attachments={allAttachments}
|
|
415
448
|
thumbnailUrls={thumbnailUrls}
|
|
449
|
+
unsent={isOfflineUnsent(message)}
|
|
416
450
|
retryThumbnail={Date.now() / 1000 - (message.getSentAt?.() ?? 0) < THUMBNAIL_RETRY_WINDOW_SECS}
|
|
417
451
|
containerStyle={s.containerStyle}
|
|
418
452
|
cellStyle={s.cellStyle}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { shouldUseCachedMedia } from '../../offline/media';
|
|
2
|
+
import { OfflineMediaBubble } from '../../offline/OfflineMediaBubble';
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { View } from 'react-native';
|
|
3
5
|
import { CometChat } from '@cometchat/chat-sdk-react-native';
|
|
@@ -48,18 +50,28 @@ export function CometChatVoiceNoteBubble({
|
|
|
48
50
|
|
|
49
51
|
return (
|
|
50
52
|
<View style={[{ width: '100%' }, s.containerStyle]}>
|
|
51
|
-
{audioAttachments.map((att, i) =>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
{audioAttachments.map((att, i) => {
|
|
54
|
+
const bubble = (audioUrl: string) => (
|
|
55
|
+
<CometChatAudioBubble
|
|
56
|
+
key={att.getUrl() ?? String(i)}
|
|
57
|
+
audioUrl={audioUrl}
|
|
58
|
+
playViewContainerStyle={s.playViewContainerStyle}
|
|
59
|
+
playIconStyle={s.playIconStyle}
|
|
60
|
+
playIconContainerStyle={s.playIconContainerStyle}
|
|
61
|
+
waveStyle={s.waveStyle}
|
|
62
|
+
waveContainerStyle={s.waveContainerStyle}
|
|
63
|
+
playProgressTextStyle={s.playProgressTextStyle}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
// Offline ON: the SDK's cached copy when it has one. OFF: today's bubble with the URL.
|
|
67
|
+
return shouldUseCachedMedia() ? (
|
|
68
|
+
<OfflineMediaBubble key={att.getUrl() ?? String(i)} attachment={att} playable>
|
|
69
|
+
{bubble}
|
|
70
|
+
</OfflineMediaBubble>
|
|
71
|
+
) : (
|
|
72
|
+
bubble(att.getUrl())
|
|
73
|
+
);
|
|
74
|
+
})}
|
|
63
75
|
{/* §7 — caption rides on the (last) message of the batch */}
|
|
64
76
|
{Boolean(caption) && (
|
|
65
77
|
<CometChatCaptionText
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleProp, Text, TextStyle, View, ViewStyle } from "react-native";
|
|
3
|
+
import { TEXT_START } from "../helper/layoutDirection";
|
|
4
|
+
import { isolateText } from "../helper/textDirection";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* "Name:" before a message preview (ENG-41391 and its reviews). The colon is its own Text right
|
|
8
|
+
* after the name, so the row layout puts it between the name and the message in both directions
|
|
9
|
+
* and for a name in any script, and a long name ellipsizes without taking the colon with it.
|
|
10
|
+
* Name and colon share a gap-free row (the caller's row may space its children); the gap before
|
|
11
|
+
* the message is a logical margin, not a trailing space (that one isn't drawn at the end of an
|
|
12
|
+
* RTL label).
|
|
13
|
+
*/
|
|
14
|
+
export const SenderLabel = ({
|
|
15
|
+
name,
|
|
16
|
+
textStyle,
|
|
17
|
+
containerStyle,
|
|
18
|
+
}: {
|
|
19
|
+
name?: string | null;
|
|
20
|
+
/** Font and colour, shared by the name and the colon. */
|
|
21
|
+
textStyle?: StyleProp<TextStyle>;
|
|
22
|
+
/** Layout limits for the label in the caller's row (max width, shrink). */
|
|
23
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
24
|
+
}) => {
|
|
25
|
+
if (!name) return null;
|
|
26
|
+
return (
|
|
27
|
+
// One accessibility stop for "Name:", as the single Text it replaces was.
|
|
28
|
+
<View style={[ROW, containerStyle]} accessible accessibilityLabel={`${name}:`}>
|
|
29
|
+
<Text style={[TEXT_START, textStyle, SHRINKS]} numberOfLines={1} ellipsizeMode='tail'>
|
|
30
|
+
{isolateText(name)}
|
|
31
|
+
</Text>
|
|
32
|
+
<Text style={[textStyle, KEEPS]}>:</Text>
|
|
33
|
+
</View>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// No shrink by default, like a plain Text in a row; callers that should yield pass flexShrink/maxWidth.
|
|
38
|
+
const ROW: ViewStyle = { flexDirection: "row", alignItems: "center", flexShrink: 0, marginEnd: 4 };
|
|
39
|
+
// The caller's text style may carry a width (e.g. 90%); inside the label both parts hug their text.
|
|
40
|
+
const SHRINKS: TextStyle = { width: undefined, maxWidth: undefined, flexGrow: 0, flexShrink: 1 };
|
|
41
|
+
const KEEPS: TextStyle = { width: undefined, maxWidth: undefined, flexGrow: 0, flexShrink: 0 };
|
package/src/theme/type.ts
CHANGED
|
@@ -538,6 +538,23 @@ export interface CometChatTheme {
|
|
|
538
538
|
callActionBubbleStyles: DeepPartial<CallActionBubbleStyles>;
|
|
539
539
|
messageInformationStyles: DeepPartial<CometChatTheme["messageInformationStyles"]>;
|
|
540
540
|
messageOptionsStyles: DeepPartial<ActionSheetStyle>;
|
|
541
|
+
/**
|
|
542
|
+
* Offline states (message list, conversation list and media bubbles). Only drawn with the
|
|
543
|
+
* SDK's offline on. Optional: anything left out derives from today's error and date tokens.
|
|
544
|
+
*/
|
|
545
|
+
offlineStyles?: {
|
|
546
|
+
/** The tappable "Not sent. Tap to retry" row of a failed message; no tint by default. */
|
|
547
|
+
failedRowStyle?: ViewStyle;
|
|
548
|
+
failedIconStyle?: ImageStyle;
|
|
549
|
+
retryTextStyle?: TextStyle;
|
|
550
|
+
notSentYetTextStyle?: TextStyle;
|
|
551
|
+
/** The "Available when online" stand-in for media the device never downloaded. */
|
|
552
|
+
mediaPlaceholderStyle?: { containerStyle?: ViewStyle; textStyle?: TextStyle };
|
|
553
|
+
/** The "Connect to load more" list footer. */
|
|
554
|
+
footerStyle?: { containerStyle?: ViewStyle; textStyle?: TextStyle };
|
|
555
|
+
/** The one-line notice ("1 unsent message was removed"). */
|
|
556
|
+
noticeStyle?: { containerStyle?: ViewStyle; textStyle?: TextStyle; actionTextStyle?: TextStyle };
|
|
557
|
+
};
|
|
541
558
|
};
|
|
542
559
|
avatarStyle: Partial<AvatarStyle>;
|
|
543
560
|
statusIndicatorStyle: StatusIndicatorStyles;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|