@cometchat/chat-uikit-react-native 4.3.2 → 4.3.4

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 (118) hide show
  1. package/android/src/main/AndroidManifest.xml +3 -4
  2. package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +0 -1
  3. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +125 -7
  4. package/android/src/main/java/com/reactnativecometchatuikit/ImageManager.java +1 -1
  5. package/ios/CommonUtil.h +4 -0
  6. package/ios/CommonUtil.m +27 -0
  7. package/package.json +1 -1
  8. package/src/AI/AIAssistBot/AIAssistBotDecorator.tsx +0 -3
  9. package/src/CometChatConversations/CometChatConversations.tsx +151 -66
  10. package/src/CometChatConversations/ConversationsConfiguration.ts +25 -4
  11. package/src/CometChatConversations/style.ts +5 -1
  12. package/src/CometChatConversationsWithMessages/CometChatConversationsWithMessages.tsx +29 -29
  13. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +598 -63
  14. package/src/CometChatMessageComposer/MessageComposerConfiguration.tsx +12 -1
  15. package/src/CometChatMessageComposer/resources/Info.png +0 -0
  16. package/src/CometChatMessageComposer/resources/index.ts +3 -1
  17. package/src/CometChatMessageHeader/listners.ts +0 -2
  18. package/src/CometChatMessageList/CometChatMessageList.tsx +139 -30
  19. package/src/CometChatMessageList/MessageListConfiguration.ts +19 -6
  20. package/src/CometChatMessages/CometChatMessages.tsx +16 -16
  21. package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +41 -3
  22. package/src/calls/CallingExtentionDecorator.tsx +5 -5
  23. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +3 -3
  24. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +2 -0
  25. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +2 -0
  26. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +3 -3
  27. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +3 -3
  28. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +51 -15
  29. package/src/extensions/LinkPreview/LinkPreviewExtentionDecorator.tsx +4 -4
  30. package/src/extensions/MessageTranslation/MessageTranslationBubble.tsx +31 -9
  31. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +83 -6
  32. package/src/extensions/Polls/Polls.tsx +106 -70
  33. package/src/extensions/Polls/PollsDecorator.tsx +3 -2
  34. package/src/extensions/Stickers/CometChatStickerKeyboard/style.ts +3 -3
  35. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +14 -6
  36. package/src/extensions/TextModeration/TextModerationExtensionDecorator.tsx +3 -3
  37. package/src/index.ts +29 -8
  38. package/src/shared/CometChatUiKit/CometChatUIKit.ts +146 -24
  39. package/src/shared/CometChatUiKit/index.ts +1 -1
  40. package/src/shared/base/vars.ts +13 -0
  41. package/src/shared/constants/UIKitConstants.ts +6 -0
  42. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +7 -0
  43. package/src/shared/events/CometChatUIEventHandler/Listener.ts +11 -1
  44. package/src/shared/events/CometChatUIEvents.ts +3 -1
  45. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +380 -0
  46. package/src/shared/formatters/CometChatMentionsFormatter/MentionTextStyle.ts +14 -0
  47. package/src/shared/formatters/CometChatMentionsFormatter/index.ts +7 -0
  48. package/src/shared/formatters/CometChatTextFormatter.ts +253 -0
  49. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +146 -0
  50. package/src/shared/formatters/index.ts +11 -0
  51. package/src/shared/framework/DataSource.ts +21 -16
  52. package/src/shared/framework/DataSourceDecorator.tsx +29 -13
  53. package/src/shared/framework/MessageDataSource.tsx +215 -49
  54. package/src/shared/helper/useKeyboard.tsx +20 -2
  55. package/src/shared/index.ts +31 -11
  56. package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +1040 -0
  57. package/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx +223 -0
  58. package/src/shared/libs/ImageZoom/helper.ts +144 -0
  59. package/src/shared/libs/ImageZoom/index.tsx +13 -0
  60. package/src/shared/libs/ImageZoom/types/index.ts +186 -0
  61. package/src/shared/libs/VideoPlayer/Video.js +0 -24
  62. package/src/shared/libs/VideoPlayerControls/assets/img/back.png +0 -0
  63. package/src/shared/libs/VideoPlayerControls/components/Back/Back.tsx +1 -1
  64. package/src/shared/resources/CometChatLocalize/CometChatLocalize.ts +2 -0
  65. package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +11 -1
  66. package/src/shared/resources/CometChatLocalize/resources/de/translation.json +11 -1
  67. package/src/shared/resources/CometChatLocalize/resources/en/translation.json +10 -1
  68. package/src/shared/resources/CometChatLocalize/resources/es/translation.json +11 -1
  69. package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +11 -1
  70. package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +10 -1
  71. package/src/shared/resources/CometChatLocalize/resources/hu/translation.json +315 -0
  72. package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +11 -1
  73. package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +11 -1
  74. package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +12 -1
  75. package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +11 -1
  76. package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +11 -1
  77. package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +11 -1
  78. package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +11 -1
  79. package/src/shared/resources/CometChatTheme/Palette.ts +16 -0
  80. package/src/shared/utils/InteractiveMessageUtils.ts +39 -1
  81. package/src/shared/utils/NetworkUtils.tsx +5 -0
  82. package/src/shared/utils/PermissionUtil.ts +142 -0
  83. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -0
  84. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +8 -6
  85. package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +5 -1
  86. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +12 -11
  87. package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +70 -22
  88. package/src/shared/views/CometChatImageBubble/assets/index.ts +5 -0
  89. package/src/shared/views/CometChatImageBubble/assets/spineer.png +0 -0
  90. package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +106 -0
  91. package/src/shared/views/CometChatImageViewerModal/index.tsx +1 -0
  92. package/src/shared/views/CometChatImageViewerModal/resources/Back.png +0 -0
  93. package/src/shared/views/CometChatImageViewerModal/resources/index.ts +5 -0
  94. package/src/shared/views/CometChatList/CometChatList.tsx +10 -1
  95. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +3 -2
  96. package/src/shared/views/{CometChatReactionsList/CometChatReactionsList.tsx → CometChatReactionList/CometChatReactionList.tsx} +17 -17
  97. package/src/shared/views/CometChatReactionList/ReactionListConfiguration.tsx +14 -0
  98. package/src/shared/views/CometChatReactionList/index.ts +12 -0
  99. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +3 -3
  100. package/src/shared/views/CometChatSchedulerBubble/CometChatSchedulerBubble.tsx +12 -0
  101. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +64 -0
  102. package/src/shared/views/CometChatSuggestionList/SuggestionItem.ts +48 -0
  103. package/src/shared/views/CometChatSuggestionList/SuggestionListConfiguration.ts +23 -0
  104. package/src/shared/views/CometChatSuggestionList/index.ts +11 -0
  105. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +33 -46
  106. package/src/shared/views/CometChatTextBubble/TextBubbleStyle.ts +0 -14
  107. package/src/shared/views/CometChatTextBubble/index.ts +2 -3
  108. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +6 -4
  109. package/src/shared/views/index.ts +14 -8
  110. package/android/src/main/java/com/reactnativecometchatuikit/VideoManager.java +0 -40
  111. package/src/shared/libs/VideoPlayerControls/assets/img/back@2x.png +0 -0
  112. package/src/shared/libs/VideoPlayerControls/assets/img/back@3x.png +0 -0
  113. package/src/shared/utils/PermissionUtilIOS.ts +0 -104
  114. package/src/shared/views/CometChatReactionsList/ReactionsListConfiguration.tsx +0 -14
  115. package/src/shared/views/CometChatReactionsList/index.ts +0 -12
  116. /package/src/shared/views/{CometChatReactionsList/ReactionsListStyle.tsx → CometChatReactionList/ReactionListStyle.tsx} +0 -0
  117. /package/src/shared/views/{CometChatReactionsList → CometChatReactionList}/resources/Spineer.png +0 -0
  118. /package/src/shared/views/{CometChatReactionsList → CometChatReactionList}/resources/index.ts +0 -0
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  //@ts-ignore
3
3
  import { CometChat } from "@cometchat/chat-sdk-react-native";
