@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
@@ -3,11 +3,11 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"
3
3
  import {
4
4
  FlatList,
5
5
  Image,
6
- ImageSourcePropType,
7
- RefreshControl,
8
6
  Text,
9
7
  TouchableOpacity,
10
8
  View,
9
+ GestureResponderEvent,
10
+ ActivityIndicator,
11
11
  } from "react-native";
12
12
  import { CometChatAvatar, localize } from "../../shared";
13
13
  import { CallTypeConstants } from "../../shared/constants/UIKitConstants";
@@ -26,6 +26,7 @@ import { Skeleton } from "./Skeleton";
26
26
  import { CometChatTheme } from "../../theme/type";
27
27
  import { deepMerge } from "../../shared/helper/helperFunctions";
28
28
  import { DeepPartial, ValueOf } from "../../shared/helper/types";
29
+ import { CometChatTooltipMenu, MenuItemInterface } from "../../shared/views/CometChatTooltipMenu";
29
30
 
30
31
  const listenerId = "callEventListener_" + new Date().getTime();
31
32
  const CometChatCalls = CallingPackage.CometChatCalls;
@@ -53,7 +54,7 @@ export interface CometChatCallLogsConfigurationInterface {
53
54
  /** Date format pattern for call logs */
54
55
  datePattern?: ValueOf<typeof DateHelper.patterns>;
55
56
  /** Flag to hide the back button in the header */
56
- hideBackButton?: boolean;
57
+ showBackButton?: boolean;
57
58
  /** Custom component to render when the call log list is empty */
58
59
  EmptyView?: () => JSX.Element;
59
60
  /** Custom component to render in case of an error */
@@ -68,12 +69,33 @@ export interface CometChatCallLogsConfigurationInterface {
68
69
  onError?: (e: CometChat.CometChatException) => void;
69
70
  /** Callback for when the back button is pressed */
70
71
  onBack?: () => void;
71
- /** Callback for when a call log item is pressed */
72
- onItemPress?: (prop: { call: any }) => void;
72
+ /**
73
+ * Callback for when a call log item is pressed.
74
+ * Receives the raw call log object.
75
+ */
76
+ onItemPress?: (call: any) => void;
73
77
  /** Custom style overrides for the call logs */
74
78
  style?: DeepPartial<CometChatTheme["callLogsStyles"]>;
75
79
  /** Configuration for outgoing calls */
76
80
  outgoingCallConfiguration?: CometChatOutgoingCallInterface;
81
+ /** Callback when the list is fetched and loaded */
82
+ onLoad?: (list: any[]) => void;
83
+ /** Callback when the list is empty (no items) */
84
+ onEmpty?: () => void;
85
+ /** Called on a long press of the default list item view */
86
+ onItemLongPress?: (prop: { call: any }) => void;
87
+ /** Hide the toolbar header */
88
+ hideHeader?: boolean;
89
+ /** Hide the loading state */
90
+ hideLoadingState?: boolean;
91
+ /**
92
+ * A function to **append** more menu items on top of the default menu items for a call log.
93
+ */
94
+ addOptions?: (call: any) => MenuItemInterface[];
95
+ /**
96
+ * A function to **replace** the default menu items entirely for a call log.
97
+ */
98
+ options?: (call: any) => MenuItemInterface[];
77
99
  }
78
100
 
79
101
  /**
@@ -94,7 +116,7 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
94
116
  TrailingView,
95
117
  AppBarOptions,
96
118
  callLogRequestBuilder,
97
- hideBackButton = true,
119
+ showBackButton = false,
98
120
  EmptyView,
99
121
  ErrorView,
100
122
  LoadingView,
@@ -106,31 +128,90 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
106
128
  style,
107
129
  outgoingCallConfiguration,
108
130
  datePattern,
131
+ onLoad,
132
+ onEmpty,
133
+ onItemLongPress,
134
+ hideHeader,
135
+ hideLoadingState,
136
+ addOptions,
137
+ options,
109
138
  } = props;
110
139
 
111
140
  const [list, setList] = useState<any[]>([]);
112
141
  const [listState, setListState] = useState<"loading" | "error" | "done">("loading");
113
142
  const [showOutgoingCallScreen, setShowOutgoingCallScreen] = useState(false);
114
- const themeV5 = useTheme();
143
+
144
+ const theme = useTheme();
115
145
  const mergedCallLogsStyle = useMemo(() => {
116
- return deepMerge(themeV5.callLogsStyles, style ?? {});
117
- }, [themeV5, style]);
146
+ return deepMerge(theme.callLogsStyles, style ?? {});
147
+ }, [theme, style]);
118
148
 
119
149
  const loggedInUser = useRef<CometChat.User>();
120
150
  const callLogRequestBuilderRef = useRef<any>();
121
151
  const outGoingCall = useRef<CometChat.Call | CometChat.CustomMessage>();
122
152
 
153
+ // State for tooltip functionality
154
+ const [tooltipVisible, setTooltipVisible] = useState<boolean>(false);
155
+ const [selectedCall, setSelectedCall] = useState<any>(null);
156
+ const tooltipPosition = useRef<{ pageX: number; pageY: number }>({
157
+ pageX: 0,
158
+ pageY: 0,
159
+ });
160
+ const [hasMoreData, setHasMoreData] = useState(true);
161
+
162
+ /**
163
+ * Function to build the list of menu items for the tooltip:
164
+ * - `options(call)` completely replaces defaults
165
+ * - `addOptions(call)` appends to the default
166
+ * - No default menu items in this snippet; so defaults is an empty array
167
+ */
168
+ const buildMenuItems = (call: any): MenuItemInterface[] => {
169
+ if (options) {
170
+ return options(call);
171
+ }
172
+ let defaultMenuItems: MenuItemInterface[] = []; // no default items here
173
+ if (addOptions) {
174
+ return [...defaultMenuItems, ...addOptions(call)];
175
+ }
176
+ return defaultMenuItems;
177
+ };
178
+
179
+ /**
180
+ * Show tooltip if user hasn't provided a custom onItemLongPress.
181
+ */
182
+ const handleItemLongPress = (call: any, e?: GestureResponderEvent) => {
183
+ if (onItemLongPress) {
184
+ // If the developer has provided a custom long-press handler, call that and return.
185
+ onItemLongPress({ call });
186
+ return;
187
+ }
188
+ // Otherwise, show the tooltip if there are menu items
189
+ const items = buildMenuItems(call);
190
+ if (items.length === 0) return;
191
+
192
+ if (e && e.nativeEvent) {
193
+ tooltipPosition.current = {
194
+ pageX: e.nativeEvent.pageX,
195
+ pageY: e.nativeEvent.pageY,
196
+ };
197
+ } else {
198
+ tooltipPosition.current = { pageX: 200, pageY: 100 };
199
+ }
200
+ setSelectedCall(call);
201
+ setTooltipVisible(true);
202
+ };
203
+
123
204
  /**
124
205
  * Initializes the call log request builder.
125
206
  */
126
207
  function setRequestBuilder() {
127
- callLogRequestBuilderRef.current =
128
- (callLogRequestBuilder && callLogRequestBuilder.build()) ??
129
- new CometChatCalls.CallLogRequestBuilder()
130
- .setLimit(30)
131
- .setAuthToken(loggedInUser.current!.getAuthToken() || "")
132
- .setCallCategory("call")
133
- .build();
208
+ const reqBuilder = callLogRequestBuilder
209
+ ? callLogRequestBuilder.setAuthToken(loggedInUser.current!.getAuthToken())
210
+ : new CometChatCalls.CallLogRequestBuilder()
211
+ .setLimit(30)
212
+ .setAuthToken(loggedInUser.current!.getAuthToken() || "")
213
+ .setCallCategory("call");
214
+ callLogRequestBuilderRef.current = reqBuilder.build();
134
215
  }
135
216
 
136
217
  /**
@@ -141,8 +222,18 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
141
222
  callLogRequestBuilderRef
142
223
  .current!.fetchNext()
143
224
  .then((callLogs: any) => {
225
+ if (callLogRequestBuilderRef.current!.limit > callLogs.length) {
226
+ setHasMoreData(false);
227
+ }
144
228
  if (callLogs.length > 0) {
145
- setList([...list, ...callLogs]);
229
+ const updatedList = [...list, ...callLogs];
230
+ setList(updatedList);
231
+ onLoad && onLoad(updatedList);
232
+ } else {
233
+ // If no new logs are returned and the current list is empty, trigger onEmpty
234
+ if (list.length === 0) {
235
+ onEmpty && onEmpty();
236
+ }
146
237
  }
147
238
  setListState("done");
148
239
  })
@@ -186,6 +277,12 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
186
277
  setShowOutgoingCallScreen(false);
187
278
  },
188
279
  });
280
+
281
+ return () => {
282
+ // Cleanup call listeners when component unmounts
283
+ CometChat.removeCallListener(listenerId);
284
+ CometChatUIEventHandler.removeCallListener(listenerId);
285
+ };
189
286
  }, []);
190
287
 
191
288
  /**
@@ -196,7 +293,6 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
196
293
  */
197
294
  const makeCall = (call: any, type: any) => {
198
295
  if (type == CallTypeConstants.audio || type == CallTypeConstants.video) {
199
- // Determine the user or group to call based on the call log item.
200
296
  let user =
201
297
  call?.getReceiverType() == "user"
202
298
  ? loggedInUser.current?.getUid() === call?.getInitiator()?.getUid()
@@ -215,8 +311,8 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
215
311
  var receiverType = user
216
312
  ? CometChat.RECEIVER_TYPE.USER
217
313
  : group
218
- ? CometChat.RECEIVER_TYPE.GROUP
219
- : undefined;
314
+ ? CometChat.RECEIVER_TYPE.GROUP
315
+ : undefined;
220
316
  if (!receiverID || !receiverType) return;
221
317
 
222
318
  var callObject = new CometChat.Call(
@@ -241,20 +337,13 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
241
337
  }
242
338
  );
243
339
  } else {
244
- console.log(
245
- "Invalid call type.",
246
- type,
247
- CallTypeConstants.audio,
248
- type != CallTypeConstants.audio || type != CallTypeConstants.video
249
- );
340
+ console.log("Invalid call type.", type);
250
341
  return;
251
342
  }
252
343
  };
