@cometchat/chat-uikit-react-native 5.0.1 → 5.1.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.
Files changed (132) hide show
  1. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  3. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  4. package/android/.gradle/7.4/gc.properties +0 -0
  5. package/android/.gradle/vcs-1/gc.properties +0 -0
  6. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +87 -41
  7. package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +10 -0
  8. package/ios/SoundPlayer.m +8 -0
  9. package/lib/CometChatMessageList/CometChatMessageList.js +1 -1
  10. package/lib/CometChatMessageList/CometChatMessageList.js.map +1 -1
  11. package/lib/extensions/Stickers/StickersExtensionDecorator.d.ts +1 -2
  12. package/lib/extensions/Stickers/StickersExtensionDecorator.js +1 -2
  13. package/lib/extensions/Stickers/StickersExtensionDecorator.js.map +1 -1
  14. package/lib/shared/CometChatUiKit/CometChatUIKit.d.ts +2 -1
  15. package/lib/shared/CometChatUiKit/CometChatUIKit.js +2 -1
  16. package/lib/shared/CometChatUiKit/CometChatUIKit.js.map +1 -1
  17. package/lib/shared/index.d.ts +15 -13
  18. package/lib/shared/index.js +30 -12
  19. package/lib/shared/index.js.map +1 -1
  20. package/lib/shared/utils/CometChatMessagePreview/CometChatMessagePreview.d.ts +10 -1
  21. package/lib/shared/utils/CometChatMessagePreview/CometChatMessagePreview.js +8 -0
  22. package/lib/shared/utils/CometChatMessagePreview/CometChatMessagePreview.js.map +1 -1
  23. package/lib/shared/utils/CometChatMessagePreview/MessagePreviewStyle.d.ts +29 -0
  24. package/lib/shared/utils/CometChatMessagePreview/MessagePreviewStyle.js +29 -0
  25. package/lib/shared/utils/CometChatMessagePreview/MessagePreviewStyle.js.map +1 -0
  26. package/lib/shared/utils/CometChatMessagePreview/index.d.ts +2 -1
  27. package/lib/shared/utils/CometChatMessagePreview/index.js +3 -1
  28. package/lib/shared/utils/CometChatMessagePreview/index.js.map +1 -1
  29. package/lib/shared/utils/CometChatMessagePreview/style.d.ts +16 -16
  30. package/lib/shared/utils/MessageUtils.js +11 -10
  31. package/lib/shared/utils/MessageUtils.js.map +1 -1
  32. package/lib/shared/utils/index.d.ts +2 -2
  33. package/lib/shared/utils/index.js +2 -2
  34. package/lib/shared/utils/index.js.map +1 -1
  35. package/lib/theme/context.js +1 -1
  36. package/lib/theme/context.js.map +1 -1
  37. package/lib/theme/default/index.d.ts +6 -0
  38. package/lib/theme/default/index.js +178 -0
  39. package/lib/theme/default/index.js.map +1 -1
  40. package/lib/theme/provider.js +1 -1
  41. package/lib/theme/provider.js.map +1 -1
  42. package/package.json +6 -4
  43. package/react-native-cometchat-ui-kit.podspec +1 -1
  44. package/src/CometChatConversations/CometChatConversations.tsx +34 -29
  45. package/src/CometChatConversations/style.ts +5 -2
  46. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +56 -44
  47. package/src/CometChatGroups/CometChatGroups.tsx +13 -10
  48. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +203 -57
  49. package/src/CometChatMessageComposer/styles.tsx +2 -6
  50. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +8 -48
  51. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +8 -14
  52. package/src/CometChatMessageList/CometChatMessageList.tsx +18 -10
  53. package/src/CometChatMessageList/style.ts +0 -16
  54. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +3 -2
  55. package/src/CometChatUsers/CometChatUsers.tsx +9 -8
  56. package/src/calls/CallUtils.ts +14 -14
  57. package/src/calls/CallingExtensionDecorator.tsx +13 -12
  58. package/src/calls/CometChatCallBubble/CometChatCallBubble.tsx +4 -3
  59. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +15 -12
  60. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +8 -6
  61. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +4 -2
  62. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +7 -6
  63. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +7 -6
  64. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +3 -2
  65. package/src/extensions/MessageTranslation/MessageTranslationBubble.tsx +3 -2
  66. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +26 -17
  67. package/src/extensions/Polls/Polls.tsx +53 -17
  68. package/src/extensions/Polls/PollsDecorator.tsx +5 -3
  69. package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +5 -4
  70. package/src/extensions/Stickers/CometChatStickerKeyboard/hooks.ts +3 -2
  71. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +5 -2
  72. package/src/index.ts +10 -4
  73. package/src/shared/CometChatUiKit/CometChatUIKit.ts +1 -2
  74. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +116 -32
  75. package/src/shared/framework/DataSource.ts +5 -2
  76. package/src/shared/framework/DataSourceDecorator.tsx +4 -4
  77. package/src/shared/framework/MessageDataSource.tsx +178 -46
  78. package/src/shared/helper/LocalizedDateHelper.ts +317 -0
  79. package/src/shared/helper/functions.js +69 -1
  80. package/src/shared/helper/useLocalizedDateHook.tsx +16 -0
  81. package/src/shared/index.ts +7 -2
  82. package/src/shared/resources/CometChatLocalizeNew/CometChatI18nProvider.tsx +106 -0
  83. package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +99 -0
  84. package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizeContext.tsx +15 -0
  85. package/src/shared/resources/CometChatLocalizeNew/LocalizationManager.ts +65 -0
  86. package/src/shared/resources/CometChatLocalizeNew/index.ts +25 -0
  87. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/de/translation.json +10 -1
  88. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/en/translation.json +10 -1
  89. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/es/translation.json +10 -1
  90. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/fr/translation.json +10 -1
  91. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/hi/translation.json +11 -1
  92. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/hu/translation.json +10 -1
  93. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +456 -0
  94. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +456 -0
  95. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +456 -0
  96. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/lt/translation.json +10 -1
  97. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/ms/translation.json +10 -1
  98. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +456 -0
  99. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/pt/translation.json +10 -1
  100. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/ru/translation.json +10 -1
  101. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/sv/translation.json +11 -1
  102. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +456 -0
  103. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/zh/translation.json +11 -1
  104. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/zh-tw/translation.json +10 -1
  105. package/src/shared/resources/CometChatLocalizeNew/type.ts +7 -0
  106. package/src/shared/resources/CometChatLocalizeNew/useCometChatTranslationHook.ts +24 -0
  107. package/src/shared/resources/index.ts +2 -2
  108. package/src/shared/utils/CommonUtils.ts +2 -1
  109. package/src/shared/utils/PermissionUtil.ts +5 -4
  110. package/src/shared/utils/conversationUtils.ts +11 -9
  111. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +8 -5
  112. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +1 -1
  113. package/src/shared/views/CometChatDate/CometChatDate.tsx +17 -14
  114. package/src/shared/views/CometChatDateSeperator/CometChatDateSeparator.tsx +6 -4
  115. package/src/shared/views/CometChatDeletedBubble/CometChatDeletedBubble.tsx +3 -2
  116. package/src/shared/views/CometChatEmojiKeyboard/emojis.ts +11 -8
  117. package/src/shared/views/CometChatList/CometChatList.tsx +5 -4
  118. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPreview/CometChatAudioPreview.tsx +15 -9
  119. package/src/shared/views/CometChatMediaRecorder/CometChatMediaRecorder.tsx +5 -4
  120. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +3 -2
  121. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +7 -6
  122. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +10 -7
  123. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +1 -0
  124. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +24 -47
  125. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +68 -73
  126. package/src/theme/type.ts +0 -2
  127. package/lib/theme/default/default.d.ts +0 -6
  128. package/lib/theme/default/default.js +0 -179
  129. package/lib/theme/default/default.js.map +0 -1
  130. package/src/shared/resources/CometChatLocalize/CometChatLocalize.ts +0 -183
  131. package/src/shared/resources/CometChatLocalize/index.ts +0 -3
  132. package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +0 -447
