@cometchat/chat-uikit-react-native 5.0.0 → 5.0.2

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 (103) hide show
  1. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +87 -49
  2. package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +10 -0
  3. package/ios/SoundPlayer.m +8 -0
  4. package/package.json +8 -9
  5. package/src/CometChatConversations/CometChatConversations.tsx +19 -14
  6. package/src/CometChatConversations/style.ts +6 -2
  7. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +1 -0
  8. package/src/CometChatGroupMembers/style.ts +1 -0
  9. package/src/CometChatGroups/CometChatGroups.tsx +1 -0
  10. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +227 -57
  11. package/src/CometChatMessageComposer/styles.tsx +3 -6
  12. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +2 -2
  13. package/src/CometChatMessageHeader/styles.ts +1 -0
  14. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +1 -1
  15. package/src/CometChatMessageList/CometChatMessageList.tsx +188 -111
  16. package/src/CometChatMessageList/style.ts +0 -16
  17. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +1 -1
  18. package/src/CometChatUsers/CometChatUsers.tsx +1 -1
  19. package/src/calls/CallUtils.ts +18 -10
  20. package/src/calls/CallingExtensionDecorator.tsx +1 -1
  21. package/src/calls/CometChatCallBubble/CometChatCallBubble.tsx +8 -7
  22. package/src/calls/CometChatCallBubble/styles.ts +1 -0
  23. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +6 -4
  24. package/src/calls/CometChatCallButtons/style.ts +2 -1
  25. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +4 -3
  26. package/src/calls/CometChatCallLogs/style.ts +1 -0
  27. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +4 -3
  28. package/src/calls/CometChatOngoingCall/CometChatOngoingCall.tsx +1 -0
  29. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +3 -3
  30. package/src/calls/CometChatOutgoingCall/OutgoingCallConfiguration.ts +1 -0
  31. package/src/extensions/CollaborativeBubble/CometChatCollaborativeBubble.tsx +1 -1
  32. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +1 -1
  33. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +1 -1
  34. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +15 -18
  35. package/src/extensions/LinkPreview/LinkPreviewExtensionDecorator.tsx +1 -1
  36. package/src/extensions/LinkPreview/style.ts +2 -2
  37. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +20 -17
  38. package/src/extensions/Polls/Polls.tsx +45 -8
  39. package/src/extensions/Polls/PollsDecorator.tsx +1 -1
  40. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +2 -4
  41. package/src/extensions/Stickers/style.ts +3 -3
  42. package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +1 -1
  43. package/src/imageresolver.d.ts +4 -0
  44. package/src/index.ts +2 -0
  45. package/src/shared/CometChatUiKit/CometChatUIKit.ts +1 -2
  46. package/src/shared/base/Types.ts +1 -0
  47. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +114 -32
  48. package/src/shared/formatters/CometChatTextFormatter.ts +1 -0
  49. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +4 -4
  50. package/src/shared/framework/DataSource.ts +6 -2
  51. package/src/shared/framework/DataSourceDecorator.tsx +5 -4
  52. package/src/shared/framework/MessageDataSource.tsx +26 -28
  53. package/src/shared/helper/types/index.ts +1 -0
  54. package/src/shared/icons/Icon.tsx +1 -1
  55. package/src/shared/index.ts +41 -126
  56. package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +1 -1
  57. package/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx +4 -2
  58. package/src/shared/modals/CometChatMessageOption.ts +1 -0
  59. package/src/shared/modals/CometChatMessageTemplate.ts +1 -0
  60. package/src/shared/resources/CometChatSoundManager/index.ts +1 -0
  61. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +0 -8
  62. package/src/shared/utils/CometChatMessagePreview/index.ts +1 -2
  63. package/src/shared/utils/CommonUtils.ts +2 -1
  64. package/src/shared/utils/MessageUtils.tsx +54 -62
  65. package/src/shared/utils/conversationUtils.ts +1 -0
  66. package/src/shared/utils/index.ts +1 -2
  67. package/src/shared/views/CometChatActionSheet/ActionItem.ts +1 -0
  68. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -1
  69. package/src/shared/views/CometChatAudioBubble/AnimatedAudioWaves.tsx +1 -1
  70. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +9 -6
  71. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +1 -1
  72. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +1 -1
  73. package/src/shared/views/CometChatConfirmDialog/style.ts +1 -0
  74. package/src/shared/views/CometChatDeletedBubble/styles.ts +1 -0
  75. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +1 -1
  76. package/src/shared/views/CometChatList/CometChatList.tsx +2 -2
  77. package/src/shared/views/CometChatList/Header.tsx +1 -1
  78. package/src/shared/views/CometChatMediaRecorder/AnimatingMic.tsx +2 -2
  79. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPreview/CometChatAudioPreview.tsx +16 -10
  80. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +7 -8
  81. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +1 -1
  82. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +84 -70
  83. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +1 -1
  84. package/src/shared/views/CometChatReactions/style.ts +5 -4
  85. package/src/shared/views/CometChatReceipt/style.ts +1 -0
  86. package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +1 -1
  87. package/src/shared/views/CometChatSuggestionList/style.ts +3 -2
  88. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +1 -1
  89. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +24 -47
  90. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +68 -73
  91. package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +1 -0
  92. package/src/theme/CometChatThemeHelper.ts +69 -58
  93. package/src/theme/context.ts +2 -2
  94. package/src/theme/default/default.ts +204 -0
  95. package/src/theme/default/index.ts +0 -238
  96. package/src/theme/provider.tsx +7 -7
  97. package/src/theme/type.ts +5 -7
  98. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  99. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  100. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  101. package/android/.gradle/7.4/gc.properties +0 -0
  102. package/android/.gradle/vcs-1/gc.properties +0 -0
  103. package/src/shared/utils/CometChatMessagePreview/MessagePreviewStyle.js +0 -42
