@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
|
@@ -21,6 +21,9 @@ import { useCompTheme } from '../../../theme/hook';
|
|
|
21
21
|
import { deepMerge } from '../../helper/helperFunctions';
|
|
22
22
|
import { SelectedAttachment } from '../../modals/SelectedAttachment';
|
|
23
23
|
import { Icon } from '../../icons/Icon';
|
|
24
|
+
import { PLAYER_DIRECTION, PLAYER_TIME_ALIGN } from '../../helper/layoutDirection';
|
|
25
|
+
import { localizeDigits } from '../../helper/LocalizedDateHelper';
|
|
26
|
+
import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
|
|
24
27
|
import { getFileTypeIcon } from '../../constants/UIKitConstants';
|
|
25
28
|
import { useLocalVideoThumbnail } from '../../utils/videoThumbnail';
|
|
26
29
|
|
|
@@ -145,6 +148,7 @@ const AudioAttachmentCard = ({
|
|
|
145
148
|
removeButtonStyle?: ViewStyle;
|
|
146
149
|
}) => {
|
|
147
150
|
const theme = useTheme();
|
|
151
|
+
const { t, language } = useCometChatTranslation();
|
|
148
152
|
const { fileId, file, uploadState, uploadProgress } = attachment;
|
|
149
153
|
|
|
150
154
|
const [status, setStatus] = useState<'stopped' | 'playing' | 'paused'>('stopped');
|
|
@@ -311,7 +315,7 @@ const AudioAttachmentCard = ({
|
|
|
311
315
|
backgroundColor: theme.color.background2,
|
|
312
316
|
borderWidth: 1,
|
|
313
317
|
borderColor: isError ? theme.color.error : theme.color.borderDefault,
|
|
314
|
-
}, audioCardStyle]}
|
|
318
|
+
}, audioCardStyle, PLAYER_DIRECTION]}
|
|
315
319
|
>
|
|
316
320
|
{/* Purple play/pause circle; LOADING dims it + spins the ring, ERROR shows the glyph. */}
|
|
317
321
|
<TouchableOpacity
|
|
@@ -327,7 +331,7 @@ const AudioAttachmentCard = ({
|
|
|
327
331
|
alignItems: 'center',
|
|
328
332
|
}}
|
|
329
333
|
accessibilityRole="button"
|
|
330
|
-
accessibilityLabel={status === 'playing' ? '
|
|
334
|
+
accessibilityLabel={status === 'playing' ? t('PAUSE_AUDIO') : t('PLAY_AUDIO')}
|
|
331
335
|
>
|
|
332
336
|
<Icon
|
|
333
337
|
name={status === 'playing' ? 'pause-fill' : 'play-arrow-fill'}
|
|
@@ -361,7 +365,7 @@ const AudioAttachmentCard = ({
|
|
|
361
365
|
<Text
|
|
362
366
|
numberOfLines={1}
|
|
363
367
|
ellipsizeMode="middle"
|
|
364
|
-
style={[{ ...theme.typography.body.medium, color: theme.color.neutral900,
|
|
368
|
+
style={[{ ...theme.typography.body.medium, color: theme.color.neutral900, marginEnd: theme.spacing.margin.m4 }, fileNameStyle]}
|
|
365
369
|
>
|
|
366
370
|
{file.name}
|
|
367
371
|
</Text>
|
|
@@ -373,12 +377,12 @@ const AudioAttachmentCard = ({
|
|
|
373
377
|
suppressHighlighting
|
|
374
378
|
style={{ ...theme.typography.caption2.medium, color: theme.color.error, marginTop: S.s0_5 }}
|
|
375
379
|
>
|
|
376
|
-
{'
|
|
380
|
+
{t('NOTIFICATION_FEED_TAP_TO_RETRY')}
|
|
377
381
|
</Text>
|
|
378
382
|
) : (
|
|
379
383
|
// REJECTED (server denied) — remove-only, no retry.
|
|
380
384
|
<Text style={{ ...theme.typography.caption2.regular, color: theme.color.error, marginTop: S.s0_5 }}>
|
|
381
|
-
{'
|
|
385
|
+
{t('ATTACHMENT_UPLOAD_FAILED')}
|
|
382
386
|
</Text>
|
|
383
387
|
)
|
|
384
388
|
) : (
|
|
@@ -409,8 +413,8 @@ const AudioAttachmentCard = ({
|
|
|
409
413
|
}}
|
|
410
414
|
/>
|
|
411
415
|
</View>
|
|
412
|
-
<Text style={{ ...theme.typography.caption1.regular, color: theme.color.neutral600, marginTop: S.s0_5 }}>
|
|
413
|
-
{`${fmtTime(dispTime)}/${fmtTime(duration)}
|
|
416
|
+
<Text style={[PLAYER_TIME_ALIGN, { ...theme.typography.caption1.regular, color: theme.color.neutral600, marginTop: S.s0_5 }]}>
|
|
417
|
+
{localizeDigits(`${fmtTime(dispTime)}/${fmtTime(duration)}`, language)}
|
|
414
418
|
</Text>
|
|
415
419
|
</>
|
|
416
420
|
)}
|
|
@@ -424,7 +428,7 @@ const AudioAttachmentCard = ({
|
|
|
424
428
|
style={[{
|
|
425
429
|
position: 'absolute',
|
|
426
430
|
top: -theme.spacing.spacing.s2,
|
|
427
|
-
|
|
431
|
+
end: -theme.spacing.spacing.s2,
|
|
428
432
|
width: theme.spacing.spacing.s6,
|
|
429
433
|
height: theme.spacing.spacing.s6,
|
|
430
434
|
borderRadius: theme.spacing.radius.r3,
|
|
@@ -435,7 +439,7 @@ const AudioAttachmentCard = ({
|
|
|
435
439
|
alignItems: 'center',
|
|
436
440
|
}, removeButtonStyle]}
|
|
437
441
|
accessibilityRole="button"
|
|
438
|
-
accessibilityLabel="
|
|
442
|
+
accessibilityLabel={t("ATTACHMENT_REMOVE")}
|
|
439
443
|
>
|
|
440
444
|
<Text style={{ ...theme.typography.caption2.regular, color: theme.color.staticWhite }}>{'✕'}</Text>
|
|
441
445
|
</TouchableOpacity>
|
|
@@ -453,6 +457,7 @@ export const CometChatAttachmentTile = ({
|
|
|
453
457
|
testID,
|
|
454
458
|
}: CometChatAttachmentTileProps) => {
|
|
455
459
|
const theme = useTheme();
|
|
460
|
+
const { t } = useCometChatTranslation();
|
|
456
461
|
const compTheme = useCompTheme();
|
|
457
462
|
const s = deepMerge(
|
|
458
463
|
theme.attachmentTileStyles ?? {},
|
|
@@ -582,7 +587,7 @@ export const CometChatAttachmentTile = ({
|
|
|
582
587
|
)}
|
|
583
588
|
</View>
|
|
584
589
|
|
|
585
|
-
<View style={{ flex: 1,
|
|
590
|
+
<View style={{ flex: 1, marginEnd: theme.spacing.margin.m3 }}>
|
|
586
591
|
<Text
|
|
587
592
|
numberOfLines={1}
|
|
588
593
|
ellipsizeMode="middle"
|
|
@@ -598,12 +603,12 @@ export const CometChatAttachmentTile = ({
|
|
|
598
603
|
suppressHighlighting
|
|
599
604
|
style={{ ...theme.typography.caption2.medium, color: theme.color.error, marginTop: theme.spacing.margin.m0_5 }}
|
|
600
605
|
>
|
|
601
|
-
{'
|
|
606
|
+
{t('NOTIFICATION_FEED_TAP_TO_RETRY')}
|
|
602
607
|
</Text>
|
|
603
608
|
) : (
|
|
604
609
|
// REJECTED (server denied) — remove-only, no retry.
|
|
605
610
|
<Text style={{ ...theme.typography.caption2.regular, color: theme.color.error, marginTop: theme.spacing.margin.m0_5 }}>
|
|
606
|
-
{'
|
|
611
|
+
{t('ATTACHMENT_UPLOAD_FAILED')}
|
|
607
612
|
</Text>
|
|
608
613
|
)
|
|
609
614
|
) : (
|
|
@@ -624,7 +629,7 @@ export const CometChatAttachmentTile = ({
|
|
|
624
629
|
style={[{
|
|
625
630
|
position: 'absolute',
|
|
626
631
|
top: -theme.spacing.spacing.s2,
|
|
627
|
-
|
|
632
|
+
end: -theme.spacing.spacing.s2,
|
|
628
633
|
width: theme.spacing.spacing.s6,
|
|
629
634
|
height: theme.spacing.spacing.s6,
|
|
630
635
|
borderRadius: theme.spacing.radius.r3,
|
|
@@ -635,7 +640,7 @@ export const CometChatAttachmentTile = ({
|
|
|
635
640
|
alignItems: 'center',
|
|
636
641
|
}, s.removeButtonStyle]}
|
|
637
642
|
accessibilityRole="button"
|
|
638
|
-
accessibilityLabel="
|
|
643
|
+
accessibilityLabel={t("ATTACHMENT_REMOVE")}
|
|
639
644
|
>
|
|
640
645
|
<Text style={{ ...theme.typography.caption2.regular, color: theme.color.staticWhite }}>{'✕'}</Text>
|
|
641
646
|
</TouchableOpacity>
|
|
@@ -758,7 +763,7 @@ export const CometChatAttachmentTile = ({
|
|
|
758
763
|
activeOpacity={0.8}
|
|
759
764
|
style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, backgroundColor: theme.color.mediaErrorOverlay, justifyContent: 'center', alignItems: 'center' }}
|
|
760
765
|
accessibilityRole="button"
|
|
761
|
-
accessibilityLabel="
|
|
766
|
+
accessibilityLabel={t("ATTACHMENT_RETRY")}
|
|
762
767
|
>
|
|
763
768
|
<View style={{ width: theme.spacing.spacing.s9, height: theme.spacing.spacing.s9, borderRadius: theme.spacing.radius.r5, backgroundColor: theme.color.error, justifyContent: 'center', alignItems: 'center' }}>
|
|
764
769
|
<Icon name="retry" size={theme.spacing.spacing.s5} color={theme.color.staticWhite} />
|
|
@@ -788,7 +793,7 @@ export const CometChatAttachmentTile = ({
|
|
|
788
793
|
style={[{
|
|
789
794
|
position: 'absolute',
|
|
790
795
|
top: -theme.spacing.spacing.s2,
|
|
791
|
-
|
|
796
|
+
end: -theme.spacing.spacing.s2,
|
|
792
797
|
width: theme.spacing.spacing.s6,
|
|
793
798
|
height: theme.spacing.spacing.s6,
|
|
794
799
|
borderRadius: theme.spacing.radius.r3,
|
|
@@ -799,7 +804,7 @@ export const CometChatAttachmentTile = ({
|
|
|
799
804
|
alignItems: 'center',
|
|
800
805
|
}, s.removeButtonStyle]}
|
|
801
806
|
accessibilityRole="button"
|
|
802
|
-
accessibilityLabel="
|
|
807
|
+
accessibilityLabel={t("ATTACHMENT_REMOVE")}
|
|
803
808
|
>
|
|
804
809
|
<Text style={{ ...theme.typography.caption2.regular, color: theme.color.staticWhite }}>{'✕'}</Text>
|
|
805
810
|
</TouchableOpacity>
|
|
@@ -13,6 +13,12 @@ import {
|
|
|
13
13
|
} from 'react-native';
|
|
14
14
|
import { CometChat } from '@cometchat/chat-sdk-react-native';
|
|
15
15
|
import { Icon } from '../../icons/Icon';
|
|
16
|
+
import { fileSizeLabel } from '../../utils/fileSizeLabel';
|
|
17
|
+
import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
|
|
18
|
+
import { directionStyle, useComponentLayoutDirection } from "../../helper/layoutDirection";
|
|
19
|
+
import { useMediaOutOfReach, useOfflineMediaUri } from '../../offline/useOfflineMediaUri';
|
|
20
|
+
import { mediaActionSource, notifyMediaUnavailable } from '../../offline/media';
|
|
21
|
+
import { MediaOutOfReachLabel } from '../../offline/OfflineViews';
|
|
16
22
|
|
|
17
23
|
export interface CometChatAttachmentViewerProps {
|
|
18
24
|
attachments: CometChat.Attachment[];
|
|
@@ -23,15 +29,15 @@ export interface CometChatAttachmentViewerProps {
|
|
|
23
29
|
visible?: boolean;
|
|
24
30
|
}
|
|
25
31
|
|
|
26
|
-
type DownloadState = 'IDLE' | 'DOWNLOADING' | 'DONE' | 'FAILED';
|
|
32
|
+
type DownloadState = 'IDLE' | 'DOWNLOADING' | 'DONE' | 'FAILED' | 'OUT_OF_REACH';
|
|
27
33
|
|
|
28
34
|
const { FileManager } = NativeModules;
|
|
29
35
|
|
|
30
36
|
function formatFileSize(bytes: number): string {
|
|
31
37
|
if (!(bytes > 0)) return ''; // undefined / 0 / NaN → show nothing (not "undefined B")
|
|
32
|
-
if (bytes >= 1_048_576) return
|
|
33
|
-
if (bytes >= 1_024) return
|
|
34
|
-
return
|
|
38
|
+
if (bytes >= 1_048_576) return fileSizeLabel('FILE_SIZE_MB', (bytes / 1_048_576).toFixed(1));
|
|
39
|
+
if (bytes >= 1_024) return fileSizeLabel('FILE_SIZE_KB', (bytes / 1_024).toFixed(0));
|
|
40
|
+
return fileSizeLabel('FILE_SIZE_BYTES', bytes);
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
function formatSentAt(sentAt: number): string {
|
|
@@ -49,11 +55,18 @@ export const CometChatAttachmentViewer = ({
|
|
|
49
55
|
onClose,
|
|
50
56
|
visible = true,
|
|
51
57
|
}: CometChatAttachmentViewerProps) => {
|
|
58
|
+
// Modal content is a new native root: give it the opener's direction (ENG-41333, §4.7).
|
|
59
|
+
const direction = useComponentLayoutDirection();
|
|
60
|
+
const { t } = useCometChatTranslation();
|
|
52
61
|
const [currentIndex, setCurrentIndex] = useState(initialIndex);
|
|
53
62
|
const [imageLoaded, setImageLoaded] = useState(false);
|
|
54
63
|
const [downloadState, setDownloadState] = useState<DownloadState>('IDLE');
|
|
55
64
|
|
|
56
65
|
const current = attachments[currentIndex];
|
|
66
|
+
// Offline ON: the saved file for display, download and Share; the URL as today otherwise.
|
|
67
|
+
const currentUri = useOfflineMediaUri(current);
|
|
68
|
+
const outOfReachRaw = useMediaOutOfReach(current);
|
|
69
|
+
const outOfReach = !!current && outOfReachRaw;
|
|
57
70
|
const senderName = message.getSender?.()?.getName?.() ?? '';
|
|
58
71
|
const sentAtStr = message.getSentAt ? formatSentAt(message.getSentAt()) : '';
|
|
59
72
|
|
|
@@ -77,8 +90,15 @@ export const CometChatAttachmentViewer = ({
|
|
|
77
90
|
|
|
78
91
|
const handleDownload = () => {
|
|
79
92
|
if (downloadState === 'DOWNLOADING' || downloadState === 'DONE') return;
|
|
93
|
+
const source = mediaActionSource(current);
|
|
94
|
+
if (source.kind === 'unavailable') {
|
|
95
|
+
// Say so, as Share does: without the notice the Download button looks like it does nothing.
|
|
96
|
+
setDownloadState('OUT_OF_REACH');
|
|
97
|
+
notifyMediaUnavailable();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
80
100
|
setDownloadState('DOWNLOADING');
|
|
81
|
-
const url =
|
|
101
|
+
const url = source.uri;
|
|
82
102
|
const name = current.getName();
|
|
83
103
|
FileManager?.checkAndDownload(url, name, (result: string) => {
|
|
84
104
|
try {
|
|
@@ -96,7 +116,13 @@ export const CometChatAttachmentViewer = ({
|
|
|
96
116
|
|
|
97
117
|
const handleShare = async () => {
|
|
98
118
|
try {
|
|
99
|
-
|
|
119
|
+
const source = mediaActionSource(current);
|
|
120
|
+
if (source.kind === 'unavailable') {
|
|
121
|
+
setDownloadState('OUT_OF_REACH');
|
|
122
|
+
notifyMediaUnavailable();
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
await Share.share({ url: source.uri, message: current.getName() });
|
|
100
126
|
} catch {
|
|
101
127
|
// share cancelled
|
|
102
128
|
}
|
|
@@ -115,14 +141,14 @@ export const CometChatAttachmentViewer = ({
|
|
|
115
141
|
onRequestClose={onClose}
|
|
116
142
|
statusBarTranslucent
|
|
117
143
|
>
|
|
118
|
-
<View style={styles.root}>
|
|
144
|
+
<View style={[styles.root, directionStyle(direction)]}>
|
|
119
145
|
{/* Header */}
|
|
120
146
|
<View style={styles.header}>
|
|
121
147
|
<TouchableOpacity
|
|
122
148
|
onPress={onClose}
|
|
123
149
|
style={styles.closeButton}
|
|
124
150
|
accessibilityRole="button"
|
|
125
|
-
accessibilityLabel="
|
|
151
|
+
accessibilityLabel={t("CLOSE")}
|
|
126
152
|
>
|
|
127
153
|
<Icon name="arrow-back-fill" color="#fff" height={22} width={22} />
|
|
128
154
|
</TouchableOpacity>
|
|
@@ -141,7 +167,7 @@ export const CometChatAttachmentViewer = ({
|
|
|
141
167
|
onPress={handleShare}
|
|
142
168
|
style={styles.actionButton}
|
|
143
169
|
accessibilityRole="button"
|
|
144
|
-
accessibilityLabel="
|
|
170
|
+
accessibilityLabel={t("SHARE")}
|
|
145
171
|
>
|
|
146
172
|
<Icon name="share-fill" color="#fff" height={20} width={20} />
|
|
147
173
|
</TouchableOpacity>
|
|
@@ -149,7 +175,7 @@ export const CometChatAttachmentViewer = ({
|
|
|
149
175
|
onPress={handleDownload}
|
|
150
176
|
style={styles.actionButton}
|
|
151
177
|
accessibilityRole="button"
|
|
152
|
-
accessibilityLabel="
|
|
178
|
+
accessibilityLabel={t("DOWNLOAD")}
|
|
153
179
|
disabled={downloadState === 'DOWNLOADING'}
|
|
154
180
|
>
|
|
155
181
|
{downloadState === 'DOWNLOADING' && (
|
|
@@ -167,15 +193,22 @@ export const CometChatAttachmentViewer = ({
|
|
|
167
193
|
|
|
168
194
|
{/* Media area */}
|
|
169
195
|
<View style={styles.mediaArea} {...panResponder.panHandlers}>
|
|
170
|
-
{
|
|
196
|
+
{/* Out of reach, the image never loads, so the spinner would run under the label for
|
|
197
|
+
ever. Same rule as CometChatMediaViewer (line 231). */}
|
|
198
|
+
{!imageLoaded && !outOfReach && (
|
|
171
199
|
<ActivityIndicator
|
|
172
200
|
color="#fff"
|
|
173
201
|
size="large"
|
|
174
202
|
style={StyleSheet.absoluteFill}
|
|
175
203
|
/>
|
|
176
204
|
)}
|
|
205
|
+
{outOfReach ? (
|
|
206
|
+
<View style={[StyleSheet.absoluteFill, { justifyContent: 'center', alignItems: 'center' }]}>
|
|
207
|
+
<MediaOutOfReachLabel t={t} textStyle={{ color: 'rgba(255,255,255,0.8)', fontSize: 14 }} />
|
|
208
|
+
</View>
|
|
209
|
+
) : null}
|
|
177
210
|
<Image
|
|
178
|
-
source={{ uri:
|
|
211
|
+
source={{ uri: currentUri }}
|
|
179
212
|
style={styles.image}
|
|
180
213
|
resizeMode="contain"
|
|
181
214
|
onLoad={() => setImageLoaded(true)}
|
|
@@ -16,6 +16,9 @@ import { Icon } from "../../icons/Icon";
|
|
|
16
16
|
import { AnimatedAudioWaves } from "./AnimatedAudioWaves";
|
|
17
17
|
import { audioPlaybackCoordinator } from "../../utils/audioPlaybackCoordinator";
|
|
18
18
|
import { TouchStart, isTapDuration, movedBeyondSlop, touchStartOf } from "../../utils/tapGesture";
|
|
19
|
+
import { PLAYER_DIRECTION, PLAYER_TIME_ALIGN } from "../../helper/layoutDirection";
|
|
20
|
+
import { localizeDigits } from "../../helper/LocalizedDateHelper";
|
|
21
|
+
import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew/useCometChatTranslationHook";
|
|
19
22
|
|
|
20
23
|
const { SoundPlayer } = NativeModules;
|
|
21
24
|
const eventEmitter = new NativeEventEmitter(SoundPlayer);
|
|
@@ -58,6 +61,8 @@ export const CometChatAudioBubble = ({
|
|
|
58
61
|
waveContainerStyle = {},
|
|
59
62
|
playProgressTextStyle = {},
|
|
60
63
|
}: CometChatAudioBubbleInterface) => {
|
|
64
|
+
// The context language: the provider sets the global one in an effect, a render later.
|
|
65
|
+
const { language } = useCometChatTranslation();
|
|
61
66
|
const [status, setStatus] = useState<"playing" | "paused" | "loading" | "">("");
|
|
62
67
|
const [duration, setDuration] = useState(0);
|
|
63
68
|
const [currentTime, setCurrentTime] = useState(0);
|
|
@@ -194,21 +199,22 @@ export const CometChatAudioBubble = ({
|
|
|
194
199
|
|
|
195
200
|
const displayDuration = useCallback(
|
|
196
201
|
() => (
|
|
197
|
-
<Text allowFontScaling={false} style={playProgressTextStyle}>
|
|
198
|
-
{
|
|
199
|
-
Math.floor((currentTime || 0)
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
<Text allowFontScaling={false} style={[PLAYER_TIME_ALIGN, playProgressTextStyle]}>
|
|
203
|
+
{localizeDigits(
|
|
204
|
+
`${String(Math.floor((currentTime || 0) / 60)).padStart(2, "0")}:${String(
|
|
205
|
+
Math.floor((currentTime || 0) % 60)
|
|
206
|
+
).padStart(2, "0")}/${String(Math.floor((duration || 0) / 60)).padStart(2, "0")}:${String(
|
|
207
|
+
Math.floor((duration || 0) % 60)
|
|
208
|
+
).padStart(2, "0")}`,
|
|
209
|
+
language
|
|
210
|
+
)}
|
|
205
211
|
</Text>
|
|
206
212
|
),
|
|
207
|
-
[currentTime, duration]
|
|
213
|
+
[currentTime, duration, language]
|
|
208
214
|
);
|
|
209
215
|
|
|
210
216
|
return (
|
|
211
|
-
<View style={playViewContainerStyle}>
|
|
217
|
+
<View style={[playViewContainerStyle, PLAYER_DIRECTION]}>
|
|
212
218
|
<View
|
|
213
219
|
style={playIconContainerStyle}
|
|
214
220
|
onTouchStart={handleTouchStart}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { useOfflineMediaUri } from '../../offline/useOfflineMediaUri';
|
|
3
|
+
import { isMediaOutOfReach, requestMediaDownload } from '../../offline/media';
|
|
4
|
+
import { MediaOutOfReachNote } from '../../offline/OfflineMediaBubble';
|
|
2
5
|
import {
|
|
3
6
|
GestureResponderEvent,
|
|
4
7
|
ImageStyle,
|
|
@@ -25,6 +28,8 @@ import { CometChatCaptionText } from '../CometChatCaptionText';
|
|
|
25
28
|
import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
|
|
26
29
|
import { ATTACHMENT_COLLAPSED_LIMIT } from '../../constants/UIKitConstants';
|
|
27
30
|
import { AdditionalParams } from "../../base/Types";
|
|
31
|
+
import { PLAYER_DIRECTION, PLAYER_TIME_ALIGN } from "../../helper/layoutDirection";
|
|
32
|
+
import { localizeDigits } from "../../helper/LocalizedDateHelper";
|
|
28
33
|
|
|
29
34
|
const { SoundPlayer, FileManager } = NativeModules;
|
|
30
35
|
const soundEvents = new NativeEventEmitter(SoundPlayer);
|
|
@@ -80,7 +85,9 @@ const AudioFilePlayer = ({
|
|
|
80
85
|
timeTextStyle,
|
|
81
86
|
downloadIconStyle,
|
|
82
87
|
}: AudioFilePlayerProps) => {
|
|
83
|
-
const
|
|
88
|
+
const { t, language } = useCometChatTranslation();
|
|
89
|
+
// Offline ON: play the SDK's cached copy (with an extension AVFoundation accepts); else the URL.
|
|
90
|
+
const url = useOfflineMediaUri(attachment, { playable: true });
|
|
84
91
|
// Dimension tokens (theme spacing): CIRCLE 56 = s14, THUMB 12 = s3, TRACK_H = s2 (8) — a proper
|
|
85
92
|
// seek-bar thickness (s1/4 read as a thin hairline). No raw pixel literals — everything derives
|
|
86
93
|
// from the theme scale.
|
|
@@ -201,6 +208,9 @@ const AudioFilePlayer = ({
|
|
|
201
208
|
};
|
|
202
209
|
|
|
203
210
|
const togglePlay = () => {
|
|
211
|
+
// Offline ON: no copy and no connection, so nothing to play; online, the SDK caches one too.
|
|
212
|
+
if (isMediaOutOfReach(attachment)) return;
|
|
213
|
+
requestMediaDownload(attachment);
|
|
204
214
|
if (status === 'playing') {
|
|
205
215
|
// User pause — the native player is still ours, so a plain resume works later.
|
|
206
216
|
wasInterruptedRef.current = false;
|
|
@@ -275,7 +285,7 @@ const AudioFilePlayer = ({
|
|
|
275
285
|
// Reuse the same native download path as the file/media bubbles.
|
|
276
286
|
const download = () => {
|
|
277
287
|
if (!url) return;
|
|
278
|
-
FileManager?.checkAndDownload?.(url, attachment.getName(), () => {});
|
|
288
|
+
FileManager?.checkAndDownload?.(attachment.getUrl() ?? url, attachment.getName(), () => {});
|
|
279
289
|
};
|
|
280
290
|
|
|
281
291
|
// All colors are theme tokens (no hardcoded literals). Sent = purple bubble, received = neutral.
|
|
@@ -301,12 +311,12 @@ const AudioFilePlayer = ({
|
|
|
301
311
|
|
|
302
312
|
return (
|
|
303
313
|
// No own frame — inherits the shared audio-bubble container from the message-bubble wrapper.
|
|
304
|
-
<View testID="bubble-audio" style={[{ flexDirection: 'row', alignItems: 'center', gap: S.s3 }, containerStyle]}>
|
|
314
|
+
<View testID="bubble-audio" style={[{ flexDirection: 'row', alignItems: 'center', gap: S.s3 }, containerStyle, PLAYER_DIRECTION]}>
|
|
305
315
|
{/* Play/pause circle */}
|
|
306
316
|
<TouchableOpacity
|
|
307
317
|
onPress={togglePlay}
|
|
308
318
|
accessibilityRole="button"
|
|
309
|
-
accessibilityLabel={status === 'playing' ? '
|
|
319
|
+
accessibilityLabel={status === 'playing' ? t('PAUSE_AUDIO') : t('PLAY_AUDIO')}
|
|
310
320
|
style={[{
|
|
311
321
|
width: CIRCLE,
|
|
312
322
|
height: CIRCLE,
|
|
@@ -333,6 +343,7 @@ const AudioFilePlayer = ({
|
|
|
333
343
|
>
|
|
334
344
|
{attachment.getName()}
|
|
335
345
|
</Text>
|
|
346
|
+
<MediaOutOfReachNote attachment={attachment} color={timeColor} />
|
|
336
347
|
|
|
337
348
|
{/* Seek track (draggable) with the download button on its right — design §8.1a */}
|
|
338
349
|
<View style={{ flexDirection: 'row', alignItems: 'center', gap: S.s2, marginTop: S.s0_5 }}>
|
|
@@ -371,7 +382,7 @@ const AudioFilePlayer = ({
|
|
|
371
382
|
onPress={download}
|
|
372
383
|
hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }}
|
|
373
384
|
accessibilityRole="button"
|
|
374
|
-
accessibilityLabel="
|
|
385
|
+
accessibilityLabel={t("DOWNLOAD_AUDIO")}
|
|
375
386
|
>
|
|
376
387
|
<Icon name="download-fill" size={S.s5} color={downloadColor as string} imageStyle={downloadIconStyle} />
|
|
377
388
|
</TouchableOpacity>
|
|
@@ -379,9 +390,9 @@ const AudioFilePlayer = ({
|
|
|
379
390
|
|
|
380
391
|
<Text
|
|
381
392
|
allowFontScaling={false}
|
|
382
|
-
style={[{ ...theme.typography.caption2.regular, color: timeColor, marginTop: S.s0_5 }, timeTextStyle]}
|
|
393
|
+
style={[PLAYER_TIME_ALIGN, { ...theme.typography.caption2.regular, color: timeColor, marginTop: S.s0_5 }, timeTextStyle]}
|
|
383
394
|
>
|
|
384
|
-
{`${fmt(displayCur)}/${fmt(duration)}
|
|
395
|
+
{localizeDigits(`${fmt(displayCur)}/${fmt(duration)}`, language)}
|
|
385
396
|
</Text>
|
|
386
397
|
</View>
|
|
387
398
|
</View>
|
|
@@ -407,6 +418,7 @@ const AudioFileCard = ({
|
|
|
407
418
|
fileNameStyle,
|
|
408
419
|
downloadIconStyle,
|
|
409
420
|
}: AudioFileCardProps) => {
|
|
421
|
+
const { t } = useCometChatTranslation();
|
|
410
422
|
const S = theme.spacing.spacing;
|
|
411
423
|
const url = attachment.getUrl();
|
|
412
424
|
const nameColor = isSentByMe ? theme.color.sendBubbleText : theme.color.receiveBubbleText;
|
|
@@ -429,7 +441,7 @@ const AudioFileCard = ({
|
|
|
429
441
|
onPress={download}
|
|
430
442
|
hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }}
|
|
431
443
|
accessibilityRole="button"
|
|
432
|
-
accessibilityLabel="
|
|
444
|
+
accessibilityLabel={t("DOWNLOAD_AUDIO")}
|
|
433
445
|
>
|
|
434
446
|
<Icon name="download-fill" size={S.s5} color={downloadColor as string} imageStyle={downloadIconStyle} />
|
|
435
447
|
</TouchableOpacity>
|
|
@@ -3,6 +3,8 @@ import { Text, View, Dimensions } from "react-native";
|
|
|
3
3
|
import { useTheme } from "../../../theme";
|
|
4
4
|
import { deepMerge } from "../../helper/helperFunctions";
|
|
5
5
|
import { BadgeStyle } from "./styles";
|
|
6
|
+
import { localizeDigits } from "../../helper/LocalizedDateHelper";
|
|
7
|
+
import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew/useCometChatTranslationHook";
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Props for the CometChatBadge component.
|
|
@@ -30,6 +32,8 @@ export interface CometChatBadgeProps {
|
|
|
30
32
|
export const CometChatBadge = (props: CometChatBadgeProps) => {
|
|
31
33
|
const { style = {}, count = 0 } = props;
|
|
32
34
|
const theme = useTheme();
|
|
35
|
+
// The context language: the provider sets the global one in an effect, a render later.
|
|
36
|
+
const { language } = useCometChatTranslation();
|
|
33
37
|
|
|
34
38
|
// Merge the theme's badge style with any custom styles provided.
|
|
35
39
|
const badgeStyle = useMemo(() => {
|
|
@@ -40,11 +44,11 @@ export const CometChatBadge = (props: CometChatBadgeProps) => {
|
|
|
40
44
|
const countText: string = useMemo(() => {
|
|
41
45
|
if (Number.isInteger(count)) {
|
|
42
46
|
if ((count as number) === 0) return "";
|
|
43
|
-
if ((count as number) > 999) return "999+";
|
|
44
|
-
return (count as number).toString();
|
|
47
|
+
if ((count as number) > 999) return localizeDigits("999+", language);
|
|
48
|
+
return localizeDigits((count as number).toString(), language);
|
|
45
49
|
}
|
|
46
|
-
return count.toString();
|
|
47
|
-
}, [count]);
|
|
50
|
+
return localizeDigits(count.toString(), language);
|
|
51
|
+
}, [count, language]);
|
|
48
52
|
|
|
49
53
|
// If count is zero or an empty string, do not render the badge.
|
|
50
54
|
if (countText.length === 0) return null;
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
} from "react-native";
|
|
20
20
|
import { SafeAreaInsetsContext } from "react-native-safe-area-context";
|
|
21
21
|
import { useTheme } from "../../../theme";
|
|
22
|
+
import { directionStyle, useComponentLayoutDirection } from "../../helper/layoutDirection";
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Props for the CometChatBottomSheet component.
|
|
@@ -79,6 +80,8 @@ export interface CometChatBottomSheetInterface {
|
|
|
79
80
|
const CometChatBottomSheet = forwardRef(
|
|
80
81
|
(props: CometChatBottomSheetInterface, ref) => {
|
|
81
82
|
const theme = useTheme();
|
|
83
|
+
// Modal content is a new native root: give it the opener's direction (ENG-41333, §4.7).
|
|
84
|
+
const direction = useComponentLayoutDirection();
|
|
82
85
|
const {
|
|
83
86
|
style = {
|
|
84
87
|
maxHeight: Dimensions.get("screen").height * 0.9,
|
|
@@ -171,6 +174,7 @@ const CometChatBottomSheet = forwardRef(
|
|
|
171
174
|
<Animated.View
|
|
172
175
|
testID='BottomSheet.overlay'
|
|
173
176
|
style={{
|
|
177
|
+
...directionStyle(direction),
|
|
174
178
|
flex: 1,
|
|
175
179
|
backgroundColor: overlayAnim.interpolate({
|
|
176
180
|
inputRange: [0, 0.2],
|
|
@@ -194,8 +198,8 @@ const CometChatBottomSheet = forwardRef(
|
|
|
194
198
|
bottom: bottomInset,
|
|
195
199
|
left: 0,
|
|
196
200
|
right: 0,
|
|
197
|
-
|
|
198
|
-
|
|
201
|
+
borderTopStartRadius: 24,
|
|
202
|
+
borderTopEndRadius: 24,
|
|
199
203
|
shadowOffset: { width: 0, height: 6 },
|
|
200
204
|
shadowOpacity: 0.37,
|
|
201
205
|
shadowRadius: 7.49,
|
|
@@ -4,6 +4,7 @@ import { useTheme, useCompTheme } from '../../theme/hook';
|
|
|
4
4
|
import { CometChatTheme } from '../../theme/type';
|
|
5
5
|
import { deepMerge } from '../helper/helperFunctions';
|
|
6
6
|
import { Icon } from '../icons/Icon';
|
|
7
|
+
import { useCometChatTranslation } from '../resources/CometChatLocalizeNew';
|
|
7
8
|
|
|
8
9
|
export interface CometChatComposerErrorBannerProps {
|
|
9
10
|
/** Message to show; `null`/empty hides the banner. */
|
|
@@ -27,6 +28,7 @@ export interface CometChatComposerErrorBannerProps {
|
|
|
27
28
|
*/
|
|
28
29
|
export function CometChatComposerErrorBanner({ message, onDismiss, style }: CometChatComposerErrorBannerProps) {
|
|
29
30
|
const theme = useTheme();
|
|
31
|
+
const { t } = useCometChatTranslation();
|
|
30
32
|
const compTheme = useCompTheme();
|
|
31
33
|
const s = deepMerge(
|
|
32
34
|
theme.composerErrorBannerStyles ?? {},
|
|
@@ -69,7 +71,7 @@ export function CometChatComposerErrorBanner({ message, onDismiss, style }: Come
|
|
|
69
71
|
onPress={onDismiss}
|
|
70
72
|
hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }}
|
|
71
73
|
accessibilityRole="button"
|
|
72
|
-
accessibilityLabel="
|
|
74
|
+
accessibilityLabel={t("DISMISS")}
|
|
73
75
|
>
|
|
74
76
|
<Icon
|
|
75
77
|
name="close"
|
|
@@ -13,7 +13,9 @@ import {
|
|
|
13
13
|
ViewStyle,
|
|
14
14
|
} from "react-native";
|
|
15
15
|
import { useTheme } from "../../../theme";
|
|
16
|
+
import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
|
|
16
17
|
import { Icon } from "../../icons/Icon";
|
|
18
|
+
import { directionStyle, useComponentLayoutDirection } from "../../helper/layoutDirection";
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* Props for the CometChatConfirmDialog component.
|
|
@@ -101,6 +103,7 @@ export interface CometChatConfirmDialogInterface {
|
|
|
101
103
|
* The rendered confirmation dialog.
|
|
102
104
|
*/
|
|
103
105
|
export const CometChatConfirmDialog = (props: CometChatConfirmDialogInterface) => {
|
|
106
|
+
const { t } = useCometChatTranslation();
|
|
104
107
|
const {
|
|
105
108
|
onConfirm,
|
|
106
109
|
onCancel,
|
|
@@ -118,11 +121,13 @@ export const CometChatConfirmDialog = (props: CometChatConfirmDialogInterface) =
|
|
|
118
121
|
confirmButtonTextStyle = {},
|
|
119
122
|
titleText = "",
|
|
120
123
|
messageText = "",
|
|
121
|
-
cancelButtonText = "
|
|
122
|
-
confirmButtonText = "
|
|
124
|
+
cancelButtonText = t("CANCEL"),
|
|
125
|
+
confirmButtonText = t("DELETE"),
|
|
123
126
|
} = props;
|
|
124
127
|
|
|
125
128
|
const theme = useTheme();
|
|
129
|
+
// Modal content is a new native root: give it the opener's direction (ENG-41333, §4.7).
|
|
130
|
+
const direction = useComponentLayoutDirection();
|
|
126
131
|
|
|
127
132
|
return (
|
|
128
133
|
<Modal
|
|
@@ -132,7 +137,7 @@ export const CometChatConfirmDialog = (props: CometChatConfirmDialogInterface) =
|
|
|
132
137
|
onRequestClose={onCancel}
|
|
133
138
|
onDismiss={onDismiss}
|
|
134
139
|
>
|
|
135
|
-
<Pressable onPress={onCancel} style={styles.wrapper}>
|
|
140
|
+
<Pressable onPress={onCancel} style={[styles.wrapper, directionStyle(direction)]}>
|
|
136
141
|
<View style={[theme.confirmDialogStyles.containerStyle, containerStyle]}>
|
|
137
142
|
{icon && (
|
|
138
143
|
<View style={[theme.confirmDialogStyles.iconContainerStyle, iconContainerStyle]}>
|
|
@@ -141,13 +141,13 @@ const styles = (theme: ReturnType<typeof useTheme>) =>
|
|
|
141
141
|
},
|
|
142
142
|
scrollContent: {
|
|
143
143
|
gap: 8,
|
|
144
|
-
|
|
144
|
+
paddingEnd: 8,
|
|
145
145
|
},
|
|
146
146
|
shimmerChip: {
|
|
147
147
|
height: 36,
|
|
148
148
|
borderRadius: 18,
|
|
149
149
|
backgroundColor: theme.color.background4,
|
|
150
|
-
|
|
150
|
+
marginEnd: 8,
|
|
151
151
|
},
|
|
152
152
|
chip: {
|
|
153
153
|
paddingHorizontal: 16,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import { useTheme } from "../../../theme";
|
|
12
12
|
import { Icon } from "../../icons/Icon";
|
|
13
13
|
import { Emojis } from "./emojis";
|
|
14
|
+
import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
|
|
14
15
|
import Styles from "./style";
|
|
15
16
|
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
|
|
16
17
|
|
|
@@ -92,7 +93,7 @@ const CategoryList: React.FC<CategoryListProps> = React.memo(
|
|
|
92
93
|
<TouchableOpacity
|
|
93
94
|
key={emojiCategory.id}
|
|
94
95
|
onPress={() => onCategorySelected(emojiCategory.id)}
|
|
95
|
-
accessibilityLabel={
|
|
96
|
+
accessibilityLabel={emojiCategory.name}
|
|
96
97
|
accessibilityRole='button'
|
|
97
98
|
>
|
|
98
99
|
<View style={[styles.iconContainer, isActive && styles.activeIcon]}>
|
|
@@ -174,7 +175,8 @@ const CometChatEmojiKeyboard: React.FC<CometChatEmojiKeyboardProps> = ({
|
|
|
174
175
|
|
|
175
176
|
// State for the currently active category and header title.
|
|
176
177
|
const [activeCategory, setActiveCategory] = useState<string | null>(null);
|
|
177
|
-
const
|
|
178
|
+
const { t } = useCometChatTranslation();
|
|
179
|
+
const [headerTitle, setHeaderTitle] = useState(() => t("EMOJI"));
|
|
178
180
|
|
|
179
181
|
// A ref to the FlatList for programmatic scrolling.
|
|
180
182
|
const flatListRef = useRef<FlatList<EmojiItem>>(null);
|
|
@@ -250,7 +252,7 @@ const CometChatEmojiKeyboard: React.FC<CometChatEmojiKeyboardProps> = ({
|
|
|
250
252
|
<TouchableOpacity
|
|
251
253
|
onPress={() => handleEmojiPress(item.char)}
|
|
252
254
|
style={styles.emojiItem}
|
|
253
|
-
accessibilityLabel={
|
|
255
|
+
accessibilityLabel={item.char}
|
|
254
256
|
accessibilityRole='button'
|
|
255
257
|
>
|
|
256
258
|
<Text style={[styles.emojiText, { color: theme.color.primary }]}>{item.char}</Text>
|