@cometchat/chat-uikit-react-native 4.3.20 → 4.3.22
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/package.json +1 -1
- package/src/AI/AIConversationSummary/AIConversationSummaryView.tsx +171 -167
- package/src/AI/CardView.tsx +55 -53
- package/src/CometChatCreateGroup/CometChatCreateGroup.tsx +8 -13
- package/src/CometChatGroups/CometChatGroups.tsx +545 -514
- package/src/CometChatJoinProtectedGroup/CometChatJoinProtectedGroup.tsx +5 -8
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +544 -378
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +90 -72
- package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +3 -8
- package/src/CometChatTransferOwnership/CometChatTransferOwnership.tsx +11 -13
- package/src/CometChatUsers/CometChatUsers.tsx +24 -23
- package/src/extensions/CollaborativeBubble/CometChatCollaborativeBubble.tsx +24 -25
- package/src/extensions/Polls/Polls.tsx +8 -16
- package/src/extensions/Polls/PollsBubble.tsx +5 -10
- package/src/extensions/SmartReplies/SmartRepliesView.tsx +16 -22
- package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +51 -51
- package/src/shared/libs/datePickerModal/DateTimePickerModal.android.js +1 -7
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.js +38 -46
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +19 -19
- package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +8 -20
- package/src/shared/views/CometChatBadge/CometChatBadge.tsx +8 -14
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +141 -140
- package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +47 -51
- package/src/shared/views/CometChatDate/CometChatDate.tsx +18 -17
- package/src/shared/views/CometChatDateTimePicker/CometChatDateTimePicker.tsx +65 -51
- package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +76 -72
- package/src/shared/views/CometChatFormBubble/CometChatFormBubble.tsx +3 -8
- package/src/shared/views/CometChatList/CometChatList.tsx +133 -134
- package/src/shared/views/CometChatListItem/CometChatListItem.tsx +62 -61
- package/src/shared/views/CometChatMediaRecorder/CometChatMediaRecorder.tsx +20 -10
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +3 -8
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +24 -23
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +107 -53
- package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +22 -14
- package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +15 -8
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +2 -6
- package/src/shared/views/SwipeRow/SwipeRow.tsx +6 -14
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.4/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.4/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
|
@@ -13,9 +13,9 @@ import {
|
|
|
13
13
|
ViewProps,
|
|
14
14
|
//@ts-ignore
|
|
15
15
|
} from 'react-native';
|
|
16
|
-
import { CometChatAvatar } from
|
|
16
|
+
import { CometChatAvatar } from '../../views/CometChatAvatar';
|
|
17
17
|
import { CometChatStatusIndicator } from '../../views/CometChatStatusIndicator';
|
|
18
|
-
import { CometChatContext } from
|
|
18
|
+
import { CometChatContext } from '../../CometChatContext';
|
|
19
19
|
//@ts-ignore
|
|
20
20
|
import SwipeRow from '../../helper/SwipeRow';
|
|
21
21
|
import { ListItemStyle } from './ListItemStyle';
|
|
@@ -71,7 +71,6 @@ export const CometChatListItem = (props: CometChatListItemInterface) => {
|
|
|
71
71
|
SubtitleView,
|
|
72
72
|
options,
|
|
73
73
|
TailView,
|
|
74
|
-
hideSeparator,
|
|
75
74
|
separatorColor,
|
|
76
75
|
headViewContainerStyle,
|
|
77
76
|
tailViewContainerStyle,
|
|
@@ -79,27 +78,18 @@ export const CometChatListItem = (props: CometChatListItemInterface) => {
|
|
|
79
78
|
onPress,
|
|
80
79
|
onLongPress,
|
|
81
80
|
rowOpens,
|
|
82
|
-
|
|
81
|
+
listItemStyle: listItemStyleProp = new ListItemStyle({}),
|
|
82
|
+
hideSeparator = true,
|
|
83
|
+
activeSwipeRows = {},
|
|
83
84
|
} = props;
|
|
84
|
-
|
|
85
|
-
const swipeRowRef = useRef<any>(null)
|
|
86
|
-
const
|
|
85
|
+
|
|
86
|
+
const swipeRowRef = useRef<any>(null);
|
|
87
|
+
const listItemStyle = new ListItemStyle({
|
|
87
88
|
backgroundColor: theme.palette.getBackgroundColor(),
|
|
88
89
|
titleColor: theme.palette.getAccent(),
|
|
89
90
|
titleFont: theme.typography.name,
|
|
91
|
+
...listItemStyleProp,
|
|
90
92
|
});
|
|
91
|
-
const listItemStyle = {
|
|
92
|
-
...defaultlistItemStyleProps,
|
|
93
|
-
...props.listItemStyle,
|
|
94
|
-
border: {
|
|
95
|
-
...defaultlistItemStyleProps.border,
|
|
96
|
-
...props.listItemStyle?.border,
|
|
97
|
-
},
|
|
98
|
-
titleFont: {
|
|
99
|
-
...defaultlistItemStyleProps.titleFont,
|
|
100
|
-
...props.listItemStyle?.titleFont,
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
93
|
|
|
104
94
|
const [swipeRowOptions, setSwipeRowOptions] = useState<any[]>([]);
|
|
105
95
|
let cancelClick = false;
|
|
@@ -153,13 +143,15 @@ export const CometChatListItem = (props: CometChatListItemInterface) => {
|
|
|
153
143
|
<Text
|
|
154
144
|
numberOfLines={1}
|
|
155
145
|
ellipsizeMode="tail"
|
|
156
|
-
style={
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
146
|
+
style={
|
|
147
|
+
[
|
|
148
|
+
Style.titleTextStyle,
|
|
149
|
+
{
|
|
150
|
+
color: listItemStyle.titleColor,
|
|
151
|
+
},
|
|
152
|
+
listItemStyle.titleFont,
|
|
153
|
+
] as StyleProp<TextStyle>
|
|
154
|
+
}
|
|
163
155
|
>
|
|
164
156
|
{title?.trim()}
|
|
165
157
|
</Text>
|
|
@@ -190,8 +182,8 @@ export const CometChatListItem = (props: CometChatListItemInterface) => {
|
|
|
190
182
|
};
|
|
191
183
|
|
|
192
184
|
const rowOpened = () => {
|
|
193
|
-
if(activeSwipeRows) activeSwipeRows[id] = swipeRowRef
|
|
194
|
-
rowOpens && rowOpens(id)
|
|
185
|
+
if (activeSwipeRows) activeSwipeRows[id] = swipeRowRef;
|
|
186
|
+
rowOpens && rowOpens(id);
|
|
195
187
|
cancelClick = true;
|
|
196
188
|
};
|
|
197
189
|
|
|
@@ -205,7 +197,7 @@ export const CometChatListItem = (props: CometChatListItemInterface) => {
|
|
|
205
197
|
const TailViewFc = () => {
|
|
206
198
|
return (
|
|
207
199
|
<View style={[Style.tailViewStyle, tailViewContainerStyle ?? {}]}>
|
|
208
|
-
|
|
200
|
+
{Boolean(TailView) && typeof TailView === 'function' && <TailView />}
|
|
209
201
|
</View>
|
|
210
202
|
);
|
|
211
203
|
};
|
|
@@ -250,35 +242,45 @@ export const CometChatListItem = (props: CometChatListItemInterface) => {
|
|
|
250
242
|
);
|
|
251
243
|
};
|
|
252
244
|
|
|
253
|
-
let ListComponent: any =
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
245
|
+
let ListComponent: any =
|
|
246
|
+
(onPress && typeof onPress == 'function') ||
|
|
247
|
+
(onLongPress && typeof onLongPress == 'function')
|
|
248
|
+
? TouchableOpacity
|
|
249
|
+
: View;
|
|
250
|
+
let listComponentProps =
|
|
251
|
+
(onPress && typeof onPress == 'function') ||
|
|
252
|
+
(onLongPress && typeof onLongPress == 'function')
|
|
253
|
+
? {
|
|
254
|
+
activeOpacity: 1,
|
|
255
|
+
onPress: clickHandler,
|
|
256
|
+
onLongPress: longPressHandler,
|
|
257
|
+
}
|
|
258
|
+
: {};
|
|
259
259
|
|
|
260
260
|
let WrapperComponent = swipeRowOptions.length ? SwipeRow : React.Fragment;
|
|
261
|
-
let wrapperComponentProps = swipeRowOptions.length
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
261
|
+
let wrapperComponentProps = swipeRowOptions.length
|
|
262
|
+
? {
|
|
263
|
+
ref: swipeRowRef,
|
|
264
|
+
key: id,
|
|
265
|
+
onRowDidOpen: rowOpened,
|
|
266
|
+
onRowDidClose: rowClosed,
|
|
267
|
+
disableRightSwipe: true,
|
|
268
|
+
disableLeftSwipe: !swipeRowOptions.length,
|
|
269
|
+
rightOpenValue: 0 - translate,
|
|
270
|
+
}
|
|
271
|
+
: {};
|
|
270
272
|
|
|
271
273
|
return (
|
|
272
|
-
<WrapperComponent
|
|
273
|
-
{...wrapperComponentProps}
|
|
274
|
-
>
|
|
274
|
+
<WrapperComponent {...wrapperComponentProps}>
|
|
275
275
|
<View
|
|
276
|
-
style={
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
276
|
+
style={
|
|
277
|
+
[
|
|
278
|
+
Style.optionStyle,
|
|
279
|
+
{
|
|
280
|
+
height: listItemStyle.height ?? 50,
|
|
281
|
+
},
|
|
282
|
+
] as ViewProps
|
|
283
|
+
}
|
|
282
284
|
>
|
|
283
285
|
<View onLayout={onLayout} style={Style.optionStyleContainer}>
|
|
284
286
|
{swipeRowOptions.length !== 0 && (
|
|
@@ -309,12 +311,17 @@ export const CometChatListItem = (props: CometChatListItemInterface) => {
|
|
|
309
311
|
<View
|
|
310
312
|
style={[
|
|
311
313
|
Style.rightContainerStyle,
|
|
312
|
-
{
|
|
314
|
+
{
|
|
315
|
+
borderBottomWidth: hideSeparator ? 0 : 1,
|
|
316
|
+
borderBottomColor: separatorColor || undefined,
|
|
317
|
+
},
|
|
313
318
|
]}
|
|
314
319
|
>
|
|
315
320
|
<View style={[Style.middleViewStyle, bodyViewContainerStyle ?? {}]}>
|
|
316
321
|
{Boolean(title) && <TitleView />}
|
|
317
|
-
{Boolean(SubtitleView) && typeof
|
|
322
|
+
{Boolean(SubtitleView) && typeof SubtitleView === 'function' && (
|
|
323
|
+
<SubtitleView />
|
|
324
|
+
)}
|
|
318
325
|
</View>
|
|
319
326
|
{Boolean(TailView) && <TailViewFc />}
|
|
320
327
|
</View>
|
|
@@ -322,9 +329,3 @@ export const CometChatListItem = (props: CometChatListItemInterface) => {
|
|
|
322
329
|
</WrapperComponent>
|
|
323
330
|
);
|
|
324
331
|
};
|
|
325
|
-
|
|
326
|
-
CometChatListItem.defaultProps = {
|
|
327
|
-
listItemStyle: new ListItemStyle({}),
|
|
328
|
-
hideSeparator: true,
|
|
329
|
-
activeSwipeRows: {}
|
|
330
|
-
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { useContext, useEffect } from 'react';
|
|
2
2
|
import { CometChatContext, CometChatContextType, ImageType, localize } from "../..";
|
|
3
|
-
import { View, TouchableOpacity, Text, Image, NativeModules, FlatList, PermissionsAndroid, Alert, Platform, Linking, TextStyle, ViewProps } from "react-native";
|
|
3
|
+
import { View, TouchableOpacity, Text, Image, NativeModules, FlatList, PermissionsAndroid, Alert, Platform, Linking, TextStyle, ViewProps, AppState } from "react-native";
|
|
4
4
|
import { Style } from "./style";
|
|
5
5
|
import { ICONS } from '../../framework/resources';
|
|
6
6
|
import { MediaRecorderStyle, MediaRecorderStyleInterface } from './MediaRecorderStyle';
|
|
7
7
|
|
|
8
8
|
let recordedTime = 0, stopRecordingIntervalId: any = null;
|
|
9
|
+
let recordingStatedAt = 0;
|
|
9
10
|
export interface CometChatMediaRecorderInterface {
|
|
10
11
|
onClose?: Function;
|
|
11
12
|
onPlay?: Function;
|
|
@@ -26,7 +27,7 @@ export interface CometChatMediaRecorderInterface {
|
|
|
26
27
|
let timerIntervalId: any = null;
|
|
27
28
|
export const CometChatMediaRecorder = (props: CometChatMediaRecorderInterface) => {
|
|
28
29
|
const {
|
|
29
|
-
onClose, style, onPause, onPlay, onSend, onStop, onStart, mediaRecorderStyle,
|
|
30
|
+
onClose, style = new MediaRecorderStyle({}), onPause, onPlay, onSend, onStop, onStart, mediaRecorderStyle,
|
|
30
31
|
pauseIconUrl, playIconUrl, recordIconUrl, deleteIconUrl, stopIconUrl, submitIconUrl
|
|
31
32
|
} = props;
|
|
32
33
|
|
|
@@ -70,6 +71,18 @@ export const CometChatMediaRecorder = (props: CometChatMediaRecorderInterface) =
|
|
|
70
71
|
}
|
|
71
72
|
}, [])
|
|
72
73
|
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
const subscription = AppState.addEventListener('change', (nextAppState) => {
|
|
76
|
+
if (nextAppState === 'background') {
|
|
77
|
+
_onStop();
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return () => {
|
|
82
|
+
subscription.remove();
|
|
83
|
+
};
|
|
84
|
+
}, []);
|
|
85
|
+
|
|
73
86
|
function permissionAlert() {
|
|
74
87
|
Alert.alert('', localize("MICROPHONE_PERMISSION"), [
|
|
75
88
|
{
|
|
@@ -114,6 +127,7 @@ export const CometChatMediaRecorder = (props: CometChatMediaRecorderInterface) =
|
|
|
114
127
|
}
|
|
115
128
|
|
|
116
129
|
const startInterval = () => {
|
|
130
|
+
recordingStatedAt = Date.now();
|
|
117
131
|
timerIntervalId = setInterval(timer, 1000);
|
|
118
132
|
}
|
|
119
133
|
|
|
@@ -131,7 +145,7 @@ export const CometChatMediaRecorder = (props: CometChatMediaRecorderInterface) =
|
|
|
131
145
|
const _onStop = () => {
|
|
132
146
|
NativeModules.FileManager.releaseMediaResources((result: string) => {
|
|
133
147
|
console.log(time, "Filepath _stopRecorderAudio", result);
|
|
134
|
-
recordedTime =
|
|
148
|
+
recordedTime = Date.now() - recordingStatedAt;
|
|
135
149
|
setRecordedFile(JSON.parse(result)?.file);
|
|
136
150
|
onStop && onStop(JSON.parse(result)?.file);
|
|
137
151
|
})
|
|
@@ -164,7 +178,7 @@ export const CometChatMediaRecorder = (props: CometChatMediaRecorderInterface) =
|
|
|
164
178
|
onPause && onPause();
|
|
165
179
|
setRecordedPlaying(false);
|
|
166
180
|
clearTimeout(stopRecordingIntervalId);
|
|
167
|
-
}, recordedTime
|
|
181
|
+
}, recordedTime)
|
|
168
182
|
})
|
|
169
183
|
}
|
|
170
184
|
|
|
@@ -246,10 +260,10 @@ export const CometChatMediaRecorder = (props: CometChatMediaRecorderInterface) =
|
|
|
246
260
|
<View style={[Style.timerContainer, { flexDirection: Boolean(recordedFile) ? "row-reverse" : "row" }]}>
|
|
247
261
|
<Text style={[
|
|
248
262
|
timerTextFont && { fontFamily: timerTextFont },
|
|
249
|
-
timerTextColor
|
|
263
|
+
timerTextColor ? { color: timerTextColor } : { color: "#000" },
|
|
250
264
|
timerTextstyle && { fontStyle: timerTextstyle },
|
|
251
265
|
!Boolean(recordedFile) && { marginRight: 10 }
|
|
252
|
-
] as TextStyle}>{formatTime(time)}</Text>
|
|
266
|
+
] as TextStyle[]}>{formatTime(time)}</Text>
|
|
253
267
|
<FlatList
|
|
254
268
|
data={soundBars}
|
|
255
269
|
keyExtractor={(item) => item.toString()}
|
|
@@ -294,8 +308,4 @@ export const CometChatMediaRecorder = (props: CometChatMediaRecorderInterface) =
|
|
|
294
308
|
</View>
|
|
295
309
|
</View>
|
|
296
310
|
)
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
CometChatMediaRecorder.defaultProps = {
|
|
300
|
-
style: new MediaRecorderStyle({}),
|
|
301
311
|
}
|
|
@@ -73,10 +73,10 @@ export const CometChatMessageBubble = memo(({
|
|
|
73
73
|
LeadingView,
|
|
74
74
|
BottomView,
|
|
75
75
|
ThreadView,
|
|
76
|
-
alignment,
|
|
76
|
+
alignment = 'left',
|
|
77
77
|
id,
|
|
78
78
|
style
|
|
79
|
-
}: CometChatMessageBubbleInterface) => {
|
|
79
|
+
}: CometChatMessageBubbleInterface ) => {
|
|
80
80
|
|
|
81
81
|
const {theme} = useContext<CometChatContextType>(CometChatContext);
|
|
82
82
|
|
|
@@ -143,9 +143,4 @@ export const CometChatMessageBubble = memo(({
|
|
|
143
143
|
|
|
144
144
|
</View>
|
|
145
145
|
)
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
//@ts-ignore
|
|
149
|
-
CometChatMessageBubble.defaultProps = {
|
|
150
|
-
alignment: "left"
|
|
151
|
-
}
|
|
146
|
+
})
|
|
@@ -109,33 +109,41 @@ export const CometChatMessageInput = (
|
|
|
109
109
|
) => {
|
|
110
110
|
const { theme } = useContext<CometChatContextType>(CometChatContext);
|
|
111
111
|
const {
|
|
112
|
-
text,
|
|
113
|
-
placeHolderText,
|
|
114
112
|
onChangeText,
|
|
115
|
-
style,
|
|
116
113
|
maxHeight,
|
|
117
114
|
SecondaryButtonView,
|
|
118
115
|
AuxiliaryButtonView,
|
|
119
|
-
auxiliaryButtonAlignment,
|
|
120
116
|
PrimaryButtonView,
|
|
121
117
|
onSelectionChange,
|
|
122
|
-
messageInputRef
|
|
118
|
+
messageInputRef,
|
|
119
|
+
placeHolderText = localize('ENTER_YOUR_MESSAGE_HERE'),
|
|
120
|
+
auxiliaryButtonAlignment = 'right',
|
|
121
|
+
style = {},
|
|
122
|
+
text = '',
|
|
123
123
|
} = props;
|
|
124
124
|
|
|
125
125
|
return (
|
|
126
|
-
<View
|
|
126
|
+
<View
|
|
127
|
+
style={{
|
|
128
|
+
backgroundColor: style?.inputBackground ?? theme.palette.getAccent100(),
|
|
129
|
+
marginHorizontal: 8,
|
|
130
|
+
borderRadius: 8,
|
|
131
|
+
}}
|
|
132
|
+
>
|
|
127
133
|
<TextInput
|
|
128
134
|
ref={messageInputRef}
|
|
129
|
-
style={
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
style={
|
|
136
|
+
[
|
|
137
|
+
styles.textInput,
|
|
138
|
+
{
|
|
139
|
+
color: style?.textColor ?? theme.palette.getAccent(),
|
|
140
|
+
maxHeight: maxHeight ?? 25 * 3,
|
|
141
|
+
},
|
|
142
|
+
text?.length
|
|
143
|
+
? style?.textFont ?? theme.typography.body
|
|
144
|
+
: style?.placeholderTextFont ?? theme.typography.body,
|
|
145
|
+
] as TextInputStyle
|
|
146
|
+
}
|
|
139
147
|
onChangeText={onChangeText}
|
|
140
148
|
placeholderTextColor={
|
|
141
149
|
style?.placeholderTextColor
|
|
@@ -176,10 +184,3 @@ export const CometChatMessageInput = (
|
|
|
176
184
|
</View>
|
|
177
185
|
);
|
|
178
186
|
};
|
|
179
|
-
|
|
180
|
-
CometChatMessageInput.defaultProps = {
|
|
181
|
-
placeHolderText: localize('ENTER_YOUR_MESSAGE_HERE'),
|
|
182
|
-
auxiliaryButtonAlignment: 'right',
|
|
183
|
-
style: {},
|
|
184
|
-
text: '',
|
|
185
|
-
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
2
|
import { Text, TextStyle, TouchableOpacity, View } from 'react-native';
|
|
3
|
-
import { CometChatContext } from
|
|
3
|
+
import { CometChatContext } from '../../CometChatContext';
|
|
4
4
|
import { Styles } from './style';
|
|
5
5
|
//@ts-ignore
|
|
6
6
|
import { CometChat } from '@cometchat/chat-sdk-react-native';
|
|
@@ -10,17 +10,24 @@ import { MessageBubbleAlignmentType } from '../../base/Types';
|
|
|
10
10
|
export interface CometChatReactionsInterface {
|
|
11
11
|
messageObject?: CometChat.BaseMessage;
|
|
12
12
|
style?: ReactionsStyleInterface;
|
|
13
|
-
onReactionPress?: (
|
|
14
|
-
|
|
13
|
+
onReactionPress?: (
|
|
14
|
+
reaction: CometChat.ReactionCount,
|
|
15
|
+
messageObject: CometChat.BaseMessage
|
|
16
|
+
) => void;
|
|
17
|
+
onReactionLongPress?: (
|
|
18
|
+
reaction: CometChat.ReactionCount,
|
|
19
|
+
messageObject: CometChat.BaseMessage
|
|
20
|
+
) => void;
|
|
15
21
|
alignment?: MessageBubbleAlignmentType;
|
|
16
22
|
}
|
|
17
23
|
const CometChatReactions = (props: CometChatReactionsInterface) => {
|
|
18
24
|
const {
|
|
19
|
-
messageObject,
|
|
20
|
-
style,
|
|
21
25
|
onReactionPress,
|
|
22
26
|
onReactionLongPress,
|
|
23
27
|
alignment,
|
|
28
|
+
|
|
29
|
+
messageObject = null,
|
|
30
|
+
style = {},
|
|
24
31
|
} = props;
|
|
25
32
|
|
|
26
33
|
const { theme } = useContext(CometChatContext);
|
|
@@ -32,7 +39,8 @@ const CometChatReactions = (props: CometChatReactionsInterface) => {
|
|
|
32
39
|
countColor: style?.countColor || theme?.palette?.getAccent(),
|
|
33
40
|
countFont: style?.countFont || theme?.typography?.text1,
|
|
34
41
|
backgroundColor: style?.backgroundColor || theme?.palette?.getAccent100(),
|
|
35
|
-
primaryBackgroundColor:
|
|
42
|
+
primaryBackgroundColor:
|
|
43
|
+
style?.primaryBackgroundColor || theme?.palette?.getPrimary150(),
|
|
36
44
|
primaryBorder: style?.primaryBorder || {
|
|
37
45
|
borderWidth: 1,
|
|
38
46
|
borderColor: theme?.palette?.getPrimary500(),
|
|
@@ -56,42 +64,60 @@ const CometChatReactions = (props: CometChatReactionsInterface) => {
|
|
|
56
64
|
const reactionView = (reactionObj: any, index: any) => {
|
|
57
65
|
let count: number = reactionObj?.count;
|
|
58
66
|
let Emoji: string = reactionObj?.reaction;
|
|
59
|
-
let Count: JSX.Element =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
let Count: JSX.Element = (
|
|
68
|
+
<Text
|
|
69
|
+
style={
|
|
70
|
+
[
|
|
71
|
+
Styles.reactionCountStyle,
|
|
72
|
+
{ color: countColor },
|
|
73
|
+
countFont,
|
|
74
|
+
] as TextStyle[]
|
|
75
|
+
}
|
|
76
|
+
>
|
|
77
|
+
{count}
|
|
78
|
+
</Text>
|
|
79
|
+
);
|
|
68
80
|
|
|
69
81
|
return count >= 1 ? (
|
|
70
|
-
<View
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
<View
|
|
83
|
+
key={index}
|
|
84
|
+
style={[
|
|
85
|
+
Styles.messageReactionsStyle,
|
|
86
|
+
{
|
|
87
|
+
backgroundColor: reactionObj?.reactedByMe
|
|
88
|
+
? primaryBackgroundColor
|
|
89
|
+
: backgroundColor,
|
|
90
|
+
paddingVertical: 0,
|
|
91
|
+
paddingHorizontal: 0,
|
|
92
|
+
},
|
|
93
|
+
{ backgroundColor: theme.palette.getBackgroundColor() },
|
|
94
|
+
]}
|
|
95
|
+
>
|
|
77
96
|
<TouchableOpacity
|
|
78
97
|
onPress={() => {
|
|
79
|
-
onReactionPress &&
|
|
98
|
+
onReactionPress &&
|
|
99
|
+
messageObject &&
|
|
100
|
+
onReactionPress(reactionObj, messageObject);
|
|
80
101
|
}}
|
|
81
102
|
onLongPress={() => {
|
|
82
|
-
onReactionLongPress &&
|
|
103
|
+
onReactionLongPress &&
|
|
104
|
+
messageObject &&
|
|
105
|
+
onReactionLongPress(reactionObj, messageObject);
|
|
83
106
|
}}
|
|
84
107
|
key={Math.random()}
|
|
85
108
|
style={[
|
|
86
109
|
Styles.messageReactionsStyle,
|
|
87
110
|
{
|
|
88
|
-
backgroundColor: reactionObj?.reactedByMe
|
|
89
|
-
|
|
111
|
+
backgroundColor: reactionObj?.reactedByMe
|
|
112
|
+
? primaryBackgroundColor
|
|
113
|
+
: backgroundColor,
|
|
114
|
+
marginRight: 0,
|
|
115
|
+
marginBottom: 0,
|
|
90
116
|
...(reactionObj?.reactedByMe ? primaryBorder : border),
|
|
91
|
-
}
|
|
117
|
+
},
|
|
92
118
|
]}
|
|
93
119
|
>
|
|
94
|
-
<Text style={[Styles.reactionListStyle, emojiFont] as TextStyle}>
|
|
120
|
+
<Text style={[Styles.reactionListStyle, emojiFont] as TextStyle[]}>
|
|
95
121
|
{Emoji} {Count}
|
|
96
122
|
</Text>
|
|
97
123
|
</TouchableOpacity>
|
|
@@ -100,43 +126,63 @@ const CometChatReactions = (props: CometChatReactionsInterface) => {
|
|
|
100
126
|
};
|
|
101
127
|
|
|
102
128
|
const extraEmojisView = (numberOfExtraEmojis: number) => {
|
|
103
|
-
let extraEmojis = reactionRef.current.slice(
|
|
104
|
-
|
|
129
|
+
let extraEmojis = reactionRef.current.slice(
|
|
130
|
+
reactionRef.current.length - numberOfExtraEmojis
|
|
131
|
+
);
|
|
132
|
+
let hasReactedByMe = extraEmojis.some(
|
|
133
|
+
(reaction: any) => reaction.reactedByMe
|
|
134
|
+
);
|
|
105
135
|
|
|
106
|
-
let totalCount = reactionRef.current.reduce(
|
|
107
|
-
|
|
136
|
+
let totalCount = reactionRef.current.reduce(
|
|
137
|
+
(acc: any, curr: any) => acc + curr.count,
|
|
138
|
+
0
|
|
139
|
+
);
|
|
140
|
+
let AllObj = new CometChat.ReactionCount('All', totalCount, false); // { reaction: "All", count: totalCount };
|
|
108
141
|
|
|
109
142
|
return (
|
|
110
|
-
<View
|
|
111
|
-
|
|
112
|
-
{
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
143
|
+
<View
|
|
144
|
+
key={new Date().getTime()}
|
|
145
|
+
style={[
|
|
146
|
+
Styles.messageReactionsStyle,
|
|
147
|
+
{
|
|
148
|
+
paddingVertical: 0,
|
|
149
|
+
paddingHorizontal: 0,
|
|
150
|
+
},
|
|
151
|
+
{ backgroundColor: theme.palette.getBackgroundColor() },
|
|
152
|
+
]}
|
|
153
|
+
>
|
|
116
154
|
<TouchableOpacity
|
|
117
155
|
onPress={() => {
|
|
118
|
-
onReactionLongPress &&
|
|
156
|
+
onReactionLongPress &&
|
|
157
|
+
messageObject &&
|
|
158
|
+
onReactionLongPress(AllObj, messageObject);
|
|
119
159
|
}}
|
|
120
160
|
onLongPress={() => {
|
|
121
|
-
onReactionLongPress &&
|
|
161
|
+
onReactionLongPress &&
|
|
162
|
+
messageObject &&
|
|
163
|
+
onReactionLongPress(AllObj, messageObject);
|
|
122
164
|
}}
|
|
123
165
|
key={Math.random()}
|
|
124
166
|
style={[
|
|
125
167
|
Styles.messageReactionsStyle,
|
|
126
168
|
{
|
|
127
|
-
backgroundColor: hasReactedByMe
|
|
169
|
+
backgroundColor: hasReactedByMe
|
|
170
|
+
? primaryBackgroundColor
|
|
171
|
+
: backgroundColor,
|
|
128
172
|
...(hasReactedByMe ? primaryBorder : border),
|
|
129
|
-
marginRight: 0,
|
|
173
|
+
marginRight: 0,
|
|
174
|
+
marginBottom: 0,
|
|
130
175
|
paddingHorizontal: 6,
|
|
131
176
|
},
|
|
132
177
|
]}
|
|
133
178
|
>
|
|
134
|
-
<Text style={[Styles.reactionListStyle, emojiFont] as TextStyle}>
|
|
179
|
+
<Text style={[Styles.reactionListStyle, emojiFont] as TextStyle[]}>
|
|
135
180
|
+{numberOfExtraEmojis}
|
|
136
181
|
</Text>
|
|
137
182
|
</TouchableOpacity>
|
|
138
|
-
</View>
|
|
139
|
-
|
|
183
|
+
</View>
|
|
184
|
+
);
|
|
185
|
+
};
|
|
140
186
|
|
|
141
187
|
React.useEffect(() => {
|
|
142
188
|
reactionRef.current = messageObject?.getReactions() || [];
|
|
@@ -144,23 +190,31 @@ const CometChatReactions = (props: CometChatReactionsInterface) => {
|
|
|
144
190
|
if (messageReactions.length > 0) {
|
|
145
191
|
if (messageReactions.length > 4) {
|
|
146
192
|
let newMessageReactions: any[] = [...messageReactions].slice(0, 3);
|
|
147
|
-
newMessageReactions.push(
|
|
193
|
+
newMessageReactions.push(
|
|
194
|
+
extraEmojisView(reactionRef.current.length - 3)
|
|
195
|
+
);
|
|
148
196
|
setReactionList(newMessageReactions);
|
|
149
197
|
} else setReactionList(messageReactions);
|
|
150
198
|
}
|
|
151
199
|
}, [messageObject]);
|
|
152
200
|
|
|
153
201
|
return reactionList.length ? (
|
|
154
|
-
<View
|
|
202
|
+
<View
|
|
203
|
+
style={[
|
|
204
|
+
Styles.messageReactionListStyle,
|
|
205
|
+
{
|
|
206
|
+
alignSelf:
|
|
207
|
+
alignment === 'right'
|
|
208
|
+
? 'flex-end'
|
|
209
|
+
: alignment === 'center'
|
|
210
|
+
? 'center'
|
|
211
|
+
: 'flex-start',
|
|
212
|
+
},
|
|
213
|
+
]}
|
|
214
|
+
>
|
|
155
215
|
{reactionList}
|
|
156
216
|
</View>
|
|
157
217
|
) : null;
|
|
158
218
|
};
|
|
159
219
|
|
|
160
|
-
// Specifies the default values for props:
|
|
161
|
-
CometChatReactions.defaultProps = {
|
|
162
|
-
messageObject: null,
|
|
163
|
-
style: {},
|
|
164
|
-
};
|
|
165
|
-
|
|
166
220
|
export { CometChatReactions };
|
|
@@ -25,13 +25,20 @@ export interface CometChatReceiptInterface {
|
|
|
25
25
|
style?: {
|
|
26
26
|
height?: string | number;
|
|
27
27
|
width?: string | number;
|
|
28
|
-
tintColor?: string
|
|
29
|
-
}
|
|
28
|
+
tintColor?: string;
|
|
29
|
+
};
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export const CometChatReceipt = (props: CometChatReceiptInterface) => {
|
|
33
|
-
const {
|
|
34
|
-
|
|
33
|
+
const {
|
|
34
|
+
style,
|
|
35
|
+
waitIcon = ICONS.WAITING,
|
|
36
|
+
sentIcon = ICONS.GREY_TICK,
|
|
37
|
+
deliveredIcon = ICONS.GREY_DOUBLE_TICK,
|
|
38
|
+
readIcon = ICONS.BLUE_DOUBLE_TICK,
|
|
39
|
+
errorIcon = ICONS.ERROR_TICK,
|
|
40
|
+
receipt = null,
|
|
41
|
+
} = props;
|
|
35
42
|
|
|
36
43
|
const { theme } = useContext<CometChatContextType>(CometChatContext);
|
|
37
44
|
|
|
@@ -74,16 +81,17 @@ export const CometChatReceipt = (props: CometChatReceiptInterface) => {
|
|
|
74
81
|
} else if (typeof icon === 'number') {
|
|
75
82
|
imageSource = icon;
|
|
76
83
|
}
|
|
77
|
-
return
|
|
84
|
+
return (
|
|
85
|
+
<Image
|
|
86
|
+
source={imageSource}
|
|
87
|
+
style={
|
|
88
|
+
[
|
|
89
|
+
styles.tickImageStyle,
|
|
90
|
+
{ tintColor: tintColor, width, height },
|
|
91
|
+
] as ImageStyle
|
|
92
|
+
}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
78
95
|
}
|
|
79
96
|
return null;
|
|
80
97
|
};
|
|
81
|
-
|
|
82
|
-
CometChatReceipt.defaultProps = {
|
|
83
|
-
waitIcon: ICONS.WAITING,
|
|
84
|
-
sentIcon: ICONS.GREY_TICK,
|
|
85
|
-
deliveredIcon: ICONS.GREY_DOUBLE_TICK,
|
|
86
|
-
readIcon: ICONS.BLUE_DOUBLE_TICK,
|
|
87
|
-
errorIcon: ICONS.ERROR_TICK,
|
|
88
|
-
receipt: null,
|
|
89
|
-
};
|