@cometchat/chat-uikit-react-native 4.3.3 → 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.
- package/ios/CommonUtil.h +4 -0
- package/ios/CommonUtil.m +27 -0
- package/package.json +1 -1
- package/src/AI/AIAssistBot/AIAssistBotDecorator.tsx +0 -3
- package/src/CometChatConversations/CometChatConversations.tsx +121 -59
- package/src/CometChatConversations/ConversationsConfiguration.ts +25 -4
- package/src/CometChatConversationsWithMessages/CometChatConversationsWithMessages.tsx +29 -29
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +554 -52
- package/src/CometChatMessageComposer/MessageComposerConfiguration.tsx +12 -1
- package/src/CometChatMessageComposer/resources/Info.png +0 -0
- package/src/CometChatMessageComposer/resources/index.ts +3 -1
- package/src/CometChatMessageHeader/listners.ts +0 -2
- package/src/CometChatMessageList/CometChatMessageList.tsx +124 -15
- package/src/CometChatMessageList/MessageListConfiguration.ts +14 -1
- package/src/CometChatMessages/CometChatMessages.tsx +16 -16
- package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +6 -1
- package/src/calls/CallingExtentionDecorator.tsx +5 -5
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +3 -3
- package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +2 -0
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +2 -0
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +3 -3
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +3 -3
- package/src/extensions/LinkPreview/LinkPreviewExtentionDecorator.tsx +4 -4
- package/src/extensions/MessageTranslation/MessageTranslationBubble.tsx +31 -9
- package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +83 -6
- package/src/extensions/Polls/Polls.tsx +106 -70
- package/src/extensions/Polls/PollsDecorator.tsx +3 -2
- package/src/extensions/Stickers/CometChatStickerKeyboard/style.ts +3 -3
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +14 -6
- package/src/extensions/TextModeration/TextModerationExtensionDecorator.tsx +3 -3
- package/src/index.ts +21 -0
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +150 -25
- package/src/shared/CometChatUiKit/index.ts +1 -1
- package/src/shared/base/vars.ts +13 -0
- package/src/shared/constants/UIKitConstants.ts +6 -0
- package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +7 -0
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +11 -1
- package/src/shared/events/CometChatUIEvents.ts +3 -1
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +380 -0
- package/src/shared/formatters/CometChatMentionsFormatter/MentionTextStyle.ts +14 -0
- package/src/shared/formatters/CometChatMentionsFormatter/index.ts +7 -0
- package/src/shared/formatters/CometChatTextFormatter.ts +253 -0
- package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +146 -0
- package/src/shared/formatters/index.ts +11 -0
- package/src/shared/framework/DataSource.ts +21 -16
- package/src/shared/framework/DataSourceDecorator.tsx +29 -13
- package/src/shared/framework/MessageDataSource.tsx +215 -49
- package/src/shared/helper/useKeyboard.tsx +20 -2
- package/src/shared/index.ts +23 -3
- package/src/shared/resources/CometChatLocalize/CometChatLocalize.ts +2 -0
- package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/de/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/en/translation.json +10 -1
- package/src/shared/resources/CometChatLocalize/resources/es/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +10 -1
- package/src/shared/resources/CometChatLocalize/resources/hu/translation.json +315 -0
- package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +12 -1
- package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +11 -1
- package/src/shared/resources/CometChatTheme/Palette.ts +16 -0
- package/src/shared/utils/InteractiveMessageUtils.ts +39 -1
- package/src/shared/utils/PermissionUtil.ts +142 -0
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +8 -6
- package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +5 -1
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +12 -11
- package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +7 -5
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +3 -2
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +3 -3
- package/src/shared/views/CometChatSchedulerBubble/CometChatSchedulerBubble.tsx +12 -0
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +64 -0
- package/src/shared/views/CometChatSuggestionList/SuggestionItem.ts +48 -0
- package/src/shared/views/CometChatSuggestionList/SuggestionListConfiguration.ts +23 -0
- package/src/shared/views/CometChatSuggestionList/index.ts +11 -0
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +33 -46
- package/src/shared/views/CometChatTextBubble/TextBubbleStyle.ts +0 -14
- package/src/shared/views/CometChatTextBubble/index.ts +2 -3
- package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +5 -3
- package/src/shared/views/index.ts +9 -3
- package/src/shared/utils/PermissionUtilIOS.ts +0 -104
|
@@ -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 {
|
|
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
|
-
<
|
|
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
|
-
{
|
|
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('
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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
|
-
<
|
|
379
|
-
style={
|
|
380
|
-
|
|
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
|
-
<
|
|
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.
|
|
415
|
+
styles.container,
|
|
416
416
|
{
|
|
417
|
-
|
|
418
|
-
|
|
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
|
-
|
|
421
|
-
question?.length > 0
|
|
422
|
-
? createPollsStyle.questionPlaceholderTextStyle
|
|
423
|
-
: createPollsStyle.questionInputTextStyle,
|
|
424
|
+
createPollsStyle.border ?? {},
|
|
424
425
|
]}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
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
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
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(
|
|
@@ -5,14 +5,15 @@ import { localize } from "../../shared/resources";
|
|
|
5
5
|
import { CometChatBottomSheet} from "../../shared/views";
|
|
6
6
|
import { ChatConfigurator, DataSource, DataSourceDecorator } from "../../shared/framework";
|
|
7
7
|
import { CometChatTheme } from "../../shared/resources/CometChatTheme";
|
|
8
|
-
import { MessageBubbleAlignmentType, MessageCategoryConstants } from "../../shared/constants/UIKitConstants";
|
|
8
|
+
import { AdditionalBubbleStylingParams, MessageBubbleAlignmentType, MessageCategoryConstants } from "../../shared/constants/UIKitConstants";
|
|
9
9
|
import { ExtensionTypeConstants } from "../ExtensionConstants";
|
|
10
|
-
import { Image, TouchableOpacity } from "react-native";
|
|
10
|
+
import { Image, Keyboard, TouchableOpacity } from "react-native";
|
|
11
11
|
import { CometChatStickerBubble } from "./StickersBubble";
|
|
12
12
|
import { StickerConfigurationInterface } from "./StickerConfiguration";
|
|
13
13
|
import { StickerIcon } from "./resources";
|
|
14
14
|
import { CometChatStickerKeyboard } from "./CometChatStickerKeyboard";
|
|
15
15
|
import { CometChatUIKit } from "../../shared/CometChatUiKit/CometChatUIKit";
|
|
16
|
+
import { isKeyboardVisible } from "../../shared/helper/useKeyboard";
|
|
16
17
|
|
|
17
18
|
export class StickersExtensionDecorator extends DataSourceDecorator {
|
|
18
19
|
|
|
@@ -27,8 +28,8 @@ export class StickersExtensionDecorator extends DataSourceDecorator {
|
|
|
27
28
|
return message.getDeletedBy() != null;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
getAllMessageTemplates(theme: CometChatTheme): CometChatMessageTemplate[] {
|
|
31
|
-
let templates = super.getAllMessageTemplates(theme);
|
|
31
|
+
getAllMessageTemplates(theme: CometChatTheme, additionalParams?: AdditionalBubbleStylingParams): CometChatMessageTemplate[] {
|
|
32
|
+
let templates = super.getAllMessageTemplates(theme, additionalParams);
|
|
32
33
|
templates.push(
|
|
33
34
|
new CometChatMessageTemplate({
|
|
34
35
|
type: ExtensionTypeConstants.sticker,
|
|
@@ -90,8 +91,15 @@ export class StickersExtensionDecorator extends DataSourceDecorator {
|
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
let views:JSX.Element[] = super.getAuxiliaryOptions(user,group,id)
|
|
93
|
-
views.push(<TouchableOpacity onPress={() => {
|
|
94
|
-
|
|
94
|
+
views.push(<TouchableOpacity key={"sticker"} onPress={() => {
|
|
95
|
+
if (isKeyboardVisible) {
|
|
96
|
+
Keyboard.dismiss();
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
setShowKeyboard(true);
|
|
99
|
+
}, 1000);
|
|
100
|
+
} else {
|
|
101
|
+
setShowKeyboard(true);
|
|
102
|
+
}
|
|
95
103
|
}} style={{justifyContent: "center"}}>
|
|
96
104
|
<Image
|
|
97
105
|
source={StickerIcon}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataSource, DataSourceDecorator } from "../../shared/framework";
|
|
2
2
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
3
|
-
import { MessageBubbleAlignmentType } from "../../shared/constants/UIKitConstants";
|
|
3
|
+
import { AdditionalBubbleStylingParams, MessageBubbleAlignmentType } from "../../shared/constants/UIKitConstants";
|
|
4
4
|
import { CometChatTheme } from "../../shared/resources/CometChatTheme";
|
|
5
5
|
import { ExtensionConstants } from "../ExtensionConstants";
|
|
6
6
|
import { getExtentionData } from "../ExtensionModerator";
|
|
@@ -20,10 +20,10 @@ export class TextModerationExtensionDecorator extends DataSourceDecorator {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
getTextMessageBubble(messageText: string, message: CometChat.TextMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme) {
|
|
23
|
+
getTextMessageBubble(messageText: string, message: CometChat.TextMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme, additionalParams?: AdditionalBubbleStylingParams) {
|
|
24
24
|
|
|
25
25
|
var text : string = this.checkModeration(message)
|
|
26
|
-
return super.getTextMessageBubble(text , message , alignment, theme);
|
|
26
|
+
return super.getTextMessageBubble(text , message , alignment, theme, additionalParams);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
|
package/src/index.ts
CHANGED
|
@@ -166,6 +166,15 @@ import {
|
|
|
166
166
|
EmojiKeyboardConfiguration,
|
|
167
167
|
EmojiKeyboardStyle,
|
|
168
168
|
|
|
169
|
+
CometChatMentionsFormatter,
|
|
170
|
+
CometChatTextFormatter,
|
|
171
|
+
CometChatUrlsFormatter,
|
|
172
|
+
MentionTextStyle,
|
|
173
|
+
CometChatSuggestionList,
|
|
174
|
+
CometChatSuggestionListInterface,
|
|
175
|
+
SuggestionListConfiguration,
|
|
176
|
+
SuggestionListConfigurationInterface,
|
|
177
|
+
SuggestionItem,
|
|
169
178
|
} from './shared';
|
|
170
179
|
|
|
171
180
|
import {
|
|
@@ -718,6 +727,18 @@ export {
|
|
|
718
727
|
EmojiKeyboardConfiguration,
|
|
719
728
|
EmojiKeyboardStyle,
|
|
720
729
|
/* Emoji Keyboard */
|
|
730
|
+
|
|
731
|
+
/* Text Formatters */
|
|
732
|
+
CometChatMentionsFormatter,
|
|
733
|
+
CometChatTextFormatter,
|
|
734
|
+
CometChatUrlsFormatter,
|
|
735
|
+
MentionTextStyle,
|
|
736
|
+
CometChatSuggestionList,
|
|
737
|
+
CometChatSuggestionListInterface,
|
|
738
|
+
SuggestionItem,
|
|
739
|
+
SuggestionListConfiguration,
|
|
740
|
+
SuggestionListConfigurationInterface
|
|
741
|
+
/* Text Formatters */
|
|
721
742
|
|
|
722
743
|
};
|
|
723
744
|
|