@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
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Alert,
|
|
3
|
+
Linking,
|
|
4
|
+
NativeModules,
|
|
5
|
+
PermissionsAndroid,
|
|
6
|
+
Platform,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
import { localize } from '../resources/CometChatLocalize/CometChatLocalize';
|
|
9
|
+
const { FileManager } = NativeModules;
|
|
10
|
+
|
|
11
|
+
let instance: PermissionUtilIOS;
|
|
12
|
+
const permissionStatus = {
|
|
13
|
+
'Not Determined': 0,
|
|
14
|
+
'Restricted': 1,
|
|
15
|
+
'Denied': 2,
|
|
16
|
+
'Authorized': 3,
|
|
17
|
+
'Unknown': -1,
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
const permissionStatusAndroid = {
|
|
21
|
+
granted: 3,
|
|
22
|
+
denied: 2,
|
|
23
|
+
never_ask_again: 2,
|
|
24
|
+
} as const;
|
|
25
|
+
|
|
26
|
+
const permissibleResources = ['camera', 'mic'] as const;
|
|
27
|
+
|
|
28
|
+
const permissionMapAndroid = {
|
|
29
|
+
camera: PermissionsAndroid.PERMISSIONS.CAMERA,
|
|
30
|
+
mic: PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type TPermissibleResources = (typeof permissibleResources)[number];
|
|
34
|
+
|
|
35
|
+
type ValueOf<T> = T[keyof T];
|
|
36
|
+
type TPermissionStatus = ValueOf<typeof permissionStatus>;
|
|
37
|
+
|
|
38
|
+
const permissionStore: Record<TPermissibleResources, TPermissionStatus> = {
|
|
39
|
+
camera: permissionStatus.Unknown,
|
|
40
|
+
mic: permissionStatus.Unknown,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
class PermissionUtilIOS {
|
|
44
|
+
status = permissionStatus;
|
|
45
|
+
constructor() {
|
|
46
|
+
if (instance) {
|
|
47
|
+
throw new Error('New instance cannot be created!!');
|
|
48
|
+
}
|
|
49
|
+
instance = this;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async init() {
|
|
53
|
+
try {
|
|
54
|
+
if (Platform.OS === "ios") {
|
|
55
|
+
const res: Record<TPermissibleResources, TPermissionStatus> =
|
|
56
|
+
await FileManager.checkResourcesPermission(['mic', 'camera']);
|
|
57
|
+
for (const resourceType in res) {
|
|
58
|
+
permissionStore[resourceType as TPermissibleResources] =
|
|
59
|
+
res[resourceType as TPermissibleResources];
|
|
60
|
+
}
|
|
61
|
+
permissionStore.camera = res.camera;
|
|
62
|
+
permissionStore.mic = res.mic;
|
|
63
|
+
} else if (Platform.OS === "android") {
|
|
64
|
+
for (const resourceType of permissibleResources) {
|
|
65
|
+
const isGranted = await PermissionsAndroid.check(permissionMapAndroid[resourceType]);
|
|
66
|
+
permissionStore[resourceType] = isGranted ? permissionStatus.Authorized : permissionStatus['Not Determined'];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return true;
|
|
70
|
+
} catch (error: any) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async get(resources: TPermissibleResources[]) {
|
|
76
|
+
return resources.map((resource) => {
|
|
77
|
+
if (!permissibleResources.includes(resource)) {
|
|
78
|
+
throw new Error('Invalid resource type');
|
|
79
|
+
}
|
|
80
|
+
return permissionStore[resource];
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async request(resources: TPermissibleResources[]) {
|
|
85
|
+
for (const resource of resources) {
|
|
86
|
+
if (!permissibleResources.includes(resource)) {
|
|
87
|
+
throw new Error('Invalid resource type');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (Platform.OS === 'ios') {
|
|
91
|
+
const res: Record<TPermissibleResources, TPermissionStatus> =
|
|
92
|
+
await FileManager.requestResourcesPermission(resources);
|
|
93
|
+
for (const resourceType in res) {
|
|
94
|
+
permissionStore[resourceType as TPermissibleResources] =
|
|
95
|
+
res[resourceType as TPermissibleResources];
|
|
96
|
+
}
|
|
97
|
+
} else if (Platform.OS === 'android') {
|
|
98
|
+
const res = await PermissionsAndroid.requestMultiple(resources.map(item => permissionMapAndroid[item]));
|
|
99
|
+
const permissionMapAndroidRevert = {};
|
|
100
|
+
for (const resource in permissionMapAndroid) {
|
|
101
|
+
permissionMapAndroidRevert[permissionMapAndroid[resource]] = resource;
|
|
102
|
+
}
|
|
103
|
+
for (const androidResource in res) {
|
|
104
|
+
permissionStore[permissionMapAndroidRevert[androidResource]] =
|
|
105
|
+
permissionStatusAndroid[res[androidResource]];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async startResourceBasedTask(resources: TPermissibleResources[]) {
|
|
111
|
+
const resourcePermStatuses = await this.get(resources);
|
|
112
|
+
let allResourcesAllowed = true;
|
|
113
|
+
for (let i = 0; i < resourcePermStatuses.length; i++) {
|
|
114
|
+
const resourcePermStatus = resourcePermStatuses[i];
|
|
115
|
+
if (resourcePermStatus === this.status['Not Determined'] || (Platform.OS === "android" && resourcePermStatuses[i] === this.status.Denied)) {
|
|
116
|
+
await this.request([resources[i]]);
|
|
117
|
+
[resourcePermStatuses[i]] = await this.get([resources[i]]);
|
|
118
|
+
}
|
|
119
|
+
if (resourcePermStatuses[i] === this.status.Denied) {
|
|
120
|
+
allResourcesAllowed = false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (allResourcesAllowed === false) {
|
|
124
|
+
Alert.alert(localize('RESOURCE_PERMISSION_REQUIRED'), undefined, [
|
|
125
|
+
{
|
|
126
|
+
style: 'cancel',
|
|
127
|
+
text: localize('CANCEL'),
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
style: 'default',
|
|
131
|
+
text: localize('SETTINGS'),
|
|
132
|
+
onPress: () => {
|
|
133
|
+
Linking.openSettings();
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
]);
|
|
137
|
+
}
|
|
138
|
+
return allResourcesAllowed;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export const permissionUtil = Object.freeze(new PermissionUtilIOS());
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useRef, useEffect, useContext } from "react";
|
|
2
|
-
import { View, Text, Image, NativeModules, ActivityIndicator, NativeEventEmitter } from "react-native";
|
|
2
|
+
import { View, Text, Image, NativeModules, ActivityIndicator, NativeEventEmitter, Platform } from "react-native";
|
|
3
3
|
import { CometChatContext } from "../../CometChatContext";
|
|
4
4
|
import { CometChatContextType, ImageType } from "../../base/Types";
|
|
5
5
|
import { AudioBubbleStyle, AudioBubbleStyleInterface } from "./AudioBubbleStyle";
|
|
@@ -137,7 +137,7 @@ export const CometChatAudioBubble = ({
|
|
|
137
137
|
};
|
|
138
138
|
|
|
139
139
|
const handleTouchEnd = () => {
|
|
140
|
-
|
|
140
|
+
if (pressTime.current === null && Platform.OS === "ios") return;
|
|
141
141
|
const endTime = Date.now();
|
|
142
142
|
const pressDuration = endTime - pressTime.current;
|
|
143
143
|
if (pressDuration < 500) {
|
|
@@ -145,9 +145,11 @@ export const CometChatAudioBubble = ({
|
|
|
145
145
|
}
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
const onTouchMove = () => {
|
|
149
|
+
if (Platform.OS === "ios") {
|
|
150
|
+
pressTime.current = null
|
|
151
|
+
}
|
|
152
|
+
}
|
|
151
153
|
|
|
152
154
|
return (
|
|
153
155
|
<View style={[Style.container, { backgroundColor, ...border, borderRadius, height, width }]}>
|
|
@@ -157,7 +159,7 @@ export const CometChatAudioBubble = ({
|
|
|
157
159
|
<View
|
|
158
160
|
onTouchStart={handleTouchStart}
|
|
159
161
|
onTouchEnd={handleTouchEnd}
|
|
160
|
-
|
|
162
|
+
onTouchMove={onTouchMove}
|
|
161
163
|
>
|
|
162
164
|
<Image
|
|
163
165
|
source={
|
|
@@ -46,7 +46,11 @@ export const CometChatAvatar = (props: CometChatAvatarProps) => {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
const getImageView = () => {
|
|
49
|
-
|
|
49
|
+
let isImage = Boolean(image);
|
|
50
|
+
if (image && image.hasOwnProperty("uri") && typeof image.uri !== "string") {
|
|
51
|
+
isImage = false;
|
|
52
|
+
}
|
|
53
|
+
if (!isImage && name) {
|
|
50
54
|
return (
|
|
51
55
|
<Text
|
|
52
56
|
style={[
|
|
@@ -68,6 +68,8 @@ export const CometChatFileBubble = ({
|
|
|
68
68
|
const downloadFile = () => {
|
|
69
69
|
if (processing) return;
|
|
70
70
|
|
|
71
|
+
if(!fileUrl) return;
|
|
72
|
+
|
|
71
73
|
setProcessing(true);
|
|
72
74
|
FileManager.checkAndDownload(fileUrl, getFileName(), async (storedFilePath) => {
|
|
73
75
|
console.log(storedFilePath);
|
|
@@ -78,6 +80,8 @@ export const CometChatFileBubble = ({
|
|
|
78
80
|
const downloadAndOpen = () => {
|
|
79
81
|
if (processing) return;
|
|
80
82
|
|
|
83
|
+
if(!fileUrl) return;
|
|
84
|
+
|
|
81
85
|
setProcessing(true);
|
|
82
86
|
FileManager.openFile(fileUrl, getFileName(), async (isOpened: string) => {
|
|
83
87
|
console.log(isOpened);
|
|
@@ -94,11 +98,11 @@ export const CometChatFileBubble = ({
|
|
|
94
98
|
onTouchStart: () => {
|
|
95
99
|
wrapperPressTime.current = Date.now();
|
|
96
100
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
onTouchMove: () => {
|
|
102
|
+
wrapperPressTime.current = null
|
|
103
|
+
},
|
|
100
104
|
onTouchEnd: () => {
|
|
101
|
-
|
|
105
|
+
if (wrapperPressTime.current === null) return;
|
|
102
106
|
const endTime = Date.now();
|
|
103
107
|
const pressDuration = endTime - wrapperPressTime.current;
|
|
104
108
|
if (pressDuration < 500) {
|
|
@@ -115,11 +119,8 @@ export const CometChatFileBubble = ({
|
|
|
115
119
|
},
|
|
116
120
|
// onTouchMove: () => {
|
|
117
121
|
// pressTimeOnAndroid.current = null
|
|
118
|
-
// }
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const shouldDownloadAndOpen = () => {
|
|
122
|
-
if (Platform.OS === "android") {
|
|
122
|
+
// },
|
|
123
|
+
onTouchEnd: () => {
|
|
123
124
|
// if (pressTimeOnAndroid.current === null) return;
|
|
124
125
|
const endTime = Date.now();
|
|
125
126
|
const pressDuration = endTime - pressTimeOnAndroid.current;
|
|
@@ -127,7 +128,7 @@ export const CometChatFileBubble = ({
|
|
|
127
128
|
downloadAndOpen();
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
|
-
}
|
|
131
|
+
} : {};
|
|
131
132
|
|
|
132
133
|
const shouldDownload = () => {
|
|
133
134
|
if (Platform.OS === "android") {
|
|
@@ -142,7 +143,7 @@ export const CometChatFileBubble = ({
|
|
|
142
143
|
|
|
143
144
|
return (
|
|
144
145
|
<View {...viewProps} style={[Style.container, { backgroundColor, borderWidth: border.borderWidth, borderColor: border.borderColor, borderRadius, height, width }]}>
|
|
145
|
-
<View {...viewPropsForAndroid}
|
|
146
|
+
<View {...viewPropsForAndroid} style={Style.messageInfoStyle}>
|
|
146
147
|
{
|
|
147
148
|
title && <Text
|
|
148
149
|
numberOfLines={1}
|
|
@@ -108,7 +108,7 @@ export const CometChatImageBubble = (props: CometChatImageBubbleInterface) => {
|
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
const handleTouchEnd = () => {
|
|
111
|
-
|
|
111
|
+
if (pressTime.current === null && Platform.OS === "ios") return;
|
|
112
112
|
const endTime = Date.now();
|
|
113
113
|
const pressDuration = endTime - pressTime.current;
|
|
114
114
|
if (pressDuration < 500) {
|
|
@@ -116,9 +116,11 @@ export const CometChatImageBubble = (props: CometChatImageBubbleInterface) => {
|
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
const onTouchMove = () => {
|
|
120
|
+
if (Platform.OS === "ios") {
|
|
121
|
+
pressTime.current = null;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
122
124
|
|
|
123
125
|
useLayoutEffect(() => {
|
|
124
126
|
if(isHttpUrl(thumbnailUrl?.uri ?? imageUrl?.uri)) {
|
|
@@ -141,7 +143,7 @@ export const CometChatImageBubble = (props: CometChatImageBubbleInterface) => {
|
|
|
141
143
|
<View
|
|
142
144
|
onTouchStart={handleTouchStart}
|
|
143
145
|
onTouchEnd={handleTouchEnd}
|
|
144
|
-
|
|
146
|
+
onTouchMove={onTouchMove}
|
|
145
147
|
style={{
|
|
146
148
|
justifyContent:'center',
|
|
147
149
|
alignItems: 'center',
|
|
@@ -136,7 +136,6 @@ export const CometChatMessageInput = (
|
|
|
136
136
|
: style.placeholderTextFont ?? theme.typography.body,
|
|
137
137
|
]}
|
|
138
138
|
onChangeText={onChangeText}
|
|
139
|
-
value={text}
|
|
140
139
|
placeholderTextColor={
|
|
141
140
|
style.placeholderTextColor
|
|
142
141
|
? style.placeholderTextColor
|
|
@@ -146,7 +145,9 @@ export const CometChatMessageInput = (
|
|
|
146
145
|
textAlignVertical="top"
|
|
147
146
|
placeholder={placeHolderText}
|
|
148
147
|
onSelectionChange={onSelectionChange}
|
|
149
|
-
|
|
148
|
+
>
|
|
149
|
+
{text}
|
|
150
|
+
</TextInput>
|
|
150
151
|
<View
|
|
151
152
|
style={{
|
|
152
153
|
flexDirection: 'row',
|
|
@@ -53,7 +53,7 @@ const CometChatReactions = (props: CometChatReactionsInterface) => {
|
|
|
53
53
|
primaryBorder,
|
|
54
54
|
} = _style;
|
|
55
55
|
|
|
56
|
-
const reactionView = (reactionObj) => {
|
|
56
|
+
const reactionView = (reactionObj, index) => {
|
|
57
57
|
let count: number = reactionObj?.count;
|
|
58
58
|
let Emoji: string = reactionObj?.reaction;
|
|
59
59
|
let Count: JSX.Element = <Text
|
|
@@ -67,7 +67,7 @@ const CometChatReactions = (props: CometChatReactionsInterface) => {
|
|
|
67
67
|
</Text>;
|
|
68
68
|
|
|
69
69
|
return count >= 1 ? (
|
|
70
|
-
<View style={[
|
|
70
|
+
<View key={index} style={[
|
|
71
71
|
Styles.messageReactionsStyle,
|
|
72
72
|
{
|
|
73
73
|
backgroundColor: reactionObj?.reactedByMe ? primaryBackgroundColor : backgroundColor,
|
|
@@ -107,7 +107,7 @@ const CometChatReactions = (props: CometChatReactionsInterface) => {
|
|
|
107
107
|
let AllObj = new CometChat.ReactionCount("All", totalCount, false); // { reaction: "All", count: totalCount };
|
|
108
108
|
|
|
109
109
|
return (
|
|
110
|
-
<View style={[
|
|
110
|
+
<View key={new Date().getTime()} style={[
|
|
111
111
|
Styles.messageReactionsStyle,
|
|
112
112
|
{
|
|
113
113
|
paddingVertical: 0, paddingHorizontal: 0,
|
|
@@ -39,6 +39,7 @@ import CometChatQuickView from "../CometChatQuickView/CometChatQuickView";
|
|
|
39
39
|
import { localize } from "../../resources";
|
|
40
40
|
import { CometChatUIKit } from "../../CometChatUiKit";
|
|
41
41
|
import { CometChatUiKitConstants } from "../..";
|
|
42
|
+
import { InteractiveMessageUtils } from "../../utils/InteractiveMessageUtils";
|
|
42
43
|
|
|
43
44
|
const { TimeZoneCodeManager } = NativeModules;
|
|
44
45
|
export interface CometChatSchedulerBubbleInterface {
|
|
@@ -621,6 +622,17 @@ export const CometChatSchedulerBubble = memo(
|
|
|
621
622
|
useEffect(() => {
|
|
622
623
|
CometChat.getLoggedinUser()
|
|
623
624
|
.then((u) => {
|
|
625
|
+
let hasInteractionCompleted: boolean = InteractiveMessageUtils.checkHasInteractionCompleted({
|
|
626
|
+
interactedElements: message?.getInteractions() || [],
|
|
627
|
+
interactionGoal: message?.getInteractionGoal() || undefined
|
|
628
|
+
});
|
|
629
|
+
if(hasInteractionCompleted) {
|
|
630
|
+
setCurrentComp((prev) => ({
|
|
631
|
+
current: componentEnum.interacted,
|
|
632
|
+
previous: prev.current,
|
|
633
|
+
}));
|
|
634
|
+
return
|
|
635
|
+
}
|
|
624
636
|
TimeZoneCodeManager.getCurrentTimeZone((timeZone) => {
|
|
625
637
|
currentTimeZoneRef.current = timeZone;
|
|
626
638
|
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { View, Text, FlatList, ListRenderItemInfo, ActivityIndicator } from 'react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { SuggestionItem } from './SuggestionItem';
|
|
4
|
+
import { CometChatListItem, ListItemStyle } from '../CometChatListItem';
|
|
5
|
+
import { AvatarStyleInterface } from '../CometChatAvatar';
|
|
6
|
+
|
|
7
|
+
export interface CometChatSuggestionListInterface {
|
|
8
|
+
separatorColor?: string
|
|
9
|
+
/**
|
|
10
|
+
* Array of selection items
|
|
11
|
+
*/
|
|
12
|
+
data: Array<SuggestionItem>;
|
|
13
|
+
listItemStyle?: ListItemStyle;
|
|
14
|
+
avatarStyle?: AvatarStyleInterface;
|
|
15
|
+
onPress: (item: SuggestionItem) => void;
|
|
16
|
+
onEndReached?: () => void;
|
|
17
|
+
loading?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const CometChatSuggestionList = (props: CometChatSuggestionListInterface) => {
|
|
21
|
+
const { data, avatarStyle, listItemStyle, separatorColor, onPress, onEndReached, loading } = props;
|
|
22
|
+
|
|
23
|
+
const _render = ({ item, index }: ListRenderItemInfo<SuggestionItem>) => {
|
|
24
|
+
let shouldLoadAvatarName = item.hideLeadingIcon ? {} : { avatarName: item.name }
|
|
25
|
+
return (
|
|
26
|
+
<CometChatListItem
|
|
27
|
+
key={index}
|
|
28
|
+
id={item.id}
|
|
29
|
+
title={item.name}
|
|
30
|
+
avatarStyle={{ ...avatarStyle }}
|
|
31
|
+
avatarURL={item.leadingIconUrl ? { uri: item.leadingIconUrl } : undefined}
|
|
32
|
+
listItemStyle={{ ...listItemStyle }}
|
|
33
|
+
onPress={() => onPress(item)}
|
|
34
|
+
{...shouldLoadAvatarName}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<View>
|
|
41
|
+
<FlatList
|
|
42
|
+
data={data}
|
|
43
|
+
renderItem={_render}
|
|
44
|
+
onEndReached={({ distanceFromEnd }) => {
|
|
45
|
+
if (distanceFromEnd < 0) return;
|
|
46
|
+
onEndReached();
|
|
47
|
+
}}
|
|
48
|
+
ItemSeparatorComponent={() => <View style={{ height: 1, marginLeft: 5, backgroundColor: separatorColor }}></View>}
|
|
49
|
+
onEndReachedThreshold={0.3}
|
|
50
|
+
keyboardShouldPersistTaps={"always"}
|
|
51
|
+
style={{
|
|
52
|
+
paddingLeft: 5
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
<View style={{
|
|
56
|
+
position: 'absolute',
|
|
57
|
+
bottom: 0,
|
|
58
|
+
width: '100%',
|
|
59
|
+
}}>
|
|
60
|
+
{loading && <ActivityIndicator animating={loading} />}
|
|
61
|
+
</View>
|
|
62
|
+
</View>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
export class SuggestionItem {
|
|
3
|
+
/**
|
|
4
|
+
* Unique identifier of item
|
|
5
|
+
*/
|
|
6
|
+
id: string;
|
|
7
|
+
/**
|
|
8
|
+
* Name to be displayed in the list
|
|
9
|
+
*/
|
|
10
|
+
name: string;
|
|
11
|
+
/**
|
|
12
|
+
* Avatar Icon Url
|
|
13
|
+
*/
|
|
14
|
+
leadingIconUrl?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Hide leading icon
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
19
|
+
hideLeadingIcon?: boolean = true;
|
|
20
|
+
/**
|
|
21
|
+
* Presence Indicator
|
|
22
|
+
*/
|
|
23
|
+
status?: 'online' | 'offline';
|
|
24
|
+
/**
|
|
25
|
+
* Name to be displayed in the composer
|
|
26
|
+
*/
|
|
27
|
+
promptText: string;
|
|
28
|
+
/**
|
|
29
|
+
* underlying text
|
|
30
|
+
* @example <@uid:superhero1>
|
|
31
|
+
*/
|
|
32
|
+
underlyingText: string;
|
|
33
|
+
/**
|
|
34
|
+
* set a tracking character.
|
|
35
|
+
* @description string length has be 1.
|
|
36
|
+
* @example '@' | '#' etc.
|
|
37
|
+
*/
|
|
38
|
+
trackingCharacter: string
|
|
39
|
+
/**
|
|
40
|
+
* extra data to be passed in JSON format
|
|
41
|
+
*/
|
|
42
|
+
data?: JSON;
|
|
43
|
+
|
|
44
|
+
constructor(props: SuggestionItem) {
|
|
45
|
+
Object.assign(this, props);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AvatarStyleInterface } from "../CometChatAvatar";
|
|
2
|
+
import { ListItemStyle } from "../CometChatListItem";
|
|
3
|
+
import { CometChatSuggestionListInterface } from "./CometChatSuggestionList";
|
|
4
|
+
import { SuggestionItem } from "./SuggestionItem";
|
|
5
|
+
|
|
6
|
+
export interface SuggestionListConfigurationInterface extends CometChatSuggestionListInterface { }
|
|
7
|
+
|
|
8
|
+
export class SuggestionListConfiguration {
|
|
9
|
+
separatorColor: string
|
|
10
|
+
/**
|
|
11
|
+
* Array of selection items
|
|
12
|
+
*/
|
|
13
|
+
data: Array<SuggestionItem>;
|
|
14
|
+
listItemStyle?: ListItemStyle
|
|
15
|
+
avatarStyle?: AvatarStyleInterface
|
|
16
|
+
onPress: (item: SuggestionItem) => void
|
|
17
|
+
onEndReached?: () => void
|
|
18
|
+
loading?: boolean
|
|
19
|
+
|
|
20
|
+
constructor(props: SuggestionListConfigurationInterface) {
|
|
21
|
+
Object.assign(this, props);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CometChatSuggestionList, CometChatSuggestionListInterface } from './CometChatSuggestionList';
|
|
2
|
+
import { SuggestionItem } from './SuggestionItem';
|
|
3
|
+
import { SuggestionListConfiguration, SuggestionListConfigurationInterface } from './SuggestionListConfiguration';
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
CometChatSuggestionList,
|
|
7
|
+
CometChatSuggestionListInterface,
|
|
8
|
+
SuggestionItem,
|
|
9
|
+
SuggestionListConfiguration,
|
|
10
|
+
SuggestionListConfigurationInterface
|
|
11
|
+
}
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import React, {useContext} from "react";
|
|
1
|
+
import React, { useContext, useEffect, useState } from "react";
|
|
2
2
|
import { View, Text, Linking, StyleProp, ViewStyle } from "react-native";
|
|
3
3
|
import { CometChatContextType } from "../../base/Types";
|
|
4
4
|
import { CometChatContext } from "../../CometChatContext";
|
|
5
5
|
import { emailPattern, phoneNumPattern, urlPattern } from "../../constants/UIKitConstants";
|
|
6
6
|
import { TextBubbleStyle, TextBubbleStyleInterface } from "./TextBubbleStyle";
|
|
7
|
+
import { CometChatMentionsFormatter, CometChatTextFormatter, CometChatUrlsFormatter } from "../../formatters";
|
|
7
8
|
|
|
8
9
|
const Link = ({ text, url, style }) => {
|
|
9
|
-
return <Text style={{...style, textDecorationLine: "underline"}} onPress={() => {
|
|
10
|
+
return <Text style={{ ...style, textDecorationLine: "underline" }} onPress={() => {
|
|
10
11
|
let finalUrl = url.startsWith("http") ? url : `http://${url}`
|
|
11
12
|
Linking.canOpenURL(finalUrl)
|
|
12
13
|
.then(res => {
|
|
13
14
|
if (res) {
|
|
14
15
|
Linking.openURL(finalUrl);
|
|
15
16
|
return;
|
|
16
|
-
}
|
|
17
|
+
}
|
|
17
18
|
console.log("Can not open link", finalUrl);
|
|
18
19
|
})
|
|
19
20
|
.catch(err => {
|
|
20
|
-
console.log({url});
|
|
21
|
+
console.log({ url });
|
|
21
22
|
console.log("Error:", err);
|
|
22
23
|
})
|
|
23
24
|
}} >{text}</Text>
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
const getPatternGroup = (str: string):{phone?: string, email?: string, url?: string} => {
|
|
27
|
+
const getPatternGroup = (str: string): { phone?: string, email?: string, url?: string } => {
|
|
27
28
|
let result = {};
|
|
28
29
|
if (str.match(phoneNumPattern))
|
|
29
30
|
result['phone'] = str;
|
|
@@ -34,32 +35,6 @@ const getPatternGroup = (str: string):{phone?: string, email?: string, url?: str
|
|
|
34
35
|
return result;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
export const FormatTextForLinks = ({str, style}) => {
|
|
38
|
-
let res = str.matchAll(phoneNumPattern + "|" + emailPattern + "|" + urlPattern);
|
|
39
|
-
for (let resPart of res) {
|
|
40
|
-
let { email, phone } = getPatternGroup(resPart[0]);
|
|
41
|
-
let pre: string, post:string;
|
|
42
|
-
pre = str.substring(0, resPart.index);
|
|
43
|
-
post = str.substring(resPart.index + resPart[0].length);
|
|
44
|
-
let urlLink = "";
|
|
45
|
-
if (email)
|
|
46
|
-
urlLink = "mailto:";
|
|
47
|
-
if (phone)
|
|
48
|
-
urlLink = "tel:";
|
|
49
|
-
return (
|
|
50
|
-
<Text style={{...style.textFont, color: style.textColor}}>
|
|
51
|
-
<Text>
|
|
52
|
-
{pre}
|
|
53
|
-
</Text>
|
|
54
|
-
<Link text={resPart[0]} url={urlLink + resPart[0].trim()} style={{...style.linkTextFont, color: style.linkTextColor}} />
|
|
55
|
-
<FormatTextForLinks str={post} style={style} />
|
|
56
|
-
</Text>
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return <Text style={{...style.textFont, color: style.textColor}}>{str}</Text>;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
38
|
export interface CometChatTextBubbleInterface {
|
|
64
39
|
/**
|
|
65
40
|
* text tobe shown
|
|
@@ -73,17 +48,24 @@ export interface CometChatTextBubbleInterface {
|
|
|
73
48
|
* text container style
|
|
74
49
|
*/
|
|
75
50
|
textContainerStyle?: StyleProp<ViewStyle>
|
|
51
|
+
textFormatters?: Array<CometChatMentionsFormatter | CometChatUrlsFormatter | CometChatTextFormatter>;
|
|
76
52
|
}
|
|
77
53
|
|
|
78
54
|
export const CometChatTextBubble = (props: CometChatTextBubbleInterface) => {
|
|
79
|
-
|
|
80
|
-
const {
|
|
55
|
+
|
|
56
|
+
const {
|
|
57
|
+
text,
|
|
58
|
+
textContainerStyle,
|
|
59
|
+
textFormatters
|
|
60
|
+
} = props;
|
|
61
|
+
|
|
62
|
+
const { theme } = useContext<CometChatContextType>(CometChatContext);
|
|
63
|
+
const [formattedText, setFormattedText] = useState<string>();
|
|
81
64
|
|
|
82
65
|
const _style = new TextBubbleStyle({
|
|
83
66
|
backgroundColor: theme?.palette.getBackgroundColor(),
|
|
84
67
|
textColor: theme?.palette.getAccent(),
|
|
85
68
|
textFont: theme?.typography.body,
|
|
86
|
-
linkTextFont: theme?.typography.body,
|
|
87
69
|
...props.style
|
|
88
70
|
});
|
|
89
71
|
|
|
@@ -93,30 +75,35 @@ export const CometChatTextBubble = (props: CometChatTextBubbleInterface) => {
|
|
|
93
75
|
borderRadius,
|
|
94
76
|
textColor,
|
|
95
77
|
textFont,
|
|
96
|
-
linkTextColor,
|
|
97
|
-
linkTextFont,
|
|
98
78
|
height,
|
|
99
79
|
width
|
|
100
80
|
} = _style;
|
|
101
81
|
|
|
102
|
-
|
|
103
|
-
text
|
|
104
|
-
|
|
105
|
-
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
let finalText = text;
|
|
84
|
+
if (textFormatters && textFormatters.length) {
|
|
85
|
+
if (textFormatters) {
|
|
86
|
+
for (let i = 0; i < textFormatters.length; i++) {
|
|
87
|
+
(finalText as string | void) = textFormatters[i].getFormattedText(finalText);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
setFormattedText(finalText as string);
|
|
92
|
+
}, [])
|
|
106
93
|
|
|
107
94
|
return <View style={[
|
|
108
95
|
{
|
|
109
96
|
alignSelf: "flex-start",
|
|
110
97
|
},
|
|
111
98
|
{
|
|
112
|
-
backgroundColor,
|
|
99
|
+
backgroundColor, borderRadius, maxHeight: height, maxWidth: width,
|
|
113
100
|
overflow: "hidden", padding: 8, paddingBottom: 0
|
|
114
101
|
},
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
<
|
|
119
|
-
|
|
102
|
+
border,
|
|
103
|
+
textContainerStyle
|
|
104
|
+
]}>
|
|
105
|
+
<Text style={[{ color: textColor }, textFont]}>{formattedText}</Text>
|
|
106
|
+
|
|
120
107
|
</View>
|
|
121
108
|
}
|
|
122
109
|
|