@@ -18,13 +18,14 @@ import { ChatConfigurator, DataSource, DataSourceDecorator } from "../../shared/
18
18
  import { CometChatMessageComposerAction } from "../../shared/helper/types";
19
19
  import { Icon } from "../../shared/icons/Icon";
20
20
  import { CometChatMessageTemplate } from "../../shared/modals";
21
- import { localize } from "../../shared/resources/CometChatLocalize";
22
21
  import { getMessagePreviewInternal } from "../../shared/utils/MessageUtils";
23
22
  import { DEFAULT_ICONS } from "../../theme/default/resources/icons";
24
23
  import { CometChatTheme } from "../../theme/type";
25
24
  import { CometChatCollaborativeBubble } from "../CollaborativeBubble/CometChatCollaborativeBubble";
26
25
  import { ExtensionConstants, ExtensionTypeConstants } from "../ExtensionConstants";
27
26
  import { getExtensionData } from "../ExtensionModerator";
27
+ import { getCometChatTranslation } from "../../shared";
28
+ const t = getCometChatTranslation();
28
29
 
29
30
  export class CollaborativeDocumentExtensionDecorator extends DataSourceDecorator {
30
31
  documentUrl: string = "v1/create";
@@ -56,7 +57,7 @@ export class CollaborativeDocumentExtensionDecorator extends DataSourceDecorator
56
57
  ) {
57
58
  return getMessagePreviewInternal(
58
59
  "collaborative-document-fill",
59
- localize("CUSTOM_MESSAGE_DOCUMENT"),
60
+ t("CUSTOM_MESSAGE_DOCUMENT"),
60
61
  { theme }
61
62
  );
62
63
  } else {
@@ -100,7 +101,7 @@ export class CollaborativeDocumentExtensionDecorator extends DataSourceDecorator
100
101
  )
