@cometchat/chat-uikit-react-native 5.0.0-beta.1 → 5.0.0
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/README.md +2 -3
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/src/main/java/com/reactnativecometchatuikit/CometChatSoundModule.java +29 -44
- package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +12 -0
- package/ios/FileManager.m +26 -9
- package/package.json +11 -36
- package/src/CometChatConversations/CometChatConversations.tsx +287 -147
- package/src/CometChatConversations/Skeleton.tsx +116 -73
- package/src/CometChatConversations/style.ts +17 -22
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +439 -227
- package/src/CometChatGroupMembers/style.ts +2 -4
- package/src/CometChatGroups/CometChatGroups.tsx +239 -135
- package/src/CometChatGroups/GroupsStyle.ts +20 -17
- package/src/CometChatGroups/Skeleton.tsx +198 -288
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +208 -73
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +97 -43
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +4 -2
- package/src/CometChatMessageList/CometChatMessageList.tsx +200 -76
- package/src/CometChatMessageList/style.ts +4 -4
- package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +77 -11
- package/src/CometChatThreadHeader/style.ts +2 -2
- package/src/CometChatUsers/CometChatUsers.tsx +203 -51
- package/src/CometChatUsers/Skeleton.tsx +174 -159
- package/src/CometChatUsers/style.ts +21 -18
- package/src/calls/CallingConfiguration.ts +4 -3
- package/src/calls/CallingExtensionDecorator.tsx +5 -3
- package/src/calls/CometChatCallButtons/CometChatCallButtonConfiguration.ts +4 -2
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +10 -8
- package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +240 -97
- package/src/calls/CometChatCallLogs/Skeleton.tsx +175 -91
- package/src/calls/CometChatCallLogs/index.ts +1 -0
- package/src/calls/CometChatCallLogs/style.ts +85 -43
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +42 -29
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +36 -10
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +39 -12
- package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +5 -4
- package/src/extensions/Polls/PollsDecorator.tsx +30 -9
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +34 -16
- package/src/index.ts +3 -1
- package/src/shared/base/Types.ts +31 -1
- package/src/shared/framework/DataSource.ts +64 -20
- package/src/shared/framework/DataSourceDecorator.tsx +46 -37
- package/src/shared/framework/MessageDataSource.tsx +518 -316
- package/src/shared/index.ts +3 -1
- package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/de/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/en/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/es/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/hu/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +3 -2
- package/src/shared/utils/MessageUtils.tsx +41 -20
- package/src/shared/utils/conversationUtils.ts +2 -2
- package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +22 -1
- package/src/shared/views/CometChatBadge/CometChatBadge.tsx +20 -8
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +177 -123
- package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +76 -10
- package/src/shared/views/CometChatConfirmDialog/style.ts +2 -2
- package/src/shared/views/CometChatDate/CometChatDate.tsx +26 -18
- package/src/shared/views/CometChatDateSeperator/CometChatDateSeparator.tsx +22 -16
- package/src/shared/views/CometChatDeletedBubble/CometChatDeletedBubble.tsx +17 -5
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +65 -35
- package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +22 -11
- package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +47 -18
- package/src/shared/views/CometChatList/CometChatList.tsx +70 -46
- package/src/shared/views/CometChatList/Header.tsx +122 -37
- package/src/shared/views/CometChatList/styles.ts +1 -0
- package/src/shared/views/CometChatListItem/CometChatListItem.tsx +116 -30
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +52 -30
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +36 -22
- package/src/shared/views/CometChatQuickReactions/CometChatQuickReactions.tsx +41 -13
- package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +132 -17
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +30 -2
- package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +10 -6
- package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +20 -13
- package/src/shared/views/CometChatStatusIndicator/styles.ts +26 -13
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +25 -2
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +94 -14
- package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +52 -16
- package/src/shared/views/CometChatTooltipMenu/index.ts +2 -1
- package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +29 -9
- package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +20 -2
- package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +29 -14
- package/src/shared/views/index.ts +2 -0
- package/src/theme/default/index.ts +5 -5
- package/src/theme/type.ts +2 -2
- package/src/shared/views/CometChatPanel/CometChatPanel.tsx +0 -57
- package/src/shared/views/CometChatPanel/PanelStyle.tsx +0 -43
- package/src/shared/views/CometChatPanel/resources/CloseIcon.png +0 -0
- package/src/shared/views/CometChatPanel/resources/index.ts +0 -3
|
@@ -1,143 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Skeleton.tsx
|
|
3
|
+
* @description
|
|
4
|
+
* Shimmer / skeleton loading component for the **Call Logs** list in CometChat UIKit.
|
|
5
|
+
* It renders a column of 20 placeholder rows that mimic an avatar, name, subtitle and a
|
|
6
|
+
* trailing action icon. A diagonal animated gradient (“shimmer”) sweeps across the rows
|
|
7
|
+
* to hint that data is loading.
|
|
8
|
+
*
|
|
9
|
+
* The component is completely theme-aware and can be customised via the `style` prop
|
|
10
|
+
* or by tweaking the UIKit theme’s `callLogsStyles.skeletonStyle` object.
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
|
|
1
14
|
import React, { useEffect, useRef } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
15
|
+
import {
|
|
16
|
+
Animated,
|
|
17
|
+
Dimensions,
|
|
18
|
+
Easing,
|
|
19
|
+
ScrollView,
|
|
20
|
+
StyleSheet,
|
|
21
|
+
View,
|
|
22
|
+
} from "react-native";
|
|
23
|
+
import Svg, {
|
|
24
|
+
Defs,
|
|
25
|
+
G,
|
|
26
|
+
LinearGradient,
|
|
27
|
+
Path,
|
|
28
|
+
Rect,
|
|
29
|
+
Stop,
|
|
30
|
+
} from "react-native-svg";
|
|
4
31
|
import { useTheme } from "../../theme";
|
|
32
|
+
import { CometChatTheme } from "../../theme/type";
|
|
5
33
|
|
|
6
34
|
const { width: screenWidth } = Dimensions.get("window");
|
|
7
35
|
|
|
8
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Shape of the style object accepted by this component.
|
|
38
|
+
* It is taken straight from the UIKit theme definition so that consumers
|
|
39
|
+
* may override only the bits they need.
|
|
40
|
+
*/
|
|
41
|
+
type SkeletonStyle = CometChatTheme["callLogsStyles"]["skeletonStyle"];
|
|
42
|
+
|
|
43
|
+
interface SkeletonProps {
|
|
44
|
+
/**
|
|
45
|
+
* Per-instance style overrides. **All keys are optional**; any missing keys
|
|
46
|
+
* fall back to the values provided by the current CometChat theme.
|
|
47
|
+
*/
|
|
48
|
+
style?: Partial<SkeletonStyle>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* -------------------------------------------------------------------------- */
|
|
52
|
+
/* Row layouts */
|
|
53
|
+
/* -------------------------------------------------------------------------- */
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Bottom SVG layer – a set of simple `Rect`s that will receive the animated
|
|
57
|
+
* gradient fill. Placed below the solid colour mask from `SkeletonItemTop`.
|
|
58
|
+
*/
|
|
59
|
+
const SkeletonItemBottom: React.FC<SkeletonProps> = ({ style = {} }) => {
|
|
9
60
|
const theme = useTheme();
|
|
61
|
+
const defaults = theme.callLogsStyles.skeletonStyle;
|
|
62
|
+
|
|
63
|
+
/* always-defined fallback */
|
|
64
|
+
const gradientColors =
|
|
65
|
+
style.linearGradientColors ??
|
|
66
|
+
defaults.linearGradientColors ??
|
|
67
|
+
["#E8E8E8", "#F5F5F5"];
|
|
10
68
|
|
|
11
69
|
return (
|
|
12
70
|
<Svg
|
|
13
71
|
height={screenWidth / 5}
|
|
14
|
-
viewBox=
|
|
15
|
-
fill=
|
|
16
|
-
preserveAspectRatio=
|
|
72
|
+
viewBox="0 0 360 72"
|
|
73
|
+
fill="none"
|
|
74
|
+
preserveAspectRatio="xMidYMid meet"
|
|
17
75
|
>
|
|
18
|
-
|
|
19
|
-
<Rect x=
|
|
20
|
-
|
|
21
|
-
<Rect x=
|
|
76
|
+
{/* Avatar circle replacement */}
|
|
77
|
+
<Rect x="16" y="12" width="48" height="48" fill="url(#shimmerGradient)" />
|
|
78
|
+
{/* Primary text placeholder */}
|
|
79
|
+
<Rect x="76" y="15" width="160" height="22" fill="url(#shimmerGradient)" />
|
|
80
|
+
{/* Secondary text placeholder */}
|
|
81
|
+
<Rect x="76" y="45" width="80" height="12" fill="url(#shimmerGradient)" />
|
|
82
|
+
{/* Trailing icon placeholder */}
|
|
83
|
+
<Rect x="312" y="20" width="32" height="32" fill="url(#shimmerGradient)" />
|
|
84
|
+
|
|
22
85
|
<Defs>
|
|
23
86
|
<LinearGradient
|
|
24
|
-
id=
|
|
87
|
+
id="shimmerGradient"
|
|
25
88
|
x1={16}
|
|
26
89
|
y1={36}
|
|
27
90
|
x2={64}
|
|
28
91
|
y2={36}
|
|
29
|
-
gradientUnits=
|
|
92
|
+
gradientUnits="userSpaceOnUse"
|
|
30
93
|
>
|
|
31
|
-
<Stop stopColor={
|
|
32
|
-
<Stop
|
|
33
|
-
offset={1}
|
|
34
|
-
stopColor={theme.conversationStyles.skeletonStyle.linearGradientColors[1]}
|
|
35
|
-
/>
|
|
94
|
+
<Stop stopColor={gradientColors[0]} />
|
|
95
|
+
<Stop offset={1} stopColor={gradientColors[1]} />
|
|
36
96
|
</LinearGradient>
|
|
37
97
|
</Defs>
|
|
38
98
|
</Svg>
|
|
39
99
|
);
|
|
40
100
|
};
|
|
41
101
|
|
|
42
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Top SVG layer – a solid colour mask with transparent “holes” cut out
|
|
104
|
+
* where the animated gradient from `SkeletonItemBottom` should be visible.
|
|
105
|
+
*/
|
|
106
|
+
const SkeletonItemTop: React.FC<SkeletonProps> = ({ style = {} }) => {
|
|
43
107
|
const theme = useTheme();
|
|
108
|
+
const defaults = theme.callLogsStyles.skeletonStyle;
|
|
44
109
|
|
|
45
110
|
return (
|
|
46
|
-
<Svg height={screenWidth / 5} viewBox=
|
|
111
|
+
<Svg height={screenWidth / 5} viewBox="0 0 360 72" fill="none">
|
|
47
112
|
<Path
|
|
48
|
-
fillRule=
|
|
49
|
-
clipRule=
|
|
113
|
+
fillRule="evenodd"
|
|
114
|
+
clipRule="evenodd"
|
|
50
115
|
d="M0 0H360V72H0V0ZM16 36C16 22.7452 26.7452 12 40 12C53.2548 12 64 22.7452 64 36C64 49.2548 53.2548 60 40 60C26.7452 60 16 49.2548 16 36ZM87 15C80.9249 15 76 19.9249 76 26C76 32.0751 80.9249 37 87 37H225C231.075 37 236 32.0751 236 26C236 19.9249 231.075 15 225 15H87ZM76 51C76 47.6863 78.6863 45 82 45H150C153.314 45 156 47.6863 156 51C156 54.3137 153.314 57 150 57H82C78.6863 57 76 54.3137 76 51ZM322 20C316.477 20 312 24.4772 312 30V42C312 47.5228 316.477 52 322 52H334C339.523 52 344 47.5228 344 42V30C344 24.4772 339.523 20 334 20H322Z"
|
|
51
|
-
fill={
|
|
116
|
+
fill={
|
|
117
|
+
style.containerBackgroundColor ??
|
|
118
|
+
defaults.containerBackgroundColor
|
|
119
|
+
}
|
|
52
120
|
/>
|
|
53
121
|
</Svg>
|
|
54
122
|
);
|
|
55
123
|
};
|
|
56
124
|
|
|
57
|
-
|
|
125
|
+
/* -------------------------------------------------------------------------- */
|
|
126
|
+
/* Main Skeleton component */
|
|
127
|
+
/* -------------------------------------------------------------------------- */
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Animated shimmer skeleton for the Call Logs list.
|
|
131
|
+
*
|
|
132
|
+
* @param props.style – Partial style overrides.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```tsx
|
|
136
|
+
* <Skeleton
|
|
137
|
+
* style={{
|
|
138
|
+
* linearGradientColors: ["#E8E8E8", "#F5F5F5"],
|
|
139
|
+
* shimmerBackgroundColor: "#FFFFFF",
|
|
140
|
+
* shimmerOpacity: 0.12,
|
|
141
|
+
* speed: 2,
|
|
142
|
+
* }}
|
|
143
|
+
* />
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export const Skeleton: React.FC<SkeletonProps> = ({ style = {} }) => {
|
|
58
147
|
const theme = useTheme();
|
|
59
|
-
const
|
|
148
|
+
const defaults = theme.callLogsStyles.skeletonStyle;
|
|
149
|
+
|
|
150
|
+
/* guaranteed speed */
|
|
151
|
+
const speed = style.speed ?? defaults.speed ?? 1;
|
|
152
|
+
|
|
153
|
+
const shimmerAnim = useRef(new Animated.Value(0)).current;
|
|
60
154
|
|
|
155
|
+
/* ------------------------------------------------------------------ */
|
|
156
|
+
/* Lifecycle */
|
|
157
|
+
/* ------------------------------------------------------------------ */
|
|
61
158
|
useEffect(() => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
Animated.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}, [animatedValue]);
|
|
76
|
-
|
|
77
|
-
const shimmerTranslateX = animatedValue.interpolate({
|
|
159
|
+
shimmerAnim.setValue(0);
|
|
160
|
+
Animated.loop(
|
|
161
|
+
Animated.timing(shimmerAnim, {
|
|
162
|
+
toValue: 1,
|
|
163
|
+
duration: (1 / speed) * 1000, // safe
|
|
164
|
+
easing: Easing.linear,
|
|
165
|
+
useNativeDriver: false,
|
|
166
|
+
})
|
|
167
|
+
).start();
|
|
168
|
+
}, [shimmerAnim, speed]);
|
|
169
|
+
|
|
170
|
+
/* Animated translation for the first and second diagonal bars */
|
|
171
|
+
const translateX = shimmerAnim.interpolate({
|
|
78
172
|
inputRange: [0, 1],
|
|
79
173
|
outputRange: [-screenWidth * 2, screenWidth],
|
|
80
174
|
});
|
|
81
175
|
|
|
176
|
+
/* ------------------------------------------------------------------ */
|
|
177
|
+
/* Render */
|
|
178
|
+
/* ------------------------------------------------------------------ */
|
|
82
179
|
return (
|
|
83
180
|
<ScrollView showsVerticalScrollIndicator={false} scrollEnabled={false}>
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
{
|
|
114
|
-
|
|
115
|
-
opacity: theme.conversationStyles.skeletonStyle.shimmerOpacity,
|
|
116
|
-
},
|
|
117
|
-
]}
|
|
118
|
-
></Animated.View>
|
|
119
|
-
<View
|
|
120
|
-
style={{
|
|
121
|
-
position: "absolute",
|
|
122
|
-
top: 0,
|
|
123
|
-
left: 0,
|
|
124
|
-
right: 0,
|
|
125
|
-
bottom: 0,
|
|
126
|
-
}}
|
|
127
|
-
>
|
|
128
|
-
{new Array(20).fill(0).map((_, i) => {
|
|
129
|
-
return <SkeletonItemTop key={i} />;
|
|
130
|
-
})}
|
|
181
|
+
{/* Bottom layer – gradient-filled rows */}
|
|
182
|
+
{Array.from({ length: 20 }).map((_, i) => (
|
|
183
|
+
<SkeletonItemBottom key={`bottom-${i}`} style={style} />
|
|
184
|
+
))}
|
|
185
|
+
|
|
186
|
+
{/* Diagonal shimmer bars (two for seamless wrap-around) */}
|
|
187
|
+
{[0, screenWidth / 2].map((offset, idx) => (
|
|
188
|
+
<Animated.View
|
|
189
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
190
|
+
key={`shimmer-${idx}`}
|
|
191
|
+
style={[
|
|
192
|
+
localStyles.animatedBar,
|
|
193
|
+
{
|
|
194
|
+
transform: [
|
|
195
|
+
{ translateX: Animated.add(translateX, offset) },
|
|
196
|
+
{ translateY: -20 },
|
|
197
|
+
{ rotate: "15deg" },
|
|
198
|
+
],
|
|
199
|
+
backgroundColor:
|
|
200
|
+
style.shimmerBackgroundColor ??
|
|
201
|
+
defaults.shimmerBackgroundColor,
|
|
202
|
+
opacity: style.shimmerOpacity ?? defaults.shimmerOpacity,
|
|
203
|
+
},
|
|
204
|
+
]}
|
|
205
|
+
/>
|
|
206
|
+
))}
|
|
207
|
+
|
|
208
|
+
<View style={StyleSheet.absoluteFill}>
|
|
209
|
+
{Array.from({ length: 20 }).map((_, i) => (
|
|
210
|
+
<SkeletonItemTop key={`top-${i}`} style={style} />
|
|
211
|
+
))}
|
|
131
212
|
</View>
|
|
132
213
|
</ScrollView>
|
|
133
214
|
);
|
|
134
215
|
};
|
|
135
216
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
217
|
+
/* ----------------------------- local styles ------------------------------ */
|
|
218
|
+
|
|
219
|
+
const localStyles = StyleSheet.create({
|
|
220
|
+
/** Base style for each diagonal shimmer bar */
|
|
221
|
+
animatedBar: {
|
|
222
|
+
position: "absolute",
|
|
139
223
|
top: 0,
|
|
140
224
|
bottom: 0,
|
|
141
|
-
|
|
225
|
+
width: "25%",
|
|
142
226
|
},
|
|
143
227
|
});
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ColorValue,
|
|
3
|
+
ImageSourcePropType,
|
|
4
|
+
ImageStyle,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
TextStyle,
|
|
7
|
+
ViewStyle,
|
|
8
|
+
} from "react-native";
|
|
2
9
|
import { AvatarStyle } from "../../shared/views/CometChatAvatar";
|
|
3
10
|
import { CometChatTheme } from "../../theme/type";
|
|
11
|
+
import { DeepPartial } from "../../shared/helper/types";
|
|
12
|
+
import { deepMerge } from "../../shared/helper/helperFunctions";
|
|
4
13
|
|
|
5
14
|
export const Style = StyleSheet.create({
|
|
6
15
|
container: {
|
|
@@ -22,6 +31,7 @@ export const Style = StyleSheet.create({
|
|
|
22
31
|
row: {
|
|
23
32
|
flexDirection: "row",
|
|
24
33
|
alignItems: "center",
|
|
34
|
+
gap: 10
|
|
25
35
|
},
|
|
26
36
|
imageStyle: {
|
|
27
37
|
height: 24,
|
|
@@ -51,62 +61,94 @@ export type CallLogsStyle = {
|
|
|
51
61
|
titleTextStyle: TextStyle;
|
|
52
62
|
missedCallTitleTextStyle: TextStyle;
|
|
53
63
|
subTitleTextStyle: TextStyle;
|
|
54
|
-
avatarStyle: AvatarStyle
|
|
64
|
+
avatarStyle: AvatarStyle;
|
|
55
65
|
callIconStyle: ImageStyle;
|
|
56
66
|
outgoingCallStatusIconStyle: ImageStyle;
|
|
57
67
|
incomingCallStatusIconStyle: ImageStyle;
|
|
58
68
|
missedCallStatusIconStyle: ImageStyle;
|
|
59
|
-
}
|
|
69
|
+
};
|
|
70
|
+
skeletonStyle: {
|
|
71
|
+
linearGradientColors?: [string, string];
|
|
72
|
+
shimmerBackgroundColor?: ColorValue;
|
|
73
|
+
shimmerOpacity?: number;
|
|
74
|
+
speed?: number;
|
|
75
|
+
containerBackgroundColor?: ColorValue;
|
|
76
|
+
};
|
|
60
77
|
};
|
|
61
78
|
|
|
62
|
-
export const
|
|
79
|
+
export const getCallLogsStyleLight = (
|
|
63
80
|
color: CometChatTheme["color"],
|
|
64
81
|
spacing: CometChatTheme["spacing"],
|
|
65
82
|
typography: CometChatTheme["typography"]
|
|
66
|
-
): CallLogsStyle =>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
83
|
+
): DeepPartial<CallLogsStyle> =>
|
|
84
|
+
deepMerge(
|
|
85
|
+
{
|
|
86
|
+
containerStyle: {},
|
|
87
|
+
titleTextStyle: {
|
|
70
88
|
color: color.textPrimary,
|
|
71
|
-
|
|
72
|
-
...typography.heading3.bold,
|
|
89
|
+
...typography.heading1.bold,
|
|
73
90
|
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
91
|
+
titleSeparatorStyle: {
|
|
92
|
+
borderBottomWidth: 1,
|
|
93
|
+
borderBottomColor: color.borderLight,
|
|
94
|
+
flexDirection: "row",
|
|
95
|
+
justifyContent: "space-between",
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
width: "100%",
|
|
78
98
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
99
|
+
errorStateStyle: {
|
|
100
|
+
containerStyle: {},
|
|
101
|
+
titleStyle: {
|
|
102
|
+
color: color.textPrimary,
|
|
103
|
+
textAlign: "center",
|
|
104
|
+
...typography.heading3.bold,
|
|
105
|
+
},
|
|
106
|
+
subTitleStyle: {
|
|
107
|
+
color: color.textSecondary,
|
|
108
|
+
textAlign: "center",
|
|
109
|
+
...typography.body.regular,
|
|
110
|
+
},
|
|
86
111
|
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
112
|
+
emptyStateStyle: {
|
|
113
|
+
containerStyle: {},
|
|
114
|
+
titleStyle: {
|
|
115
|
+
color: color.textPrimary,
|
|
116
|
+
textAlign: "center",
|
|
117
|
+
...typography.heading3.bold,
|
|
118
|
+
},
|
|
119
|
+
subTitleStyle: {
|
|
120
|
+
color: color.textSecondary,
|
|
121
|
+
textAlign: "center",
|
|
122
|
+
...typography.body.regular,
|
|
123
|
+
},
|
|
91
124
|
},
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
125
|
+
|
|
126
|
+
itemStyle: getCallLogsItemStyle(color, spacing, typography),
|
|
127
|
+
skeletonStyle: {
|
|
128
|
+
linearGradientColors: ["#E8E8E8", "#F5F5F5"] as [string, string],
|
|
129
|
+
shimmerBackgroundColor: color.staticBlack,
|
|
130
|
+
shimmerOpacity: 0.01,
|
|
131
|
+
speed: 1,
|
|
132
|
+
containerBackgroundColor: color.background2,
|
|
133
|
+
},
|
|
134
|
+
} as const,
|
|
135
|
+
{}
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
export const getCallLogsStyleDark = (
|
|
139
|
+
color: CometChatTheme["color"],
|
|
140
|
+
spacing: CometChatTheme["spacing"],
|
|
141
|
+
typography: CometChatTheme["typography"]
|
|
142
|
+
): DeepPartial<CallLogsStyle> =>
|
|
143
|
+
deepMerge(getCallLogsStyleLight(color, spacing, typography), {
|
|
144
|
+
skeletonStyle: {
|
|
145
|
+
linearGradientColors: ["#383838", "#272727"] as [string, string],
|
|
146
|
+
shimmerBackgroundColor: color.staticWhite,
|
|
147
|
+
shimmerOpacity: 0.01,
|
|
148
|
+
speed: 1,
|
|
149
|
+
containerBackgroundColor: color.background2,
|
|
106
150
|
},
|
|
107
|
-
|
|
108
|
-
};
|
|
109
|
-
};
|
|
151
|
+
});
|
|
110
152
|
|
|
111
153
|
export type CallLogsItemStyle = {
|
|
112
154
|
containerStyle: ViewStyle;
|
|
@@ -141,7 +183,7 @@ export const getCallLogsItemStyle = (
|
|
|
141
183
|
},
|
|
142
184
|
missedCallTitleTextStyle: {
|
|
143
185
|
color: color.error,
|
|
144
|
-
|
|
186
|
+
...typography.heading4.medium,
|
|
145
187
|
},
|
|
146
188
|
subTitleTextStyle: {
|
|
147
189
|
color: color.textSecondary,
|
|
@@ -67,6 +67,11 @@ export interface CometChatOutgoingCallInterface {
|
|
|
67
67
|
* Custom view for the end call button.
|
|
68
68
|
*/
|
|
69
69
|
EndCallView?: (call: CometChat.Call | CometChat.CustomMessage) => JSX.Element;
|
|
70
|
+
/**
|
|
71
|
+
* Callback fired when an error occurs.
|
|
72
|
+
* @param {CometChat.CometChatException} error - The error object.
|
|
73
|
+
*/
|
|
74
|
+
onError?: (error: CometChat.CometChatException) => void;
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
/**
|
|
@@ -91,12 +96,15 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
|
|
|
91
96
|
SubtitleView,
|
|
92
97
|
AvatarView,
|
|
93
98
|
EndCallView,
|
|
99
|
+
onError,
|
|
94
100
|
} = props;
|
|
95
101
|
|
|
96
102
|
// State to track whether the call is connected.
|
|
97
103
|
const [isCallConnected, setCallConnected] = useState(false);
|
|
98
104
|
|
|
99
|
-
//
|
|
105
|
+
// Controls visibility of this modal.
|
|
106
|
+
const [isModalVisible, setModalVisible] = useState(true);
|
|
107
|
+
|
|
100
108
|
const ongoingCall = useRef<CometChat.Call | CometChat.CustomMessage>();
|
|
101
109
|
const callSessionId = useRef<string>();
|
|
102
110
|
const callListener = useRef<any>(null);
|
|
@@ -110,14 +118,8 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
|
|
|
110
118
|
return deepMerge(theme.outgoingCallStyle, style ?? {});
|
|
111
119
|
}, [theme.outgoingCallStyle, style]);
|
|
112
120
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
*
|
|
116
|
-
* @param {CometChat.BaseMessage} call - The call object.
|
|
117
|
-
* @returns {Boolean} True if it is a default call; otherwise false.
|
|
118
|
-
*/
|
|
119
|
-
function checkIfDefaultCall(call: CometChat.BaseMessage): Boolean {
|
|
120
|
-
return call.getCategory() == MessageCategoryConstants.call;
|
|
121
|
+
function checkIfDefaultCall(call: CometChat.BaseMessage): boolean {
|
|
122
|
+
return call.getCategory() === MessageCategoryConstants.call;
|
|
121
123
|
}
|
|
122
124
|
|
|
123
125
|
/**
|
|
@@ -135,6 +137,7 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
|
|
|
135
137
|
})
|
|
136
138
|
.catch((err) => {
|
|
137
139
|
console.log("Error", err);
|
|
140
|
+
onError && onError(err);
|
|
138
141
|
});
|
|
139
142
|
}
|
|
140
143
|
};
|
|
@@ -143,16 +146,16 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
|
|
|
143
146
|
useEffect(() => {
|
|
144
147
|
if (
|
|
145
148
|
call &&
|
|
146
|
-
(call["status"]
|
|
147
|
-
(call.getCategory()
|
|
148
|
-
call.getType()
|
|
149
|
+
(call["status"] === "ongoing" ||
|
|
150
|
+
(call.getCategory() === (CometChat.CATEGORY_CUSTOM as CometChat.MessageCategory) &&
|
|
151
|
+
call.getType() === MessageTypeConstants.meeting))
|
|
149
152
|
) {
|
|
150
153
|
ongoingCall.current = call;
|
|
151
154
|
if (call.getType() == MessageTypeConstants.meeting) {
|
|
152
155
|
callSessionId.current = ((call as CometChat.CustomMessage).getCustomData() as any)?.sessionId;
|
|
153
156
|
}
|
|
154
|
-
if (call
|
|
155
|
-
callSessionId.current = call
|
|
157
|
+
if (call.getCategory() === MessageCategoryConstants.call) {
|
|
158
|
+
callSessionId.current = call["sessionId"];
|
|
156
159
|
}
|
|
157
160
|
setCallConnected(true);
|
|
158
161
|
}
|
|
@@ -169,13 +172,13 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
|
|
|
169
172
|
CometChat.addCallListener(
|
|
170
173
|
listenerId,
|
|
171
174
|
new CometChat.CallListener({
|
|
172
|
-
onOutgoingCallAccepted(
|
|
175
|
+
onOutgoingCallAccepted: (acceptedCall: any) => {
|
|
173
176
|
CometChatSoundManager.pause();
|
|
174
|
-
ongoingCall.current =
|
|
175
|
-
callSessionId.current =
|
|
177
|
+
ongoingCall.current = acceptedCall;
|
|
178
|
+
callSessionId.current = acceptedCall["sessionId"];
|
|
176
179
|
setCallConnected(true);
|
|
177
180
|
},
|
|
178
|
-
onOutgoingCallRejected: (
|
|
181
|
+
onOutgoingCallRejected: () => {
|
|
179
182
|
CometChatSoundManager.pause();
|
|
180
183
|
ongoingCall.current = undefined;
|
|
181
184
|
callSessionId.current = undefined;
|
|
@@ -186,8 +189,9 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
|
|
|
186
189
|
|
|
187
190
|
// Listen for call failure events.
|
|
188
191
|
CometChatUIEventHandler.addCallListener(listenerId, {
|
|
189
|
-
ccCallFailed: () => {
|
|
192
|
+
ccCallFailed: (error: CometChat.CometChatException) => {
|
|
190
193
|
setCallConnected(false);
|
|
194
|
+
onError && onError(error);
|
|
191
195
|
},
|
|
192
196
|
});
|
|
193
197
|
|
|
@@ -230,7 +234,9 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
|
|
|
230
234
|
|
|
231
235
|
// Determine call type (audio or meeting) and initialize call settings.
|
|
232
236
|
const callType =
|
|
233
|
-
call?.getType() ===
|
|
237
|
+
call?.getType() === MessageTypeConstants.meeting
|
|
238
|
+
? call["customData"]?.["callType"]
|
|
239
|
+
: call.getType();
|
|
234
240
|
|
|
235
241
|
callSettings.current =
|
|
236
242
|
callSettingsBuilder?.setCallEventListener(callListener.current) ??
|
|
@@ -248,17 +254,26 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
|
|
|
248
254
|
};
|
|
249
255
|
}, []);
|
|
250
256
|
|
|
251
|
-
|
|
257
|
+
/**
|
|
258
|
+
* Handles closing the modal (via hardware back button on Android or a custom button).
|
|
259
|
+
* This is where you can call onEndCallButtonPressed or do any other cleanup.
|
|
260
|
+
*/
|
|
261
|
+
const handleModalClose = () => {
|
|
262
|
+
if (onEndCallButtonPressed) {
|
|
263
|
+
onEndCallButtonPressed(call as CometChat.Call);
|
|
264
|
+
}
|
|
265
|
+
// Hide the modal – onDismiss fires after the animation completes
|
|
266
|
+
setModalVisible(false);
|
|
267
|
+
};
|
|
268
|
+
|
|
252
269
|
const callReceiverName = call?.getReceiver?.().getName?.() ?? "Unknown";
|
|
253
270
|
|
|
254
271
|
return (
|
|
255
272
|
<Modal
|
|
256
273
|
transparent
|
|
257
|
-
animated
|
|
258
274
|
animationType="fade"
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
275
|
+
visible={isModalVisible}
|
|
276
|
+
onRequestClose={handleModalClose}
|
|
262
277
|
>
|
|
263
278
|
<SafeAreaView style={{ flex: 1 }}>
|
|
264
279
|
{isCallConnected ? (
|
|
@@ -285,7 +300,7 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
|
|
|
285
300
|
name={callReceiverName}
|
|
286
301
|
image={{
|
|
287
302
|
uri:
|
|
288
|
-
call?.getReceiverType?.()
|
|
303
|
+
call?.getReceiverType?.() === "user"
|
|
289
304
|
? (call?.getReceiver?.() as CometChat.User)?.getAvatar()
|
|
290
305
|
: (call?.getReceiver?.() as CometChat.Group)?.getIcon(),
|
|
291
306
|
}}
|
|
@@ -297,9 +312,7 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
|
|
|
297
312
|
) : (
|
|
298
313
|
<TouchableOpacity
|
|
299
314
|
style={outgoingCallStyle.endCallButtonStyle}
|
|
300
|
-
onPress={
|
|
301
|
-
onEndCallButtonPressed && onEndCallButtonPressed(call as CometChat.Call)
|
|
302
|
-
}
|
|
315
|
+
onPress={handleModalClose}
|
|
303
316
|
>
|
|
304
317
|
<Icon
|
|
305
318
|
name="call-end-fill"
|