4
- import { CometChatMessageTypes, GroupMemberScope, MessageBubbleAlignmentType, MessageCategoryConstants, MessageOptionConstants, MessageTypeConstants } from "../constants/UIKitConstants";
4
+ import { AdditionalBubbleStylingParams, CometChatMessageTypes, GroupMemberScope, MessageBubbleAlignmentType, MessageCategoryConstants, MessageOptionConstants, MessageTypeConstants } from "../constants/UIKitConstants";
5
5
  import { CometChatMessageOption } from "../modals/CometChatMessageOption";
6
6
  import { CometChatMessageTemplate } from "../modals/CometChatMessageTemplate";
7
7
  import { DataSource } from "./DataSource";
@@ -24,6 +24,9 @@ import { CardBubbleStyle } from "../views/CometChatCardBubble/CardBubbleStyle";
24
24
  import { SchedulerMessage } from "../modals/InteractiveData/InteractiveMessage";
25
25
  import { CometChatSchedulerBubble, SchedulerBubbleStyles } from "../views/CometChatSchedulerBubble";
26
26
  import { View } from "react-native";
27
+ import { CommonUtils } from "../utils/CommonUtils";
28
+ import { CometChatUIKit } from "../CometChatUiKit";
29
+ import { CometChatMentionsFormatter, CometChatTextFormatter, CometChatUrlsFormatter, MentionTextStyle } from "../formatters";
27
30
 