101
102
  attachmentOptions.push({
102
103
  id: "document",
103
- title: localize("COLLABORATIVE_DOCUMENT"),
104
+ title: t("COLLABORATIVE_DOCUMENT"),
104
105
  icon: (
105
106
  <Icon
106
107
  name='collaborative-document-icon'
@@ -222,11 +223,11 @@ export class CollaborativeDocumentExtensionDecorator extends DataSourceDecorator
222
223
 
223
224
  return (
224
225
  <CometChatCollaborativeBubble
225
- title={localize("COLLABORATIVE_DOCUMENT")}
226
+ title={t("COLLABORATIVE_DOCUMENT")}
226
227
  titleStyle={_style?.titleStyle}
227
- subtitle={localize("OPEN_DOCUMENT_TO_DRAW")}
228
+ subtitle={t("OPEN_DOCUMENT_TO_DRAW")}
228
229
  subtitleStyle={_style?.subtitleStyle}
229
- buttonText={localize("OPEN_DOCUMENT")}
230
+ buttonText={t("OPEN_DOCUMENT")}
230
231
  icon={
231
232
  <Icon
232
233
  name='collaborative-whiteboard-fill'
@@ -9,7 +9,6 @@ import { CometChatUIEvents, MessageEvents } from "../../shared/events";
9
9
  import { ChatConfigurator } from "../../shared/framework";
10
10
  import { CometChatMessageComposerAction } from "../../shared/helper/types";
11
11
  import { CometChatMessageTemplate } from "../../shared/modals";
12
- import { localize } from "../../shared/resources/CometChatLocalize";
13
12
  import { CometChatCollaborativeBubble } from "../CollaborativeBubble/CometChatCollaborativeBubble";
14
13
  import { ExtensionConstants, ExtensionTypeConstants } from "../ExtensionConstants";
15
14
  import { getExtensionData } from "../ExtensionModerator";
@@ -26,6 +25,8 @@ import { Icon } from "../../shared/icons/Icon";
26
25
  import { getMessagePreviewInternal } from "../../shared/utils/MessageUtils";
27
26
  import { DEFAULT_ICONS } from "../../theme/default/resources/icons";
28
27
  import { CometChatTheme } from "../../theme/type";
28
+ import { getCometChatTranslation } from "../../shared";
29
+ const t = getCometChatTranslation();
29
30
 
30
31
  /**
31
32
  * Extension decorator for Collaborative Whiteboard messages.
@@ -92,7 +93,7 @@ export class CollaborativeWhiteboardExtensionDecorator extends DataSourceDecorat
92
93
  ) {
93
94
  return getMessagePreviewInternal(
94
95
  "collaborative-whiteboard-fill",
95
- localize("COLLABORATIVE_WHITEBOARD"),
96
+ t("COLLABORATIVE_WHITEBOARD"),
96
97
  { theme }
97
98
  );
98
99
  } else {
@@ -155,7 +156,7 @@ export class CollaborativeWhiteboardExtensionDecorator extends DataSourceDecorat
155
156
  ) {
156
157
  attachmentOptions.push({
157
158
  id: "whiteboard",
158
- title: localize("COLLABORATIVE_WHITEBOARD"),
159
+ title: t("COLLABORATIVE_WHITEBOARD"),
159
160
  icon: (
160
161
  <Icon
161
162
  name='collaborative-whiteboard-icon'
@@ -297,11 +298,11 @@ export class CollaborativeWhiteboardExtensionDecorator extends DataSourceDecorat
297
298
 
298
299
  return (
299
300
  <CometChatCollaborativeBubble
300
- title={localize("COLLABORATIVE_WHITEBOARD")}
301
+ title={t("COLLABORATIVE_WHITEBOARD")}
301
302
  titleStyle={_style?.titleStyle}
302
- subtitle={localize("OPEN_WHITEBOARD_TO_DRAW")}
303
+ subtitle={t("OPEN_WHITEBOARD_TO_DRAW")}
303
304
  subtitleStyle={_style?.subtitleStyle}
304
- buttonText={localize("OPEN_WHITEBOARD")}
305
+ buttonText={t("OPEN_WHITEBOARD")}
305
306
  icon={
306
307
  <Icon
307
308
  name='collaborative-whiteboard-fill'
@@ -9,10 +9,10 @@ import {
9
9
  Text,
10
10
  View,
11
11
  } from "react-native";
12
- import { localize } from "../../shared/resources/CometChatLocalize";
13
12
  import { DefaultLinkPreview } from "./resources";
14
13
  import { useTheme } from "../../theme";
15
14
  import { CometChatTheme } from "../../theme/type";
15
+ import { useCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew";
16
16
 
17
17
  /**
18
18
  * Props for the LinkPreviewBubble component.
@@ -52,6 +52,7 @@ export interface LinkPreviewBubbleInterface {
52
52
  export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
53
53
  const { style, link, title, ChildView, image, onPress, description, favicon } = props;
54
54
  const theme = useTheme();
55
+ const {t}=useCometChatTranslation()
55
56
 
56
57
  const _style = style;
57
58
 
@@ -88,7 +89,7 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
88
89
  } else {
89
90
  const opened = await Linking.openURL(link);
90
91
  if (!opened) {
91
- Alert.alert(localize("SOMETHING_WRONG"));
92
+ Alert.alert(t("SOMETHING_WRONG"));
92
93
  }
93
94
  }
94
95
  }
@@ -4,10 +4,10 @@ import {
4
4
  CometChatMentionsFormatter,
5
5
  CometChatTextFormatter,
6
6
  CometChatUrlsFormatter,
7
- localize,
8
7
  } from "../../shared";
9
8
  import { CometChatTextBubble } from "../../shared/views";
10
9
  import { useTheme } from "../../theme";
10
+ import { useCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew";
11
11
 
12
12
  /**
13
13
  * Props for MessageTranslationBubble component.
@@ -54,6 +54,7 @@ export interface MessageTranslationBubbleProps {
54
54
  */
55
55
  export const MessageTranslationBubble: React.FC<MessageTranslationBubbleProps> = (props) => {
56
56
  const theme = useTheme();
57
+ const {t}= useCometChatTranslation()
57
58
 
58
59
  // Destructure the props.
59
60
  const {
@@ -128,7 +129,7 @@ export const MessageTranslationBubble: React.FC<MessageTranslationBubbleProps> =
128
129
  },
129
130
  ]}
130
131
  >
131
- {localize("TEXT_TRANSLATED")}
132
+ {t("TEXT_TRANSLATED")}
132
133
  </Text>
133
134
  </View>
134
135
  );
@@ -1,7 +1,6 @@
1
1
  import { ChatConfigurator, DataSource, DataSourceDecorator } from "../../shared/framework";
2
2
  import { CometChat } from "@cometchat/chat-sdk-react-native";
3
3
  import { CometChatMessageOption } from "../../shared/modals";
4
- import { CometChatLocalize, localize } from "../../shared/resources/CometChatLocalize";
5
4
  import { ExtensionConstants, ExtensionURLs } from "../ExtensionConstants";
6
5
  import React, { JSX } from "react";
7
6
  import {
@@ -9,10 +8,14 @@ import {
9
8
  CometChatTextFormatter,
10
9
  CometChatUIKit,
11
10
  CometChatUrlsFormatter,
11
+ getCurrentLanguage,
12
12
  MentionTextStyle,
13
13
  } from "../../shared";
14
14
  import { AdditionalParams, MessageBubbleAlignmentType } from "../../shared/base/Types";
15
- import { MentionsTargetElement, MessageOptionConstants } from "../../shared/constants/UIKitConstants";
15
+ import {
16
+ MentionsTargetElement,
17
+ MessageOptionConstants,
18
+ } from "../../shared/constants/UIKitConstants";
16
19
  import { CometChatUIEvents, MessageEvents } from "../../shared/events";
17
20
  import { CometChatUIEventHandler } from "../../shared/events/CometChatUIEventHandler/CometChatUIEventHandler";
18
21
  import { messageStatus } from "../../shared/utils/CometChatMessageHelper";
@@ -20,7 +23,11 @@ import { CommonUtils } from "../../shared/utils/CommonUtils";
20
23
  import { MessageTranslationBubble } from "./MessageTranslationBubble";
21
24
  import { CometChatTheme } from "../../theme/type";
22
25
  import { Icon } from "../../shared/icons/Icon";
26
+ import { MentionContext } from "../../shared/framework/MessageDataSource";
23
27
  import { DeepPartial } from "../../shared/helper/types";
28
+ import { getCometChatTranslation } from "../../shared";
29
+
30
+ const t = getCometChatTranslation();
24
31
 
25
32
  /**
26
33
  * Decorator class for handling message translation in the chat application.
@@ -72,7 +79,8 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
72
79
  additionalParams
73
80
  );
74
81
  // Add the translate option to the options list.
75
- !additionalParams?.hideTranslateMessageOption && optionsList.push(this.getTranslateOption(messageObject, theme));
82
+ !additionalParams?.hideTranslateMessageOption &&
83
+ optionsList.push(this.getTranslateOption(messageObject, theme));
76
84
  return optionsList;
77
85
  }
78
86
 
@@ -90,7 +98,7 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
90
98
  ): CometChatMessageOption {
91
99
  return {
92
100
  id: MessageOptionConstants.translateMessage,
93
- title: localize("TRANSLATE"),
101
+ title: t("TRANSLATE"),
94
102
  icon: (
95
103
  <Icon
96
104
  name='translate'
@@ -184,10 +192,11 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
184
192
  * @param {CometChat.TextMessage} message - The text message to be translated.
185
193
  */
186
194
  translateMessage = (message: CometChat.TextMessage) => {
195
+ const language = getCurrentLanguage()
187
196
  const messageId = message.getId();
188
197
  const messageText = message.getText();
189
198
  // Get the target language for translation.
190
- let translateToLanguage = CometChatLocalize.getLocale();
199
+ let translateToLanguage = language
191
200
 
192
201
  // Hide the bottom sheet (if visible).
193
202
  CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.ccToggleBottomSheet, {
@@ -289,31 +298,30 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
289
298
 
290
299
  // Select the appropriate style based on the sender.
291
300
  const _style: Partial<CometChatTheme["textBubbleStyles"]> = isMessageSentByLoggedInUser
292
- ? (theme.messageListStyles.outgoingMessageBubbleStyles.textBubbleStyles as CometChatTheme["textBubbleStyles"])
293
- : (theme.messageListStyles.incomingMessageBubbleStyles.textBubbleStyles as CometChatTheme["textBubbleStyles"]);
301
+ ? (theme.messageListStyles.outgoingMessageBubbleStyles
302
+ .textBubbleStyles as CometChatTheme["textBubbleStyles"])
303
+ : (theme.messageListStyles.incomingMessageBubbleStyles
304
+ .textBubbleStyles as CometChatTheme["textBubbleStyles"]);
294
305
 
295
306
  // Create URL formatter and set properties.
296
307
  let linksTextFormatter = ChatConfigurator.getDataSource().getUrlsFormatter(loggedInUser!);
297
- let mentionsTextFormatter = ChatConfigurator.getDataSource().getMentionsFormatter(loggedInUser!);
308
+ let mentionsTextFormatter = ChatConfigurator.getDataSource().getMentionsFormatter(
309
+ loggedInUser!,
310
+ theme
311
+ );
298
312
  linksTextFormatter.setMessage(message);
299
313
  linksTextFormatter.setId("ccDefaultUrlsFormatterId");
300
314
  linksTextFormatter.setStyle({ linkTextColor: theme.color.receiveBubbleLink });
301
315
  if (isMessageSentByLoggedInUser) {
302
316
  linksTextFormatter.setStyle({ linkTextColor: theme.color.sendBubbleText });
303
317
  }
318
+ mentionsTextFormatter.setContext(isMessageSentByLoggedInUser ? MentionContext.Outgoing : MentionContext.Incoming);
304
319
 
305
320
  // Configure mentions formatter if mentioned users are present.
306
321
  if (!additionalParams?.disableMentions && mentionedUsers && mentionedUsers.length) {
307
322
  mentionsTextFormatter.setLoggedInUser(loggedInUser!);
308
323
  mentionsTextFormatter.setMessage(message);
309
324
  mentionsTextFormatter.setId("ccDefaultMentionFormatterId");
310
- let isUserSentMessage = message.getSender().getUid() == loggedInUser!.getUid();
311
- if (isUserSentMessage) {
312
- mentionsTextFormatter.setMentionsStyle(_style?.mentionsStyle);
313
- } else {
314
- mentionsTextFormatter.setMentionsStyle(_style?.mentionsStyle);
315
- }
316
- mentionsTextFormatter.setTextStyle(_style?.textStyle);
317
325
  }
318
326
 
319
327
  let finalFormatters: CometChatTextFormatter[] = [];
@@ -330,6 +338,7 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
330
338
  formatter.setMessage(message);
331
339
  formatter.setTargetElement(MentionsTargetElement.textbubble);
332
340
  formatter.setLoggedInUser(CometChatUIKit.loggedInUser!);
341
+ formatter.setContext(isMessageSentByLoggedInUser ? "outgoing" : "incoming");
333
342
  }
334
343
  formatter.setMessage(message);
335
344
  finalFormatters.push(CommonUtils.clone(formatter));
@@ -358,8 +367,8 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
358
367
  tempTranslatedMsg
359
368
  ? tempTranslatedMsg[message.getId()]
360
369
  : this.translatedMessage[message.getId()]
361
- ? this.translatedMessage[message.getId()]
362
- : ""
370
+ ? this.translatedMessage[message.getId()]
371
+ : ""
363
372
  }
364
373
  textStyle={_style?.textStyle}
365
374
  textContainerStyle={_style?.textContainerStyle}
@@ -2,6 +2,7 @@ import React, { useEffect, useLayoutEffect, useRef, useState } from "react";
2
2
  import {
3
3
  ActivityIndicator,
4
4
  FlatList,
5
+ InteractionManager,
5
6
  Keyboard,
6
7
  KeyboardAvoidingView,
7
8
  NativeModules,
@@ -16,8 +17,8 @@ import {
16
17
  import { CometChat } from "@cometchat/chat-sdk-react-native";
17
18
  import { commonVars } from "../../shared/base/vars";
18
19
  import { Icon } from "../../shared/icons/Icon";
19
- import { localize } from "../../shared/resources/CometChatLocalize";
20
20
  import { useTheme } from "../../theme";
21
+ import { useCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew";
21
22
 
22
23
  const { CommonUtil } = NativeModules;
23
24
 
@@ -127,9 +128,11 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
127
128
  const [loader, setLoader] = useState(false);
128
129
  const loggedInUser = useRef<CometChat.User | null>(null);
129
130
  const theme = useTheme();
131
+ const {t} =useCometChatTranslation()
130
132
  const answerRefs = useRef<(TextInput | null)[]>([]);
131
133
  const [lastRemovedIndex, setLastRemovedIndex] = useState<number | null>(null);
132
- const [focusedIndex, setFocusedIndex] = useState<number | null>(null);
134
+ const [newlyAddedIndex, setNewlyAddedIndex] = useState<number | null>(null);
135
+ const flatListRef = useRef<FlatList>(null);
133
136
 
134
137
  /**
135
138
  * Validates the poll question and answer inputs.
@@ -138,17 +141,17 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
138
141
  */
139
142
  function validate() {
140
143
  if (!question.trim()) {
141
- setError(localize("INVALID_POLL_QUESTION"));
144
+ setError(t("INVALID_POLL_QUESTION"));
142
145
  return false;
143
146
  }
144
147
  const filledAnswers = answers.filter((item) => item.trim() !== "");
145
148
  const hasEmptyAnswers = answers.some((item) => item.trim() === "");
146
149
  if (filledAnswers.length < 2) {
147
- setError(answerHelpText || localize("INVALID_POLL_OPTION"));
150
+ setError(answerHelpText || t("INVALID_POLL_OPTION"));
148
151
  return false;
149
152
  }
150
153
  if (hasEmptyAnswers) {
151
- setError(answerHelpText || localize("INVALID_POLL_OPTION"));
154
+ setError(answerHelpText || t("INVALID_POLL_OPTION"));
152
155
  return false;
153
156
  }
154
157
  setError("");
@@ -176,7 +179,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
176
179
  .catch((error) => {
177
180
  console.log("poll error", error);
178
181
  setLoader(false);
179
- setError(localize("SOMETHING_WRONG"));
182
+ setError(t("SOMETHING_WRONG"));
180
183
  onError && onError(error);
181
184
  });
182
185
  }
@@ -269,7 +272,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
269
272
  let existingAnswers = [...answers];
270
273
  existingAnswers.push("");
271
274
  setAnswers(existingAnswers);
272
- setFocusedIndex(existingAnswers.length - 1);
275
+ setNewlyAddedIndex(existingAnswers.length - 1);
273
276
  } else {
274
277
  setError("You can only add up to 12 options.");
275
278
  }
@@ -298,6 +301,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
298
301
  answerRefs.current[index] = el;
299
302
  }}
300
303
  value={item}
304
+ autoFocus={index === newlyAddedIndex}
301
305
  onChangeText={(text) => handleAnswerTextChange(text, index)}
302
306
  placeholder={answerPlaceholderText}
303
307
  placeholderTextColor={theme.color.textTertiary}
@@ -340,7 +344,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
340
344
  { color: theme.color.primary, textAlign: "center" },
341
345
  ]}
342
346
  >
343
- {"+ " + (addAnswerText || localize("ADD_OPTIONS"))}
347
+ {"+ " + (addAnswerText || t("ADD_OPTIONS"))}
344
348
  </Text>
345
349
  </TouchableOpacity>
346
350
  );
@@ -357,16 +361,43 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
357
361
  }, [lastRemovedIndex]);
