@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
@@ -166,6 +166,8 @@ export const CometChatIncomingCall = (props: CometChatIncomingCallInterface) =>
166
166
 
167
167
  callListener.current = new CometChatCalls.OngoingCallListener({
168
168
  onCallEnded: () => {
169
+ CometChatCalls.endSession()
170
+ CometChat.clearActiveCall()
169
171
  CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccCallEnded,{});
170
172
  setShowCallScreen(false);
171
173
  acceptedCall.current = null;
@@ -169,7 +169,9 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface) =>
169
169
 
170
170
  callListener.current = new CometChatCalls.OngoingCallListener({
171
171
  onCallEnded: () => {
172
+ CometChatCalls.endSession()
172
173
  if (checkIfDefualtCall(call)) {
174
+ CometChat.clearActiveCall()
173
175
  setCallConnected(false);
174
176
  call.setStatus("ended");
175
177
  CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccCallEnded, { call });
@@ -1,7 +1,7 @@
1
1
  import { DataSource, DataSourceDecorator } from "../../shared/framework";
2
2
  // @ts-ignore
3
3
  import { CometChat } from "@cometchat/chat-sdk-react-native";
4
- import { MessageBubbleAlignmentType , MetadataConstants, MessageCategoryConstants, ReceiverTypeConstants } from "../../shared/constants/UIKitConstants";
4
+ import { MessageBubbleAlignmentType , MetadataConstants, MessageCategoryConstants, ReceiverTypeConstants, AdditionalBubbleStylingParams } from "../../shared/constants/UIKitConstants";
5
5
  import { CometChatTheme } from "../../shared/resources/CometChatTheme";
6
6
  import { ExtensionConstants, ExtensionTypeConstants } from "../ExtensionConstants";
7
7
  import { getExtentionData } from "../ExtensionModerator";
@@ -139,8 +139,8 @@ export class CollaborativeDocumentExtensionDecorator extends DataSourceDecorator
139
139
 
140
140
 
141
141
 
142
- getAllMessageTemplates(theme: CometChatTheme): CometChatMessageTemplate[] {
143
- let templateList : CometChatMessageTemplate[] = super.getAllMessageTemplates(theme );
142
+ getAllMessageTemplates(theme: CometChatTheme, additionalParams?: AdditionalBubbleStylingParams): CometChatMessageTemplate[] {
143
+ let templateList : CometChatMessageTemplate[] = super.getAllMessageTemplates(theme, additionalParams);
144
144
 
145
145
 
146
146
 
@@ -1,7 +1,7 @@
1
1
  import { DataSource, DataSourceDecorator } from "../../shared/framework";
2
2
  // @ts-ignore
3
3
  import { CometChat } from "@cometchat/chat-sdk-react-native";
4
- import { MessageBubbleAlignmentType , MetadataConstants, MessageCategoryConstants , MessageTypeConstants,ReceiverTypeConstants } from "../../shared/constants/UIKitConstants";
4
+ import { MessageBubbleAlignmentType , MetadataConstants, MessageCategoryConstants , MessageTypeConstants,ReceiverTypeConstants, AdditionalBubbleStylingParams } from "../../shared/constants/UIKitConstants";
5
5
  import { CometChatTheme } from "../../shared/resources/CometChatTheme";
6
6
  import { ExtensionConstants } from "../ExtensionConstants";
7
7
  import { ExtensionTypeConstants } from "../ExtensionConstants";
@@ -143,8 +143,8 @@ export class CollaborativeWhiteboardExtensionDecorator extends DataSourceDecorat
143
143
 
144
144
 
145
145
 
146
- getAllMessageTemplates(theme: CometChatTheme): CometChatMessageTemplate[] {
147
- let templateList : CometChatMessageTemplate[] = super.getAllMessageTemplates(theme );
146
+ getAllMessageTemplates(theme: CometChatTheme, additionalParams?: AdditionalBubbleStylingParams): CometChatMessageTemplate[] {
147
+ let templateList : CometChatMessageTemplate[] = super.getAllMessageTemplates(theme, additionalParams);
148
148
 
149
149
 
150
150
 
@@ -1,5 +1,5 @@
1
- import React, { useState } from 'react'
2
- import { View, Text, TouchableOpacity, Linking, Image, Alert } from 'react-native'
1
+ import React, { useEffect, useRef, useState } from "react";
2
+ import { View, Text, TouchableOpacity, Linking, Image, Alert, Platform } from 'react-native'
3
3
  import { LinkPreviewBubbleStyle, LinkPreviewBubbleStyleInterface } from './LInkPreviewBubbleStyle';
4
4
  import { localize } from '../../shared/resources/CometChatLocalize';
5
5
  import { DefaultLinkPreview } from "./resources";
@@ -30,20 +30,53 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
30
30
 
31
31
  const [imageSource, setImageSource] = useState({ uri: image.startsWith("https:") ? image : `https:${image.split("http:")[1]}` });
32
32
 
33
+
34
+ const pressTime = useRef(0);
35
+
36
+ const handleTouchStart = () => {
37
+ pressTime.current = Date.now();
38
+ };
39
+
40
+ const handleTouchEnd = () => {
41
+ if (pressTime.current === null && Platform.OS === "ios") return;
42
+ const endTime = Date.now();
43
+ const pressDuration = endTime - pressTime.current;
44
+ if (pressDuration < 500) {
45
+ onPress ? onPress() : (Linking.canOpenURL(link) && Linking.openURL(link)) || Alert.alert(localize("SOMETHING_WRONG"))
46
+ }
47
+ };
48
+
49
+ const onTouchMove = () => {
50
+ if (Platform.OS === "ios") {
51
+ pressTime.current = null;
52
+ }
53
+ }
54
+
55
+
33
56
  return (
34
- <TouchableOpacity style={{
35
- backgroundColor: _style.backgroundColor,
36
- borderRadius: 8,
37
- }}
38
- onPress={() => onPress ? onPress() : (Linking.canOpenURL(link) && Linking.openURL(link)) || Alert.alert(localize("SOMETHING_WRONG"))}
39
- >
40
- <Image
41
- source={imageSource }
42
- style={{ height: 100, width: "100%", alignSelf: "center" }}
43
- onError={(err) => {
44
- setImageSource(DefaultLinkPreview)
57
+ <View>
58
+
59
+ <View
60
+ style={{
61
+ backgroundColor: _style.backgroundColor,
62
+ borderRadius: 8,
45
63
  }}
46
- />
64
+ onTouchStart={handleTouchStart}
65
+ onTouchEnd={handleTouchEnd}
66
+ onTouchMove={onTouchMove}
67
+ >
68
+
69
+ <Image
70
+ source={imageSource}
71
+ style={{ height: 100, width: "100%", alignSelf: "center" }}
72
+ onError={(err) => {
73
+ setImageSource(DefaultLinkPreview)
74
+ }}
75
+ />
76
+
77
+
78
+ </View>
79
+
47
80
  <View style={{ margin: 8 }}>
48
81
  <Text
49
82
  style={{
@@ -68,6 +101,9 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
68
101
  ChildView && <ChildView />
69
102
  }
70
103
  </View>
71
- </TouchableOpacity>
104
+
105
+
106
+ </View>
107
+
72
108
  )
73
109
  }
@@ -3,7 +3,7 @@ import { CometChat } from "@cometchat/chat-sdk-react-native";
3
3
  import { DataSource, DataSourceDecorator } from "../../shared/framework";
4
4
  import { LinkPreviewConfigurationInterface } from "./LinkPreviewConfiguration";
5
5
  import { CometChatTheme } from "../../shared/resources/CometChatTheme";
6
- import { MessageBubbleAlignmentType } from "../../shared/constants/UIKitConstants";
6
+ import { AdditionalBubbleStylingParams, MessageBubbleAlignmentType } from "../../shared/constants/UIKitConstants";
7
7
  import { getExtentionData } from "../ExtensionModerator";
8
8
  import { ExtensionConstants } from "../ExtensionConstants";
9
9
  import { LinkPreviewBubble } from "./LinkPreviewBubble";
@@ -27,10 +27,10 @@ export class LinkPreviewExtentionDecorator extends DataSourceDecorator {
27
27
  return "LinkPreviewExtention";
28
28
  }
29
29
 
30
- getTextMessageContentView(message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme): JSX.Element {
30
+ getTextMessageContentView(message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme, additionalParams?: AdditionalBubbleStylingParams): JSX.Element {
31
31
  let linkData = getExtentionData(message, ExtensionConstants.linkPreview);
32
32
  if (!linkData || linkData.links.length == 0) {
33
- return super.getTextMessageContentView(message, alignment, theme);
33
+ return super.getTextMessageContentView(message, alignment, theme, additionalParams);
34
34
  } else {
35
35
  const { image, favicon, title, url, description } = linkData.links[0]
36
36
  let img = image.length == 0 ? favicon : image;
@@ -40,7 +40,7 @@ export class LinkPreviewExtentionDecorator extends DataSourceDecorator {
40
40
  image={img}
41
41
  ChildView={() => super.getTextMessageBubble(
42
42
  (message as CometChat.TextMessage).getText()
43
- ,(message as CometChat.TextMessage), alignment, theme )}
43
+ ,(message as CometChat.TextMessage), alignment, theme, additionalParams )}
44
44
  title={title}
45
45
  style={{
46
46
  backgroundColor: "transparent",
@@ -1,5 +1,5 @@
1
1
  import { StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native';
2
- import React, { useContext } from 'react';
2
+ import React, { useContext, useEffect, useState } from 'react';
3
3
  import {
4
4
  CometChatContext,
5
5
  } from '../../shared/CometChatContext';
@@ -7,7 +7,7 @@ import {
7
7
  CometChatTextBubble,
8
8
  TextBubbleStyle, } from "../../shared/views";
9
9
  import { FontStyleInterface } from "../../shared/base";
10
- import { FormatTextForLinks } from '../../shared/views/CometChatTextBubble';
10
+ import { CometChatMentionsFormatter, CometChatTextFormatter, CometChatUrlsFormatter } from '../../shared';
11
11
 
12
12
  interface textStyle extends FontStyleInterface {
13
13
  color?: string;
@@ -25,6 +25,7 @@ export interface MessageTranslationBubble {
25
25
  };
26
26
  textContainerStyle?: StyleProp<ViewStyle>;
27
27
  alignment?: string;
28
+ textFormatters?: Array<CometChatMentionsFormatter | CometChatUrlsFormatter | CometChatTextFormatter>;
28
29
  }
29
30
 
30
31
  export const MessageTranslationBubble = (props: MessageTranslationBubble) => {
@@ -35,7 +36,33 @@ export const MessageTranslationBubble = (props: MessageTranslationBubble) => {
35
36
  style = {},
36
37
  textContainerStyle,
37
38
  alignment,
39
+ textFormatters,
38
40
  } = props;
41
+ const [formattedText, setFormattedText] = useState<string>();
42
+ const [formattedTranslatedText, setFormattedTranslatedText] = useState<string>();
43
+
44
+ useEffect(() => {
45
+ let _formattedText = text;
46
+ let _formattedTranslatedText = text;
47
+ if (textFormatters && textFormatters.length) {
48
+ if (textFormatters) {
49
+ for (let i = 0; i < textFormatters.length; i++) {
50
+ (_formattedText as string | void) = textFormatters[i].getFormattedText(_formattedText);
51
+ }
52
+ }
53
+ }
54
+ if (textFormatters && textFormatters.length) {
55
+ if (textFormatters) {
56
+ for (let i = 0; i < textFormatters.length; i++) {
57
+ (_formattedTranslatedText as string | void) = textFormatters[i].getFormattedText(_formattedTranslatedText);
58
+ }
59
+ }
60
+ }
61
+
62
+ setFormattedText(_formattedText as string);
63
+ setFormattedTranslatedText(_formattedTranslatedText as string);
64
+ }, [])
65
+
39
66
  const _style = {
40
67
  ...new TextBubbleStyle({}),
41
68
  backgroundColor:
@@ -77,8 +104,6 @@ export const MessageTranslationBubble = (props: MessageTranslationBubble) => {
77
104
  borderRadius,
78
105
  textColor,
79
106
  textFont,
80
- linkTextColor,
81
- linkTextFont,
82
107
  height,
83
108
  width,
84
109
  } = _style;
@@ -99,12 +124,9 @@ export const MessageTranslationBubble = (props: MessageTranslationBubble) => {
99
124
  textContainerStyle,
100
125
  ]}
101
126
  >
102
- <FormatTextForLinks
103
- str={text}
104
- style={{ textColor, textFont, linkTextColor, linkTextFont }}
105
- />
127
+ <Text style={[{ color: textColor }, textFont ]}>{formattedText}</Text>
106
128
  <Text style={[styles.textsPadding, style.translatedTextStyle]}>
107
- {translatedText}
129
+ {formattedTranslatedText}
108
130
  </Text>
109
131
  <Text style={[styles.textsPadding, style.translatedMsgStyle]}>
110
132
  Translated Message
@@ -1,4 +1,4 @@
1
- import { DataSource, DataSourceDecorator } from '../../shared/framework';
1
+ import { ChatConfigurator, DataSource, DataSourceDecorator } from '../../shared/framework';
2
2
  // @ts-ignore
3
3
  import { CometChat } from '@cometchat/chat-sdk-react-native';
4
4
  import { ExtensionConstants, ExtensionURLs } from '../ExtensionConstants';
@@ -11,6 +11,7 @@ import { CometChatMessageOption } from "../../shared/modals";
11
11
  import React from 'react';
12
12
  import { CometChatTheme } from '../../shared/resources/CometChatTheme';
13
13
  import {
14
+ AdditionalBubbleStylingParams,
14
15
  MessageBubbleAlignmentType,
15
16
  MessageOptionConstants,
16
17
  } from '../../shared/constants/UIKitConstants';
@@ -20,6 +21,8 @@ import { CometChatUIEventHandler } from '../../shared/events/CometChatUIEventHan
20
21
  import { CometChatUIEvents, MessageEvents } from '../../shared/events';
21
22
  import { messageStatus } from '../../shared/utils/CometChatMessageHelper';
22
23
  import { ICONS } from './resources';
24
+ import { CometChatTextFormatter, CometChatUIKit, CometChatUrlsFormatter, MentionTextStyle } from '../../shared';
25
+ import { CommonUtils } from '../../shared/utils/CommonUtils';
23
26
  export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
24
27
  messageTranslationConfiguration?: MessageTranslationConfigurationInterface;
25
28
 
@@ -55,7 +58,7 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
55
58
  getTranslateOption(messageObject): CometChatMessageOption {
56
59
  return {
57
60
  id: MessageOptionConstants.translateMessage,
58
- title: localize('TRANSLATE_MESSAGE'),
61
+ title: localize('TRANSLATE'),
59
62
  icon: ICONS.TRANSLATE,
60
63
  onPress: () => {
61
64
  this.translateMessage(messageObject);
@@ -178,7 +181,8 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
178
181
  messageText: string,
179
182
  message: CometChat.TextMessage,
180
183
  alignment: MessageBubbleAlignmentType,
181
- theme: CometChatTheme
184
+ theme: CometChatTheme,
185
+ additionalParams?: AdditionalBubbleStylingParams
182
186
  ): JSX.Element {
183
187
  let tempTranslatedMsg = {};
184
188
  let translatedMetaData = message.getMetadata();
@@ -192,6 +196,78 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
192
196
  translatedMetaData['@injected']['extensions']['translate'];
193
197
  }
194
198
 
199
+ let loggedInUser = CometChatUIKit.loggedInUser;
200
+ let mentionedUsers = message.getMentionedUsers();
201
+ let textFormatters = [...additionalParams?.textFormatters] || [];
202
+
203
+ let linksTextFormatter = ChatConfigurator.getDataSource().getUrlsFormatter(loggedInUser);
204
+ linksTextFormatter.setMessage(message);
205
+ linksTextFormatter.setId("ccDefaultUrlsFormatterId")
206
+ textFormatters.push(linksTextFormatter);
207
+
208
+ if (!additionalParams?.disableMentions && mentionedUsers && mentionedUsers.length) {
209
+
210
+ let mentionsTextFormatter =
211
+ ChatConfigurator.getDataSource().getMentionsFormatter(loggedInUser);
212
+ mentionsTextFormatter.setLoggedInUser(loggedInUser);
213
+ mentionsTextFormatter.setMessage(message);
214
+ mentionsTextFormatter.setId("ccDefaultMentionFormatterId")
215
+ let isUserSentMessage = alignment === "right";
216
+ if (isUserSentMessage) {
217
+ mentionsTextFormatter.setMentionsStyle(
218
+ new MentionTextStyle({
219
+ loggedInUserTextStyle: {
220
+ color: theme.palette.getTertiary(),
221
+ ...theme.typography.title2,
222
+ },
223
+ textStyle: {
224
+ color: theme.palette.getTertiary(),
225
+ ...theme.typography.subtitle1,
226
+ },
227
+ })
228
+ );
229
+ } else {
230
+ mentionsTextFormatter.setMentionsStyle(
231
+ new MentionTextStyle({
232
+ loggedInUserTextStyle: {
233
+ color: theme.palette.getPrimary(),
234
+ ...theme.typography.title2,
235
+ },
236
+ textStyle: {
237
+ color: theme.palette.getPrimary(),
238
+ ...theme.typography.subtitle1,
239
+ },
240
+ })
241
+ );
242
+ }
243
+
244
+ textFormatters.push(mentionsTextFormatter);
245
+
246
+ }
247
+ let finalFormatters = [];
248
+
249
+ let customerHasPassedUrlsFormatter;
250
+
251
+ textFormatters.forEach(formatter => {
252
+ if (formatter instanceof CometChatUrlsFormatter) {
253
+ if (formatter.getId() !== "ccDefaultUrlsFormatterId") {
254
+ customerHasPassedUrlsFormatter = true
255
+ }
256
+ }
257
+ formatter.setMessage(message);
258
+ let suggestionUsers = formatter.getSuggestionItems();
259
+ suggestionUsers.length > 0 && formatter.setSuggestionItems(suggestionUsers);
260
+ let _formatter = CommonUtils.clone(formatter);
261
+ finalFormatters.push(_formatter);
262
+ })
263
+
264
+ if (customerHasPassedUrlsFormatter) {
265
+ let customUrlsIndex = finalFormatters.findIndex((formatter: CometChatTextFormatter[]) => (formatter instanceof CometChatUrlsFormatter && formatter.getId() === "ccDefaultUrlsFormatterId"));
266
+ if (customUrlsIndex > -1) {
267
+ finalFormatters.splice(customUrlsIndex, 1);
268
+ }
269
+ }
270
+
195
271
  if (
196
272
  (tempTranslatedMsg && tempTranslatedMsg[message.getId()]) ||
197
273
  (this.translatedMessage && this.translatedMessage[message.getId()])
@@ -202,15 +278,16 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
202
278
  tempTranslatedMsg
203
279
  ? tempTranslatedMsg[message.getId()]
204
280
  : this.translatedMessage[message.getId()]
205
- ? this.translatedMessage[message.getId()]
206
- : ''
281
+ ? this.translatedMessage[message.getId()]
282
+ : ''
207
283
  }
208
284
  text={messageText}
209
285
  alignment={alignment}
286
+ textFormatters={finalFormatters}
210
287
  {...this.messageTranslationConfiguration}
211
288
  />
212
289
  );
213
290
  }
214
- return super.getTextMessageBubble(messageText, message, alignment, theme);
291
+ return super.getTextMessageBubble(messageText, message, alignment, theme, additionalParams);
215
292
  }
216
293
  }
@@ -4,11 +4,14 @@ import {
4
4
  TouchableOpacity,
5
5
  TextInput,
6
6
  Image,
7
- FlatList,
7
+ ScrollView,
8
+ KeyboardAvoidingView,
9
+ Platform,
10
+ NativeModules,
8
11
  } from 'react-native';
9
12
  import React, {
13
+ useCallback,
10
14
  useContext,
11
- useEffect,
12
15
  useLayoutEffect,
13
16
  useRef,
14
17
  useState,
@@ -27,6 +30,8 @@ import { localize } from "../../shared/resources/CometChatLocalize";
27
30
  import { ICONS } from './resources';
28
31
  import { CometChatContextType } from '../../shared/base/Types';
29
32
  import { CometChatSwipeRow } from '../../shared/views/SwipeRow';
33
+ import { commonVars } from '../../shared/base/vars';
34
+ const { CommonUtil } = NativeModules;
30
35
 
31
36
  export interface PollsStyleInterface {
32
37
  titleTextStyle?: FontStyleInterface;
@@ -172,6 +177,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
172
177
  const [error, setError] = React.useState('');
173
178
  const [answersList, setAnswersList] = useState([]);
174
179
  const [answers, setAnswers] = useState({});
180
+ const [kbOffset, setKbOffset] = React.useState(59);
175
181
  const loggedInUser = useRef(null);
176
182
  const answersFinalValues = useRef([]);
177
183
 
@@ -296,12 +302,12 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
296
302
  options={
297
303
  defaultAnswers <= item.id
298
304
  ? () => [
299
- {
300
- id: item.id,
301
- icon: deleteIcon ?? ICONS.KICK,
302
- onPress: removeRow,
303
- },
304
- ]
305
+ {
306
+ id: item.id,
307
+ icon: deleteIcon ?? ICONS.KICK,
308
+ onPress: removeRow,
309
+ },
310
+ ]
305
311
  : () => []
306
312
  }
307
313
  >
@@ -371,77 +377,107 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
371
377
  setAnswersList(answerslist);
372
378
  CometChat.getLoggedinUser()
373
379
  .then((u) => (loggedInUser.current = u))
374
- .catch((e) => {});
380
+ .catch((e) => { });
381
+ if (Platform.OS === "ios") {
382
+ if (Number.isInteger(commonVars.safeAreaInsets.top)) {
383
+ setKbOffset(commonVars.safeAreaInsets.top)
384
+ return;
385
+ }
386
+ CommonUtil.getSafeAreaInsets().then(res => {
387
+ if (Number.isInteger(res.top)) {
388
+ commonVars.safeAreaInsets.top = res.top;
389
+ commonVars.safeAreaInsets.bottom = res.bottom;
390
+ setKbOffset(res.top)
391
+ }
392
+ })
393
+ }
375
394
  }, []);
376
395
 
396
+ const getPollAnswers = useCallback(() => {
397
+ return (
398
+ answersList.map((item, index) => (
399
+ <React.Fragment key={item.id}>
400
+ <AnswersListItem item={item} index={index} />
401
+ {index === answersList.length - 1 && <AddAnswer />}
402
+ </React.Fragment>
403
+ ))
404
+ )
405
+ }, [answersList])
406
+
377
407
  return (
378
- <View
379
- style={[
380
- styles.container,
381
- {
382
- width: createPollsStyle.width ?? 'auto',
383
- height: createPollsStyle.height ?? 'auto',
384
- backgroundColor:
385
- createPollsStyle.backgroundColor ??
386
- theme.palette.getBackgroundColor(),
387
- borderRadius: createPollsStyle.borderRadius ?? 0,
388
- },
389
- createPollsStyle.border ?? {},
390
- ]}
408
+ <KeyboardAvoidingView
409
+ style={{ flex: 1 }}
410
+ behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
411
+ keyboardVerticalOffset={Platform.select({ ios: kbOffset + 10 })}
391
412
  >
392
- <Header
393
- title={title}
394
- joinIcon={createPollIcon ?? createIcon}
395
- closeIcon={closeIcon}
396
- titleStyle={[
397
- createPollsStyle.titleTextStyle ?? theme.typography.heading,
398
- { color: theme.palette.getAccent() },
399
- ]}
400
- closeIconTint={
401
- createPollsStyle.closeIconTint ?? theme.palette.getPrimary()
402
- }
403
- createIconTint={
404
- createPollsStyle.createIconTint ?? theme.palette.getPrimary()
405
- }
406
- onSubmit={polls}
407
- onCancel={onClose ? onClose : () => {}}
408
- />
409
- <TextInput
410
- value={question}
411
- onChangeText={setQuestion}
412
- placeholder={questionPlaceholderText}
413
- placeholderTextColor={theme.palette.getAccent600()}
413
+ <ScrollView
414
414
  style={[
415
- styles.textInput,
415
+ styles.container,
416
416
  {
417
- borderBottomColor: theme.palette.getAccent200(),
418
- color: theme.palette.getAccent(),
417
+ width: createPollsStyle.width ?? 'auto',
418
+ height: createPollsStyle.height ?? 'auto',
419
+ backgroundColor:
420
+ createPollsStyle.backgroundColor ??
421
+ theme.palette.getBackgroundColor(),
422
+ borderRadius: createPollsStyle.borderRadius ?? 0,
419
423
  },
420
- theme.typography.body,
421
- question?.length > 0
422
- ? createPollsStyle.questionPlaceholderTextStyle
423
- : createPollsStyle.questionInputTextStyle,
424
+ createPollsStyle.border ?? {},
424
425
  ]}
425
- />
426
- <View style={styles.addAnswerButtonContainer}>
427
- <Text
428
- style={
429
- (theme.typography.text2,
430
- {
431
- color: theme.palette.getAccent500(),
432
- })
426
+ contentContainerStyle={{
427
+ paddingBottom: 50
428
+ }}
429
+ >
430
+ <Header
431
+ title={title}
432
+ joinIcon={createPollIcon ?? createIcon}
433
+ closeIcon={closeIcon}
434
+ titleStyle={[
435
+ createPollsStyle.titleTextStyle ?? theme.typography.heading,
436
+ { color: theme.palette.getAccent() },
437
+ ]}
438
+ closeIconTint={
439
+ createPollsStyle.closeIconTint ?? theme.palette.getPrimary()
433
440
  }
434
- >
435
- {localize('SET_THE_ANSWERS')}
436
- </Text>
437
- </View>
438
- <FlatList
439
- keyExtractor={(_, i) => `${i}`}
440
- data={answersList}
441
- renderItem={AnswersListItem}
442
- ListFooterComponent={AddAnswer}
443
- />
444
- </View>
441
+ createIconTint={
442
+ createPollsStyle.createIconTint ?? theme.palette.getPrimary()
443
+ }
444
+ onSubmit={polls}
445
+ onCancel={onClose ? onClose : () => { }}
446
+ />
447
+ <TextInput
448
+ value={question}
449
+ onChangeText={setQuestion}
450
+ placeholder={questionPlaceholderText}
451
+ placeholderTextColor={theme.palette.getAccent600()}
452
+ style={[
453
+ styles.textInput,
454
+ {
455
+ borderBottomColor: theme.palette.getAccent200(),
456
+ color: theme.palette.getAccent(),
457
+ },
458
+ theme.typography.body,
459
+ question?.length > 0
460
+ ? createPollsStyle.questionPlaceholderTextStyle
461
+ : createPollsStyle.questionInputTextStyle,
462
+ ]}
463
+ />
464
+ <View style={styles.addAnswerButtonContainer}>
465
+ <Text
466
+ style={
467
+ (theme.typography.text2,
468
+ {
469
+ color: theme.palette.getAccent500(),
470
+ })
471
+ }
472
+ >
473
+ {localize('SET_THE_ANSWERS')}
474
+ </Text>
475
+ </View>
476
+
477
+ {getPollAnswers()}
478
+
479
+ </ScrollView>
480
+ </KeyboardAvoidingView>
445
481
  );
446
482
  };
447
483
 
@@ -5,6 +5,7 @@ import {
5
5
  MessageBubbleAlignmentType,
6
6
  MetadataConstants,
7
7
  MessageCategoryConstants,
8
+ AdditionalBubbleStylingParams,
8
9
  } from '../../shared/constants/UIKitConstants';
9
10
  import { CometChatTheme } from '../../shared/resources/CometChatTheme';
10
11
  import { ExtensionTypeConstants } from '../ExtensionConstants';
@@ -107,9 +108,9 @@ export class PollsExtensionDecorator extends DataSourceDecorator {
107
108
  return attachmentOptions;
108
109
  }
109
110
 
110
- getAllMessageTemplates(theme: CometChatTheme): CometChatMessageTemplate[] {
111
+ getAllMessageTemplates(theme: CometChatTheme, additionalParams?: AdditionalBubbleStylingParams): CometChatMessageTemplate[] {
111
112
  let templateList: CometChatMessageTemplate[] = super.getAllMessageTemplates(
112
- theme
113
+ theme, additionalParams
113
114
  );
114
115
 
115
116
  templateList.push(
@@ -28,9 +28,9 @@ export const Styles = StyleSheet.create({
28
28
  flexDirection: "row",
29
29
  },
30
30
  stickerItemStyle: {
31
- width: "20%",
32
- height: 60,
33
- margin: 8,
31
+ width: "18%",
32
+ aspectRatio: 1,
33
+ margin: "1%",
34
34
  padding: 0,
35
35
  },
36
36
  stickerMsgStyle: {