@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.
Files changed (98) hide show
  1. package/README.md +2 -3
  2. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  3. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  4. package/android/src/main/java/com/reactnativecometchatuikit/CometChatSoundModule.java +29 -44
  5. package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +12 -0
  6. package/ios/FileManager.m +26 -9
  7. package/package.json +11 -36
  8. package/src/CometChatConversations/CometChatConversations.tsx +287 -147
  9. package/src/CometChatConversations/Skeleton.tsx +116 -73
  10. package/src/CometChatConversations/style.ts +17 -22
  11. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +439 -227
  12. package/src/CometChatGroupMembers/style.ts +2 -4
  13. package/src/CometChatGroups/CometChatGroups.tsx +239 -135
  14. package/src/CometChatGroups/GroupsStyle.ts +20 -17
  15. package/src/CometChatGroups/Skeleton.tsx +198 -288
  16. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +208 -73
  17. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +97 -43
  18. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +4 -2
  19. package/src/CometChatMessageList/CometChatMessageList.tsx +200 -76
  20. package/src/CometChatMessageList/style.ts +4 -4
  21. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +77 -11
  22. package/src/CometChatThreadHeader/style.ts +2 -2
  23. package/src/CometChatUsers/CometChatUsers.tsx +203 -51
  24. package/src/CometChatUsers/Skeleton.tsx +174 -159
  25. package/src/CometChatUsers/style.ts +21 -18
  26. package/src/calls/CallingConfiguration.ts +4 -3
  27. package/src/calls/CallingExtensionDecorator.tsx +5 -3
  28. package/src/calls/CometChatCallButtons/CometChatCallButtonConfiguration.ts +4 -2
  29. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +10 -8
  30. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +240 -97
  31. package/src/calls/CometChatCallLogs/Skeleton.tsx +175 -91
  32. package/src/calls/CometChatCallLogs/index.ts +1 -0
  33. package/src/calls/CometChatCallLogs/style.ts +85 -43
  34. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +42 -29
  35. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +36 -10
  36. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +39 -12
  37. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +5 -4
  38. package/src/extensions/Polls/PollsDecorator.tsx +30 -9
  39. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +34 -16
  40. package/src/index.ts +3 -1
  41. package/src/shared/base/Types.ts +31 -1
  42. package/src/shared/framework/DataSource.ts +64 -20
  43. package/src/shared/framework/DataSourceDecorator.tsx +46 -37
  44. package/src/shared/framework/MessageDataSource.tsx +518 -316
  45. package/src/shared/index.ts +3 -1
  46. package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +3 -2
  47. package/src/shared/resources/CometChatLocalize/resources/de/translation.json +3 -2
  48. package/src/shared/resources/CometChatLocalize/resources/en/translation.json +3 -2
  49. package/src/shared/resources/CometChatLocalize/resources/es/translation.json +3 -2
  50. package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +3 -2
  51. package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +3 -2
  52. package/src/shared/resources/CometChatLocalize/resources/hu/translation.json +3 -2
  53. package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +3 -2
  54. package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +3 -2
  55. package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +3 -2
  56. package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +3 -2
  57. package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +3 -2
  58. package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +3 -2
  59. package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +3 -2
  60. package/src/shared/utils/MessageUtils.tsx +41 -20
  61. package/src/shared/utils/conversationUtils.ts +2 -2
  62. package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +22 -1
  63. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +20 -8
  64. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +177 -123
  65. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +76 -10
  66. package/src/shared/views/CometChatConfirmDialog/style.ts +2 -2
  67. package/src/shared/views/CometChatDate/CometChatDate.tsx +26 -18
  68. package/src/shared/views/CometChatDateSeperator/CometChatDateSeparator.tsx +22 -16
  69. package/src/shared/views/CometChatDeletedBubble/CometChatDeletedBubble.tsx +17 -5
  70. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +65 -35
  71. package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +22 -11
  72. package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +47 -18
  73. package/src/shared/views/CometChatList/CometChatList.tsx +70 -46
  74. package/src/shared/views/CometChatList/Header.tsx +122 -37
  75. package/src/shared/views/CometChatList/styles.ts +1 -0
  76. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +116 -30
  77. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +52 -30
  78. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +36 -22
  79. package/src/shared/views/CometChatQuickReactions/CometChatQuickReactions.tsx +41 -13
  80. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +132 -17
  81. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +30 -2
  82. package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +10 -6
  83. package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +20 -13
  84. package/src/shared/views/CometChatStatusIndicator/styles.ts +26 -13
  85. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +25 -2
  86. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +94 -14
  87. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +52 -16
  88. package/src/shared/views/CometChatTooltipMenu/index.ts +2 -1
  89. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +29 -9
  90. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +20 -2
  91. package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +29 -14
  92. package/src/shared/views/index.ts +2 -0
  93. package/src/theme/default/index.ts +5 -5
  94. package/src/theme/type.ts +2 -2
  95. package/src/shared/views/CometChatPanel/CometChatPanel.tsx +0 -57
  96. package/src/shared/views/CometChatPanel/PanelStyle.tsx +0 -43
  97. package/src/shared/views/CometChatPanel/resources/CloseIcon.png +0 -0
  98. 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 { Animated, Dimensions, Easing, ScrollView, StyleSheet, View } from "react-native";