358
362
 
359
363
  useEffect(() => {
360
- if (focusedIndex !== null && answerRefs.current[focusedIndex]) {
361
- answerRefs.current[focusedIndex]?.focus();
362
- setFocusedIndex(null);
364
+ if (newlyAddedIndex !== null) {
365
+ const timer = setTimeout(() => {
366
+ if (answerRefs.current[newlyAddedIndex]) {
367
+ answerRefs.current[newlyAddedIndex]?.focus();
368
+ }
369
+ setNewlyAddedIndex(null);
370
+ }, 50);
371
+
372
+ return () => clearTimeout(timer);
363
373
  }
364
- }, [focusedIndex]);
374
+ return;
375
+ }, [newlyAddedIndex]);
365
376
 
366
377
  useEffect(() => {
367
378
  answerRefs.current = answers.map((_, i) => answerRefs.current[i] || null);
368
379
  }, [answers]);
369
380
 
381
+ useEffect(() => {
382
+ let timer: ReturnType<typeof setTimeout>;
383
+ if (answers.length > 0 && flatListRef.current) {
384
+ timer = setTimeout(() => {
385
+ flatListRef.current?.scrollToEnd({ animated: true });
386
+ }, 50);
387
+ }
388
+ return () => {
389
+ if (timer) clearTimeout(timer);
390
+ };
391
+ }, [answers.length]);
392
+
393
+ useEffect(() => {
394
+ if (answers.length) {
395
+ InteractionManager.runAfterInteractions(() => {
396
+ flatListRef.current?.scrollToEnd({ animated: true });
397
+ });
398
+ }
399
+ }, [answers.length]);
400
+
370
401
  useEffect(() => {
371
402
  let answerslist = new Array(defaultAnswers).fill("");
372
403
  setAnswers(answerslist);
@@ -411,7 +442,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
411
442
  { color: theme.color.iconPrimary, paddingLeft: 10 },
412
443
  ]}
