@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
|
@@ -5,7 +5,7 @@ export const Emojis = [
|
|
|
5
5
|
{
|
|
6
6
|
people: {
|
|
7
7
|
id: "people",
|
|
8
|
-
name
|
|
8
|
+
get name() { return t("SMILEY_PEOPLE"); },
|
|
9
9
|
symbol: "Smileys",
|
|
10
10
|
emojis: {
|
|
11
11
|
grinning: {
|
|
@@ -1704,7 +1704,7 @@ export const Emojis = [
|
|
|
1704
1704
|
{
|
|
1705
1705
|
animals: {
|
|
1706
1706
|
id: "animals_and_nature",
|
|
1707
|
-
name
|
|
1707
|
+
get name() { return t("ANIMALES_NATURE"); },
|
|
1708
1708
|
symbol: "Animals",
|
|
1709
1709
|
emojis: {
|
|
1710
1710
|
dog: {
|
|
@@ -2467,7 +2467,7 @@ export const Emojis = [
|
|
|
2467
2467
|
{
|
|
2468
2468
|
food: {
|
|
2469
2469
|
id: "food_and_drink",
|
|
2470
|
-
name
|
|
2470
|
+
get name() { return t("FOOD_DRINK"); },
|
|
2471
2471
|
symbol: "Food",
|
|
2472
2472
|
emojis: {
|
|
2473
2473
|
green_apple: {
|
|
@@ -2950,7 +2950,7 @@ export const Emojis = [
|
|
|
2950
2950
|
{
|
|
2951
2951
|
activity: {
|
|
2952
2952
|
id: "activity",
|
|
2953
|
-
name
|
|
2953
|
+
get name() { return t("ACTIVITY"); },
|
|
2954
2954
|
symbol: "Activity",
|
|
2955
2955
|
emojis: {
|
|
2956
2956
|
soccer: {
|
|
@@ -3380,7 +3380,7 @@ export const Emojis = [
|
|
|
3380
3380
|
{
|
|
3381
3381
|
travel: {
|
|
3382
3382
|
id: "travel_and_places",
|
|
3383
|
-
name
|
|
3383
|
+
get name() { return t("TRAVEL_PLACES"); },
|
|
3384
3384
|
symbol: "Travel",
|
|
3385
3385
|
emojis: {
|
|
3386
3386
|
red_car: {
|
|
@@ -3876,7 +3876,7 @@ export const Emojis = [
|
|
|
3876
3876
|
{
|
|
3877
3877
|
objects: {
|
|
3878
3878
|
id: "objects",
|
|
3879
|
-
name
|
|
3879
|
+
get name() { return t("OBJECTS"); },
|
|
3880
3880
|
symbol: "Objects",
|
|
3881
3881
|
emojis: {
|
|
3882
3882
|
watch: {
|
|
@@ -4771,7 +4771,7 @@ export const Emojis = [
|
|
|
4771
4771
|
{
|
|
4772
4772
|
symbols: {
|
|
4773
4773
|
id: "symbols",
|
|
4774
|
-
name
|
|
4774
|
+
get name() { return t("SYMBOLS"); },
|
|
4775
4775
|
symbol: "Symbols",
|
|
4776
4776
|
emojis: {
|
|
4777
4777
|
heart: {
|
|
@@ -5931,7 +5931,7 @@ export const Emojis = [
|
|
|
5931
5931
|
{
|
|
5932
5932
|
flags: {
|
|
5933
5933
|
id: "flags",
|
|
5934
|
-
name
|
|
5934
|
+
get name() { return t("FLAGS"); },
|
|
5935
5935
|
symbol: "Flags",
|
|
5936
5936
|
emojis: {
|
|
5937
5937
|
afghanistan: {
|
|
@@ -12,10 +12,10 @@ const Styles = (theme: CometChatTheme) => {
|
|
|
12
12
|
return StyleSheet.create({
|
|
13
13
|
fixedHeader: {
|
|
14
14
|
paddingBottom: 8,
|
|
15
|
-
|
|
15
|
+
paddingStart: 12,
|
|
16
16
|
alignSelf: "flex-start",
|
|
17
17
|
top: 0,
|
|
18
|
-
|
|
18
|
+
start: 0,
|
|
19
19
|
zIndex: 1,
|
|
20
20
|
},
|
|
21
21
|
flatListContent: {
|
|
@@ -6,8 +6,6 @@ import {
|
|
|
6
6
|
ImageStyle,
|
|
7
7
|
NativeEventEmitter,
|
|
8
8
|
NativeModules,
|
|
9
|
-
NativeSyntheticEvent,
|
|
10
|
-
NativeTouchEvent,
|
|
11
9
|
Platform,
|
|
12
10
|
Text,
|
|
13
11
|
TextStyle,
|
|
@@ -127,6 +125,15 @@ export const CometChatFileBubble = ({
|
|
|
127
125
|
}
|
|
128
126
|
} else {
|
|
129
127
|
if (downloadAndOpenFile) {
|
|
128
|
+
if (Platform.OS == "ios") {
|
|
129
|
+
// native openFile downloads without the share sheet that checkAndDownload shows
|
|
130
|
+
setProcessing(true);
|
|
131
|
+
FileManager.openFile(fileUrl, fileName, (result: string) => {
|
|
132
|
+
setProcessing(false);
|
|
133
|
+
if (JSON.parse(result).success == true) setFileExists(true);
|
|
134
|
+
});
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
130
137
|
openFileAfterDownloading.current = true;
|
|
131
138
|
downloadFile();
|
|
132
139
|
}
|
|
@@ -135,7 +142,7 @@ export const CometChatFileBubble = ({
|
|
|
135
142
|
};
|
|
136
143
|
|
|
137
144
|
/**
|
|
138
|
-
*
|
|
145
|
+
* Starts an Android DownloadManager download if not already processing or downloaded.
|
|
139
146
|
*/
|
|
140
147
|
const downloadFile = () => {
|
|
141
148
|
if (processing || fileExists) return; // Do not process if file already exists
|
|
@@ -144,19 +151,9 @@ export const CometChatFileBubble = ({
|
|
|
144
151
|
|
|
145
152
|
setProcessing(true);
|
|
146
153
|
FileManager.checkAndDownload(fileUrl, getFileName(), (result: string) => {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
setProcessing(false);
|
|
151
|
-
setFileExists(true);
|
|
152
|
-
}
|
|
153
|
-
if (openFileAfterDownloading.current) {
|
|
154
|
-
openFile();
|
|
155
|
-
openFileAfterDownloading.current = false;
|
|
156
|
-
}
|
|
157
|
-
} else if (Platform.OS == "android") {
|
|
158
|
-
downloadIdRef.current = JSON.parse(result).downloadId;
|
|
159
|
-
}
|
|
154
|
+
// Android only (iOS downloads through openFile in checkFileExists); the
|
|
155
|
+
// downloadComplete listener opens the file once this downloadId finishes.
|
|
156
|
+
downloadIdRef.current = JSON.parse(result).downloadId;
|
|
160
157
|
});
|
|
161
158
|
};
|
|
162
159
|
|
|
@@ -224,17 +221,6 @@ export const CometChatFileBubble = ({
|
|
|
224
221
|
: {};
|
|
225
222
|
}, []);
|
|
226
223
|
|
|
227
|
-
/**
|
|
228
|
-
* Handler to download the file when the download icon is pressed.
|
|
229
|
-
*
|
|
230
|
-
* @param {NativeSyntheticEvent<NativeTouchEvent>} e - The touch event.
|
|
231
|
-
*/
|
|
232
|
-
const shouldDownload = (e: NativeSyntheticEvent<NativeTouchEvent>) => {
|
|
233
|
-
e.stopPropagation();
|
|
234
|
-
setProcessing(true);
|
|
235
|
-
downloadFile();
|
|
236
|
-
};
|
|
237
|
-
|
|
238
224
|
return (
|
|
239
225
|
<View {...viewProps} style={{ flexDirection: "row", gap: 8 }}>
|
|
240
226
|
<View {...viewPropsForAndroid} style={{ height: 32, width: 32 }}>
|
|
@@ -10,9 +10,14 @@ import {
|
|
|
10
10
|
} from 'react-native';
|
|
11
11
|
import { CometChat } from '@cometchat/chat-sdk-react-native';
|
|
12
12
|
import { CometChatTheme } from '../../../theme/type';
|
|
13
|
+
import { cachedPathOf, isMediaOutOfReach, requestMediaDownload, shouldUseCachedMedia } from '../../offline/media';
|
|
14
|
+
import { sdkConnected } from '../../offline/gate';
|
|
15
|
+
import { MediaOutOfReachNote } from '../../offline/OfflineMediaBubble';
|
|
16
|
+
import { OFFLINE_STRING_KEYS } from '../../offline/notices';
|
|
13
17
|
import { deepMerge } from '../../helper/helperFunctions';
|
|
14
18
|
import { useCompTheme } from '../../../theme/hook';
|
|
15
19
|
import { Icon } from '../../icons/Icon';
|
|
20
|
+
import { fileSizeLabel } from '../../utils/fileSizeLabel';
|
|
16
21
|
import { getFileTypeIcon, ATTACHMENT_COLLAPSED_LIMIT } from '../../constants/UIKitConstants';
|
|
17
22
|
import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
|
|
18
23
|
import { groupAttachments } from '../../utils/groupAttachments';
|
|
@@ -33,15 +38,15 @@ const fileEventEmitter = new NativeEventEmitter(FileManager);
|
|
|
33
38
|
// now-retired multi-section gallery bubble.)
|
|
34
39
|
// ---------------------------------------------------------------------------
|
|
35
40
|
|
|
36
|
-
type DownloadState = 'IDLE' | 'DOWNLOADING' | 'DONE' | 'FAILED';
|
|
41
|
+
type DownloadState = 'IDLE' | 'DOWNLOADING' | 'DONE' | 'FAILED' | 'OUT_OF_REACH';
|
|
37
42
|
|
|
38
43
|
function formatFileSize(bytes?: number): string {
|
|
39
44
|
// Missing/invalid size (e.g. an attachment reconstructed without a size field) → no label,
|
|
40
45
|
// so the row shows just the extension instead of "undefined B".
|
|
41
46
|
if (typeof bytes !== 'number' || !isFinite(bytes) || bytes <= 0) return '';
|
|
42
|
-
if (bytes >= 1_048_576) return
|
|
43
|
-
if (bytes >= 1_024) return
|
|
44
|
-
return
|
|
47
|
+
if (bytes >= 1_048_576) return fileSizeLabel('FILE_SIZE_MB', (bytes / 1_048_576).toFixed(1));
|
|
48
|
+
if (bytes >= 1_024) return fileSizeLabel('FILE_SIZE_KB', Math.round(bytes / 1_024));
|
|
49
|
+
return fileSizeLabel('FILE_SIZE_BYTES', bytes);
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
function getExtension(name: string): string {
|
|
@@ -79,7 +84,7 @@ export function CometChatFilesBubble({
|
|
|
79
84
|
const [expanded, setExpanded] = useState(false);
|
|
80
85
|
const [downloadStates, setDownloadStates] = useState<Record<string, DownloadState>>({});
|
|
81
86
|
// Android's DownloadManager is async — map each downloadId to the file to OPEN once its
|
|
82
|
-
// `downloadComplete` event fires (iOS
|
|
87
|
+
// `downloadComplete` event fires (iOS downloads and opens in one native openFile call).
|
|
83
88
|
const pendingOpensRef = useRef<Record<string, { url: string; name: string; key: string }>>({});
|
|
84
89
|
useEffect(() => {
|
|
85
90
|
if (Platform.OS !== 'android') return;
|
|
@@ -119,12 +124,50 @@ export function CometChatFilesBubble({
|
|
|
119
124
|
const hiddenCount = files.length - ATTACHMENT_COLLAPSED_LIMIT;
|
|
120
125
|
const showExpandButton = files.length > ATTACHMENT_COLLAPSED_LIMIT;
|
|
121
126
|
|
|
127
|
+
/**
|
|
128
|
+
* A copy this kit downloaded earlier opens as usual. The SDK's own copy opens on iOS, where the
|
|
129
|
+
* native module takes a file URL; Android's needs a content URI and the kit has no native code for
|
|
130
|
+
* one, so there it waits for a connection. Nothing to open: "Available when online".
|
|
131
|
+
*/
|
|
132
|
+
const openFileOffline = (file: CometChat.Attachment, key: string) => {
|
|
133
|
+
const name = file.getName();
|
|
134
|
+
const cached = cachedPathOf(file);
|
|
135
|
+
const outOfReach = () => setDownloadStates(prev => ({ ...prev, [key]: 'OUT_OF_REACH' }));
|
|
136
|
+
const opened = () => setDownloadStates(prev => ({ ...prev, [key]: 'DONE' }));
|
|
137
|
+
FileManager?.doesFileExist?.(name, (existResult: string) => {
|
|
138
|
+
let exists = false;
|
|
139
|
+
try { exists = !!JSON.parse(existResult)?.exists; } catch {}
|
|
140
|
+
if (exists) {
|
|
141
|
+
if (Platform.OS === 'android') FileManager?.openFileWithOption?.(name, () => {});
|
|
142
|
+
else FileManager?.openFile?.(file.getUrl(), name, () => {});
|
|
143
|
+
opened();
|
|
144
|
+
} else if (cached && Platform.OS === 'ios') {
|
|
145
|
+
FileManager?.openFile?.(cached, name, (result: string) => {
|
|
146
|
+
let ok = false;
|
|
147
|
+
try { ok = !!JSON.parse(result)?.success; } catch {}
|
|
148
|
+
if (ok) opened();
|
|
149
|
+
else outOfReach();
|
|
150
|
+
});
|
|
151
|
+
} else {
|
|
152
|
+
outOfReach();
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
|
|
122
157
|
const handleDownload = (file: CometChat.Attachment) => {
|
|
123
158
|
const url = file.getUrl();
|
|
124
159
|
const name = file.getName();
|
|
125
160
|
const key = url;
|
|
126
161
|
if ((downloadStates[key] ?? 'IDLE') === 'DOWNLOADING') return;
|
|
127
162
|
|
|
163
|
+
// Offline ON, online, no copy on the device: the SDK caches one too, for later (AC-12.3).
|
|
164
|
+
requestMediaDownload(file);
|
|
165
|
+
// Offline ON, no connection: only what is on the device can open (README §3.8).
|
|
166
|
+
if (shouldUseCachedMedia() && sdkConnected() === false) {
|
|
167
|
+
openFileOffline(file, key);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
128
171
|
// Tap = OPEN the document (mirror CometChatFileBubble — the multi bubble previously only
|
|
129
172
|
// downloaded and never opened, so multi-doc messages "didn't open" after sending). If a local
|
|
130
173
|
// copy already exists, open it immediately; otherwise download first, then open on completion.
|
|
@@ -138,18 +181,19 @@ export function CometChatFilesBubble({
|
|
|
138
181
|
}
|
|
139
182
|
|
|
140
183
|
setDownloadStates(prev => ({ ...prev, [key]: 'DOWNLOADING' }));
|
|
184
|
+
if (Platform.OS === 'ios') {
|
|
185
|
+
// native openFile downloads without the share sheet that checkAndDownload shows
|
|
186
|
+
FileManager?.openFile?.(url, name, (result: string) => {
|
|
187
|
+
let ok = false;
|
|
188
|
+
try { ok = !!JSON.parse(result)?.success; } catch {}
|
|
189
|
+
setDownloadStates(prev => ({ ...prev, [key]: ok ? 'DONE' : 'FAILED' }));
|
|
190
|
+
});
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
141
193
|
FileManager?.checkAndDownload?.(url, name, (result: string) => {
|
|
142
194
|
try {
|
|
143
195
|
const parsed = JSON.parse(result);
|
|
144
|
-
if (
|
|
145
|
-
// iOS resolves the download in this callback — open on success.
|
|
146
|
-
if (parsed.success) {
|
|
147
|
-
FileManager?.openFile?.(url, name, () => {});
|
|
148
|
-
setDownloadStates(prev => ({ ...prev, [key]: 'DONE' }));
|
|
149
|
-
} else {
|
|
150
|
-
setDownloadStates(prev => ({ ...prev, [key]: 'FAILED' }));
|
|
151
|
-
}
|
|
152
|
-
} else if (parsed.downloadId != null) {
|
|
196
|
+
if (parsed.downloadId != null) {
|
|
153
197
|
// Android: DownloadManager is async — the downloadComplete listener opens it.
|
|
154
198
|
pendingOpensRef.current[String(parsed.downloadId)] = { url, name, key };
|
|
155
199
|
} else {
|
|
@@ -198,7 +242,7 @@ export function CometChatFilesBubble({
|
|
|
198
242
|
: { paddingVertical: S.padding.p3, paddingHorizontal: S.padding.p3 }),
|
|
199
243
|
}}
|
|
200
244
|
accessibilityRole="button"
|
|
201
|
-
accessibilityLabel={
|
|
245
|
+
accessibilityLabel={t('DOWNLOAD_FILE_NAMED').replace('{name}', () => file.getName())}
|
|
202
246
|
>
|
|
203
247
|
{/* Colored file type icon */}
|
|
204
248
|
<Icon name={getFileTypeIcon(file.getName())} size={S.spacing.s8} />
|
|
@@ -220,6 +264,12 @@ export function CometChatFilesBubble({
|
|
|
220
264
|
>
|
|
221
265
|
{sizeLabel}
|
|
222
266
|
</Text>
|
|
267
|
+
{dlState === 'OUT_OF_REACH' && !isMediaOutOfReach(file) ? (
|
|
268
|
+
<Text style={{ ...theme.typography.caption2.regular, color: subtextColor, marginTop: S.margin.m0_5 }}>
|
|
269
|
+
{t(OFFLINE_STRING_KEYS.mediaAvailableWhenOnline)}
|
|
270
|
+
</Text>
|
|
271
|
+
) : null}
|
|
272
|
+
<MediaOutOfReachNote attachment={file} color={subtextColor} />
|
|
223
273
|
{dlState === 'FAILED' && (
|
|
224
274
|
<Text
|
|
225
275
|
style={{ ...theme.typography.caption2.regular, color: theme.color.error, marginTop: S.margin.m0_5 }}
|
|
@@ -3,8 +3,12 @@ import { ActivityIndicator, Image, Modal, StyleSheet, TouchableOpacity, View } f
|
|
|
3
3
|
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
|
|
4
4
|
import { ReactNativeZoomableViewWithGestures } from "../../libs/ImageZoom";
|
|
5
5
|
import { Icon } from "../../icons/Icon";
|
|
6
|
+
import { directionStyle, useComponentLayoutDirection, useKitRTL } from "../../helper/layoutDirection";
|
|
6
7
|
|
|
7
8
|
export const ImageViewerModal = ({ imageUrl, isVisible, onClose }: any) => {
|
|
9
|
+
// Modal content is a new native root: give it the opener's direction (ENG-41333, §4.7).
|
|
10
|
+
const direction = useComponentLayoutDirection();
|
|
11
|
+
const isRTL = useKitRTL();
|
|
8
12
|
const [downloaded, setDownloaded] = useState(false);
|
|
9
13
|
const insets = useSafeAreaInsets();
|
|
10
14
|
|
|
@@ -19,7 +23,7 @@ export const ImageViewerModal = ({ imageUrl, isVisible, onClose }: any) => {
|
|
|
19
23
|
return (
|
|
20
24
|
<Modal animationType='slide' transparent={false} visible={isVisible} onRequestClose={onClose}>
|
|
21
25
|
{/* keep SafeAreaView so bottom inset is handled too */}
|
|
22
|
-
<SafeAreaView style={styles.centeredView} edges={["bottom"]}>
|
|
26
|
+
<SafeAreaView style={[styles.centeredView, directionStyle(direction)]} edges={["bottom"]}>
|
|
23
27
|
<View
|
|
24
28
|
style={[
|
|
25
29
|
styles.header,
|
|
@@ -34,8 +38,8 @@ export const ImageViewerModal = ({ imageUrl, isVisible, onClose }: any) => {
|
|
|
34
38
|
style={[
|
|
35
39
|
styles.closeButton,
|
|
36
40
|
{
|
|
37
|
-
//
|
|
38
|
-
|
|
41
|
+
// Clear the rounded corner on the start side (the inset is physical, the margin logical).
|
|
42
|
+
marginStart: Math.max(10, (isRTL ? insets.right : insets.left) + 6),
|
|
39
43
|
},
|
|
40
44
|
]}
|
|
41
45
|
onPress={onClose}
|
|
@@ -2,6 +2,10 @@ import React, { useEffect, useMemo, useState } from 'react';
|
|
|
2
2
|
import { Image, 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 { useMediaOutOfReach, useOfflineMediaUri } from '../../offline/useOfflineMediaUri';
|
|
6
|
+
import { isMediaOutOfReach, requestMediaDownload, shouldUseCachedMedia } from '../../offline/media';
|
|
7
|
+
import { MediaOutOfReachLabel } from '../../offline/OfflineViews';
|
|
8
|
+
import { t as translate } from '../../resources/CometChatLocalizeNew/LocalizationManager';
|
|
5
9
|
import { useTheme } from '../../../theme';
|
|
6
10
|
import { useCompTheme } from '../../../theme/hook';
|
|
7
11
|
import { deepMerge } from '../../helper/helperFunctions';
|
|
@@ -10,6 +14,10 @@ import { CometChatMediaViewer } from '../CometChatMediaViewer';
|
|
|
10
14
|
import { CometChatCaptionText } from '../CometChatCaptionText';
|
|
11
15
|
import { Icon } from '../../icons/Icon';
|
|
12
16
|
import { isImageMime } from '../CometChatMediaViewer/mediaViewerUtils';
|
|
17
|
+
import { localizeDigits } from '../../helper/LocalizedDateHelper';
|
|
18
|
+
import { pinLtr } from '../../helper/textDirection';
|
|
19
|
+
// The hook module itself: the folder index also loads the I18n provider.
|
|
20
|
+
import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew/useCometChatTranslationHook';
|
|
13
21
|
import { AdditionalParams } from "../../base/Types";
|
|
14
22
|
|
|
15
23
|
// ---------------------------------------------------------------------------
|
|
@@ -19,10 +27,10 @@ import { AdditionalParams } from "../../base/Types";
|
|
|
19
27
|
// ---------------------------------------------------------------------------
|
|
20
28
|
|
|
21
29
|
interface BorderRadii {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
topStart?: number;
|
|
31
|
+
topEnd?: number;
|
|
32
|
+
bottomStart?: number;
|
|
33
|
+
bottomEnd?: number;
|
|
26
34
|
}
|
|
27
35
|
|
|
28
36
|
// ---- Cell ----------------------------------------------------------------
|
|
@@ -51,10 +59,25 @@ const ImageCell = ({
|
|
|
51
59
|
overflowTextStyle,
|
|
52
60
|
}: ImageCellProps) => {
|
|
53
61
|
const theme = useTheme();
|
|
62
|
+
const { language } = useCometChatTranslation();
|
|
63
|
+
// Offline ON: the SDK's cached copy when it has one, else the URL (exactly today's with offline off).
|
|
64
|
+
const imageUri = useOfflineMediaUri(attachment);
|
|
54
65
|
// An IMAGE bubble previews images only. A non-image attachment (video/audio/file) OR an image that
|
|
55
66
|
// can't be decoded (unsupported format / dead URL → onError) shows a "no preview" placeholder cell
|
|
56
67
|
// instead of a broken/blank tile.
|
|
57
68
|
const [failed, setFailed] = useState(false);
|
|
69
|
+
// Offline ON: a reconnect or a finished download gets another try at the image.
|
|
70
|
+
const outOfReach = useMediaOutOfReach(attachment);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (!outOfReach && shouldUseCachedMedia()) setFailed(false);
|
|
73
|
+
}, [outOfReach, imageUri]);
|
|
74
|
+
const handlePress = () => {
|
|
75
|
+
// Offline ON: no copy on the device and no connection, so the viewer would only show an error.
|
|
76
|
+
if (isMediaOutOfReach(attachment)) return;
|
|
77
|
+
// Offline ON, online, no copy on the device: ask the SDK for one (AC-12.3).
|
|
78
|
+
if (requestMediaDownload(attachment)) setFailed(false);
|
|
79
|
+
onPress?.();
|
|
80
|
+
};
|
|
58
81
|
const mime = attachment.getMimeType?.() ?? '';
|
|
59
82
|
// Placeholder only for a KNOWN non-image kind (a proper "type/subtype" mime that isn't image/*) or a
|
|
60
83
|
// genuine decode failure (onError). An empty / bare-extension mime — e.g. an optimistic OUTGOING
|
|
@@ -62,16 +85,16 @@ const ImageCell = ({
|
|
|
62
85
|
// image so a valid image never flashes the "no preview" placeholder for a frame before it loads.
|
|
63
86
|
const showPlaceholder = (mime.includes('/') && !isImageMime(mime)) || failed;
|
|
64
87
|
const borderStyle = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
88
|
+
borderTopStartRadius: radii.topStart ?? 0,
|
|
89
|
+
borderTopEndRadius: radii.topEnd ?? 0,
|
|
90
|
+
borderBottomStartRadius: radii.bottomStart ?? 0,
|
|
91
|
+
borderBottomEndRadius: radii.bottomEnd ?? 0,
|
|
69
92
|
};
|
|
70
93
|
|
|
71
94
|
return (
|
|
72
95
|
<TouchableOpacity
|
|
73
96
|
testID={testID}
|
|
74
|
-
onPress={
|
|
97
|
+
onPress={handlePress}
|
|
75
98
|
activeOpacity={0.85}
|
|
76
99
|
style={[{ flex: 1, aspectRatio, overflow: 'hidden' }, borderStyle, cellStyle]}
|
|
77
100
|
accessibilityRole="button"
|
|
@@ -83,10 +106,17 @@ const ImageCell = ({
|
|
|
83
106
|
style={[StyleSheet.absoluteFill, borderStyle, { backgroundColor: theme.color.neutral200, justifyContent: 'center', alignItems: 'center' }]}
|
|
84
107
|
>
|
|
85
108
|
<Icon name="unknown-file-type" size={theme.spacing.spacing.s12} />
|
|
109
|
+
{failed && shouldUseCachedMedia() ? (
|
|
110
|
+
// Offline ON: never downloaded and not reachable now (AC-12.3).
|
|
111
|
+
<MediaOutOfReachLabel
|
|
112
|
+
t={translate}
|
|
113
|
+
textStyle={{ color: theme.color.textSecondary }}
|
|
114
|
+
/>
|
|
115
|
+
) : null}
|
|
86
116
|
</View>
|
|
87
117
|
) : (
|
|
88
118
|
<Image
|
|
89
|
-
source={{ uri:
|
|
119
|
+
source={{ uri: imageUri }}
|
|
90
120
|
style={[StyleSheet.absoluteFill, borderStyle]}
|
|
91
121
|
resizeMode="cover"
|
|
92
122
|
onError={() => setFailed(true)}
|
|
@@ -100,7 +130,8 @@ const ImageCell = ({
|
|
|
100
130
|
style={[StyleSheet.absoluteFill, { backgroundColor: theme.color.mediaOverlay, justifyContent: 'center', alignItems: 'center' }, overflowOverlayStyle]}
|
|
101
131
|
>
|
|
102
132
|
{/* heading1.bold = { fontSize: 24, fontWeight: '700' }; letterSpacing -0.5 is a micro-adjust. */}
|
|
103
|
-
|
|
133
|
+
{/* Android ENG-57501: the language's digits, pinned LTR so RTL never draws "3+". */}
|
|
134
|
+
<Text style={[{ ...theme.typography.heading1.bold, color: theme.color.staticWhite, letterSpacing: -0.5 }, overflowTextStyle]}>{pinLtr(localizeDigits(`+${overflowCount}`, language))}</Text>
|
|
104
135
|
</View>
|
|
105
136
|
)}
|
|
106
137
|
</TouchableOpacity>
|
|
@@ -148,25 +179,25 @@ const ImageGrid = ({
|
|
|
148
179
|
if (count === 1) {
|
|
149
180
|
return (
|
|
150
181
|
<View style={{ flexDirection: 'row' }}>
|
|
151
|
-
{cell(0, {
|
|
182
|
+
{cell(0, { topStart: CORNER, topEnd: CORNER, bottomStart: CORNER, bottomEnd: CORNER }, 4 / 3)}
|
|
152
183
|
</View>
|
|
153
184
|
);
|
|
154
185
|
}
|
|
155
186
|
if (count === 2) {
|
|
156
187
|
return (
|
|
157
188
|
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
158
|
-
{cell(0, {
|
|
159
|
-
{cell(1, {
|
|
189
|
+
{cell(0, { topStart: CORNER, bottomStart: CORNER })}
|
|
190
|
+
{cell(1, { topEnd: CORNER, bottomEnd: CORNER })}
|
|
160
191
|
</View>
|
|
161
192
|
);
|
|
162
193
|
}
|
|
163
194
|
if (count === 3) {
|
|
164
195
|
return (
|
|
165
196
|
<View style={{ gap: GAP }}>
|
|
166
|
-
<View style={{ flexDirection: 'row' }}>{cell(0, {
|
|
197
|
+
<View style={{ flexDirection: 'row' }}>{cell(0, { topStart: CORNER, topEnd: CORNER }, 4 / 3)}</View>
|
|
167
198
|
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
168
|
-
{cell(1, {
|
|
169
|
-
{cell(2, {
|
|
199
|
+
{cell(1, { bottomStart: CORNER })}
|
|
200
|
+
{cell(2, { bottomEnd: CORNER })}
|
|
170
201
|
</View>
|
|
171
202
|
</View>
|
|
172
203
|
);
|
|
@@ -175,12 +206,12 @@ const ImageGrid = ({
|
|
|
175
206
|
return (
|
|
176
207
|
<View style={{ gap: GAP }}>
|
|
177
208
|
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
178
|
-
{cell(0, {
|
|
179
|
-
{cell(1, {
|
|
209
|
+
{cell(0, { topStart: CORNER })}
|
|
210
|
+
{cell(1, { topEnd: CORNER })}
|
|
180
211
|
</View>
|
|
181
212
|
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
182
|
-
{cell(2, {
|
|
183
|
-
{cell(3, {
|
|
213
|
+
{cell(2, { bottomStart: CORNER })}
|
|
214
|
+
{cell(3, { bottomEnd: CORNER })}
|
|
184
215
|
</View>
|
|
185
216
|
</View>
|
|
186
217
|
);
|
|
@@ -190,12 +221,12 @@ const ImageGrid = ({
|
|
|
190
221
|
return (
|
|
191
222
|
<View style={{ gap: GAP }}>
|
|
192
223
|
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
193
|
-
{cell(0, {
|
|
194
|
-
{cell(1, {
|
|
224
|
+
{cell(0, { topStart: CORNER })}
|
|
225
|
+
{cell(1, { topEnd: CORNER })}
|
|
195
226
|
</View>
|
|
196
227
|
<View style={{ flexDirection: 'row', gap: GAP }}>
|
|
197
|
-
{cell(2, {
|
|
198
|
-
{cell(3, {
|
|
228
|
+
{cell(2, { bottomStart: CORNER })}
|
|
229
|
+
{cell(3, { bottomEnd: CORNER }, undefined, overflowCount)}
|
|
199
230
|
</View>
|
|
200
231
|
</View>
|
|
201
232
|
);
|
|
@@ -14,6 +14,9 @@ import { getInlineAudioRecorderStyle } from './style';
|
|
|
14
14
|
import {
|
|
15
15
|
CometChatInlineAudioRecorderProps,
|
|
16
16
|
} from './types';
|
|
17
|
+
import { PLAYER_DIRECTION } from "../../helper/layoutDirection";
|
|
18
|
+
import { localizeDigits } from "../../helper/LocalizedDateHelper";
|
|
19
|
+
import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew/useCometChatTranslationHook";
|
|
17
20
|
|
|
18
21
|
/**
|
|
19
22
|
* Formats duration in milliseconds to MM:SS format.
|
|
@@ -62,6 +65,8 @@ export const CometChatInlineAudioRecorder: React.FC<CometChatInlineAudioRecorder
|
|
|
62
65
|
playIcon,
|
|
63
66
|
}) => {
|
|
64
67
|
const theme = useTheme();
|
|
68
|
+
// The context language: the provider sets the global one in an effect, a render later.
|
|
69
|
+
const { language } = useCometChatTranslation();
|
|
65
70
|
const recorder = useAudioRecorder();
|
|
66
71
|
|
|
67
72
|
// Animation value for the pulsing recording indicator
|
|
@@ -444,28 +449,38 @@ export const CometChatInlineAudioRecorder: React.FC<CometChatInlineAudioRecorder
|
|
|
444
449
|
/>
|
|
445
450
|
</TouchableOpacity>
|
|
446
451
|
|
|
447
|
-
{/*
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
452
|
+
{/* ENG-41316: the player part (play, waveform, time) stays left to right in RTL; the strip
|
|
453
|
+
around it (delete, pause/mic, send) follows the layout (design: Media Recorder, RTL). */}
|
|
454
|
+
<View
|
|
455
|
+
style={[
|
|
456
|
+
styles.player,
|
|
457
|
+
{ gap: (mergedStyle.containerStyle as { gap?: number } | undefined)?.gap ?? 12 },
|
|
458
|
+
PLAYER_DIRECTION,
|
|
459
|
+
]}
|
|
460
|
+
>
|
|
461
|
+
{/* Record/Play Button */}
|
|
462
|
+
{renderRecordPlayButton()}
|
|
463
|
+
|
|
464
|
+
{/* Waveform Visualizer */}
|
|
465
|
+
<View style={styles.waveformContainer}>
|
|
466
|
+
<AudioWaveformVisualizer
|
|
467
|
+
isAnimating={recorder.isRecording}
|
|
468
|
+
isPlaying={recorder.isPlaying}
|
|
469
|
+
playbackProgress={playbackProgress}
|
|
470
|
+
amplitudes={recorder.amplitudes}
|
|
471
|
+
onSeek={handleSeek}
|
|
472
|
+
onSeekStart={handleSeekStart}
|
|
473
|
+
onSeekEnd={handleSeekEnd}
|
|
474
|
+
allowSeeking={allowSeeking}
|
|
475
|
+
style={mergedStyle.waveformStyle}
|
|
476
|
+
/>
|
|
477
|
+
</View>
|
|
464
478
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
479
|
+
{/* Duration Display */}
|
|
480
|
+
<Text style={[styles.duration, mergedStyle.durationTextStyle]}>
|
|
481
|
+
{localizeDigits(displayDuration, language)}
|
|
482
|
+
</Text>
|
|
483
|
+
</View>
|
|
469
484
|
|
|
470
485
|
{/* Pause/Mic Button */}
|
|
471
486
|
{renderPauseMicButton()}
|
|
@@ -517,6 +532,11 @@ const styles = StyleSheet.create({
|
|
|
517
532
|
waveformContainer: {
|
|
518
533
|
flex: 1,
|
|
519
534
|
},
|
|
535
|
+
player: {
|
|
536
|
+
flex: 1,
|
|
537
|
+
flexDirection: 'row',
|
|
538
|
+
alignItems: 'center',
|
|
539
|
+
},
|
|
520
540
|
duration: {
|
|
521
541
|
// Gap handles spacing between elements
|
|
522
542
|
},
|
|
@@ -6,6 +6,10 @@ import {
|
|
|
6
6
|
UseAudioRecorderReturn,
|
|
7
7
|
AudioSegment,
|
|
8
8
|
} from './types';
|
|
9
|
+
import { getCometChatTranslation } from '../../resources/CometChatLocalizeNew/LocalizationManager';
|
|
10
|
+
|
|
11
|
+
// Reads the current language when called, so the alert follows a language change.
|
|
12
|
+
const t = getCometChatTranslation();
|
|
9
13
|
|
|
10
14
|
// Create event emitter for FileManager
|
|
11
15
|
const FileManagerEmitter = new NativeEventEmitter(NativeModules.FileManager);
|
|
@@ -483,15 +487,15 @@ export function useAudioRecorder(): UseAudioRecorderReturn {
|
|
|
483
487
|
const showPermissionAlert = useCallback(() => {
|
|
484
488
|
Alert.alert(
|
|
485
489
|
'',
|
|
486
|
-
'
|
|
490
|
+
t('MICROPHONE_PERMISSION'),
|
|
487
491
|
[
|
|
488
492
|
{
|
|
489
493
|
style: 'cancel',
|
|
490
|
-
text: '
|
|
494
|
+
text: t('CANCEL'),
|
|
491
495
|
},
|
|
492
496
|
{
|
|
493
497
|
style: 'default',
|
|
494
|
-
text: '
|
|
498
|
+
text: t('SETTINGS'),
|
|
495
499
|
onPress: () => {
|
|
496
500
|
Linking.openSettings();
|
|
497
501
|
},
|