@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.
- package/android/src/main/AndroidManifest.xml +3 -4
- package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +0 -1
- package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +125 -7
- package/android/src/main/java/com/reactnativecometchatuikit/ImageManager.java +1 -1
- 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 +151 -66
- package/src/CometChatConversations/ConversationsConfiguration.ts +25 -4
- package/src/CometChatConversations/style.ts +5 -1
- package/src/CometChatConversationsWithMessages/CometChatConversationsWithMessages.tsx +29 -29
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +598 -63
- 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 +139 -30
- package/src/CometChatMessageList/MessageListConfiguration.ts +19 -6
- package/src/CometChatMessages/CometChatMessages.tsx +16 -16
- package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +41 -3
- 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/LinkPreviewBubble.tsx +51 -15
- 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 +29 -8
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +146 -24
- 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 +31 -11
- package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +1040 -0
- package/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx +223 -0
- package/src/shared/libs/ImageZoom/helper.ts +144 -0
- package/src/shared/libs/ImageZoom/index.tsx +13 -0
- package/src/shared/libs/ImageZoom/types/index.ts +186 -0
- package/src/shared/libs/VideoPlayer/Video.js +0 -24
- package/src/shared/libs/VideoPlayerControls/assets/img/back.png +0 -0
- package/src/shared/libs/VideoPlayerControls/components/Back/Back.tsx +1 -1
- 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/NetworkUtils.tsx +5 -0
- package/src/shared/utils/PermissionUtil.ts +142 -0
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -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 +70 -22
- package/src/shared/views/CometChatImageBubble/assets/index.ts +5 -0
- package/src/shared/views/CometChatImageBubble/assets/spineer.png +0 -0
- package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +106 -0
- package/src/shared/views/CometChatImageViewerModal/index.tsx +1 -0
- package/src/shared/views/CometChatImageViewerModal/resources/Back.png +0 -0
- package/src/shared/views/CometChatImageViewerModal/resources/index.ts +5 -0
- package/src/shared/views/CometChatList/CometChatList.tsx +10 -1
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +3 -2
- package/src/shared/views/{CometChatReactionsList/CometChatReactionsList.tsx → CometChatReactionList/CometChatReactionList.tsx} +17 -17
- package/src/shared/views/CometChatReactionList/ReactionListConfiguration.tsx +14 -0
- package/src/shared/views/CometChatReactionList/index.ts +12 -0
- 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 +6 -4
- package/src/shared/views/index.ts +14 -8
- package/android/src/main/java/com/reactnativecometchatuikit/VideoManager.java +0 -40
- package/src/shared/libs/VideoPlayerControls/assets/img/back@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/back@3x.png +0 -0
- package/src/shared/utils/PermissionUtilIOS.ts +0 -104
- package/src/shared/views/CometChatReactionsList/ReactionsListConfiguration.tsx +0 -14
- package/src/shared/views/CometChatReactionsList/index.ts +0 -12
- /package/src/shared/views/{CometChatReactionsList/ReactionsListStyle.tsx → CometChatReactionList/ReactionListStyle.tsx} +0 -0
- /package/src/shared/views/{CometChatReactionsList → CometChatReactionList}/resources/Spineer.png +0 -0
- /package/src/shared/views/{CometChatReactionsList → CometChatReactionList}/resources/index.ts +0 -0
|
@@ -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());
|
|
@@ -161,6 +161,7 @@ export const CometChatActionSheet = (props: CometChatActionSheetInterface) => {
|
|
|
161
161
|
paddingHorizontal: props.style?.paddingHorizontal
|
|
162
162
|
}),
|
|
163
163
|
...props.style,
|
|
164
|
+
listItemTitleFont: {...theme.typography.subtitle1, ...(props.style.listItemTitleFont ?? {})},
|
|
164
165
|
};
|
|
165
166
|
|
|
166
167
|
const [listMode, setListMode] = React.useState(true);
|
|
@@ -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}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
1
|
+
import React, { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
2
2
|
import { View, Image, NativeModules, Platform, NativeEventEmitter, EmitterSubscription } from "react-native";
|
|
3
3
|
import { ImageType } from "../../base";
|
|
4
4
|
import { ImageBubbleStyle, ImageBubbleStyleInterface } from "./ImageBubbleStyle";
|
|
5
|
+
import { ImageViewerModal } from "../CometChatImageViewerModal";
|
|
6
|
+
import { ICONS } from "./assets";
|
|
7
|
+
import { isHttpUrl } from "../../utils/NetworkUtils";
|
|
5
8
|
|
|
6
9
|
const { FileManager, ImageManager } = NativeModules;
|
|
7
10
|
const eventEmitter = new NativeEventEmitter(FileManager);
|
|
@@ -49,6 +52,8 @@ export const CometChatImageBubble = (props: CometChatImageBubbleInterface) => {
|
|
|
49
52
|
|
|
50
53
|
const _style = new ImageBubbleStyle(style || {});
|
|
51
54
|
const [isOpening, setOpening] = useState(false);
|
|
55
|
+
const [downloaded, setDownloaded] = useState(false);
|
|
56
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
52
57
|
const url = useRef("");
|
|
53
58
|
|
|
54
59
|
const {
|
|
@@ -103,35 +108,78 @@ export const CometChatImageBubble = (props: CometChatImageBubbleInterface) => {
|
|
|
103
108
|
};
|
|
104
109
|
|
|
105
110
|
const handleTouchEnd = () => {
|
|
106
|
-
|
|
111
|
+
if (pressTime.current === null && Platform.OS === "ios") return;
|
|
107
112
|
const endTime = Date.now();
|
|
108
113
|
const pressDuration = endTime - pressTime.current;
|
|
109
114
|
if (pressDuration < 500) {
|
|
110
|
-
|
|
115
|
+
setIsVisible(true)
|
|
111
116
|
}
|
|
112
117
|
};
|
|
113
118
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
const onTouchMove = () => {
|
|
120
|
+
if (Platform.OS === "ios") {
|
|
121
|
+
pressTime.current = null;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
useLayoutEffect(() => {
|
|
126
|
+
if(isHttpUrl(thumbnailUrl?.uri ?? imageUrl?.uri)) {
|
|
127
|
+
Image.prefetch(thumbnailUrl?.uri ?? imageUrl?.uri).then((res) => {
|
|
128
|
+
setDownloaded(res);
|
|
129
|
+
});
|
|
130
|
+
} else {
|
|
131
|
+
setDownloaded(true);
|
|
132
|
+
}
|
|
133
|
+
}, []);
|
|
117
134
|
|
|
118
135
|
return (
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
136
|
+
<>
|
|
137
|
+
{
|
|
138
|
+
isVisible &&
|
|
139
|
+
<ImageViewerModal imageUrl={imageUrl} isVisible={isVisible} onClose={()=>{
|
|
140
|
+
setIsVisible(false)
|
|
141
|
+
}}/>
|
|
142
|
+
}
|
|
143
|
+
<View
|
|
144
|
+
onTouchStart={handleTouchStart}
|
|
145
|
+
onTouchEnd={handleTouchEnd}
|
|
146
|
+
onTouchMove={onTouchMove}
|
|
147
|
+
style={{
|
|
148
|
+
justifyContent:'center',
|
|
149
|
+
alignItems: 'center',
|
|
150
|
+
height,
|
|
151
|
+
width
|
|
133
152
|
}}
|
|
134
|
-
|
|
135
|
-
|
|
153
|
+
>
|
|
154
|
+
{
|
|
155
|
+
!downloaded
|
|
156
|
+
? <View>
|
|
157
|
+
<Image
|
|
158
|
+
resizeMode={"contain"}
|
|
159
|
+
source={ICONS.Spinner}
|
|
160
|
+
style={{
|
|
161
|
+
height: 20,
|
|
162
|
+
width: 20,
|
|
163
|
+
backgroundColor,
|
|
164
|
+
}}
|
|
165
|
+
/>
|
|
166
|
+
</View>
|
|
167
|
+
: <Image
|
|
168
|
+
resizeMode={resizeMode || "cover"}
|
|
169
|
+
loadingIndicatorSource={ICONS.Spinner}
|
|
170
|
+
source={thumbnailUrl ?? imageUrl}
|
|
171
|
+
style={{
|
|
172
|
+
height,
|
|
173
|
+
width,
|
|
174
|
+
aspectRatio,
|
|
175
|
+
backgroundColor,
|
|
176
|
+
borderRadius,
|
|
177
|
+
...border
|
|
178
|
+
}}
|
|
179
|
+
/>
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
</View>
|
|
183
|
+
</>
|
|
136
184
|
)
|
|
137
185
|
}
|
|
Binary file
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React, { useLayoutEffect, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Modal,
|
|
4
|
+
View,
|
|
5
|
+
Image,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
SafeAreaView,
|
|
9
|
+
ActivityIndicator,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import { ICONS } from './resources';
|
|
12
|
+
import { ReactNativeZoomableViewWithGestures } from '../../libs/ImageZoom';
|
|
13
|
+
|
|
14
|
+
export const ImageViewerModal = ({ imageUrl, isVisible, onClose }) => {
|
|
15
|
+
|
|
16
|
+
const [downloaded, setDownloaded] = useState(false);
|
|
17
|
+
useLayoutEffect(() => {
|
|
18
|
+
Image.prefetch(imageUrl.uri).then((res) => {
|
|
19
|
+
setDownloaded(res);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
Image.getSize(
|
|
23
|
+
imageUrl.uri,
|
|
24
|
+
(res) => {
|
|
25
|
+
console.log('success : ', res);
|
|
26
|
+
},
|
|
27
|
+
(res) => {
|
|
28
|
+
console.log('error : ', res);
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}, []);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Modal
|
|
35
|
+
animationType="slide"
|
|
36
|
+
transparent={false}
|
|
37
|
+
visible={isVisible}
|
|
38
|
+
onRequestClose={onClose}
|
|
39
|
+
>
|
|
40
|
+
<SafeAreaView style={styles.centeredView}>
|
|
41
|
+
<View style={styles.container}>
|
|
42
|
+
<View style={styles.header}>
|
|
43
|
+
<TouchableOpacity style={styles.closeButton} onPress={onClose}>
|
|
44
|
+
<Image
|
|
45
|
+
source={ICONS.backIcon}
|
|
46
|
+
style={{ tintColor: '#fff', height: 20, width: 20 }}
|
|
47
|
+
/>
|
|
48
|
+
</TouchableOpacity>
|
|
49
|
+
</View>
|
|
50
|
+
{downloaded ? (
|
|
51
|
+
<View style={styles.imageContainer}>
|
|
52
|
+
<ReactNativeZoomableViewWithGestures onSwipeDown={onClose}>
|
|
53
|
+
<Image
|
|
54
|
+
source={imageUrl}
|
|
55
|
+
style={styles.imageStyle}
|
|
56
|
+
resizeMode="contain"
|
|
57
|
+
/>
|
|
58
|
+
</ReactNativeZoomableViewWithGestures>
|
|
59
|
+
</View>
|
|
60
|
+
) : (
|
|
61
|
+
<ActivityIndicator color={'#fff'} />
|
|
62
|
+
)}
|
|
63
|
+
</View>
|
|
64
|
+
</SafeAreaView>
|
|
65
|
+
</Modal>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const styles = StyleSheet.create({
|
|
70
|
+
centeredView: {
|
|
71
|
+
flex: 1,
|
|
72
|
+
zIndex: 1,
|
|
73
|
+
elevation: 1,
|
|
74
|
+
},
|
|
75
|
+
container: {
|
|
76
|
+
flex: 1,
|
|
77
|
+
justifyContent: 'center',
|
|
78
|
+
alignItems: 'center',
|
|
79
|
+
backgroundColor: '#000',
|
|
80
|
+
},
|
|
81
|
+
header: {
|
|
82
|
+
position: 'absolute',
|
|
83
|
+
top: 0,
|
|
84
|
+
backgroundColor: 'transparent',
|
|
85
|
+
justifyContent: 'flex-start',
|
|
86
|
+
width: '100%',
|
|
87
|
+
zIndex: 100,
|
|
88
|
+
},
|
|
89
|
+
imageContainer: {
|
|
90
|
+
flex: 1,
|
|
91
|
+
height: '100%',
|
|
92
|
+
width: '100%',
|
|
93
|
+
},
|
|
94
|
+
imageStyle: {
|
|
95
|
+
width: '100%',
|
|
96
|
+
height: '100%',
|
|
97
|
+
},
|
|
98
|
+
closeButton: {
|
|
99
|
+
zIndex: 10,
|
|
100
|
+
height: 60,
|
|
101
|
+
width: 60,
|
|
102
|
+
justifyContent: 'center',
|
|
103
|
+
alignItems: 'center',
|
|
104
|
+
elevation: 10,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ImageViewerModal } from './ImageViewerModal';
|
|
Binary file
|
|
@@ -42,6 +42,7 @@ export interface CometChatListActionsInterface {
|
|
|
42
42
|
removeItemFromList: (itemId: string | number) => void;
|
|
43
43
|
getListItem: (itemId: string | number) => void;
|
|
44
44
|
getSelectedItems: () => Array<any>,
|
|
45
|
+
getAllListItems: () => Array<any>,
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
export interface CometChatListStylesInterface {
|
|
@@ -176,6 +177,7 @@ export const CometChatList = React.forwardRef<
|
|
|
176
177
|
getListItem,
|
|
177
178
|
updateAndMoveToFirst,
|
|
178
179
|
getSelectedItems,
|
|
180
|
+
getAllListItems,
|
|
179
181
|
};
|
|
180
182
|
});
|
|
181
183
|
|
|
@@ -316,7 +318,7 @@ export const CometChatList = React.forwardRef<
|
|
|
316
318
|
|
|
317
319
|
/**
|
|
318
320
|
* This will move item to first location if item doesn't exits then add it to first location.
|
|
319
|
-
* @param item
|
|
321
|
+
* @param item
|
|
320
322
|
*/
|
|
321
323
|
const updateAndMoveToFirst = (item: any) => {
|
|
322
324
|
let newList = [...list];
|
|
@@ -360,6 +362,13 @@ export const CometChatList = React.forwardRef<
|
|
|
360
362
|
return list.find((item: any) => item[listItemKey] == itemId);
|
|
361
363
|
};
|
|
362
364
|
|
|
365
|
+
/**
|
|
366
|
+
* get all list items
|
|
367
|
+
*/
|
|
368
|
+
const getAllListItems = (): any => {
|
|
369
|
+
return list;
|
|
370
|
+
};
|
|
371
|
+
|
|
363
372
|
/**
|
|
364
373
|
* update list
|
|
365
374
|
* @param {boolean} thrughKeyword - pass true if wants to set only new users.
|
|
@@ -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',
|
|
@@ -6,17 +6,17 @@ import { CometChatListItem, ListItemStyleInterface } from '../CometChatListItem'
|
|
|
6
6
|
import { CometChatContext } from '../../CometChatContext';
|
|
7
7
|
import { CometChatUIEventHandler, MessageEvents } from '../../events';
|
|
8
8
|
import { messageStatus } from '../../utils/CometChatMessageHelper';
|
|
9
|
-
import { ReactionListStyle, ReactionListStyleInterface } from './
|
|
9
|
+
import { ReactionListStyle, ReactionListStyleInterface } from './ReactionListStyle';
|
|
10
10
|
import { localize } from '../../resources';
|
|
11
11
|
import { ImageType } from '../../base';
|
|
12
12
|
import { LoadingIcon } from './resources';
|
|
13
13
|
import { CommonUtils } from '../../utils/CommonUtils';
|
|
14
14
|
|
|
15
|
-
export interface
|
|
15
|
+
export interface CometChatReactionListInterface {
|
|
16
16
|
messageObject: CometChat.BaseMessage;
|
|
17
17
|
onPress?: (messageReaction: CometChat.Reaction, messageObject: CometChat.BaseMessage) => void;
|
|
18
18
|
reactionRequestBuilder?: CometChat.ReactionsRequestBuilder;
|
|
19
|
-
|
|
19
|
+
reactionListStyle?: ReactionListStyleInterface;
|
|
20
20
|
avatarStyle?: AvatarStyleInterface;
|
|
21
21
|
listItemStyle?: ListItemStyleInterface;
|
|
22
22
|
selectedReaction?: string;
|
|
@@ -26,11 +26,11 @@ export interface CometChatReactionsListInterface {
|
|
|
26
26
|
LoadingStateView?: () => JSX.Element;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export const
|
|
29
|
+
export const CometChatReactionList = (props: CometChatReactionListInterface) => {
|
|
30
30
|
|
|
31
31
|
const {
|
|
32
32
|
messageObject, onPress, reactionRequestBuilder, avatarStyle,
|
|
33
|
-
listItemStyle, selectedReaction,
|
|
33
|
+
listItemStyle, selectedReaction, reactionListStyle,
|
|
34
34
|
ErrorStateView,
|
|
35
35
|
errorStateText,
|
|
36
36
|
loadingIconURL,
|
|
@@ -50,18 +50,18 @@ export const CometChatReactionsList = (props: CometChatReactionsListInterface) =
|
|
|
50
50
|
let reactionListMap: Record<string, CometChat.Reaction[]> = useRef({});
|
|
51
51
|
|
|
52
52
|
const _style = new ReactionListStyle({
|
|
53
|
-
subtitleColor:
|
|
54
|
-
subtitleFont:
|
|
55
|
-
activeEmojiBackgroundColor:
|
|
56
|
-
sliderEmojiCountColor:
|
|
57
|
-
tailViewFont:
|
|
58
|
-
sliderEmojiCountFont:
|
|
59
|
-
sliderEmojiFont:
|
|
60
|
-
errorTextColor:
|
|
61
|
-
errorTextFont:
|
|
62
|
-
loadingTint:
|
|
63
|
-
separatorColor:
|
|
64
|
-
...
|
|
53
|
+
subtitleColor: reactionListStyle?.subtitleColor || theme.palette.getAccent600(),
|
|
54
|
+
subtitleFont: reactionListStyle?.subtitleFont || theme.typography.subtitle2,
|
|
55
|
+
activeEmojiBackgroundColor: reactionListStyle?.activeEmojiBackgroundColor || theme.palette.getAccent100(),
|
|
56
|
+
sliderEmojiCountColor: reactionListStyle?.sliderEmojiCountColor || theme.palette.getAccent700(),
|
|
57
|
+
tailViewFont: reactionListStyle?.tailViewFont || theme.typography.title1,
|
|
58
|
+
sliderEmojiCountFont: reactionListStyle?.sliderEmojiCountFont || theme.typography.subtitle1,
|
|
59
|
+
sliderEmojiFont: reactionListStyle?.sliderEmojiFont || theme.typography.subtitle1,
|
|
60
|
+
errorTextColor: reactionListStyle?.errorTextColor || theme?.palette?.getError(),
|
|
61
|
+
errorTextFont: reactionListStyle?.errorTextFont || theme?.typography?.subtitle1,
|
|
62
|
+
loadingTint: reactionListStyle?.loadingTint || theme?.palette.getAccent700(),
|
|
63
|
+
separatorColor: reactionListStyle?.separatorColor || theme.palette.getAccent100(),
|
|
64
|
+
...reactionListStyle,
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
const {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CometChatReactionListInterface } from './CometChatReactionList';
|
|
2
|
+
|
|
3
|
+
export interface ReactionListConfigurationInterface extends Omit<CometChatReactionListInterface,
|
|
4
|
+
'messageObject' | 'errorStateText'
|
|
5
|
+
> { }
|
|
6
|
+
|
|
7
|
+
export class ReactionListConfiguration {
|
|
8
|
+
constructor(props: ReactionListConfigurationInterface) {
|
|
9
|
+
if (props)
|
|
10
|
+
for (const [key, value] of Object.entries(props)) {
|
|
11
|
+
this[key] = value;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CometChatReactionList, CometChatReactionListInterface } from './CometChatReactionList';
|
|
2
|
+
import { ReactionListStyle, ReactionListStyleInterface } from './ReactionListStyle';
|
|
3
|
+
import { ReactionListConfiguration, ReactionListConfigurationInterface } from './ReactionListConfiguration';
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
CometChatReactionList,
|
|
7
|
+
CometChatReactionListInterface,
|
|
8
|
+
ReactionListStyle,
|
|
9
|
+
ReactionListStyleInterface,
|
|
10
|
+
ReactionListConfiguration,
|
|
11
|
+
ReactionListConfigurationInterface
|
|
12
|
+
}
|