413
444
  >
414
- {title ? title : localize("CREATE_POLL")}
445
+ {title ? title : t("CREATE_POLL")}
415
446
  </Text>
416
447
  </View>
417
448
  {/* Question Input */}
@@ -423,7 +454,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
423
454
  { marginTop: 15, color: theme.color.textPrimary },
424
455
  ]}
425
456
  >
426
- {localize("QUESTION")}
457
+ {t("QUESTION")}
427
458
  </Text>
428
459
  <TextInput
429
460
  value={question}
@@ -448,17 +479,22 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
448
479
  { marginTop: 25, color: theme.color.textPrimary, marginBottom: 2 },
449
480
  ]}
450
481
  >
451
- {localize("OPTIONS")}
482
+ {t("OPTIONS")}
452
483
  </Text>
453
484
  </View>
454
485
  </View>
455
486
  {/* Main Content: Answers list */}
456
487
  <View style={{ flex: 1 }}>
457
488
  <FlatList
489
+ ref={flatListRef}
458
490
  data={answers}
459
491
  keyExtractor={(item, index) => index.toString()}
460
492
  renderItem={renderAnswerItem}
461
- ListFooterComponent={<View style={{ paddingBottom: 20 }}><AddAnswer /></View>}
493
+ ListFooterComponent={
494
+ <View style={{ paddingBottom: 20 }}>
495
+ <AddAnswer />
496
+ </View>
497
+ }
462
498
  removeClippedSubviews={false}
