@cometchat/chat-uikit-react-native 5.6.0 → 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/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/ios/CometChatKeyboardModule.m +9 -0
- package/ios/CometChatKeyboardModule.swift +71 -0
- package/ios/KeyboardLanguageDirection.swift +24 -0
- package/ios/RichTextEditorView.swift +253 -51
- package/ios/RichTextEditorViewManager.m +1 -0
- package/package.json +1 -1
- 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 +21 -8
- package/src/CometChatCompactMessageComposer/styles.ts +7 -7
- package/src/CometChatConversations/CometChatConversations.tsx +36 -30
- package/src/CometChatConversations/Skeleton.tsx +4 -1
- package/src/CometChatConversations/style.ts +1 -1
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +35 -18
- package/src/CometChatGroupMembers/Skeleton.tsx +4 -1
- package/src/CometChatGroupMembers/style.ts +6 -4
- package/src/CometChatGroups/CometChatGroups.tsx +13 -6
- package/src/CometChatGroups/GroupsStyle.ts +1 -1
- package/src/CometChatGroups/Skeleton.tsx +4 -1
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +44 -30
- package/src/CometChatMessageComposer/styles.tsx +1 -1
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +22 -13
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +8 -1
- package/src/CometChatMessageInformation/Skeleton.tsx +4 -1
- package/src/CometChatMessageList/CometChatMessageList.tsx +97 -128
- 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 +10 -3
- package/src/CometChatNotificationFeed/style.ts +1 -1
- package/src/CometChatNotificationFeed/utils.ts +17 -18
- package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +8 -1
- 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 +14 -11
- package/src/CometChatSavedMessages/style.ts +3 -3
- package/src/CometChatSearch/CometChatSearch.tsx +38 -35
- 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 +11 -7
- package/src/CometChatThreadHeader/Header.tsx +2 -2
- package/src/CometChatUsers/CometChatUsers.tsx +8 -1
- package/src/CometChatUsers/Skeleton.tsx +4 -1
- package/src/CometChatUsers/style.ts +1 -1
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +8 -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 +2 -2
- package/src/index.ts +5 -1
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +17 -0
- package/src/shared/CometChatUiKit/UIKitSettings.ts +8 -0
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +13 -10
- 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 +17 -94
- 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/offline/OfflineViews.tsx +5 -1
- package/src/shared/offline/notices.ts +15 -21
- 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 +50 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +51 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +50 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +51 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +50 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +50 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +50 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +50 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +50 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +58 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +50 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +50 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +50 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +66 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +50 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +50 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +50 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +50 -2
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +13 -12
- package/src/shared/utils/CometChatMessagePreview/style.ts +1 -1
- package/src/shared/utils/MessageUtils.tsx +14 -14
- package/src/shared/utils/PermissionUtil.ts +16 -5
- package/src/shared/utils/attachmentLimits.ts +3 -2
- package/src/shared/utils/conversationUtils.ts +3 -5
- 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/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 +13 -9
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +16 -10
- package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +10 -6
- 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/CometChatFilesBubble/CometChatFilesBubble.tsx +5 -4
- package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +7 -3
- package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +29 -23
- 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 +10 -14
- 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 +16 -11
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +24 -4
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +18 -2
- package/src/shared/views/CometChatNewMessageIndicator/CometChatNewMessageIndicator.tsx +3 -2
- package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +3 -2
- 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/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 +22 -22
- package/src/shared/views/SenderLabel.tsx +41 -0
- package/src/theme/default/default.ts +1 -1
|
@@ -108,7 +108,7 @@ class PermissionUtilIOS {
|
|
|
108
108
|
|
|
109
109
|
async startResourceBasedTask(resources: TPermissibleResources[]) {
|
|
110
110
|
const resourcePermStatuses = await this.get(resources);
|
|
111
|
-
|
|
111
|
+
const denied: TPermissibleResources[] = [];
|
|
112
112
|
for (let i = 0; i < resourcePermStatuses.length; i++) {
|
|
113
113
|
const resourcePermStatus = resourcePermStatuses[i];
|
|
114
114
|
if (
|
|
@@ -118,12 +118,23 @@ class PermissionUtilIOS {
|
|
|
118
118
|
await this.request([resources[i]]);
|
|
119
119
|
[resourcePermStatuses[i]] = await this.get([resources[i]]);
|
|
120
120
|
}
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
// iOS Restricted (Screen Time / MDM) can't be granted in-app either: block it like Denied.
|
|
122
|
+
if (
|
|
123
|
+
resourcePermStatuses[i] === this.status.Denied ||
|
|
124
|
+
resourcePermStatuses[i] === this.status.Restricted
|
|
125
|
+
) {
|
|
126
|
+
denied.push(resources[i]);
|
|
123
127
|
}
|
|
124
128
|
}
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
const allResourcesAllowed = denied.length === 0;
|
|
130
|
+
if (!allResourcesAllowed) {
|
|
131
|
+
// ENG-57317: name what was actually denied (a voice call asks for the microphone only).
|
|
132
|
+
const message = !denied.includes("mic")
|
|
133
|
+
? "CAMERA_PERMISSION"
|
|
134
|
+
: denied.includes("camera")
|
|
135
|
+
? "CAMERA_MICROPHONE_PERMISSION"
|
|
136
|
+
: "MICROPHONE_ACCESS_PERMISSION";
|
|
137
|
+
Alert.alert("", t(message), [
|
|
127
138
|
{
|
|
128
139
|
style: "cancel",
|
|
129
140
|
text: t("CANCEL"),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
+
import { localizeDigits } from '../helper/LocalizedDateHelper';
|
|
2
3
|
import { CometChat } from '@cometchat/chat-sdk-react-native';
|
|
3
4
|
import {
|
|
4
5
|
DEFAULT_MAX_ATTACHMENT_COUNT,
|
|
@@ -103,7 +104,7 @@ export function acceptPickedAttachments<T>(
|
|
|
103
104
|
const remaining = Math.max(0, maxCount - existingCount);
|
|
104
105
|
if (files.length > remaining) {
|
|
105
106
|
// Over the limit → drop the ENTIRE pick (already-staged files are untouched).
|
|
106
|
-
showToast(t('ATTACHMENT_COUNT_EXCEEDED').replace('{max}', String(maxCount)));
|
|
107
|
+
showToast(t('ATTACHMENT_COUNT_EXCEEDED').replace('{max}', localizeDigits(String(maxCount))));
|
|
107
108
|
return [];
|
|
108
109
|
}
|
|
109
110
|
return files;
|
|
@@ -127,7 +128,7 @@ export async function toastAttachmentRejection(
|
|
|
127
128
|
const { fileSizeMax } = await getFileUploadLimits();
|
|
128
129
|
showToast(
|
|
129
130
|
t('ATTACHMENT_SIZE_EXCEEDED')
|
|
130
|
-
.replace('{max}',
|
|
131
|
+
.replace('{max}', localizeDigits(t('FILE_SIZE_MB').replace('{size}', String(Math.round(fileSizeMax / 1024 / 1024)))))
|
|
131
132
|
);
|
|
132
133
|
return;
|
|
133
134
|
}
|
|
@@ -106,16 +106,14 @@ export class CometChatConversationUtils {
|
|
|
106
106
|
|
|
107
107
|
if (lastMessage.getCategory() == "call") {
|
|
108
108
|
let color: ColorValue | undefined = theme?.color?.textSecondary;
|
|
109
|
-
|
|
109
|
+
const isAudio = lastMessage.getType() == "audio";
|
|
110
|
+
let text = t(isAudio ? "VOICE_CALL" : "VIDEO_CALL");
|
|
110
111
|
let iconName: IconName = "phone-incoming-fill";
|
|
111
|
-
if (lastMessage.getType() == "audio") {
|
|
112
|
-
text = "Voice call";
|
|
113
|
-
}
|
|
114
112
|
if (uid === lastMessage.getSender()?.getUid()) {
|
|
115
113
|
iconName = "phone-outgoing-fill";
|
|
116
114
|
} else if ((lastMessage as CometChat.Call).getAction() === "unanswered") {
|
|
117
115
|
color = theme?.color?.error;
|
|
118
|
-
text =
|
|
116
|
+
text = t(isAudio ? "MISSED_VOICE_CALL" : "MISSED_VIDEO_CALL");
|
|
119
117
|
}
|
|
120
118
|
|
|
121
119
|
return getMessagePreviewInternal(iconName, text, {iconColor: color, theme});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Font size for the translated label drawn inside the search file icon (CometChatSearch).
|
|
3
|
+
* The label sits on a front page ~54 units wide; 15 is the design size for "FILE". Longer words
|
|
4
|
+
* (ARCHIVO, BESTAND, FASCICOLO) or wide CJK glyphs shrink so they stay inside the page.
|
|
5
|
+
*/
|
|
6
|
+
export function fileIconFontSize(label: string): number {
|
|
7
|
+
// ponytail: width estimate (CJK ≈ 1em, others ≈ 0.65em bold), not a text measurement.
|
|
8
|
+
const units = [...label].reduce((w, c) => w + (c.charCodeAt(0) >= 0x2e80 ? 1 : 0.65), 0);
|
|
9
|
+
return Math.min(15, 46 / Math.max(units, 1));
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getCometChatTranslation } from "../resources/CometChatLocalizeNew/LocalizationManager";
|
|
2
|
+
import { localizeDigits } from "../helper/LocalizedDateHelper";
|
|
3
|
+
|
|
4
|
+
const t = getCometChatTranslation();
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A file size with its unit in the kit language ("1.5 MB" in English, "١.٥ ميغابايت" in Arabic).
|
|
8
|
+
* `size` is already rounded by the caller; only the unit and the digits change here (the decimal
|
|
9
|
+
* point stays ".").
|
|
10
|
+
*/
|
|
11
|
+
export function fileSizeLabel(
|
|
12
|
+
key: "FILE_SIZE_BYTES" | "FILE_SIZE_KB" | "FILE_SIZE_MB",
|
|
13
|
+
size: string | number
|
|
14
|
+
): string {
|
|
15
|
+
return localizeDigits(t(key).replace("{size}", String(size)));
|
|
16
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { sentenceWithNames, withSentenceDirection } from "../helper/textDirection";
|
|
2
|
+
|
|
3
|
+
// ENG-41314: the sentence for a group member action ("X added Y"), built from the translated
|
|
4
|
+
// template (placeholders ${byName}/${onName}/${role}) or a simple fallback when the key has no
|
|
5
|
+
// translation. Names are isolated and the sentence takes the template's direction. Pure, so it
|
|
6
|
+
// can be tested without the data source.
|
|
7
|
+
//
|
|
8
|
+
// RTL parity (Android GroupActionText.kt): when the logged-in user did the action ("You added
|
|
9
|
+
// Sara") or had it done to them ("Ann added you"), the sentence uses its own template, because the
|
|
10
|
+
// verb changes with the person in most languages. `you` is the actor form, `youTarget` the target
|
|
11
|
+
// form (joined / left have none).
|
|
12
|
+
const ACTIONS: Record<string, { key: string; word: string; needsOn: boolean; you: string; youTarget?: string }> = {
|
|
13
|
+
added: {
|
|
14
|
+
key: "MESSAGE_LIST_ACTION_ADDED", word: "ADDED", needsOn: true,
|
|
15
|
+
you: "MESSAGE_LIST_ACTION_YOU_ADDED", youTarget: "MESSAGE_LIST_ACTION_ADDED_YOU",
|
|
16
|
+
},
|
|
17
|
+
joined: { key: "MESSAGE_LIST_ACTION_JOINED", word: "JOINED", needsOn: false, you: "MESSAGE_LIST_ACTION_YOU_JOINED" },
|
|
18
|
+
left: { key: "MESSAGE_LIST_ACTION_LEFT", word: "LEFT", needsOn: false, you: "MESSAGE_LIST_ACTION_YOU_LEFT" },
|
|
19
|
+
kicked: {
|
|
20
|
+
key: "MESSAGE_LIST_ACTION_KICKED", word: "KICKED", needsOn: true,
|
|
21
|
+
you: "MESSAGE_LIST_ACTION_YOU_KICKED", youTarget: "MESSAGE_LIST_ACTION_KICKED_YOU",
|
|
22
|
+
},
|
|
23
|
+
banned: {
|
|
24
|
+
key: "MESSAGE_LIST_ACTION_BANNED", word: "BANNED", needsOn: true,
|
|
25
|
+
you: "MESSAGE_LIST_ACTION_YOU_BANNED", youTarget: "MESSAGE_LIST_ACTION_BANNED_YOU",
|
|
26
|
+
},
|
|
27
|
+
unbanned: {
|
|
28
|
+
key: "MESSAGE_LIST_ACTION_UNBANNED", word: "UNBANNED", needsOn: true,
|
|
29
|
+
you: "MESSAGE_LIST_ACTION_YOU_UNBANNED", youTarget: "MESSAGE_LIST_ACTION_UNBANNED_YOU",
|
|
30
|
+
},
|
|
31
|
+
scopeChanged: {
|
|
32
|
+
key: "MESSAGE_LIST_ACTION_SCOPE_CHANGED", word: "MADE", needsOn: true,
|
|
33
|
+
you: "MESSAGE_LIST_ACTION_YOU_SCOPE_CHANGED", youTarget: "MESSAGE_LIST_ACTION_SCOPE_CHANGED_YOU",
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Whether the logged-in user did the action (`actor`) or had it done to them (`target`). */
|
|
38
|
+
export type GroupActionSelf = { actor?: boolean; target?: boolean };
|
|
39
|
+
|
|
40
|
+
export function groupActionText(
|
|
41
|
+
action: string,
|
|
42
|
+
by: string | undefined,
|
|
43
|
+
on: string | undefined,
|
|
44
|
+
t: (key: string) => string,
|
|
45
|
+
newScope = "",
|
|
46
|
+
serverText = "",
|
|
47
|
+
self: GroupActionSelf = {}
|
|
48
|
+
): string {
|
|
49
|
+
const translated = (key: string) => {
|
|
50
|
+
const s = t(key);
|
|
51
|
+
return s === key ? undefined : s;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const spec = ACTIONS[action];
|
|
55
|
+
// Server text, not a template: no placeholders to fill.
|
|
56
|
+
if (!spec) return withSentenceDirection(serverText);
|
|
57
|
+
|
|
58
|
+
// The actor form wins when the user is both. translate() already falls back to the kit's English
|
|
59
|
+
// you-form, so the plain template is used only when no bundle at all has the key.
|
|
60
|
+
const youKey = self.actor ? spec.you : self.target ? spec.youTarget : undefined;
|
|
61
|
+
const fallback = action === "scopeChanged"
|
|
62
|
+
? `\${byName} ${t(spec.word)} \${onName} \${role}`
|
|
63
|
+
: spec.needsOn
|
|
64
|
+
? `\${byName} ${t(spec.word)} \${onName}`
|
|
65
|
+
: `\${byName} ${t(spec.word)}`;
|
|
66
|
+
const role = newScope ? t(newScope.toUpperCase()) : "";
|
|
67
|
+
const template = ((youKey && translated(youKey)) || translated(spec.key) || fallback)
|
|
68
|
+
.replace("${role}", role)
|
|
69
|
+
.trim();
|
|
70
|
+
|
|
71
|
+
// A missing name reads "User" in the localized sentence. Not `serverText`: for an SDK-parsed
|
|
72
|
+
// action that is the SDK's English "%s kicked %s" with the empty name left blank.
|
|
73
|
+
const byName = by || "User";
|
|
74
|
+
return sentenceWithNames(template, spec.needsOn ? { byName, onName: on || "User" } : { byName });
|
|
75
|
+
}
|
package/src/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import Markdown from 'react-native-markdown-display';
|
|
|
4
4
|
import { CometChat } from '@cometchat/chat-sdk-react-native';
|
|
5
5
|
import { CometChatCardView } from '@cometchat/cards-react-native';
|
|
6
6
|
import { useTheme } from '../../../theme';
|
|
7
|
+
import { CODE_DIRECTION } from '../../helper/layoutDirection';
|
|
7
8
|
import { CometChatTheme } from '../../../theme/type';
|
|
8
9
|
import { CometChatUIEventHandler, CometChatUIEvents } from '../../events';
|
|
9
10
|
|
|
@@ -56,7 +57,8 @@ const CometChatAIAssistantMessageBubble: React.FC<CometChatAIAssistantMessageBub
|
|
|
56
57
|
backgroundColor: bubbleStyle?.containerStyle?.backgroundColor || 'transparent',
|
|
57
58
|
borderRadius: bubbleStyle?.containerStyle?.borderRadius || theme.spacing.radius.r3,
|
|
58
59
|
minWidth: bubbleStyle?.containerStyle?.minWidth || 90,
|
|
59
|
-
|
|
60
|
+
// Fill the bubble (it gets fillWidth): markdown has no natural width to shrink to.
|
|
61
|
+
alignSelf: bubbleStyle?.containerStyle?.alignSelf || 'stretch',
|
|
60
62
|
maxWidth: '100%',
|
|
61
63
|
overflow: 'hidden',
|
|
62
64
|
...bubbleStyle?.containerStyle,
|
|
@@ -100,6 +102,7 @@ const CometChatAIAssistantMessageBubble: React.FC<CometChatAIAssistantMessageBub
|
|
|
100
102
|
padding: theme.spacing.padding.p0_5,
|
|
101
103
|
},
|
|
102
104
|
code_block: {
|
|
105
|
+
...CODE_DIRECTION,
|
|
103
106
|
backgroundColor: theme.color.background3,
|
|
104
107
|
color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
|
|
105
108
|
borderRadius: theme.spacing.radius.r2,
|
|
@@ -107,6 +110,7 @@ const CometChatAIAssistantMessageBubble: React.FC<CometChatAIAssistantMessageBub
|
|
|
107
110
|
fontFamily: 'monospace',
|
|
108
111
|
},
|
|
109
112
|
fence: {
|
|
113
|
+
...CODE_DIRECTION,
|
|
110
114
|
backgroundColor: theme.color.background3,
|
|
111
115
|
color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
|
|
112
116
|
borderRadius: theme.spacing.radius.r2,
|
|
@@ -137,7 +141,7 @@ const CometChatAIAssistantMessageBubble: React.FC<CometChatAIAssistantMessageBub
|
|
|
137
141
|
padding: 0,
|
|
138
142
|
},
|
|
139
143
|
th: {
|
|
140
|
-
|
|
144
|
+
borderEndWidth: 1,
|
|
141
145
|
borderBottomWidth: 1,
|
|
142
146
|
borderColor: theme.color.borderDefault,
|
|
143
147
|
backgroundColor: theme.color.background3,
|
|
@@ -148,10 +152,10 @@ const CometChatAIAssistantMessageBubble: React.FC<CometChatAIAssistantMessageBub
|
|
|
148
152
|
fontSize: bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize,
|
|
149
153
|
margin: 0,
|
|
150
154
|
borderTopWidth: 0,
|
|
151
|
-
|
|
155
|
+
borderStartWidth: 0,
|
|
152
156
|
},
|
|
153
157
|
td: {
|
|
154
|
-
|
|
158
|
+
borderEndWidth: 1,
|
|
155
159
|
borderBottomWidth: 1,
|
|
156
160
|
borderColor: theme.color.borderDefault,
|
|
157
161
|
backgroundColor: theme.color.background1,
|
|
@@ -161,7 +165,7 @@ const CometChatAIAssistantMessageBubble: React.FC<CometChatAIAssistantMessageBub
|
|
|
161
165
|
fontSize: bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize,
|
|
162
166
|
margin: 0,
|
|
163
167
|
borderTopWidth: 0,
|
|
164
|
-
|
|
168
|
+
borderStartWidth: 0,
|
|
165
169
|
},
|
|
166
170
|
tr: {
|
|
167
171
|
borderBottomWidth: 0,
|
|
@@ -219,9 +223,9 @@ const CometChatAIAssistantMessageBubble: React.FC<CometChatAIAssistantMessageBub
|
|
|
219
223
|
color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
|
|
220
224
|
},
|
|
221
225
|
blockquote: {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
226
|
+
borderStartWidth: 3,
|
|
227
|
+
borderStartColor: theme.color.borderDefault,
|
|
228
|
+
paddingStart: theme.spacing.padding.p2,
|
|
225
229
|
color: theme.color.textSecondary,
|
|
226
230
|
},
|
|
227
231
|
link: {
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import { useTheme } from '../../../theme';
|
|
12
12
|
import { useCompTheme } from '../../../theme/hook';
|
|
13
13
|
import { CometChatTheme } from '../../../theme/type';
|
|
14
|
+
import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
|
|
14
15
|
import { SelectedAttachment } from '../../modals/SelectedAttachment';
|
|
15
16
|
import { deepMerge } from '../../helper/helperFunctions';
|
|
16
17
|
|
|
@@ -36,6 +37,7 @@ export const CometChatAttachmentPreviewItem = ({
|
|
|
36
37
|
style,
|
|
37
38
|
}: CometChatAttachmentPreviewItemProps) => {
|
|
38
39
|
const theme = useTheme();
|
|
40
|
+
const { t } = useCometChatTranslation();
|
|
39
41
|
const compTheme = useCompTheme();
|
|
40
42
|
const s = deepMerge(
|
|
41
43
|
theme.attachmentPreviewItemStyles ?? {},
|
|
@@ -197,7 +199,7 @@ export const CometChatAttachmentPreviewItem = ({
|
|
|
197
199
|
alignItems: 'center',
|
|
198
200
|
}}
|
|
199
201
|
accessibilityRole="button"
|
|
200
|
-
accessibilityLabel="
|
|
202
|
+
accessibilityLabel={t("ATTACHMENT_RETRY")}
|
|
201
203
|
>
|
|
202
204
|
<Text style={{ fontSize: theme.typography.heading2.regular.fontSize, color: theme.color.error }}>
|
|
203
205
|
{'⚠'}
|
|
@@ -238,7 +240,7 @@ export const CometChatAttachmentPreviewItem = ({
|
|
|
238
240
|
style={[{
|
|
239
241
|
position: 'absolute',
|
|
240
242
|
top: theme.spacing.spacing.s1,
|
|
241
|
-
|
|
243
|
+
end: theme.spacing.spacing.s1,
|
|
242
244
|
width: theme.spacing.spacing.s4,
|
|
243
245
|
height: theme.spacing.spacing.s4,
|
|
244
246
|
borderRadius: theme.spacing.radius.r2,
|
|
@@ -247,7 +249,7 @@ export const CometChatAttachmentPreviewItem = ({
|
|
|
247
249
|
alignItems: 'center',
|
|
248
250
|
}, s.removeButtonStyle]}
|
|
249
251
|
accessibilityRole="button"
|
|
250
|
-
accessibilityLabel="
|
|
252
|
+
accessibilityLabel={t("ATTACHMENT_REMOVE")}
|
|
251
253
|
>
|
|
252
254
|
<Text
|
|
253
255
|
style={{
|
|
@@ -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,10 +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";
|
|
16
19
|
import { useMediaOutOfReach, useOfflineMediaUri } from '../../offline/useOfflineMediaUri';
|
|
17
20
|
import { mediaActionSource, notifyMediaUnavailable } from '../../offline/media';
|
|
18
21
|
import { MediaOutOfReachLabel } from '../../offline/OfflineViews';
|
|
19
|
-
import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
|
|
20
22
|
|
|
21
23
|
export interface CometChatAttachmentViewerProps {
|
|
22
24
|
attachments: CometChat.Attachment[];
|
|
@@ -33,9 +35,9 @@ const { FileManager } = NativeModules;
|
|
|
33
35
|
|
|
34
36
|
function formatFileSize(bytes: number): string {
|
|
35
37
|
if (!(bytes > 0)) return ''; // undefined / 0 / NaN → show nothing (not "undefined B")
|
|
36
|
-
if (bytes >= 1_048_576) return
|
|
37
|
-
if (bytes >= 1_024) return
|
|
38
|
-
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);
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
function formatSentAt(sentAt: number): string {
|
|
@@ -53,12 +55,14 @@ export const CometChatAttachmentViewer = ({
|
|
|
53
55
|
onClose,
|
|
54
56
|
visible = true,
|
|
55
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();
|
|
56
61
|
const [currentIndex, setCurrentIndex] = useState(initialIndex);
|
|
57
62
|
const [imageLoaded, setImageLoaded] = useState(false);
|
|
58
63
|
const [downloadState, setDownloadState] = useState<DownloadState>('IDLE');
|
|
59
64
|
|
|
60
65
|
const current = attachments[currentIndex];
|
|
61
|
-
const { t } = useCometChatTranslation();
|
|
62
66
|
// Offline ON: the saved file for display, download and Share; the URL as today otherwise.
|
|
63
67
|
const currentUri = useOfflineMediaUri(current);
|
|
64
68
|
const outOfReachRaw = useMediaOutOfReach(current);
|
|
@@ -137,14 +141,14 @@ export const CometChatAttachmentViewer = ({
|
|
|
137
141
|
onRequestClose={onClose}
|
|
138
142
|
statusBarTranslucent
|
|
139
143
|
>
|
|
140
|
-
<View style={styles.root}>
|
|
144
|
+
<View style={[styles.root, directionStyle(direction)]}>
|
|
141
145
|
{/* Header */}
|
|
142
146
|
<View style={styles.header}>
|
|
143
147
|
<TouchableOpacity
|
|
144
148
|
onPress={onClose}
|
|
145
149
|
style={styles.closeButton}
|
|
146
150
|
accessibilityRole="button"
|
|
147
|
-
accessibilityLabel="
|
|
151
|
+
accessibilityLabel={t("CLOSE")}
|
|
148
152
|
>
|
|
149
153
|
<Icon name="arrow-back-fill" color="#fff" height={22} width={22} />
|
|
150
154
|
</TouchableOpacity>
|
|
@@ -163,7 +167,7 @@ export const CometChatAttachmentViewer = ({
|
|
|
163
167
|
onPress={handleShare}
|
|
164
168
|
style={styles.actionButton}
|
|
165
169
|
accessibilityRole="button"
|
|
166
|
-
accessibilityLabel="
|
|
170
|
+
accessibilityLabel={t("SHARE")}
|
|
167
171
|
>
|
|
168
172
|
<Icon name="share-fill" color="#fff" height={20} width={20} />
|
|
169
173
|
</TouchableOpacity>
|
|
@@ -171,7 +175,7 @@ export const CometChatAttachmentViewer = ({
|
|
|
171
175
|
onPress={handleDownload}
|
|
172
176
|
style={styles.actionButton}
|
|
173
177
|
accessibilityRole="button"
|
|
174
|
-
accessibilityLabel="
|
|
178
|
+
accessibilityLabel={t("DOWNLOAD")}
|
|
175
179
|
disabled={downloadState === 'DOWNLOADING'}
|
|
176
180
|
>
|
|
177
181
|
{downloadState === 'DOWNLOADING' && (
|
|
@@ -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}
|