253
344
 
254
345
  /**
255
346
  * Handles the press event on the call icon.
256
- *
257
- * @param {any} item - The call log item.
258
347
  */
259
348
  const onPress = (item: any) => {
260
349
  if (onCallIconPress) {
@@ -268,9 +357,6 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
268
357
 
269
358
  /**
270
359
  * Extracts and returns call details for display.
271
- *
272
- * @param {any} call - The call log item.
273
- * @returns {object} An object containing the title and avatar URL.
274
360
  */
275
361
  const getCallDetails = (call: any) => {
276
362
  const { mode, initiator, receiver, receiverType } = call;
@@ -286,14 +372,14 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
286
372
  receiverType === "group"
287
373
  ? receiver["name"]
288
374
  : loggedInUser.current?.getUid() == initiator?.getUid()
289
- ? receiver["name"]
290
- : initiator["name"],
375
+ ? receiver["name"]
376
+ : initiator["name"],
291
377
  avatarUrl:
292
378
  receiverType === "group"
293
379
  ? receiver["avatar"]
294
380
  : loggedInUser.current?.getUid() == initiator?.getUid()
295
- ? receiver["avatar"]
296
- : initiator["avatar"],
381
+ ? receiver["avatar"]
382
+ : initiator["avatar"],
297
383
  };
298
384
  }
299
385
  return { title: "", avatarUrl: undefined };
@@ -301,18 +387,19 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
301
387
 
302
388
  /**
303
389
  * Renders each call log item.
304
- *
305
- * @param {object} param0 - Object containing the item and index.
306
- * @returns {JSX.Element} The rendered call log item.
307
390
  */
308
391
  const _render = ({ item, index }: any) => {
392
+ // If user provides a custom item view, use that
309
393
  if (ItemView) return ItemView(item);
310
394
 
311
395
  const { title, avatarUrl } = getCallDetails(item);
312
396
  const callStatus = CallUtils.getCallStatusForCallLogs(item, loggedInUser.current!);
313
397
 
314
398
  return (
315
- <TouchableOpacity onPress={() => onItemPress?.(item)}>
399
+ <TouchableOpacity
400
+ onPress={() => onItemPress?.(item)}
401
+ onLongPress={(e) => handleItemLongPress(item, e)}
402
+ >
316
403
  <View style={mergedCallLogsStyle.itemStyle.containerStyle}>
317
404
  {LeadingView ? (
318
405
  LeadingView(item)
@@ -346,16 +433,16 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
346
433
  callStatus === "missed"
347
434
  ? "call-missed-outgoing"
348
435
  : callStatus === "incoming"
349
- ? "call-received"
350
- : "call-made"
436
+ ? "call-received"
437
+ : "call-made"
351
438
  }
352
439
  size={16}
353
440
  color={
354
441
  callStatus === "missed"
355
442
  ? mergedCallLogsStyle.itemStyle.missedCallStatusIconStyle.tintColor
356
443
  : callStatus === "incoming"
357
- ? mergedCallLogsStyle.itemStyle.incomingCallStatusIconStyle.tintColor
358
- : mergedCallLogsStyle.itemStyle.outgoingCallStatusIconStyle.tintColor
444
+ ? mergedCallLogsStyle.itemStyle.incomingCallStatusIconStyle.tintColor
445
+ : mergedCallLogsStyle.itemStyle.outgoingCallStatusIconStyle.tintColor
359
446
  }
360
447
  containerStyle={{ marginTop: 2 }}
361
448
  />
@@ -395,8 +482,6 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
395
482
 
396
483
  /**
397
484
  * Renders the error view for the call logs.
398
- *
399
- * @returns {JSX.Element | null} The error state view.
400
485
  */
401
486
  const ErrorStateView = useCallback(() => {
402
487
  if (hideError) return null;
@@ -404,14 +489,14 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
404
489
  return (
405
490
  <ErrorEmptyView
406
491
  title='Oops!'
407
- subTitle='Looks like something went wrong.'
408
- tertiaryTitle='Please try again.'
492
+ subTitle={localize("SOMETHING_WENT_WRONG")}
493
+ tertiaryTitle={localize("WRONG_TEXT_TRY_AGAIN")}
409
494
  Icon={
410
495
  <Icon
411
496
  name='error-state'
412
- size={themeV5.spacing.margin.m15 << 1}
497
+ size={theme.spacing.margin.m15 << 1}
413
498
  containerStyle={{
414
- marginBottom: themeV5.spacing.margin.m5,
499
+ marginBottom: theme.spacing.margin.m5,
415
500
  }}
416
501
  />
417
502
  }
@@ -422,17 +507,17 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
422
507
  <TouchableOpacity
423
508
  onPress={fetchCallLogs}
424
509
  style={{
425
- backgroundColor: themeV5.color.primary,
426
- paddingVertical: themeV5.spacing.spacing.s3,
427
- paddingHorizontal: themeV5.spacing.spacing.s10,
428
- borderRadius: themeV5.spacing.radius.r2,
429
- marginTop: themeV5.spacing.spacing.s5,
510
+ backgroundColor: theme.color.primary,
511
+ paddingVertical: theme.spacing.spacing.s3,
512
+ paddingHorizontal: theme.spacing.spacing.s10,
513
+ borderRadius: theme.spacing.radius.r2,
514
+ marginTop: theme.spacing.spacing.s5,
430
515
  }}
431
516
  >
432
517
  <Text
433
518
  style={{
434
- color: themeV5.color.primaryButtonIcon,
435
- ...themeV5.typography.button.medium,
519
+ color: theme.color.primaryButtonIcon,
520
+ ...theme.typography.button.medium,
436
521
  }}
437
522
  >
438
523
  {localize("RETRY")}
@@ -441,12 +526,10 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
441
526
  }
442
527
  />
443
528
  );
444
- }, [themeV5]);
529
+ }, [theme]);
445
530
 
446
531
  /**
447
532
  * Renders the empty state view for call logs.
448
- *
449
- * @returns {JSX.Element} The empty state view.
450
533
  */
451
534
  const EmptyStateView = useCallback(() => {
452
535
  if (EmptyView) return <EmptyView />;
@@ -457,10 +540,10 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
457
540
  Icon={
458
541
  <Icon
459
542
  name='call-fill'
460
- size={themeV5.spacing.spacing.s15 << 1}
461
- color={themeV5.color.neutral300}
543
+ size={theme.spacing.spacing.s15 << 1}
544
+ color={theme.color.neutral300}
462
545
  containerStyle={{
463
- marginBottom: themeV5.spacing.spacing.s5,
546
+ marginBottom: theme.spacing.spacing.s5,
464
547
  }}
465
548
  />
466
549
  }
@@ -469,57 +552,85 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
469
552
  subTitleStyle={mergedCallLogsStyle.emptyStateStyle?.subTitleStyle}
470
553
  />
471
554
  );
472
- }, [themeV5]);
555
+ }, [theme]);
556
+
557
+ const renderFooter = useCallback(() => {
558
+ if (listState !== "loading" || !hasMoreData) return null;
559
+ return (
560
+ <View
561
+ style={{
562
+ paddingVertical: 20,
563
+ flex: 1,
564
+ alignItems: "center",
565
+ justifyContent: "center",
566
+ }}
567
+ >
568
+ <ActivityIndicator size='small' color={theme.color.primary} />
569
+ </View>
570
+ );
571
+ }, [theme, listState]);
473
572
 