463
499
  keyboardShouldPersistTaps="always"
464
500
  keyboardDismissMode="interactive"
@@ -511,7 +547,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
511
547
  }}
512
548
  >
513
549
  <Text style={[theme.typography.button.medium, { color: theme.color.primaryButtonText }]}>
514
- {localize("CREATE")}
550
+ {t("CREATE")}
515
551
  </Text>
516
552
  </TouchableOpacity>
517
553
  </View>
@@ -4,7 +4,6 @@ import { MessageCategoryConstants, MetadataConstants } from "../../shared/consta
4
4
  import { ChatConfigurator } from "../../shared/framework";
5
5
  import { CometChatMessageComposerAction } from "../../shared/helper/types";
6
6
  import { CometChatMessageTemplate } from "../../shared/modals";
7
- import { localize } from "../../shared/resources/CometChatLocalize";
8
7
  import { ExtensionTypeConstants } from "../ExtensionConstants";
9
8
  import { getExtensionData } from "../ExtensionModerator";
10
9
  import { PollsConfigurationInterface } from "./PollsConfigurations";
@@ -21,6 +20,9 @@ import { getMessagePreviewInternal } from "../../shared/utils/MessageUtils";
21
20
  import { CometChatTheme } from "../../theme/type";
22
21
  import { CometChatCreatePoll } from "./Polls";
