@cometchat/chat-uikit-react-native 5.0.0 → 5.0.2

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 (103) hide show
  1. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +87 -49
  2. package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +10 -0
  3. package/ios/SoundPlayer.m +8 -0
  4. package/package.json +8 -9
  5. package/src/CometChatConversations/CometChatConversations.tsx +19 -14
  6. package/src/CometChatConversations/style.ts +6 -2
  7. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +1 -0
  8. package/src/CometChatGroupMembers/style.ts +1 -0
  9. package/src/CometChatGroups/CometChatGroups.tsx +1 -0
  10. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +227 -57
  11. package/src/CometChatMessageComposer/styles.tsx +3 -6
  12. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +2 -2
  13. package/src/CometChatMessageHeader/styles.ts +1 -0
  14. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +1 -1
  15. package/src/CometChatMessageList/CometChatMessageList.tsx +188 -111
  16. package/src/CometChatMessageList/style.ts +0 -16
  17. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +1 -1
  18. package/src/CometChatUsers/CometChatUsers.tsx +1 -1
  19. package/src/calls/CallUtils.ts +18 -10
  20. package/src/calls/CallingExtensionDecorator.tsx +1 -1
  21. package/src/calls/CometChatCallBubble/CometChatCallBubble.tsx +8 -7
  22. package/src/calls/CometChatCallBubble/styles.ts +1 -0
  23. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +6 -4
  24. package/src/calls/CometChatCallButtons/style.ts +2 -1
  25. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +4 -3
  26. package/src/calls/CometChatCallLogs/style.ts +1 -0
  27. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +4 -3
  28. package/src/calls/CometChatOngoingCall/CometChatOngoingCall.tsx +1 -0
  29. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +3 -3
  30. package/src/calls/CometChatOutgoingCall/OutgoingCallConfiguration.ts +1 -0
  31. package/src/extensions/CollaborativeBubble/CometChatCollaborativeBubble.tsx +1 -1
  32. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +1 -1
  33. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +1 -1
  34. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +15 -18
  35. package/src/extensions/LinkPreview/LinkPreviewExtensionDecorator.tsx +1 -1
  36. package/src/extensions/LinkPreview/style.ts +2 -2
  37. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +20 -17
  38. package/src/extensions/Polls/Polls.tsx +45 -8
  39. package/src/extensions/Polls/PollsDecorator.tsx +1 -1
  40. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +2 -4
  41. package/src/extensions/Stickers/style.ts +3 -3
  42. package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +1 -1
  43. package/src/imageresolver.d.ts +4 -0
  44. package/src/index.ts +2 -0
  45. package/src/shared/CometChatUiKit/CometChatUIKit.ts +1 -2
  46. package/src/shared/base/Types.ts +1 -0
  47. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +114 -32
  48. package/src/shared/formatters/CometChatTextFormatter.ts +1 -0
  49. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +4 -4
  50. package/src/shared/framework/DataSource.ts +6 -2
  51. package/src/shared/framework/DataSourceDecorator.tsx +5 -4
  52. package/src/shared/framework/MessageDataSource.tsx +26 -28
  53. package/src/shared/helper/types/index.ts +1 -0
  54. package/src/shared/icons/Icon.tsx +1 -1
  55. package/src/shared/index.ts +41 -126
  56. package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +1 -1
  57. package/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx +4 -2
  58. package/src/shared/modals/CometChatMessageOption.ts +1 -0
  59. package/src/shared/modals/CometChatMessageTemplate.ts +1 -0
  60. package/src/shared/resources/CometChatSoundManager/index.ts +1 -0
  61. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +0 -8
  62. package/src/shared/utils/CometChatMessagePreview/index.ts +1 -2
  63. package/src/shared/utils/CommonUtils.ts +2 -1
  64. package/src/shared/utils/MessageUtils.tsx +54 -62
  65. package/src/shared/utils/conversationUtils.ts +1 -0
  66. package/src/shared/utils/index.ts +1 -2
  67. package/src/shared/views/CometChatActionSheet/ActionItem.ts +1 -0
  68. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -1
  69. package/src/shared/views/CometChatAudioBubble/AnimatedAudioWaves.tsx +1 -1
  70. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +9 -6
  71. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +1 -1
  72. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +1 -1
  73. package/src/shared/views/CometChatConfirmDialog/style.ts +1 -0
  74. package/src/shared/views/CometChatDeletedBubble/styles.ts +1 -0
  75. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +1 -1
  76. package/src/shared/views/CometChatList/CometChatList.tsx +2 -2
  77. package/src/shared/views/CometChatList/Header.tsx +1 -1
  78. package/src/shared/views/CometChatMediaRecorder/AnimatingMic.tsx +2 -2
  79. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPreview/CometChatAudioPreview.tsx +16 -10
  80. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +7 -8
  81. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +1 -1
  82. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +84 -70
  83. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +1 -1
  84. package/src/shared/views/CometChatReactions/style.ts +5 -4
  85. package/src/shared/views/CometChatReceipt/style.ts +1 -0
  86. package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +1 -1
  87. package/src/shared/views/CometChatSuggestionList/style.ts +3 -2
  88. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +1 -1
  89. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +24 -47
  90. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +68 -73
  91. package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +1 -0
  92. package/src/theme/CometChatThemeHelper.ts +69 -58
  93. package/src/theme/context.ts +2 -2
  94. package/src/theme/default/default.ts +204 -0
  95. package/src/theme/default/index.ts +0 -238
  96. package/src/theme/provider.tsx +7 -7
  97. package/src/theme/type.ts +5 -7
  98. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  99. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  100. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  101. package/android/.gradle/7.4/gc.properties +0 -0
  102. package/android/.gradle/vcs-1/gc.properties +0 -0
  103. package/src/shared/utils/CometChatMessagePreview/MessagePreviewStyle.js +0 -42