3
- import Svg, { Defs, G, LinearGradient, Path, Stop, Rect } from "react-native-svg";
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
- const SkeletonItemBottom = () => {
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='0 0 360 72'
15
- fill='none'
16
- preserveAspectRatio='xMidYMid meet'
72
+ viewBox="0 0 360 72"
73
+ fill="none"
74
+ preserveAspectRatio="xMidYMid meet"
17
75
  >
18
- <Rect x='16' y='12' width='48' height='48' fill='url(#paint0_linear_4_115)' />
19
- <Rect x='76' y='15' width='160' height='22' fill='url(#paint0_linear_4_115)' />
20
- <Rect x='76' y='45' width='80' height='12' fill='url(#paint0_linear_4_115)' />
21
- <Rect x='312' y='20' width='32' height='32' fill='url(#paint0_linear_4_115)' />
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='paint0_linear_4_115'
87
+ id="shimmerGradient"
25
88
  x1={16}
26
89
  y1={36}
27
90
  x2={64}
28
91
  y2={36}
29
- gradientUnits='userSpaceOnUse'
92
+ gradientUnits="userSpaceOnUse"
30
93
  >
31
- <Stop stopColor={theme.conversationStyles.skeletonStyle.linearGradientColors[0]} />
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
- const SkeletonItemTop = () => {
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='0 0 360 72' fill='none'>
111
+ <Svg height={screenWidth / 5} viewBox="0 0 360 72" fill="none">
47
112
  <Path
48
- fillRule='evenodd'
49
- clipRule='evenodd'
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={theme.conversationStyles.containerStyle.backgroundColor}
116
+ fill={
117
+ style.containerBackgroundColor ??
118
+ defaults.containerBackgroundColor
119
+ }
52
120
  />
53
121
  </Svg>
54
122
  );
55
123
  };
56
124
 