23
22
  import { PollsBubble } from "./PollsBubble";
23
+ import { getCometChatTranslation } from "../../shared";
24
+
25
+ const t = getCometChatTranslation();
24
26
 
25
27
  /**
26
28
  *
@@ -87,7 +89,7 @@ export class PollsExtensionDecorator extends DataSourceDecorator {
87
89
  MessageCategoryConstants.custom &&
88
90
  (conversation.getLastMessage() as CometChat.BaseMessage).getDeletedAt() === undefined
89
91
  ) {
90
- return getMessagePreviewInternal("bar-chart-fill", localize("CUSTOM_MESSAGE_POLL"), {
92
+ return getMessagePreviewInternal("bar-chart-fill", t("CUSTOM_MESSAGE_POLL"), {
91
93
  theme,
92
94
  });
93
95
  } else {
@@ -152,7 +154,7 @@ export class PollsExtensionDecorator extends DataSourceDecorator {
152
154
  )
153
155
  attachmentOptions.push({
154
156
  id: "polls",
155
- title: localize("CUSTOM_MESSAGE_POLL"),
157
+ title: t("CUSTOM_MESSAGE_POLL"),
156
158
  icon: <Icon name='poll_icon' color={theme.color.primary} />,
157
159
  CustomView: (user, group, _id, pollsProps) => {
158
160
  return (
@@ -2,7 +2,6 @@ import { CometChat } from "@cometchat/chat-sdk-react-native";
2
2
  import React, { useRef } from "react";
3
3
  import { ActivityIndicator, FlatList, Image, Text, TouchableOpacity, View } from "react-native";
4
4
  import { Icon } from "../../../shared/icons/Icon";
5
- import { localize } from "../../../shared/resources/CometChatLocalize";
6
5
  import { ErrorEmptyView } from "../../../shared/views/ErrorEmptyView/ErrorEmptyView";
7
6
  import { useTheme } from "../../../theme";
8
7
  import { CometChatTheme } from "../../../theme/type";
@@ -10,6 +9,7 @@ import { ExtensionConstants } from "../../ExtensionConstants";
10
9
  import { Hooks } from "./hooks";
11
10
  import { Skeleton } from "./Skeleton";
12
11
  import { Styles } from "./style";
12
+ import { useCometChatTranslation } from "../../../shared/resources/CometChatLocalizeNew";
13
13
 
14
14
  /**
15
15
  * Interface defining the props for CometChatStickerKeyboard component
@@ -98,6 +98,7 @@ export const CometChatStickerKeyboard = (props: CometChatStickerKeyboardInterfac
98
98
  const [loading, setLoading] = React.useState<boolean>(true);
99
99
  const [error, setError] = React.useState<string | null>(null);
100
100
  const theme = useTheme();
101
+ const {t}= useCometChatTranslation()
101
102
  const flatListRef = useRef<FlatList>(null);
102
103
 
103
104
  /**
@@ -142,7 +143,7 @@ export const CometChatStickerKeyboard = (props: CometChatStickerKeyboardInterfac
142
143
  { color: theme.color.textTertiary, textAlign: "center" },
143
144
  ]}
144
145
  >
145
- {localize("SOMETHING_WENT_WRONG")}
146
+ {t("SOMETHING_WENT_WRONG")}
146
147
  </Text>
147
148
  </View>
148
149
  </View>
@@ -162,8 +163,8 @@ export const CometChatStickerKeyboard = (props: CometChatStickerKeyboardInterfac
162
163
  if (stickerList.length === 0) {
163
164
  return (
164
165
  <ErrorEmptyView
165
- title='No Stickers Available'
166
- subTitle='You don’t have any stickers yet.'
166
+ title={t("NO_STICKERS_AVAILABLE")}
167
+ subTitle={t("YOU_DONT_HAVE_STICKERS_YET")}
167
168
  Icon={
168
169
  <Icon
169
170
  containerStyle={{ marginBottom: 10 }}
@@ -2,9 +2,9 @@ import { CometChat } from "@cometchat/chat-sdk-react-native";
2
2
  import React from "react";
3
3
  import { MessageEvents } from "../../../shared/events";
4
4
  import { CometChatUIEventHandler } from "../../../shared/events/CometChatUIEventHandler/CometChatUIEventHandler";
5
- import { localize } from "../../../shared/resources/CometChatLocalize";
6
5
  import { ExtensionConstants, ExtensionURLs } from "../../ExtensionConstants";
7
6
  import { CometChatStickerKeyboardInterface } from "./CometChatStickerKeyboard";
7
+ import { useCometChatTranslation } from "../../../shared/resources/CometChatLocalizeNew";
8
8
 
9
9
  export const Hooks = (
10
10
  props: CometChatStickerKeyboardInterface, // Adjust type based on actual usage
@@ -18,6 +18,7 @@ export const Hooks = (
18
18
  setLoading: React.Dispatch<React.SetStateAction<boolean>>,
19
19
  setError: React.Dispatch<React.SetStateAction<string | null>>,
20
20
  ) => {
21
+ const { t } = useCometChatTranslation();
21
22
  React.useEffect(() => {
22
23
  setLoading(true); // Start loading
23
24
  CometChat.callExtension(ExtensionConstants.stickers, "GET", ExtensionURLs.stickers, {})
@@ -44,7 +45,7 @@ export const Hooks = (
44
45
  })
45
46
  .catch((error) => {
46
47
  console.log(error);
47
- setError(props?.errorText || localize("SOMETHING_WENT_WRONG"));
48
+ setError(props?.errorText || t("SOMETHING_WENT_WRONG"));
48
49
  setLoading(false); // End loading even if there's an error
49
50
  CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageError, error);
50
51
  });
@@ -12,7 +12,6 @@ import { ChatConfigurator, DataSource, DataSourceDecorator } from "../../shared/
12
12
  import { CometChatUIKit } from "../../shared/CometChatUiKit/CometChatUIKit";
13
13
  import { MessageCategoryConstants, ViewAlignment } from "../../shared/constants/UIKitConstants";
14
14
  import { Icon } from "../../shared/icons/Icon";
15
- import { localize } from "../../shared/resources";
16
15
  import { getUnixTimestampInMilliseconds } from "../../shared/utils/CometChatMessageHelper";
17
16
  import { getMessagePreviewInternal } from "../../shared/utils/MessageUtils";
18
17
  import { useTheme } from "../../theme";
@@ -22,6 +21,9 @@ import { CometChatStickerKeyboard } from "./CometChatStickerKeyboard";
22
21
  import { CometChatStickerBubble } from "./StickersBubble";
23
22
  import { StickerConfigurationInterface } from "./StickerConfiguration";
24
23
  import { AdditionalAuxiliaryOptionsParams } from "../../shared/base/Types";
24
+ import { getCometChatTranslation } from "../../shared";
25
+
26
+ const t = getCometChatTranslation();
25
27
 
26
28
  /**
27
29
  * StickerButton Component
@@ -39,6 +41,7 @@ const StickerButton = ({ user, group, id, stickerIconStyle, stickerIcon }: any)
39
41
  const loggedInUser = useRef<CometChat.User | null>(null); // Stores the currently logged-in user.
40
42
  const theme = useTheme(); // Retrieves theme configurations for styling.
41
43
 
44
+
42
45
  /**
43
46
  * Fetches the logged-in user and sets it to `loggedInUser` ref.
44
47
  */