@@ -1,10 +1,8 @@
1
- import React, { useRef, useState } from "react";
1
+ import React, { useState, useEffect, useRef } from "react";
2
2
  import {
3
3
  ActivityIndicator,
4
- Animated,
5
4
  Dimensions,
6
5
  Modal,
7
- PanResponder,
8
6
  Platform,
9
7
  StyleSheet,
10
8
  TouchableWithoutFeedback,
@@ -41,47 +39,16 @@ export interface CometChatVideoPlayerProps {
41
39
 
42
40
  export const CometChatVideoPlayer = (props: CometChatVideoPlayerProps) => {
43
41
  const { videoUri, isVisible, onClose, onLoad, loadingIconColor } = props;
44
-
45
42
  const [isPaused, setPaused] = useState(false);
46
43
  const [isLoading, setIsLoading] = useState(true);
44
+ const [showCloseButton, setShowCloseButton] = useState(true);
45
+ const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
47
46
 
48
- // Animated value for vertical position
49
- const pan = useRef(new Animated.ValueXY()).current;
50
-
51
- // Threshold for swipe-down to trigger close
52
- const SWIPE_THRESHOLD = 150;
53
-
54
- // PanResponder to handle swipe gestures
55
- const panResponder = useRef(
56
- PanResponder.create({
57
- onStartShouldSetPanResponder: () => true,
58
- onMoveShouldSetPanResponder: (_, gestureState) => {
59
- // Only respond to vertical gestures
60
- return Math.abs(gestureState.dy) > Math.abs(gestureState.dx);
61
- },
62
- onPanResponderMove: Animated.event([null, { dy: pan.y }], { useNativeDriver: false }),
63
- onPanResponderRelease: (_, gestureState) => {
64
- if (gestureState.dy > SWIPE_THRESHOLD) {
65
- // User swiped down enough to dismiss
66
- Animated.timing(pan, {
67
- toValue: { x: 0, y: Dimensions.get("window").height },
68
- duration: 200,
69
- useNativeDriver: false,
70
- }).start(() => {
71
- handleClose();
72
- pan.setValue({ x: 0, y: 0 }); // Reset position
73
- });
74
- } else {
75
- // Not enough swipe, reset position
76
- Animated.spring(pan, {
77
- toValue: { x: 0, y: 0 },
78
- useNativeDriver: false,
79
- }).start();
80
- }
81
- },
82
- })
83
- ).current;
84
-
47
+ // Handle closing the video player
48
+ const handleClose = () => {
49
+ setPaused(true);
50
+ onClose();
51
+ };
85
52
  const handleLoadStart = () => {
86
53
  setIsLoading(true);
87
54
  setPaused(false);
@@ -96,14 +63,47 @@ export const CometChatVideoPlayer = (props: CometChatVideoPlayerProps) => {
96
63
  onLoad();
97
64
  };
98
65
 
99
- /**
100
- * Closes the video (pauses it) and calls parent onClose.
101
- */
102
- const handleClose = () => {
103
- setPaused(true);
104
- onClose();
66
+ const resetHideTimer = () => {
67
+ // Clear existing timer
68
+ if (timerRef.current) {
69
+ clearTimeout(timerRef.current);
70
+ timerRef.current = null;
71
+ }
72
+
73
+ // Show close button and set new timer
74
+ setShowCloseButton(true);
75
+ timerRef.current = setTimeout(() => {
76
+ setShowCloseButton(false);
77
+ }, 2500);
78
+ };
79
+
80
+ // Handle tap on video area
81
+ const handleVideoTap = () => {
82
+ resetHideTimer();
105
83
  };
106
84
 
85
+ // Set up and clean up timers based on visibility
86
+ useEffect(() => {
87
+ if (isVisible) {
88
+ resetHideTimer();
89
+ } else {
90
+ // Clean up on close
91
+ if (timerRef.current) {
92
+ clearTimeout(timerRef.current);
93
+ timerRef.current = null;
94
+ }
95
+ // Reset to visible state for next open
96
+ setShowCloseButton(true);
97
+ }
98
+
99
+ // Clear timer when component unmounts
100
+ return () => {
101
+ if (timerRef.current) {
102
+ clearTimeout(timerRef.current);
103
+ }
104
+ };
105
+ }, [isVisible]);
106
+
107
107
  return (
108
108
  <Modal
109
109
  animationType='fade'
@@ -113,11 +113,8 @@ export const CometChatVideoPlayer = (props: CometChatVideoPlayerProps) => {
113
113
  onRequestClose={handleClose}
114
114
  >
115
115
  <View style={styles.modalBackground}>
116
- <Animated.View
117
- style={[styles.overlay, { transform: [{ translateY: pan.y }] }]}
118
- {...panResponder.panHandlers}
119
- >
120
- <View style={styles.smallPlayerContainer}>
116
+ <TouchableWithoutFeedback onPress={handleVideoTap}>
117
+ <View style={styles.playerContainer}>
121
118
  <Video
122
119
  source={{ uri: videoUri }}
123
120
  controls={true}
@@ -127,9 +124,8 @@ export const CometChatVideoPlayer = (props: CometChatVideoPlayerProps) => {
127
124
  onLoad={handleLoad}
128
125
  onError={(e) => console.warn("Video Error: ", e?.error)}
129
126
  paused={isPaused}
130
- style={styles.smallVideo}
127
+ style={styles.video}
131
128
  />
132
-
133
129
  {isLoading && (
134
130
  <ActivityIndicator
135
131
  style={styles.loadingIndicator}
@@ -138,15 +134,15 @@ export const CometChatVideoPlayer = (props: CometChatVideoPlayerProps) => {
138
134
  />
139
135
  )}
140
136
 
141
- {/* Optional: Custom close button */}
142
-
143
- <TouchableWithoutFeedback onPress={handleClose}>
144
- <View style={styles.closeButton}>
145
- <Icon name='close' size={18} color={"#fff"} />
146
- </View>
147
- </TouchableWithoutFeedback>
137
+ {showCloseButton && (
138
+ <TouchableWithoutFeedback onPress={handleClose}>
139
+ <View style={styles.closeButton}>
140
+ <Icon name='close' size={22} color={"#fff"} />
141
+ </View>
142
+ </TouchableWithoutFeedback>
143
+ )}
148
144
  </View>
149
- </Animated.View>
145
+ </TouchableWithoutFeedback>
150
146
  </View>
151
147
  </Modal>
152
148
  );
@@ -156,24 +152,23 @@ const { width, height } = Dimensions.get("window");
156
152
  const styles = StyleSheet.create({
157
153
  modalBackground: {
158
154
  flex: 1,
159
- backgroundColor: "rgba(0,0,0,0.8)", // Semi-transparent background
155
+ backgroundColor: "rgba(0,0,0,0.8)",
160
156
  justifyContent: "center",
161
157
  alignItems: "center",
162
158
  },
163
- overlay: {},
164
- smallPlayerContainer: {
165
- width: width * 0.95, // Adjust the width of the player
166
- height: height * 0.6, // Adjust the height as needed
159
+ playerContainer: {
160
+ width: width,
161
+ height: height * 0.96,
167
162
  backgroundColor: "black",
168
163
  borderRadius: 10,
169
164
  overflow: "hidden",
170
- elevation: 5, // For Android shadow
171
- shadowColor: "#000", // For iOS shadow
165
+ elevation: 5,
166
+ shadowColor: "#000",
172
167
  shadowOffset: { width: 0, height: 2 },
173
168
  shadowOpacity: 0.8,
174
169
  shadowRadius: 2,
175
170
  },
176
- smallVideo: {
171
+ video: {
177
172
  width: "100%",
178
173
  height: "100%",
179
174
  },
@@ -184,11 +179,11 @@ const styles = StyleSheet.create({
184
179
  },
185
180
  closeButton: {
186
181
  position: "absolute",
187
- top: Platform.OS === "ios" ? 50 : 10,
188
- right: Platform.OS === "ios" ? 8 : 10,
182
+ top: Platform.OS === "ios" ? 60 : 15,
183
+ right: 10,
189
184
  width: 30,
190
185
  height: 30,
191
- backgroundColor: "rgba(0,0,0,0.5)",
186
+ backgroundColor: "rgba(0,0,0,0.3)",
192
187
  borderRadius: 15,
193
188
  justifyContent: "center",
194
189
  alignItems: "center",
@@ -1,3 +1,4 @@
1
+ import { JSX } from "react";
1
2
  import { StyleProp, Text, TextStyle, View, ViewStyle } from "react-native";
2
3
 
3
4
  /**
@@ -286,7 +286,7 @@ export class CometChatThemeHelper {
286
286
  for (let i = 100; i < 900; i += 100) {
287
287
  // Ensure the blend percentage is defined in your blendColorsPercentage object
288
288
  const percentage = blendColorsPercentage[i] || 0; // Default to 0 if not defined
289
- color[`extendedPrimary${i}` as keyof typeof color ] =
289
+ color[`extendedPrimary${i}` as keyof typeof color] =
290
290
  color[`extendedPrimary${i}` as keyof typeof color] === undefined
291
291
  ? CometChatThemeHelper.blendColors(color.primary as string, Colors.WHITE, percentage)
292
292
  : color[`extendedPrimary${i}` as keyof typeof color];
@@ -339,87 +339,98 @@ export class CometChatThemeHelper {
339
339
  spacing: DeepPartial<CometChatTheme["spacing"]>
340
340
  ): CometChatTheme["spacing"] {
341
341
  if (!spacing.spacing) {
342
- spacing.spacing = {};
342
+ spacing.spacing = {} as any;
343
343
  }
344
344
 
345
- spacing.spacing.s0 =
346
- spacing.spacing.s0 !== undefined ? spacing.spacing.s0 : defaultSpacing.spacing.s0;
347
- spacing.spacing.s1 =
348
- spacing.spacing.s1 !== undefined ? spacing.spacing.s1 : defaultSpacing.spacing.s1;
349
- spacing.spacing.s2 =
350
- spacing.spacing.s2 !== undefined ? spacing.spacing.s2 : defaultSpacing.spacing.s2;
351
- spacing.spacing.s3 =
352
- spacing.spacing.s3 !== undefined ? spacing.spacing.s3 : defaultSpacing.spacing.s3;
353
- spacing.spacing.s4 =
354
- spacing.spacing.s4 !== undefined ? spacing.spacing.s4 : defaultSpacing.spacing.s4;
355
- spacing.spacing.s5 =
356
- spacing.spacing.s5 !== undefined ? spacing.spacing.s5 : defaultSpacing.spacing.s5;
357
- spacing.spacing.s6 =
358
- spacing.spacing.s6 !== undefined ? spacing.spacing.s6 : defaultSpacing.spacing.s6;
359
- spacing.spacing.s7 =
360
- spacing.spacing.s7 !== undefined ? spacing.spacing.s7 : defaultSpacing.spacing.s7;
361
- spacing.spacing.s8 =
362
- spacing.spacing.s8 !== undefined ? spacing.spacing.s8 : defaultSpacing.spacing.s8;
363
- spacing.spacing.s9 =
364
- spacing.spacing.s9 !== undefined ? spacing.spacing.s9 : defaultSpacing.spacing.s9;
365
- spacing.spacing.s10 =
366
- spacing.spacing.s10 !== undefined ? spacing.spacing.s10 : defaultSpacing.spacing.s10;
367
- spacing.spacing.s11 =
368
- spacing.spacing.s11 !== undefined ? spacing.spacing.s11 : defaultSpacing.spacing.s11;
369
- spacing.spacing.s12 =
370
- spacing.spacing.s12 !== undefined ? spacing.spacing.s12 : defaultSpacing.spacing.s12;
371
- spacing.spacing.s13 =
372
- spacing.spacing.s13 !== undefined ? spacing.spacing.s13 : defaultSpacing.spacing.s13;
373
- spacing.spacing.s14 =
374
- spacing.spacing.s14 !== undefined ? spacing.spacing.s14 : defaultSpacing.spacing.s14;
375
- spacing.spacing.s15 =
376
- spacing.spacing.s15 !== undefined ? spacing.spacing.s15 : defaultSpacing.spacing.s15;
377
- spacing.spacing.s16 =
378
- spacing.spacing.s16 !== undefined ? spacing.spacing.s16 : defaultSpacing.spacing.s16;
379
- spacing.spacing.s17 =
380
- spacing.spacing.s17 !== undefined ? spacing.spacing.s17 : defaultSpacing.spacing.s17;
381
- spacing.spacing.s18 =
382
- spacing.spacing.s18 !== undefined ? spacing.spacing.s18 : defaultSpacing.spacing.s18;
383
- spacing.spacing.s19 =
384
- spacing.spacing.s19 !== undefined ? spacing.spacing.s19 : defaultSpacing.spacing.s19;
385
- spacing.spacing.s20 =
386
- spacing.spacing.s20 !== undefined ? spacing.spacing.s20 : defaultSpacing.spacing.s20;
387
- spacing.spacing.max = spacing.spacing.max !== undefined ? spacing.spacing.max : defaultSpacing.spacing.max;
345
+ spacing.spacing!.s0 =
346
+ spacing.spacing!.s0 !== undefined ? spacing.spacing?.s0 : defaultSpacing.spacing?.s0;
347
+ spacing.spacing!.s1 =
348
+ spacing.spacing!.s1 !== undefined ? spacing.spacing?.s1 : defaultSpacing.spacing?.s1;
349
+ spacing.spacing!.s2 =
350
+ spacing.spacing!.s2 !== undefined ? spacing.spacing?.s2 : defaultSpacing.spacing?.s2;
351
+ spacing.spacing!.s3 =
352
+ spacing.spacing!.s3 !== undefined ? spacing.spacing?.s3 : defaultSpacing.spacing?.s3;
353
+ spacing.spacing!.s4 =
354
+ spacing.spacing!.s4 !== undefined ? spacing.spacing?.s4 : defaultSpacing.spacing?.s4;
355
+ spacing.spacing!.s5 =
356
+ spacing.spacing!.s5 !== undefined ? spacing.spacing?.s5 : defaultSpacing.spacing?.s5;
357
+ spacing.spacing!.s6 =
358
+ spacing.spacing!.s6 !== undefined ? spacing.spacing?.s6 : defaultSpacing.spacing?.s6;
359
+ spacing.spacing!.s7 =
360
+ spacing.spacing!.s7 !== undefined ? spacing.spacing?.s7 : defaultSpacing.spacing?.s7;
361
+ spacing.spacing!.s8 =
362
+ spacing.spacing!.s8 !== undefined ? spacing.spacing?.s8 : defaultSpacing.spacing?.s8;
363
+ spacing.spacing!.s9 =
364
+ spacing.spacing!.s9 !== undefined ? spacing.spacing?.s9 : defaultSpacing.spacing?.s9;
365
+ spacing.spacing!.s10 =
366
+ spacing.spacing!.s10 !== undefined ? spacing.spacing?.s10 : defaultSpacing.spacing?.s10;
367
+ spacing.spacing!.s11 =
368
+ spacing.spacing!.s11 !== undefined ? spacing.spacing?.s11 : defaultSpacing.spacing?.s11;
369
+ spacing.spacing!.s12 =
370
+ spacing.spacing!.s12 !== undefined ? spacing.spacing?.s12 : defaultSpacing.spacing?.s12;
371
+ spacing.spacing!.s13 =
372
+ spacing.spacing!.s13 !== undefined ? spacing.spacing?.s13 : defaultSpacing.spacing?.s13;
373
+ spacing.spacing!.s14 =
374
+ spacing.spacing!.s14 !== undefined ? spacing.spacing?.s14 : defaultSpacing.spacing?.s14;
375
+ spacing.spacing!.s15 =
376
+ spacing.spacing!.s15 !== undefined ? spacing.spacing?.s15 : defaultSpacing.spacing?.s15;
377
+ spacing.spacing!.s16 =
378
+ spacing.spacing!.s16 !== undefined ? spacing.spacing?.s16 : defaultSpacing.spacing?.s16;
379
+ spacing.spacing!.s17 =
380
+ spacing.spacing!.s17 !== undefined ? spacing.spacing?.s17 : defaultSpacing.spacing?.s17;
381
+ spacing.spacing!.s18 =
382
+ spacing.spacing!.s18 !== undefined ? spacing.spacing?.s18 : defaultSpacing.spacing?.s18;
383
+ spacing.spacing!.s19 =
384
+ spacing.spacing!.s19 !== undefined ? spacing.spacing?.s19 : defaultSpacing.spacing?.s19;
385
+ spacing.spacing!.s20 =
386
+ spacing.spacing!.s20 !== undefined ? spacing.spacing?.s20 : defaultSpacing.spacing?.s20;
387
+ spacing.spacing!.max =
388
+ spacing.spacing!.max !== undefined ? spacing.spacing?.max : defaultSpacing.spacing?.max;
388
389
 
389
390
  if (!spacing.padding) {
390
- spacing.padding = {};
391
+ spacing.padding = {} as any;
391
392
  }
392
393
  if (!spacing.margin) {
393
- spacing.margin = {};
394
+ spacing.margin = {} as any;
394
395
  }
395
396
  if (!spacing.radius) {
396
- spacing.radius = {};
397
+ spacing.radius = {} as any;
397
398
  }
398
399
  /**padding**/
399
400
  Object.keys(defaultSpacing.padding).forEach((key) => {
400
- const paddingKey = key as keyof typeof spacing.padding
401
+ const k = key as string;
402
+ const paddingKey = k as keyof typeof spacing.padding;
403
+ const spacingKey = k.replace("p", "s") as keyof typeof spacing.spacing;
404
+
401
405
  spacing.padding![paddingKey] =
402
406
  spacing.padding![paddingKey] === undefined
403
- ? spacing.spacing![paddingKey.replace("p", "s") as keyof typeof spacing.spacing]
407
+ ? spacing.spacing![spacingKey]
404
408
  : spacing.padding![paddingKey];
405
409
  });
406
410
 
407
411
  /**margin**/
408
412
  Object.keys(defaultSpacing.margin).forEach((key) => {
409
- const marginKey = key as keyof typeof spacing.margin
410
- spacing.margin![marginKey] =
413
+ const k = key as string;
414
+ const marginKey = k as keyof typeof spacing.margin;
415
+ const spacingKey = k.replace("m", "s") as keyof typeof spacing.spacing;
416
+
417
+ spacing.margin![marginKey] = (
411
418
  spacing.margin?.[marginKey] === undefined
412
- ? spacing.spacing?.[marginKey.replace("m", "s") as keyof typeof spacing.spacing]
413
- : spacing.margin?.[marginKey];
419
+ ? spacing.spacing?.[spacingKey]
420
+ : spacing.margin?.[marginKey]
421
+ )!;
414
422
  });
415
423
 
416
424
  /**radius**/
417
425
  Object.keys(defaultSpacing.radius).forEach((key) => {
418
- const radiusKey = key as keyof typeof spacing.radius;
426
+ const k = key as string;
427
+ const radiusKey = k as keyof typeof spacing.radius;
428
+ const spacingKey = k.replace("r", "s") as keyof typeof spacing.spacing;
429
+
419
430
  spacing.radius![radiusKey] =
420
- spacing.radius?.[radiusKey] === undefined
421
- ? spacing.spacing?.[radiusKey.replace("r", "s") as keyof typeof spacing.spacing ]
422
- : spacing.radius?.[radiusKey];
431
+ (spacing.radius?.[radiusKey] === undefined
432
+ ? spacing.spacing?.[spacingKey]
433
+ : spacing.radius?.[radiusKey])!;
423
434
  });
424
435
 
425
436
  return spacing as CometChatTheme["spacing"];
@@ -1,6 +1,6 @@
1
1
  import { createContext } from "react";
2
2
  import { DeepPartial } from "../shared/helper/types";
3
- import { defaultDarkTheme, defaultLightTheme } from "./default";
3
+ import { defaultDarkTheme, defaultLightTheme } from "./default/default";
4
4
  import { CometChatTheme } from "./type";
5
5
 
6
6
  export interface ThemeProviderValue {
@@ -17,4 +17,4 @@ export const themeProviderDefaultValue: ThemeProviderValue = {
17
17
 
18
18
  export const ThemeContext = createContext<ThemeProviderValue>(themeProviderDefaultValue);
19
19
 
20
- export const CompThemeContext = createContext<DeepPartial<ThemeProviderValue["light"]>>({});
20
+ export const CompThemeContext = createContext<DeepPartial<ThemeProviderValue["light"]>>({} as any);
@@ -0,0 +1,204 @@
1
+ import { getCallButtonStyle } from "../../calls/CometChatCallButtons/style";
2
+ import { getCallLogsItemStyle, getCallLogsStyleLight, getCallLogsStyleDark } from "../../calls/CometChatCallLogs/style";
3
+ import { getIncomingCallStyle } from "../../calls/CometChatIncomingCall/style";
4
+ import { getOutgoingCallStyle } from "../../calls/CometChatOutgoingCall";
5
+ import {
6
+ getConversationStyleDark,
7
+ getConversationStyleLight,
8
+ } from "../../CometChatConversations/style";
9
+ import {
10
+ getGroupMemberStyleDark,
11
+ getGroupMemberStyleLight,
12
+ } from "../../CometChatGroupMembers/style";
13
+ import { getGroupListStyleLight, getUserGroupStyleDark } from "../../CometChatGroups/GroupsStyle";
14
+ import { getComposerStyle } from "../../CometChatMessageComposer/styles";
15
+ import { getMessageHeaderStyle } from "../../CometChatMessageHeader/styles";
16
+ import {
17
+ getMessageInormationListStyleDark,
18
+ getMessageInormationListStyleLight,
19
+ } from "../../CometChatMessageInformation/styles";
20
+ import {
21
+ getMessageListStylesDark,
22
+ getMessageListStylesLight,
23
+ } from "../../CometChatMessageList/style";
24
+ import {
25
+ getThreadHeaderStyleDark,
26
+ getThreadHeaderStyleLight,
27
+ } from "../../CometChatThreadHeader/style";
28
+ import { getUserListStyleDark, getUserListStyleLight } from "../../CometChatUsers/style";
29
+ import { getAvatarStyle } from "../../shared/views/CometChatAvatar/styles";
30
+ import { getBadgeStyle } from "../../shared/views/CometChatBadge";
31
+ import {
32
+ getConfirmDialogStyleDark,
33
+ getConfirmDialogStyleLight,
34
+ } from "../../shared/views/CometChatConfirmDialog/style";
35
+ import { getDateStyleDark, getDateStyleLight } from "../../shared/views/CometChatDate";
36
+ import {
37
+ getQuickReactionStyleDark,
38
+ getQuickReactionStyleLight,
39
+ } from "../../shared/views/CometChatQuickReactions/QuickReactionsStyle";
40
+ import {
41
+ getReactionListStyleDark,
42
+ getReactionListStyleLight,
43
+ } from "../../shared/views/CometChatReactionList/ReactionListStyle";
44
+ import { getMessageReceiptStyle } from "../../shared/views/CometChatReceipt/style";
45
+ import { getStatusIndicatorStyles } from "../../shared/views/CometChatStatusIndicator/styles";
46
+ import {
47
+ getMentionsListStyleDark,
48
+ getMentionsListStyleLight,
49
+ } from "../../shared/views/CometChatSuggestionList/style";
50
+ import { ActionSheetStyle, CometChatTheme } from "../type";
51
+ import { defaultColorDark } from "./color/dark";
52
+ import { defaultColorLight } from "./color/light";
53
+ import { defaultSpacing } from "./spacing";
54
+ import { defaultTypography } from "./typography";
55
+ import { DeepPartial } from "../../shared/helper/types";
56
+ import { getMediaRecorderStyle } from "../../shared/views/CometChatMediaRecorder/style";
57
+ import { getDateSeparatorStyleDark, getDateSeparatorStyleLight } from "../../shared/views/CometChatDateSeperator";
58
+
59
+ const getActionSheetStyle = (
60
+ color: CometChatTheme["color"],
61
+ spacing: CometChatTheme["spacing"],
62
+ typography: CometChatTheme["typography"]
63
+ ): ActionSheetStyle => {
64
+ return {
65
+ optionsItemStyle: {
66
+ containerStyle: {
67
+ paddingVertical: spacing.padding.p3,
68
+ paddingHorizontal: spacing.padding.p8,
69
+ backgroundColor: color.background1,
70
+ flexDirection: "row",
71
+ alignItems: "center",
72
+ gap: 5,
73
+ },
74
+ titleStyle: {
75
+ ...typography.body.regular,
76
+ color: color.textPrimary,
77
+ },
78
+ iconStyle: {
79
+ height: 24,
80
+ width: 24,
81
+ },
82
+ iconContainerStyle: {},
83
+ },
84
+ };
85
+ };
86
+
87
+ const getAIOptionsStyle = (
88
+ color: CometChatTheme["color"],
89
+ spacing: CometChatTheme["spacing"],
90
+ typography: CometChatTheme["typography"]
91
+ ): ActionSheetStyle => {
92
+ return {
93
+ optionsItemStyle: {
94
+ containerStyle: {
95
+ padding: spacing.padding.p4,
96
+ backgroundColor: color.background1,
97
+ flexDirection: "row",
98
+ alignItems: "center",
99
+ gap: 5,
100
+ },
101
+ titleStyle: {
102
+ ...typography.body.regular,
103
+ color: color.textPrimary,
104
+ paddingLeft: spacing.padding.p1,
105
+ },
106
+ iconStyle: {
107
+ height: 24,
108
+ width: 24,
109
+ },
110
+ iconContainerStyle: {},
111
+ },
112
+ };
113
+ };
114
+
115
+ export const lightThemeMaker = (
116
+ spacing: CometChatTheme["spacing"],
117
+ color: CometChatTheme["color"],
118
+ typography: CometChatTheme["typography"]
119
+ ): DeepPartial<CometChatTheme> => {
120
+ return {
121
+ mode:'light',
122
+ spacing: spacing,
123
+ color: color,
124
+ typography: typography,
125
+ avatarStyle: getAvatarStyle(color, spacing, typography),
126
+ receiptStyles: getMessageReceiptStyle(color, spacing, typography),
127
+ statusIndicatorStyle: getStatusIndicatorStyles(color, spacing, typography),
128
+ badgeStyle: getBadgeStyle(color, spacing, typography),
129
+ dateStyles: getDateStyleLight(color, spacing, typography),
130
+ dateSeparatorStyles: getDateSeparatorStyleLight(color, spacing, typography),
131
+ conversationStyles: getConversationStyleLight(color, spacing, typography),
132
+ confirmDialogStyles: getConfirmDialogStyleLight(color, spacing, typography),
133
+ messageHeaderStyles: getMessageHeaderStyle(color, spacing, typography),
134
+ messageComposerStyles: getComposerStyle(color, spacing, typography),
135
+ userStyles: getUserListStyleLight(color, spacing, typography),
136
+ groupStyles: getGroupListStyleLight(color, spacing, typography),
137
+ groupMemberStyle: getGroupMemberStyleLight(color, spacing, typography),
138
+ callButtonStyles: getCallButtonStyle(color, spacing, typography),
139
+ messageListStyles: getMessageListStylesLight(color, spacing, typography),
140
+ reactionListStyles: getReactionListStyleLight(color, spacing, typography),
141
+ messageInformationStyles: getMessageInormationListStyleLight(color, spacing, typography),
142
+ actionSheetStyle: getActionSheetStyle(color, spacing, typography),
143
+ mentionsListStyle: getMentionsListStyleLight(color, spacing, typography),
144
+ threadHeaderStyles: getThreadHeaderStyleLight(color, spacing, typography),
145
+ aiOptionsStyle: getAIOptionsStyle(color, spacing, typography),
146
+ quickReactionStyle: getQuickReactionStyleLight(color, spacing, typography),
147
+ outgoingCallStyle: getOutgoingCallStyle(color, spacing, typography),
148
+ incomingCallStyle: getIncomingCallStyle(color, spacing, typography),
149
+ callLogsStyles: getCallLogsStyleLight(color, spacing, typography),
150
+ callLogsItemStyle: getCallLogsItemStyle(color, spacing, typography),
151
+ mediaRecorderStyle: getMediaRecorderStyle(color, spacing, typography),
152
+ };
153
+ };
154
+
155
+ export const darkThemeMaker = (
156
+ spacing: CometChatTheme["spacing"],
157
+ color: CometChatTheme["color"],
158
+ typography: CometChatTheme["typography"]
159
+ ): DeepPartial<CometChatTheme> => {
160
+ return {
161
+ mode:'dark',
162
+ spacing: spacing,
163
+ color: color,
164
+ typography: typography,
165
+ avatarStyle: getAvatarStyle(color, spacing, typography),
166
+ receiptStyles: getMessageReceiptStyle(color, spacing, typography),
167
+ statusIndicatorStyle: getStatusIndicatorStyles(color, spacing, typography),
168
+ badgeStyle: getBadgeStyle(color, spacing, typography),
169
+ dateStyles: getDateStyleDark(color, spacing, typography),
170
+ dateSeparatorStyles: getDateSeparatorStyleDark(color, spacing, typography),
171
+ conversationStyles: getConversationStyleDark(color, spacing, typography),
172
+ confirmDialogStyles: getConfirmDialogStyleDark(color, spacing, typography),
173
+ messageHeaderStyles: getMessageHeaderStyle(color, spacing, typography),
174
+ messageComposerStyles: getComposerStyle(color, spacing, typography),
175
+ userStyles: getUserListStyleDark(color, spacing, typography),
176
+ groupMemberStyle: getGroupMemberStyleDark(color, spacing, typography),
177
+ groupStyles: getUserGroupStyleDark(color, spacing, typography),
178
+ callButtonStyles: getCallButtonStyle(color, spacing, typography),
179
+ messageListStyles: getMessageListStylesDark(color, spacing, typography),
180
+ reactionListStyles: getReactionListStyleDark(color, spacing, typography),
181
+ messageInformationStyles: getMessageInormationListStyleDark(color, spacing, typography),
182
+ actionSheetStyle: getActionSheetStyle(color, spacing, typography),
183
+ mentionsListStyle: getMentionsListStyleDark(color, spacing, typography),
184
+ threadHeaderStyles: getThreadHeaderStyleDark(color, spacing, typography),
185
+ aiOptionsStyle: getAIOptionsStyle(color, spacing, typography),
186
+ quickReactionStyle: getQuickReactionStyleDark(color, spacing, typography),
187
+ outgoingCallStyle: getOutgoingCallStyle(color, spacing, typography),
188
+ incomingCallStyle: getIncomingCallStyle(color, spacing, typography),
189
+ callLogsStyles: getCallLogsStyleDark(color, spacing, typography),
190
+ callLogsItemStyle: getCallLogsItemStyle(color, spacing, typography),
191
+ mediaRecorderStyle: getMediaRecorderStyle(color, spacing, typography),
192
+ };
193
+ };
194
+
195
+ export const defaultLightTheme: DeepPartial<CometChatTheme> = lightThemeMaker(
196
+ defaultSpacing,
197
+ defaultColorLight,
198
+ defaultTypography
199
+ );
200
+ export const defaultDarkTheme: DeepPartial<CometChatTheme> = darkThemeMaker(
201
+ defaultSpacing,
202
+ defaultColorDark,
203
+ defaultTypography
204
+ );