474
573
  return (
475
- <View style={{ backgroundColor: themeV5.color.background1, height: "100%", width: "100%" }}>
574
+ <View
575
+ style={{
576
+ backgroundColor: theme.color.background1,
577
+ height: "100%",
578
+ width: "100%",
579
+ }}
580
+ >
476
581
  <>
477
582
  {/* Header with optional back button and app bar options */}
478
- <View
479
- style={[
480
- Style.row,
481
- Style.headerStyle,
482
- {
483
- padding: themeV5.spacing.spacing.s4,
484
- borderBottomWidth: 1,
485
- borderBottomColor: themeV5.color.borderLight,
486
- ...mergedCallLogsStyle.titleSeparatorStyle,
487
- },
488
- ]}
489
- >
490
- <View style={Style.row}>
491
- {!hideBackButton ? (
492
- <TouchableOpacity style={Style.imageStyle} onPress={onBack}>
493
- <Image
494
- source={BackIcon}
495
- style={[Style.imageStyle, { tintColor: themeV5.color.iconPrimary }]}
496
- />
497
- </TouchableOpacity>
498
- ) : null}
499
- <Text style={mergedCallLogsStyle.titleTextStyle}>{localize("CALLS")}</Text>
583
+ {!hideHeader && (
584
+ <View
585
+ style={[
586
+ Style.row,
587
+ Style.headerStyle,
588
+ {
589
+ padding: theme.spacing.spacing.s4,
590
+ borderBottomWidth: 1,
591
+ borderBottomColor: theme.color.borderLight,
592
+ ...mergedCallLogsStyle.titleSeparatorStyle,
593
+ },
594
+ ]}
595
+ >
596
+ <View style={Style.row}>
597
+ {showBackButton ? (
598
+ <TouchableOpacity style={Style.imageStyle} onPress={onBack}>
599
+ <Image
600
+ source={BackIcon}
601
+ style={[Style.imageStyle, { tintColor: theme.color.iconPrimary }]}
602
+ />
603
+ </TouchableOpacity>
604
+ ) : null}
605
+ <Text style={mergedCallLogsStyle.titleTextStyle}>{localize("CALLS")}</Text>
606
+ </View>
607
+ <View style={Style.row}>{AppBarOptions && <AppBarOptions />}</View>
500
608
  </View>
501
- <View style={Style.row}>{AppBarOptions && <AppBarOptions />}</View>
502
- </View>
609
+ )}
610
+
503
611
  {/* Render call logs based on state */}
504
- {listState == "loading" && list.length == 0 ? (
505
- LoadingView ? (
506
- <LoadingView />
612
+ {listState === "loading" && list.length === 0 ? (
613
+ !hideLoadingState ? (
614
+ LoadingView ? (
615
+ <LoadingView />
616
+ ) : (
617
+ <Skeleton style={mergedCallLogsStyle.skeletonStyle} />
618
+ )
507
619
  ) : (
508
- <Skeleton />
620
+ <View />
509
621
  )
510
- ) : listState == "error" && list.length == 0 ? (
622
+ ) : listState === "error" && list.length === 0 ? (
511
623
  <ErrorStateView />
512
- ) : list.length == 0 ? (
624
+ ) : list.length === 0 ? (
513
625
  <EmptyStateView />
514
626
  ) : (
515
627
  <FlatList
516
628
  data={list}
517
629
  keyExtractor={(item, index) => item.sessionId + "_" + index}
630
+ extraData={{ list, listState }}
518
631
  renderItem={_render}
519
632
  onEndReached={fetchCallLogs}
520
- refreshControl={
521
- <RefreshControl refreshing={listState === "loading"} onRefresh={fetchCallLogs} />
522
- }
633
+ ListFooterComponent={renderFooter}
523
634
  />
524
635
  )}
525
636
  </>
@@ -542,6 +653,38 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
542
653
  {...outgoingCallConfiguration}
543
654
  />
544
655
  )}
656
+
657
+ {/* Tooltip menu for calls (on default long-press) */}
658
+ {selectedCall && tooltipVisible && (
659
+ <View
660
+ style={{
661
+ position: "absolute",
662
+ top: tooltipPosition.current.pageY,
663
+ left: tooltipPosition.current.pageX,
664
+ zIndex: 9999,
665
+ }}
666
+ >
667
+ <CometChatTooltipMenu
668
+ visible={tooltipVisible}
669
+ onClose={() => setTooltipVisible(false)}
670
+ onDismiss={() => setTooltipVisible(false)}
671
+ event={{
672
+ nativeEvent: tooltipPosition.current,
673
+ }}
674
+ menuItems={buildMenuItems(selectedCall).map((menuItem) => ({
675
+ text: menuItem.text,
676
+ onPress: () => {
677
+ menuItem.onPress();
678
+ setTooltipVisible(false);
679
+ },
680
+ textColor: menuItem.textStyle?.color,
681
+ iconColor: menuItem.iconStyle?.tintColor,
682
+ disabled: menuItem.disabled,
683
+ }))}
684
+ />
685
+ </View>
686
+ )}
687
+ {/* End tooltip menu */}
545
688
  </View>
546
689
  );
547
690
  };