@@ -352,7 +355,7 @@ export class StickersExtensionDecorator extends DataSourceDecorator {
352
355
  message.getCategory() === MessageCategoryConstants.custom &&
353
356
  message.getDeletedAt() === undefined
354
357
  ) {
355
- return getMessagePreviewInternal("sticker-fill", localize("CUSTOM_MESSAGE_STICKER"), {
358
+ return getMessagePreviewInternal("sticker-fill", t("CUSTOM_MESSAGE_STICKER"), {
356
359
  theme,
357
360
  });
358
361
  } else {
package/src/index.ts CHANGED
@@ -32,7 +32,6 @@ import {
32
32
  CometChatListItemInterface,
33
33
  CometChatListStylesInterface,
34
34
  //Resources
35
- CometChatLocalize,
36
35
  CometChatMediaRecorder,
37
36
  CometChatMediaRecorderInterface,
38
37
  CometChatMentionsFormatter,
@@ -77,10 +76,11 @@ import {
77
76
  SelectionMode,
78
77
  SuggestionItem,
79
78
  UIKitSettings,
80
- localize,
81
79
  messageStatus,
82
80
  Icon,
83
81
  MenuItemInterface,
82
+ getCometChatTranslation,
83
+ getCurrentLanguage,
84
84
  } from "./shared";
85
85
 
86
86
  import {
@@ -158,6 +158,7 @@ import {
158
158
 
159
159
  import { CometChatMessageListProps as CometChatMessageListInterface } from "./CometChatMessageList";
160
160
  import { CometChatTheme } from "./theme/type";
161
+ import { getLastSeenTime } from "./shared";
161
162
  export {
162
163
  CallUIEvents,
163
164
  CallingExtension,
@@ -201,7 +202,6 @@ export {
201
202
  //
202
203
  CometChatListItem,
203
204
  //
204
- CometChatLocalize,
205
205
  CometChatMediaRecorder,
206
206
  /* Emoji Keyboard */
207
207
  /* Text Formatters */
@@ -249,13 +249,19 @@ export {
249
249
  SuggestionItem,
250
250
  ThumbnailGenerationExtension,
251
251
  UIKitSettings,
252
- localize,
253
252
  messageStatus,
254
253
  Icon,
254
+ getCometChatTranslation,
255
+ getCurrentLanguage
255
256
  };
256
257
  export { CometChatThemeProvider, useTheme } from "./theme";
257
258
 
259
+ export {CometChatI18nProvider,useCometChatTranslation} from "./shared/resources/CometChatLocalizeNew"
260
+ export {localizedDateHelperInstance,LocalizedDateHelper} from "./shared/helper/LocalizedDateHelper"
261
+ export { useLocalizedDate } from "./shared/helper/useLocalizedDateHook";
262
+
258
263
  export { CometChatMessageHeader } from "./CometChatMessageHeader";
264
+ export {getLastSeenTime}
259
265
 
260
266
  export type {
261
267
  CometChatMessageComposerAction,