@@ -1,6 +1,6 @@
1
1
  import { CometChat } from "@cometchat/chat-sdk-react-native";
2
- import React from "react";
3
- import { StyleProp, Text, TextStyle, View } from "react-native";
2
+ import React, { JSX } from "react";
3
+ import { ColorValue, StyleProp, Text, TextStyle } from "react-native";
4
4
  import { CometChatUIKit } from "../../CometChatUiKit";
5
5
  import {
6
6
  MentionsTargetElement,
@@ -12,12 +12,32 @@ import { localize } from "../../resources";
12
12
  import { SuggestionItem } from "../../views/CometChatSuggestionList";
13
13
  import { CometChatTextFormatter } from "../CometChatTextFormatter";
14
14
  import { CometChatTheme } from "../../../theme/type";
15
+ import { deepMerge } from "../../helper/helperFunctions";
15
16
 
16
17
  /**
17
18
  * Represents the CometChatMentionsFormatter class.
18
19
  * This class extends the CometChatTextFormatter class and provides methods for handling mentions in text.
19
20
  * @extends CometChatTextFormatter
20
21
  */
22
+
23
+ type MentionsSubStyle = {
24
+ textStyle?: TextStyle;
25
+ selfTextStyle?: TextStyle;
26
+ };
27
+
28
+ type MentionContext = "composer" | "conversation" | "incoming" | "outgoing";
29
+
30
+ function isCometChatTheme(t: unknown): t is CometChatTheme {
31
+ return (
32
+ !!t &&
33
+ typeof t === "object" &&
34
+ "typography" in t &&
35
+ "color" in t &&
36
+ typeof (t as any).typography === "object" &&
37
+ typeof (t as any).color === "object"
38
+ );
39
+ }
40
+
21
41
  export class CometChatMentionsFormatter extends CometChatTextFormatter {
22
42
  /**
23
43
  * List of users for mentions.
@@ -44,6 +64,29 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
44
64
  */
45
65
  private customRequest?: CometChat.UsersRequestBuilder | CometChat.GroupMembersRequestBuilder;
46
66
 
67
+ private composerStyle: MentionsSubStyle;
68
+ private conversationStyle: MentionsSubStyle;
69
+ private incomingBubbleStyle: MentionsSubStyle;
70
+ private outgoingBubbleStyle: MentionsSubStyle;
71
+ private currentContext: MentionContext = "incoming";
72
+ private resolveStyle(isSelf: boolean): TextStyle {
73
+ let style: MentionsSubStyle;
74
+ switch (this.currentContext) {
75
+ case "composer":
76
+ style = this.composerStyle;
77
+ break;
78
+ case "conversation":
79
+ style = this.conversationStyle;
80
+ break;
81
+ case "outgoing":
82
+ style = this.outgoingBubbleStyle;
83
+ break;
84
+ default:
85
+ style = this.incomingBubbleStyle;
86
+ }
87
+ return isSelf ? (style.selfTextStyle ?? {}) : (style.textStyle ?? {});
88
+ }
89
+
47
90
  /**
48
91
  * Limit of unique users to be added in the composer.
49
92
  */
@@ -76,11 +119,33 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
76
119
  * Initializes a new CometChatMentionsFormatter.
77
120
  * @param {CometChat.User} loggedInUser - The user who is currently logged in.
78
121
  */
79
- constructor(loggedInUser?: CometChat.User) {
122
+ constructor(themeOrUser?: CometChatTheme | CometChat.User, loggedInUser?: CometChat.User) {
80
123
  super();
81
124
  this.regexPattern = /<@uid:(.*?)>/g;
82
125
  this.trackCharacter = "@";
83
- this.loggedInUser = loggedInUser;
126
+
127
+ const theme = isCometChatTheme(themeOrUser) ? themeOrUser : undefined;
128
+ this.loggedInUser = isCometChatTheme(themeOrUser)
129
+ ? loggedInUser
130
+ : (themeOrUser as CometChat.User | undefined);
131
+
132
+ const fallback: MentionsSubStyle = {
133
+ textStyle: { fontWeight: "700", fontSize: 14, lineHeight: 19.6, color: "#6852D6" },
134
+ selfTextStyle: { fontWeight: "700", fontSize: 14, lineHeight: 19.6, color: "#FFAB00" },
135
+ };
136
+
137
+ const fromTheme = (c: ColorValue): MentionsSubStyle => {
138
+ const baseStyle = theme?.typography?.body?.bold || {};
139
+ return {
140
+ textStyle: { ...baseStyle, color: c },
141
+ selfTextStyle: { ...baseStyle, color: theme?.color?.warning || "#FFAB00" },
142
+ };
143
+ };
144
+
145
+ this.incomingBubbleStyle = theme ? fromTheme(theme.color.receiveBubbleTextHighlight) : fallback;
146
+ this.outgoingBubbleStyle = theme ? fromTheme(theme.color.sendBubbleTextHighlight) : fallback;
147
+ this.composerStyle = this.incomingBubbleStyle; // reasonable defaults
148
+ this.conversationStyle = this.incomingBubbleStyle;
84
149
  }
85
150
 
86
151
  /**
@@ -282,13 +347,38 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
282
347
  return this.mentionsStyle;
283
348
  }
284
349
 
285
- /**
286
- * Sets the mentions style.
287
- *
288
- * @param {CometChatTheme["mentionsStyle"]} mentionsStyle - The mentions style to be set.
289
- */
290
- setMentionsStyle(mentionsStyle?: CometChatTheme["mentionsStyle"]) {
291
- this.mentionsStyle = mentionsStyle;
350
+ setComposerMentionStyle(s: MentionsSubStyle) {
351
+ this.composerStyle = deepMerge(this.composerStyle, s);
352
+ return this;
353
+ }
354
+ setConversationMentionStyle(s: MentionsSubStyle) {
355
+ this.conversationStyle = deepMerge(this.conversationStyle, s);
356
+ return this;
357
+ }
358
+ setIncomingBubbleMentionStyle(s: MentionsSubStyle) {
359
+ this.incomingBubbleStyle = deepMerge(this.incomingBubbleStyle, s);
360
+ return this;
361
+ }
362
+ setOutgoingBubbleMentionStyle(s: MentionsSubStyle) {
363
+ this.outgoingBubbleStyle = deepMerge(this.outgoingBubbleStyle, s);
364
+ return this;
365
+ }
366
+
367
+ /** maintain back-compat */
368
+ setMentionsStyle(patch?: CometChatTheme["mentionsStyle"]) {
369
+ if (!patch) return this;
370
+ const apply = (dst: MentionsSubStyle) => deepMerge(dst, patch);
371
+ this.setIncomingBubbleMentionStyle(apply(this.incomingBubbleStyle))
372
+ .setOutgoingBubbleMentionStyle(apply(this.outgoingBubbleStyle))
373
+ .setComposerMentionStyle(apply(this.composerStyle))
374
+ .setConversationMentionStyle(apply(this.conversationStyle));
375
+ return this;
376
+ }
377
+
378
+ /** called from data-sources */
379
+ setContext(ctx: MentionContext) {
380
+ this.currentContext = ctx;
381
+ return this;
292
382
  }
293
383
 
294
384
  getFormattedText(
@@ -319,19 +409,6 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
319
409
  this.temp(this.messageObject, uid);
320
410
  return;
321
411
  }
322
-
323
- // let obj = { uid, trackCharacter: this.trackCharacter };
324
- // CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.ccMentionClick, {
325
- // item: {
326
- // body: {
327
- // CometChatUserGroupMembersObject: obj,
328
- // message: this.messageObject ?? null,
329
- // id: uid,
330
- // },
331
- // // event,
332
- // source: "mentions", //add through enum
333
- // }
334
- // });
335
412
  };
336
413
 
337
414
  /**
@@ -361,7 +438,7 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
361
438
  // Break the string into segments split by the regex
362
439
  let match;
363
440
  let lastIndex = 0;
364
- let segments = [];
441
+ let segments: any[] = [];
365
442
 
366
443
  while ((match = regex.exec(inputText)) !== null) {
367
444
  // Add preceding non-UID segment, if any
@@ -387,10 +464,15 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
387
464
  if (userRegistry.hasOwnProperty(segment)) {
388
465
  let _loggedInUser = this.loggedInUser || CometChatUIKit.loggedInUser;
389
466
 
390
- let textStyle =
391
- _loggedInUser?.getUid() == segment
392
- ? this.getMentionsStyle()?.selfTextStyle
393
- : this.getMentionsStyle()?.textStyle;
467
+ const isSelf = _loggedInUser?.getUid() === segment;
468
+ const isOutgoing =
469
+ this.messageObject?.getSender()?.getUid() === _loggedInUser?.getUid();
470
+
471
+ if (this.target === MentionsTargetElement.textbubble) {
472
+ // Only for bubbles – keep whatever was set for conversation & composer
473
+ this.setContext(isOutgoing ? "outgoing" : "incoming");
474
+ }
475
+ const textStyle = this.resolveStyle(isSelf);
394
476
  let onPressProp = this.temp
395
477
  ? { onPress: (event: any) => this.onMentionClick(event, segment) }
396
478
  : {};
@@ -436,12 +518,12 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
436
518
  return inputText;
437
519
  } else if (React.isValidElement(inputText)) {
438
520
  // inputText is a React element
439
- if ((inputText as React.ReactElement).props.children) {
521
+ if ((inputText as React.ReactElement<any>).props.children) {
440
522
  // If the React element have children, we map over these children
441
523
  // and call addMentionsView recursively for each child.
442
- return React.cloneElement(inputText as React.ReactElement, {
524
+ return React.cloneElement(inputText as React.ReactElement<any>, {
443
525
  children: React.Children.map(
444
- (inputText as React.ReactElement).props.children,
526
+ (inputText as React.ReactElement<any>).props.children,
445
527
  (child) => {
446
528
  return this.addMentionsView(child);
447
529
  }
@@ -1,6 +1,7 @@
1
1
  import { CometChat } from "@cometchat/chat-sdk-react-native";
2
2
  import { CometChatUIEventHandler, CometChatUIEvents } from "../events";
3
3
  import { SuggestionItem } from "../views/CometChatSuggestionList";
4
+ import { JSX } from "react";
4
5
 
5
6
  /**
6
7
  * CometChatTextFormatter
@@ -1,5 +1,5 @@
1
1
  import { CometChat } from "@cometchat/chat-sdk-react-native";
2
- import React from "react";
2
+ import React, { JSX } from "react";
3
3
  import { ColorValue, Linking, Text, TextStyle } from "react-native";
4
4
  import { emailPattern, phoneNumPattern, urlPattern } from "../../constants/UIKitConstants";
5
5
  import { CometChatTextFormatter } from "../CometChatTextFormatter";
@@ -103,11 +103,11 @@ export class CometChatUrlsFormatter extends CometChatTextFormatter {
103
103
  return <Text>{str}</Text>;
104
104
  } else if (React.isValidElement(str)) {
105
105
  // str is a React element
106
- if ((str as React.ReactElement).props.children) {
106
+ if ((str as React.ReactElement<any>).props.children) {
107
107
  // If the React element have children, we map over these children
108
108
  // and call addMentionsSpan recursively for each child.
109
- return React.cloneElement(str as React.ReactElement, {
110
- children: React.Children.map((str as React.ReactElement).props.children, (child) => {
109
+ return React.cloneElement(str as React.ReactElement<any>, {
110
+ children: React.Children.map((str as React.ReactElement<any>).props.children, (child) => {
111
111
  return this.getFormatTextForLinks({ str: child, style: style });
112
112
  }),
113
113
  });
@@ -15,6 +15,7 @@ import {
15
15
  import { CometChatMessageComposerAction } from "../helper/types";
16
16
  import { CometChatMessageOption } from "../modals/CometChatMessageOption";
17
17
  import { CometChatMessageTemplate } from "../modals/CometChatMessageTemplate";
18
+ import { JSX } from "react";
18
19
 
19
20
  export interface DataSource {
20
21
  //message options based on types
@@ -224,7 +225,10 @@ export interface DataSource {
224
225
  additionalAuxiliaryHeaderOptionsParams?: AdditionalAuxiliaryHeaderOptionsParams
225
226
  ): JSX.Element | null;
226
227
 
227
- getAllTextFormatters(loggedInUser?: CometChat.User): CometChatTextFormatter[];
228
- getMentionsFormatter(loggedInUser?: CometChat.User): CometChatMentionsFormatter;
228
+ getAllTextFormatters(loggedInUser?: CometChat.User, theme?: CometChatTheme): CometChatTextFormatter[];
229
+ getMentionsFormatter(
230
+ loggedInUser?: CometChat.User,
231
+ theme?: CometChatTheme
232
+ ): CometChatMentionsFormatter;
229
233
  getUrlsFormatter(loggedInUser?: CometChat.User): CometChatUrlsFormatter;
230
234
  }
@@ -9,6 +9,7 @@ import {
9
9
  import { CometChatMessageComposerAction } from "../helper/types";
10
10
  import { CometChatMessageOption, CometChatMessageTemplate } from "../modals";
11
11
  import { DataSource } from "./DataSource";
12
+ import { JSX } from "react";
12
13
 
13
14
  export class DataSourceDecorator implements DataSource {
14
15
  dataSource: DataSource;
@@ -303,15 +304,15 @@ export class DataSourceDecorator implements DataSource {
303
304
  return this.dataSource.getAuxiliaryHeaderAppbarOptions(user, group, additionalAuxiliaryHeaderOptionsParams);
304
305
  }
305
306
 
306
- getAllTextFormatters(loggedInUser?: CometChat.User): CometChatTextFormatter[] {
307
+ getAllTextFormatters(loggedInUser?: CometChat.User, theme?: CometChatTheme): CometChatTextFormatter[] {
307
308
  return [
308
- this.dataSource.getMentionsFormatter(loggedInUser),
309
+ this.dataSource.getMentionsFormatter(loggedInUser, theme),
309
310
  this.dataSource.getUrlsFormatter(loggedInUser),
310
311
  ];
311
312
  }
312
313
 
313
- getMentionsFormatter(loggedInUser?: CometChat.User): CometChatMentionsFormatter {
314
- return this.dataSource.getMentionsFormatter(loggedInUser);
314
+ getMentionsFormatter(loggedInUser?: CometChat.User, theme?: CometChatTheme): CometChatMentionsFormatter {
315
+ return this.dataSource.getMentionsFormatter(loggedInUser, theme);
315
316
  }
316
317
 
317
318
  getUrlsFormatter(loggedInUser?: CometChat.User): CometChatUrlsFormatter {
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { JSX } from "react";
2
2
  import { CometChat } from "@cometchat/chat-sdk-react-native";
3
3
  import {
4
4
  CometChatMentionsFormatter,
@@ -39,6 +39,11 @@ import { DataSource } from "./DataSource";
39
39
  import { CommonUtils } from "../utils/CommonUtils";
40
40
  import { DimensionValue, ViewStyle } from "react-native";
41
41
 
42
+ export enum MentionContext {
43
+ Incoming = 'incoming',
44
+ Outgoing = 'outgoing',
45
+ }
46
+
42
47
  function isAudioMessage(message: CometChat.BaseMessage): message is CometChat.MediaMessage {
43
48
  return (
44
49
  message.getCategory() == CometChat.CATEGORY_MESSAGE &&
@@ -667,8 +672,8 @@ export class MessageDataSource implements DataSource {
667
672
  return (
668
673
  <CometChatTextBubble
669
674
  text={`${message.getMessage()}`}
670
- textContainerStyle={theme.messageListStyles.groupActionBubbleStyles.textContainerStyle}
671
- textStyle={theme.messageListStyles.groupActionBubbleStyles.textStyle}
675
+ textContainerStyle={theme.messageListStyles?.groupActionBubbleStyles?.textContainerStyle}
676
+ textStyle={theme?.messageListStyles?.groupActionBubbleStyles?.textStyle}
672
677
  />
673
678
  );
674
679
  }
@@ -738,8 +743,10 @@ export class MessageDataSource implements DataSource {
738
743
 
739
744
  let linksTextFormatter = ChatConfigurator.getDataSource().getUrlsFormatter(loggedInUser!);
740
745
  let mentionsTextFormatter = ChatConfigurator.getDataSource().getMentionsFormatter(
741
- loggedInUser!
746
+ loggedInUser!,
747
+ theme
742
748
  );
749
+ mentionsTextFormatter.setContext(isMessageSentByLoggedInUser ? MentionContext.Outgoing : MentionContext.Incoming);
743
750
  linksTextFormatter.setMessage(message);
744
751
  linksTextFormatter.setId("ccDefaultUrlsFormatterId");
745
752
  linksTextFormatter.setStyle({ linkTextColor: theme.color.receiveBubbleLink });
@@ -751,13 +758,6 @@ export class MessageDataSource implements DataSource {
751
758
  mentionsTextFormatter.setLoggedInUser(loggedInUser!);
752
759
  mentionsTextFormatter.setMessage(message);
753
760
  mentionsTextFormatter.setId("ccDefaultMentionFormatterId");
754
- let isUserSentMessage = message.getSender().getUid() == loggedInUser!.getUid();
755
- if (isUserSentMessage) {
756
- mentionsTextFormatter.setMentionsStyle(_style?.mentionsStyle);
757
- } else {
758
- mentionsTextFormatter.setMentionsStyle(_style?.mentionsStyle);
759
- }
760
- mentionsTextFormatter.setTextStyle(_style?.textStyle);
761
761
  }
762
762
 
763
763
  let finalFormatters: CometChatTextFormatter[] = [];
@@ -775,7 +775,9 @@ export class MessageDataSource implements DataSource {
775
775
  formatter.setMessage(message);
776
776
  formatter.setTargetElement(MentionsTargetElement.textbubble);
777
777
  formatter.setLoggedInUser(CometChatUIKit.loggedInUser!);
778
+ formatter.setContext(isMessageSentByLoggedInUser ? "outgoing" : "incoming");
778
779
  }
780
+
779
781
  formatter.setMessage(message);
780
782
  finalFormatters.push(CommonUtils.clone(formatter));
781
783
  if (urlFormatterExists && mentionsFormatterExists) {
@@ -1340,7 +1342,7 @@ export class MessageDataSource implements DataSource {
1340
1342
  theme: CometChatTheme,
1341
1343
  additionalAttachmentOptionsParams?: AdditionalAttachmentOptionsParams
1342
1344
  ) => {
1343
- const attachmentOptions = [];
1345
+ const attachmentOptions: CometChatMessageComposerAction[] = [];
1344
1346
  if (!additionalAttachmentOptionsParams?.hideCameraOption) {
1345
1347
  attachmentOptions.push({
1346
1348
  id: MessageTypeConstants.takePhoto,
@@ -1363,7 +1365,6 @@ export class MessageDataSource implements DataSource {
1363
1365
  }
1364
1366
  />
1365
1367
  ),
1366
- onClick: null,
1367
1368
  });
1368
1369
  }
1369
1370
  if (!additionalAttachmentOptionsParams?.hideImageAttachmentOption) {
@@ -1388,7 +1389,6 @@ export class MessageDataSource implements DataSource {
1388
1389
  }
1389
1390
  />
1390
1391
  ),
1391
- onClick: null,
1392
1392
  });
1393
1393
  }
1394
1394
 
@@ -1414,7 +1414,6 @@ export class MessageDataSource implements DataSource {
1414
1414
  }
1415
1415
  />
1416
1416
  ),
1417
- onClick: null,
1418
1417
  });
1419
1418
  }
1420
1419
 
@@ -1440,7 +1439,6 @@ export class MessageDataSource implements DataSource {
1440
1439
  }
1441
1440
  />
1442
1441
  ),
1443
- onClick: null,
1444
1442
  });
1445
1443
  }
1446
1444
  if (!additionalAttachmentOptionsParams?.hideFileAttachmentOption) {
@@ -1465,7 +1463,6 @@ export class MessageDataSource implements DataSource {
1465
1463
  }
1466
1464
  />
1467
1465
  ),
1468
- onClick: null,
1469
1466
  });
1470
1467
  }
1471
1468
  return attachmentOptions;
@@ -1474,7 +1471,7 @@ export class MessageDataSource implements DataSource {
1474
1471
  theme: CometChatTheme,
1475
1472
  additionalAttachmentOptionsParams?: AdditionalAttachmentOptionsParams
1476
1473
  ) => {
1477
- const attachmentOptions = [];
1474
+ const attachmentOptions: CometChatMessageComposerAction[] = [];
1478
1475
  if (!additionalAttachmentOptionsParams?.hideCameraOption) {
1479
1476
  attachmentOptions.push({
1480
1477
  id: MessageTypeConstants.takePhoto,
@@ -1497,7 +1494,6 @@ export class MessageDataSource implements DataSource {
1497
1494
  }
1498
1495
  />
1499
1496
  ),
1500
- onClick: null,
1501
1497
  });
1502
1498
  }
1503
1499
  if (!additionalAttachmentOptionsParams?.hideImageAttachmentOption) {
@@ -1522,7 +1518,6 @@ export class MessageDataSource implements DataSource {
1522
1518
  }
1523
1519
  />
1524
1520
  ),
1525
- onClick: null,
1526
1521
  });
1527
1522
  }
1528
1523
 
@@ -1548,7 +1543,6 @@ export class MessageDataSource implements DataSource {
1548
1543
  }
1549
1544
  />
1550
1545
  ),
1551
- onClick: null,
1552
1546
  });
1553
1547
  }
1554
1548
 
@@ -1574,7 +1568,6 @@ export class MessageDataSource implements DataSource {
1574
1568
  }
1575
1569
  />
1576
1570
  ),
1577
- onClick: null,
1578
1571
  });
1579
1572
  }
1580
1573
  if (!additionalAttachmentOptionsParams?.hideFileAttachmentOption) {
@@ -1599,13 +1592,12 @@ export class MessageDataSource implements DataSource {
1599
1592
  }
1600
1593
  />
1601
1594
  ),
1602
- onClick: null,
1603
1595
  });
1604
1596
  }
1605
1597
 
1606
1598
  return attachmentOptions;
1607
1599
  };
1608
-
1600
+
1609
1601
  getAttachmentOptions(
1610
1602
  theme: CometChatTheme,
1611
1603
  user?: any,
@@ -1632,15 +1624,21 @@ export class MessageDataSource implements DataSource {
1632
1624
  return CometChatConversationUtils.getMessagePreview(conversation.getLastMessage(), theme);
1633
1625
  }
1634
1626
 
1635
- getAllTextFormatters(loggedInUser?: CometChat.User): CometChatTextFormatter[] {
1627
+ getAllTextFormatters(
1628
+ loggedInUser?: CometChat.User,
1629
+ theme?: CometChatTheme
1630
+ ): CometChatTextFormatter[] {
1636
1631
  return [
1637
- ChatConfigurator.getDataSource().getMentionsFormatter(loggedInUser),
1632
+ ChatConfigurator.getDataSource().getMentionsFormatter(loggedInUser, theme),
1638
1633
  ChatConfigurator.getDataSource().getUrlsFormatter(loggedInUser),
1639
1634
  ];
1640
1635
  }
1641
1636
 
1642
- getMentionsFormatter(loggedInUser?: CometChat.User): CometChatMentionsFormatter {
1643
- return new CometChatMentionsFormatter(loggedInUser);
1637
+ getMentionsFormatter(
1638
+ loggedInUser?: CometChat.User,
1639
+ theme?: CometChatTheme
1640
+ ): CometChatMentionsFormatter {
1641
+ return new CometChatMentionsFormatter(theme!, loggedInUser);
1644
1642
  }
1645
1643
 
1646
1644
  getUrlsFormatter(loggedInUser?: CometChat.User): CometChatUrlsFormatter {
@@ -10,6 +10,7 @@ import {
10
10
  } from "react-native";
11
11
  import { Typography } from "../../../theme/default";
12
12
  import { ActionItemInterface } from "../../views";
13
+ import { JSX } from "react";
13
14
 
14
15
  export type ImageType = ImageURISource;
15
16
 
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { JSX } from "react";
2
2
  import {
3
3
  ColorValue,
4
4
  DimensionValue,