57
- export const Skeleton = () => {
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 animatedValue = useRef(new Animated.Value(0)).current;
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
- const startShimmer = () => {
63
- animatedValue.setValue(0);
64
- Animated.loop(
65
- Animated.timing(animatedValue, {
66
- toValue: 1,
67
- duration: (1 / theme.conversationStyles.skeletonStyle.speed) * 1000,
68
- easing: Easing.linear,
69
- useNativeDriver: false,
70
- })
71
- ).start();
72
- };
73
-
74
- startShimmer();
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
- {new Array(20).fill(0).map((_, i) => {
85
- return <SkeletonItemBottom key={i} />;
86
- })}
87
- <Animated.View
88
- style={[
89
- {
90
- transform: [
91
- { translateX: shimmerTranslateX },
92
- { translateY: -20 },
93
- { rotate: "15deg" },
94
- ],
95
- },
96
- styles.animatedView,
97
- {
98
- backgroundColor: theme.conversationStyles.skeletonStyle.shimmerBackgroundColor,
99
- opacity: theme.conversationStyles.skeletonStyle.shimmerOpacity,
100
- },
101
- ]}
102
- ></Animated.View>
103
- <Animated.View
104
- style={[
105
- {
106
- transform: [
107
- { translateX: Animated.add(shimmerTranslateX, screenWidth / 2) },
108
- { translateY: -20 },
109
- { rotate: "15deg" },
110
- ],
111
- },
112
- styles.animatedView,
113
- {
114
- backgroundColor: theme.conversationStyles.skeletonStyle.shimmerBackgroundColor,
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
- const styles = StyleSheet.create({
137
- animatedView: {
138
- width: "25%",
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
- position: "absolute",
225
+ width: "25%",
142
226
  },
143
227
  });
@@ -1,5 +1,6 @@
1
1
  import { CometChatCallLogs, CometChatCallLogsConfigurationInterface } from "./CometChatCallLogs";
2
2
 
3
3
  export { CometChatCallLogs };
4
+ export { getCallLogsStyleDark, getCallLogsStyleLight } from "./style";
4
5
 
5
6
  export type { CometChatCallLogsConfigurationInterface };
@@ -1,6 +1,15 @@
1
- import { ImageSourcePropType, ImageStyle, StyleSheet, TextStyle, ViewStyle } from "react-native";
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 getCallLogsStyle = (
79
+ export const getCallLogsStyleLight = (
63
80
  color: CometChatTheme["color"],
64
81
  spacing: CometChatTheme["spacing"],
65
82
  typography: CometChatTheme["typography"]
66
- ): CallLogsStyle => {
67
- return {
68
- errorStateStyle: {
69
- titleStyle: {
83
+ ): DeepPartial<CallLogsStyle> =>
84
+ deepMerge(
85
+ {
86
+ containerStyle: {},
87
+ titleTextStyle: {
70
88
  color: color.textPrimary,
71
- textAlign: "center",
72
- ...typography.heading3.bold,
89
+ ...typography.heading1.bold,
73
90
  },
74
- subTitleStyle: {
75
- color: color.textSecondary,
76
- textAlign: "center",
77
- ...typography.body.regular,
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
- containerStyle: {},
80
- },
81
- emptyStateStyle: {
82
- titleStyle: {
83
- color: color.textPrimary,
84
- textAlign: "center",
85
- ...typography.heading3.bold,
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
- subTitleStyle: {
88
- color: color.textSecondary,
89
- textAlign: "center",
90
- ...typography.body.regular,
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
- containerStyle: {},
93
- },
94
- containerStyle: {},
95
- titleTextStyle: {
96
- color: color.textPrimary,
97
- ...typography.heading1.bold,
98
- },
99
- titleSeparatorStyle: {
100
- borderBottomWidth: 1,
101
- borderBottomColor: color.borderLight,
102
- flexDirection: "row",
103
- justifyContent: "space-between",
104
- alignItems: "center",
105
- width: "100%",
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
- itemStyle: getCallLogsItemStyle(color, spacing, typography)
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
- ...typography.heading4.medium
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
- // Refs to store ongoing call, session ID, call listener and settings.
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
- * Checks if the provided call is a default CometChat call.
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"] == "ongoing" ||
147
- (call.getCategory() == (CometChat.CATEGORY_CUSTOM as CometChat.MessageCategory) &&
148
- call.getType() == MessageTypeConstants.meeting))
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?.getCategory() == MessageCategoryConstants.call) {
155
- callSessionId.current = call?.["sessionId"];
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(call: any) {
175
+ onOutgoingCallAccepted: (acceptedCall: any) => {
173
176
  CometChatSoundManager.pause();
174
- ongoingCall.current = call;
175
- callSessionId.current = call["sessionId"];
177
+ ongoingCall.current = acceptedCall;
178
+ callSessionId.current = acceptedCall["sessionId"];
176
179
  setCallConnected(true);
177
180
  },
178
- onOutgoingCallRejected: (call: any) => {
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() === "meeting" ? call?.["customData"]?.["callType"] : 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
- // Retrieve the receiver's name or fallback to "Unknown".
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
- onRequestClose={() =>
260
- onEndCallButtonPressed && onEndCallButtonPressed(call as CometChat.Call)
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?.() == "user"
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"