28
31
  function isAudioMessage(message: CometChat.BaseMessage): message is CometChat.MediaMessage {
29
32
  return message.getCategory() == CometChat.CATEGORY_MESSAGE &&
@@ -63,7 +66,7 @@ export class MessageDataSource implements DataSource {
63
66
  getEditOption(): CometChatMessageOption {
64
67
  return {
65
68
  id: MessageOptionConstants.editMessage,
66
- title: localize("EDIT_MESSAGE"),
69
+ title: localize("EDIT"),
67
70
  icon: ICONS.EDIT
68
71
  }
69
72
  }
@@ -99,7 +102,7 @@ export class MessageDataSource implements DataSource {
99
102
  getCopyOption(): CometChatMessageOption {
100
103
  return {
101
104
  id: MessageOptionConstants.copyMessage,
102
- title: localize("COPY_MESSAGE"),
105
+ title: localize("COPY"),
103
106
  icon: ICONS.COPY
104
107
  }
105
108
  }
@@ -113,7 +116,7 @@ export class MessageDataSource implements DataSource {
113
116
  getInformationOption(): CometChatMessageOption {
114
117
  return {
115
118
  id: MessageOptionConstants.messageInformation,
116
- title: localize("INFORMATION"),
119
+ title: localize("INFO"),
117
120
  icon: ICONS.INFO
118
121
  }
119
122
  }
@@ -121,31 +124,52 @@ export class MessageDataSource implements DataSource {
121
124
  getPrivateMessageOption(): CometChatMessageOption {
122
125
  return {
123
126
  id: MessageOptionConstants.sendMessagePrivately,
124
- title: localize('SEND_MESSAGE_IN_PRIVATE'),
127
+ title: localize('MESSAGE_PRIVATELY'),
125
128
  icon: ICONS.PRIVATE_MESSAGE
126
129
  }
127
130
  }
128
131
 
129
132
  isSentByMe(loggedInUser: CometChat.User, message: CometChat.BaseMessage) {
133
+ if (!loggedInUser) return false;
130
134
  return loggedInUser.getUid() == message?.getSender()?.getUid();
131
135
  }
132
136
 
133
137
  getTextMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group): CometChatMessageOption[] {
134
- let msgOptions = [];
135
- msgOptions.push(this.getCopyOption());
136
- let _isSentByMe = this.isSentByMe(loggedInUser, messageObject);
137
- let canEdit = false;
138
- if (group) {
139
- canEdit = group['scope'] != GroupMemberScope.participant; //need clarification on why only moderator can edit and not participant or admin.
140
- }
141
- if (_isSentByMe || canEdit)
142
- msgOptions.push(this.getEditOption())
143
138
 
144
- let optionsList: Array<CometChatMessageOption> = ChatConfigurator.dataSource.getCommonOptions(loggedInUser, messageObject, group);
139
+ let messageOptionList: CometChatMessageOption[] = [];
140
+
141
+
145
142
  if (isDeletedMessage(messageObject))
146
- return optionsList;
143
+ return messageOptionList;
144
+
145
+
146
+ if (this.validateOption(loggedInUser, messageObject, group, MessageOptionConstants.replyInThread)) {
147
+ messageOptionList.push(this.getReplyInThreadOption());
148
+ }
149
+
150
+ if (this.validateOption(loggedInUser, messageObject, group, MessageOptionConstants.shareMessage)) {
151
+ messageOptionList.push(this.getShareOption());
152
+ }
153
+
154
+ messageOptionList.push(this.getCopyOption());
147
155
 
148
- return [...msgOptions, ...optionsList];
156
+ if (this.validateOption(loggedInUser, messageObject, group, MessageOptionConstants.editMessage)) {
157
+ messageOptionList.push(this.getEditOption());
158
+ }
159
+
160
+ if (this.validateOption(loggedInUser, messageObject, group, MessageOptionConstants.messageInformation)) {
161
+ messageOptionList.push(this.getInformationOption());
162
+ }
163
+
164
+ if (this.validateOption(loggedInUser, messageObject, group, MessageOptionConstants.deleteMessage)) {
165
+ messageOptionList.push(this.getDeleteOption());
166
+ }
167
+
168
+ if (this.validateOption(loggedInUser, messageObject, group, MessageOptionConstants.sendMessagePrivately)) {
169
+ messageOptionList.push(this.getPrivateMessageOption());
170
+ }
171
+
172
+ return messageOptionList;
149
173
  }
150
174
 
151
175
  getFormMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group): CometChatMessageOption[] {
@@ -194,7 +218,7 @@ export class MessageDataSource implements DataSource {
194
218
  return optionsList;
195
219
  }
196
220
  getMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group): CometChatMessageOption[] {
197
- let optionsList: Array<CometChatMessageOption> = [...ChatConfigurator.dataSource.getCommonOptions(loggedInUser, messageObject, group)];
221
+ let optionsList: Array<CometChatMessageOption> = [];
198
222
  if (isDeletedMessage(messageObject))
199
223
  return optionsList;
200
224
  if (messageObject.getCategory() == MessageCategoryConstants.message) {
@@ -218,41 +242,94 @@ export class MessageDataSource implements DataSource {
218
242
  }
219
243
 
220
244
  }
245
+ else if(messageObject.getCategory() == MessageCategoryConstants.custom){
246
+ optionsList.push(...ChatConfigurator.dataSource.getCommonOptions(loggedInUser, messageObject, group));
247
+ }else if(messageObject.getCategory() == MessageCategoryConstants.interactive){
248
+ let type: string = messageObject.getType();
249
+ switch (type) {
250
+ case MessageTypeConstants.form:
251
+ optionsList.push(...ChatConfigurator.dataSource.getFormMessageOptions(loggedInUser, messageObject, group));
252
+ break;
253
+ case MessageTypeConstants.card:
254
+ optionsList.push(...ChatConfigurator.dataSource.getCardMessageOptions(loggedInUser, messageObject, group));
255
+ break;
256
+ case MessageTypeConstants.scheduler:
257
+ optionsList.push(...ChatConfigurator.dataSource.getSchedulerMessageOptions(loggedInUser, messageObject, group));
258
+ break;
259
+ }
260
+ }
221
261
  return optionsList;
222
262
  }
223
- getCommonOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group): CometChatMessageOption[] {
224
- let optionsList: Array<CometChatMessageOption> = [];
225
- let _isSentByMe = this.isSentByMe(loggedInUser, messageObject);
226
- let canDelete = false;
227
- if (isDeletedMessage(messageObject)) return optionsList;
228
- if ((group?.getScope() != undefined && group?.getScope() != GroupMemberScope.participant) || _isSentByMe) {
229
- canDelete = true;
263
+
264
+
265
+ private validateOption(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group | null, optionId: string): boolean {
266
+
267
+ if (MessageOptionConstants.replyInThread === optionId &&(!messageObject.parentMessageId|| messageObject.parentMessageId === 0)) {
268
+ return true;
230
269
  }
231
- if (!messageObject.getParentMessageId()) {
232
- optionsList.push(this.getReplyInThreadOption());
270
+
271
+ if (MessageOptionConstants.shareMessage === optionId && (messageObject instanceof CometChat.TextMessage || messageObject instanceof CometChat.MediaMessage)) {
272
+ return true;
233
273
  }
234
- if (isTextMessage(messageObject) || isImageMessage(messageObject) || isFileMessage(messageObject) || isVideoMessage(messageObject) || isAudioMessage(messageObject)) {
235
- optionsList.push(this.getShareOption());
274
+
275
+ if (MessageOptionConstants.copyMessage === optionId && messageObject instanceof CometChat.TextMessage) {
276
+ return true;
236
277
  }
237
278
 
238
- if (_isSentByMe && !isDeletedMessage(messageObject)) {
239
- optionsList.push(this.getInformationOption());
240
- // if (!isDeletedMessage(messageObject)) {
241
- // optionsList.push(this.getForwardOption())
242
- // }
279
+ let isSentByMe: boolean = this.isSentByMe(loggedInUser, messageObject);
280
+
281
+ if (MessageOptionConstants.messageInformation === optionId && isSentByMe) {
282
+ return true;
243
283
  }
244
284
 
245
- if (Boolean(group) && !_isSentByMe) {
246
- optionsList.push(this.getPrivateMessageOption());
285
+ let memberIsNotParticipant: boolean = group && (group.owner === loggedInUser.uid || group.scope !== GroupMemberScope.participant);
286
+
287
+ if (MessageOptionConstants.deleteMessage === optionId && (isSentByMe || memberIsNotParticipant)) {
288
+ return true;
247
289
  }
248
290
 
249
- if (_isSentByMe && !isDeletedMessage(messageObject)) {
250
- if (!group || (group && canDelete)) {
251
- optionsList.push(this.getDeleteOption());
252
- }
291
+ if (MessageOptionConstants.editMessage === optionId && (isSentByMe || memberIsNotParticipant)) {
292
+ return true;
253
293
  }
254
294
 
255
- return optionsList;
295
+ if (MessageOptionConstants.copyMessage === optionId && messageObject instanceof CometChat.TextMessage) {
296
+ return true;
297
+ }
298
+
299
+ if (MessageOptionConstants.sendMessagePrivately === optionId && group
300
+ && loggedInUser.getUid() != messageObject.getSender()?.getUid()) {
301
+ return true;
302
+ }
303
+
304
+ return false;
305
+ }
306
+
307
+ getCommonOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group): CometChatMessageOption[] {
308
+ let messageOptionList: CometChatMessageOption[] = [];
309
+
310
+ if (isDeletedMessage(messageObject)) return messageOptionList;
311
+
312
+ if( this.validateOption(loggedInUser, messageObject, group, MessageOptionConstants.replyInThread) ) {
313
+ messageOptionList.push(this.getReplyInThreadOption());
314
+ }
315
+
316
+ if (this.validateOption(loggedInUser, messageObject,group, MessageOptionConstants.shareMessage)) {
317
+ messageOptionList.push(this.getShareOption());
318
+ }
319
+
320
+ if(this.validateOption(loggedInUser, messageObject, group, MessageOptionConstants.messageInformation)) {
321
+ messageOptionList.push(this.getInformationOption());
322
+ }
323
+
324
+ if (this.validateOption(loggedInUser, messageObject, group, MessageOptionConstants.deleteMessage)) {
325
+ messageOptionList.push(this.getDeleteOption());
326
+ }
327
+
328
+ if (this.validateOption(loggedInUser, messageObject, group, MessageOptionConstants.sendMessagePrivately)) {
329
+ messageOptionList.push(this.getPrivateMessageOption());
330
+ }
331
+
332
+ return messageOptionList;
256
333
  }
257
334
 
258
335
  getGroupActionBubble(message: CometChat.BaseMessage, theme: CometChatTheme): JSX.Element {
@@ -305,7 +382,82 @@ export class MessageDataSource implements DataSource {
305
382
  return null;
306
383
  }
307
384
 
308
- getTextMessageBubble(messageText: string, message: CometChat.TextMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme): JSX.Element {
385
+ getTextMessageBubble(messageText: string, message: CometChat.TextMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme, additionalParams?: AdditionalBubbleStylingParams): JSX.Element {
386
+ let loggedInUser = CometChatUIKit.loggedInUser;
387
+ let mentionedUsers = message.getMentionedUsers();
388
+ let textFormatters = [...(additionalParams?.textFormatters || [])] || [];
389
+
390
+ let linksTextFormatter = ChatConfigurator.getDataSource().getUrlsFormatter(loggedInUser);
391
+ linksTextFormatter.setMessage(message);
392
+ linksTextFormatter.setId("ccDefaultUrlsFormatterId")
393
+ textFormatters.push(linksTextFormatter);
394
+
395
+ if (!additionalParams?.disableMentions && mentionedUsers && mentionedUsers.length) {
396
+
397
+ let mentionsTextFormatter = ChatConfigurator.getDataSource().getMentionsFormatter(loggedInUser);
398
+ mentionsTextFormatter.setLoggedInUser(loggedInUser);
399
+ mentionsTextFormatter.setId("ccDefaultMentionFormatterId")
400
+ let isUserSentMessage = alignment === "right";
401
+ if (isUserSentMessage) {
402
+ mentionsTextFormatter.setMentionsStyle(
403
+ new MentionTextStyle({
404
+ loggedInUserTextStyle: {
405
+ color: theme.palette.getTertiary(),
406
+ ...theme.typography.title2,
407
+ fontSize: 16
408
+ },
409
+ textStyle: {
410
+ color: theme.palette.getTertiary(),
411
+ ...theme.typography.subtitle1,
412
+ fontSize: 16
413
+ },
414
+ })
415
+ );
416
+ } else {
417
+ mentionsTextFormatter.setMentionsStyle(
418
+ new MentionTextStyle({
419
+ loggedInUserTextStyle: {
420
+ color: theme.palette.getPrimary(),
421
+ ...theme.typography.title2,
422
+ fontSize: 16
423
+ },
424
+ textStyle: {
425
+ color: theme.palette.getPrimary(),
426
+ ...theme.typography.subtitle1,
427
+ fontSize: 16
428
+ },
429
+ })
430
+ );
431
+ }
432
+
433
+ textFormatters.push(mentionsTextFormatter);
434
+
435
+ }
436
+
437
+ let finalFormatters = [];
438
+
439
+ let customerHasPassedUrlsFormatter;
440
+
441
+ textFormatters.forEach(formatter => {
442
+ if (formatter instanceof CometChatUrlsFormatter) {
443
+ if (formatter.getId() !== "ccDefaultUrlsFormatterId") {
444
+ customerHasPassedUrlsFormatter = true
445
+ }
446
+ }
447
+ formatter.setMessage(message);
448
+ let suggestionUsers = formatter.getSuggestionItems();
449
+ suggestionUsers.length > 0 && formatter.setSuggestionItems(suggestionUsers);
450
+ let _formatter = CommonUtils.clone(formatter);
451
+ finalFormatters.push(_formatter);
452
+ })
453
+
454
+ if (customerHasPassedUrlsFormatter) {
455
+ let customUrlsIndex = finalFormatters.findIndex((formatter: CometChatTextFormatter[]) => (formatter instanceof CometChatUrlsFormatter && formatter.getId() === "ccDefaultUrlsFormatterId"));
456
+ if (customUrlsIndex > -1) {
457
+ finalFormatters.splice(customUrlsIndex, 1);
458
+ }
459
+ }
460
+
309
461
  return <CometChatTextBubble
310
462
  text={messageText}
311
463
  style={{
@@ -314,6 +466,7 @@ export class MessageDataSource implements DataSource {
314
466
  textColor: alignment == "right" ? theme?.palette.getSecondary() : theme?.palette?.getAccent(),
315
467
  borderRadius: 8
316
468
  }}
469
+ textFormatters={finalFormatters}
317
470
  />
318
471
  }
319
472
 
@@ -326,7 +479,7 @@ export class MessageDataSource implements DataSource {
326
479
  }
327
480
 
328
481
  getSchedulerMessageBubble(message: SchedulerMessage, theme: CometChatTheme, style?: SchedulerBubbleStyles, onScheduleClick?: (data: any) => void): JSX.Element {
329
- return <CometChatSchedulerBubble
482
+ return <CometChatSchedulerBubble
330
483
  schedulerMessage={message}
331
484
  onScheduleClick={onScheduleClick}
332
485
  style={style}
@@ -372,8 +525,8 @@ export class MessageDataSource implements DataSource {
372
525
  }
373
526
  return null;
374
527
  }
375
- getTextMessageContentView(message: CometChat.TextMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme): JSX.Element {
376
- return ChatConfigurator.dataSource.getTextMessageBubble(message.getText(), message, alignment, theme);
528
+ getTextMessageContentView(message: CometChat.TextMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme, additionalParams?: AdditionalBubbleStylingParams): JSX.Element {
529
+ return ChatConfigurator.dataSource.getTextMessageBubble(message.getText(), message, alignment, theme, additionalParams);
377
530
  }
378
531
  getFormMessageContentView(message: FormMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme): JSX.Element {
379
532
  return ChatConfigurator.dataSource.getFormMessageBubble(message, theme);
@@ -433,7 +586,7 @@ export class MessageDataSource implements DataSource {
433
586
  , message, theme);
434
587
  }
435
588
 
436
- getTextMessageTemplate(theme: CometChatTheme): CometChatMessageTemplate {
589
+ getTextMessageTemplate(theme: CometChatTheme, additionalParams?: AdditionalBubbleStylingParams): CometChatMessageTemplate {
437
590
  return new CometChatMessageTemplate({
438
591
  type: MessageTypeConstants.text,
439
592
  category: MessageCategoryConstants.message,
@@ -441,7 +594,7 @@ export class MessageDataSource implements DataSource {
441
594
  if (isDeletedMessage(message)) {
442
595
  return ChatConfigurator.dataSource.getDeleteMessageBubble(message, theme);
443
596
  } else {
444
- return ChatConfigurator.dataSource.getTextMessageContentView(message, _alignment, theme);
597
+ return ChatConfigurator.dataSource.getTextMessageContentView(message, _alignment, theme, additionalParams);
445
598
  }
446
599
  },
447
600
  options: (loggedInuser, message, group) => ChatConfigurator.dataSource.getTextMessageOptions(loggedInuser, message, group),
@@ -556,9 +709,9 @@ export class MessageDataSource implements DataSource {
556
709
  });
557
710
  }
558
711
 
559
- getAllMessageTemplates(theme: CometChatTheme): CometChatMessageTemplate[] {
712
+ getAllMessageTemplates(theme: CometChatTheme, additionalParams?: AdditionalBubbleStylingParams): CometChatMessageTemplate[] {
560
713
  return [
561
- ChatConfigurator.dataSource.getTextMessageTemplate(theme),
714
+ ChatConfigurator.dataSource.getTextMessageTemplate(theme, additionalParams),
562
715
  ChatConfigurator.dataSource.getFormMessageTemplate(theme),
563
716
  ChatConfigurator.dataSource.getSchedulerMessageTemplate(theme),
564
717
  ChatConfigurator.dataSource.getCardMessageTemplate(theme),
@@ -746,4 +899,17 @@ export class MessageDataSource implements DataSource {
746
899
  return CometChatConversationUtils.getMessagePreview(conversation.getLastMessage());
747
900
  };
748
901
 
902
+ getAllTextFormatters(loggedInUser?: CometChat.User): CometChatTextFormatter[] {
903
+ return [ChatConfigurator.getDataSource().getMentionsFormatter(loggedInUser),
904
+ ChatConfigurator.getDataSource().getUrlsFormatter(loggedInUser)];
905
+ }
906
+
907
+ getMentionsFormatter(loggedInUser?: CometChat.User): CometChatMentionsFormatter {
908
+ return new CometChatMentionsFormatter(loggedInUser);
909
+ }
910
+
911
+ getUrlsFormatter(loggedInUser?: CometChat.User): CometChatUrlsFormatter {
912
+ return new CometChatUrlsFormatter(loggedInUser);
913
+ }
914
+
749
915
  }
@@ -6,17 +6,35 @@ import {
6
6
  Platform,
7
7
  } from 'react-native';
8
8
 
9
+ export let isKeyboardVisible = false;
10
+
9
11
  export const useKeyboard = () => {
10
12
  const [keyboardHeight, setKeyboardHeight] = useState(0);
11
13
 
12
14
  useEffect(() => {
13
15
  function onKeyboardDidShow(e: KeyboardEvent) {
14
- if (Platform.OS === 'ios') LayoutAnimation.linear();
16
+ isKeyboardVisible = true;
17
+ if (Platform.OS === 'ios') {
18
+ LayoutAnimation.configureNext({
19
+ duration: 200,
20
+ create: {type: 'linear', property: 'opacity'},
21
+ update: {type: 'linear', property: 'opacity'},
22
+ delete: {type: 'linear', property: 'opacity'},
23
+ });
24
+ }
15
25
  setKeyboardHeight(e.endCoordinates.height);
16
26
  }
17
27
 
18
28
  function onKeyboardDidHide() {
19
- if (Platform.OS === 'ios') LayoutAnimation.linear();
29
+ isKeyboardVisible = false;
30
+ if (Platform.OS === 'ios') {
31
+ LayoutAnimation.configureNext({
32
+ duration: 200,
33
+ create: {type: 'linear', property: 'opacity'},
34
+ update: {type: 'linear', property: 'opacity'},
35
+ delete: {type: 'linear', property: 'opacity'},
36
+ });
37
+ }
20
38
  setKeyboardHeight(0);
21
39
  }
22
40
 
@@ -130,7 +130,6 @@ import {
130
130
  CometChatStatusIndicatorInterface,
131
131
  DateConfigurationInterface,
132
132
  DateStyleInterface,
133
- FormatTextForLinks,
134
133
  ReceiptConfigurationInterface,
135
134
  StatusIndicatorConfigurationInterface,
136
135
  StatusIndicatorStyleInterface,
@@ -145,10 +144,10 @@ import {
145
144
  ReactionsConfigurationInterface,
146
145
  ReactionsStyle,
147
146
  ReactionsStyleInterface,
148
- CometChatReactionsList,
149
- CometChatReactionsListInterface,
150
- ReactionsListConfiguration,
151
- ReactionsListConfigurationInterface,
147
+ CometChatReactionList,
148
+ CometChatReactionListInterface,
149
+ ReactionListConfiguration,
150
+ ReactionListConfigurationInterface,
152
151
  ReactionListStyle,
153
152
  ReactionListStyleInterface,
154
153
  CometChatQuickReactions,
@@ -163,9 +162,22 @@ import {
163
162
  EmojiKeyboardStyle,
164
163
 
165
164
  CometChatSchedulerBubble,
166
- CometChatSchedulerBubbleInterface
165
+ CometChatSchedulerBubbleInterface,
166
+
167
+ CometChatSuggestionList,
168
+ CometChatSuggestionListInterface,
169
+ SuggestionItem,
170
+ SuggestionListConfiguration,
171
+ SuggestionListConfigurationInterface
167
172
  } from './views';
168
173
 
174
+ import {
175
+ CometChatMentionsFormatter,
176
+ CometChatTextFormatter,
177
+ CometChatUrlsFormatter,
178
+ MentionTextStyle
179
+ } from './formatters';
180
+
169
181
  import {
170
182
  CometChatUIKit,
171
183
  CometChatUIKitHelper,
@@ -205,7 +217,6 @@ export {
205
217
  CometChatStatusIndicatorInterface,
206
218
  DateConfigurationInterface,
207
219
  DateStyleInterface,
208
- FormatTextForLinks,
209
220
  ReceiptConfigurationInterface,
210
221
  StatusIndicatorConfigurationInterface,
211
222
  StatusIndicatorStyleInterface,
@@ -344,10 +355,10 @@ export {
344
355
  ReactionsConfigurationInterface,
345
356
  ReactionsStyle,
346
357
  ReactionsStyleInterface,
347
- CometChatReactionsList,
348
- CometChatReactionsListInterface,
349
- ReactionsListConfiguration,
350
- ReactionsListConfigurationInterface,
358
+ CometChatReactionList,
359
+ CometChatReactionListInterface,
360
+ ReactionListConfiguration,
361
+ ReactionListConfigurationInterface,
351
362
  ReactionListStyle,
352
363
  ReactionListStyleInterface,
353
364
  CometChatQuickReactions,
@@ -361,4 +372,13 @@ export {
361
372
  EmojiKeyboardConfiguration,
362
373
  EmojiKeyboardStyle,
363
374
 
375
+ CometChatMentionsFormatter,
376
+ CometChatTextFormatter,
377
+ CometChatUrlsFormatter,
378
+ MentionTextStyle,
379
+ CometChatSuggestionList,
380
+ CometChatSuggestionListInterface,
381
+ SuggestionItem,
382
+ SuggestionListConfiguration,
383
+ SuggestionListConfigurationInterface
364
384
  };