@cometchat/chat-uikit-react-native 5.0.1 → 5.1.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 (132) hide show
  1. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  3. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  4. package/android/.gradle/7.4/gc.properties +0 -0
  5. package/android/.gradle/vcs-1/gc.properties +0 -0
  6. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +87 -41
  7. package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +10 -0
  8. package/ios/SoundPlayer.m +8 -0
  9. package/lib/CometChatMessageList/CometChatMessageList.js +1 -1
  10. package/lib/CometChatMessageList/CometChatMessageList.js.map +1 -1
  11. package/lib/extensions/Stickers/StickersExtensionDecorator.d.ts +1 -2
  12. package/lib/extensions/Stickers/StickersExtensionDecorator.js +1 -2
  13. package/lib/extensions/Stickers/StickersExtensionDecorator.js.map +1 -1
  14. package/lib/shared/CometChatUiKit/CometChatUIKit.d.ts +2 -1
  15. package/lib/shared/CometChatUiKit/CometChatUIKit.js +2 -1
  16. package/lib/shared/CometChatUiKit/CometChatUIKit.js.map +1 -1
  17. package/lib/shared/index.d.ts +15 -13
  18. package/lib/shared/index.js +30 -12
  19. package/lib/shared/index.js.map +1 -1
  20. package/lib/shared/utils/CometChatMessagePreview/CometChatMessagePreview.d.ts +10 -1
  21. package/lib/shared/utils/CometChatMessagePreview/CometChatMessagePreview.js +8 -0
  22. package/lib/shared/utils/CometChatMessagePreview/CometChatMessagePreview.js.map +1 -1
  23. package/lib/shared/utils/CometChatMessagePreview/MessagePreviewStyle.d.ts +29 -0
  24. package/lib/shared/utils/CometChatMessagePreview/MessagePreviewStyle.js +29 -0
  25. package/lib/shared/utils/CometChatMessagePreview/MessagePreviewStyle.js.map +1 -0
  26. package/lib/shared/utils/CometChatMessagePreview/index.d.ts +2 -1
  27. package/lib/shared/utils/CometChatMessagePreview/index.js +3 -1
  28. package/lib/shared/utils/CometChatMessagePreview/index.js.map +1 -1
  29. package/lib/shared/utils/CometChatMessagePreview/style.d.ts +16 -16
  30. package/lib/shared/utils/MessageUtils.js +11 -10
  31. package/lib/shared/utils/MessageUtils.js.map +1 -1
  32. package/lib/shared/utils/index.d.ts +2 -2
  33. package/lib/shared/utils/index.js +2 -2
  34. package/lib/shared/utils/index.js.map +1 -1
  35. package/lib/theme/context.js +1 -1
  36. package/lib/theme/context.js.map +1 -1
  37. package/lib/theme/default/index.d.ts +6 -0
  38. package/lib/theme/default/index.js +178 -0
  39. package/lib/theme/default/index.js.map +1 -1
  40. package/lib/theme/provider.js +1 -1
  41. package/lib/theme/provider.js.map +1 -1
  42. package/package.json +6 -4
  43. package/react-native-cometchat-ui-kit.podspec +1 -1
  44. package/src/CometChatConversations/CometChatConversations.tsx +34 -29
  45. package/src/CometChatConversations/style.ts +5 -2
  46. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +56 -44
  47. package/src/CometChatGroups/CometChatGroups.tsx +13 -10
  48. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +203 -57
  49. package/src/CometChatMessageComposer/styles.tsx +2 -6
  50. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +8 -48
  51. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +8 -14
  52. package/src/CometChatMessageList/CometChatMessageList.tsx +18 -10
  53. package/src/CometChatMessageList/style.ts +0 -16
  54. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +3 -2
  55. package/src/CometChatUsers/CometChatUsers.tsx +9 -8
  56. package/src/calls/CallUtils.ts +14 -14
  57. package/src/calls/CallingExtensionDecorator.tsx +13 -12
  58. package/src/calls/CometChatCallBubble/CometChatCallBubble.tsx +4 -3
  59. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +15 -12
  60. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +8 -6
  61. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +4 -2
  62. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +7 -6
  63. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +7 -6
  64. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +3 -2
  65. package/src/extensions/MessageTranslation/MessageTranslationBubble.tsx +3 -2
  66. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +26 -17
  67. package/src/extensions/Polls/Polls.tsx +53 -17
  68. package/src/extensions/Polls/PollsDecorator.tsx +5 -3
  69. package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +5 -4
  70. package/src/extensions/Stickers/CometChatStickerKeyboard/hooks.ts +3 -2
  71. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +5 -2
  72. package/src/index.ts +10 -4
  73. package/src/shared/CometChatUiKit/CometChatUIKit.ts +1 -2
  74. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +116 -32
  75. package/src/shared/framework/DataSource.ts +5 -2
  76. package/src/shared/framework/DataSourceDecorator.tsx +4 -4
  77. package/src/shared/framework/MessageDataSource.tsx +178 -46
  78. package/src/shared/helper/LocalizedDateHelper.ts +317 -0
  79. package/src/shared/helper/functions.js +69 -1
  80. package/src/shared/helper/useLocalizedDateHook.tsx +16 -0
  81. package/src/shared/index.ts +7 -2
  82. package/src/shared/resources/CometChatLocalizeNew/CometChatI18nProvider.tsx +106 -0
  83. package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +99 -0
  84. package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizeContext.tsx +15 -0
  85. package/src/shared/resources/CometChatLocalizeNew/LocalizationManager.ts +65 -0
  86. package/src/shared/resources/CometChatLocalizeNew/index.ts +25 -0
  87. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/de/translation.json +10 -1
  88. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/en/translation.json +10 -1
  89. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/es/translation.json +10 -1
  90. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/fr/translation.json +10 -1
  91. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/hi/translation.json +11 -1
  92. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/hu/translation.json +10 -1
  93. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +456 -0
  94. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +456 -0
  95. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +456 -0
  96. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/lt/translation.json +10 -1
  97. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/ms/translation.json +10 -1
  98. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +456 -0
  99. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/pt/translation.json +10 -1
  100. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/ru/translation.json +10 -1
  101. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/sv/translation.json +11 -1
  102. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +456 -0
  103. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/zh/translation.json +11 -1
  104. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/zh-tw/translation.json +10 -1
  105. package/src/shared/resources/CometChatLocalizeNew/type.ts +7 -0
  106. package/src/shared/resources/CometChatLocalizeNew/useCometChatTranslationHook.ts +24 -0
  107. package/src/shared/resources/index.ts +2 -2
  108. package/src/shared/utils/CommonUtils.ts +2 -1
  109. package/src/shared/utils/PermissionUtil.ts +5 -4
  110. package/src/shared/utils/conversationUtils.ts +11 -9
  111. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +8 -5
  112. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +1 -1
  113. package/src/shared/views/CometChatDate/CometChatDate.tsx +17 -14
  114. package/src/shared/views/CometChatDateSeperator/CometChatDateSeparator.tsx +6 -4
  115. package/src/shared/views/CometChatDeletedBubble/CometChatDeletedBubble.tsx +3 -2
  116. package/src/shared/views/CometChatEmojiKeyboard/emojis.ts +11 -8
  117. package/src/shared/views/CometChatList/CometChatList.tsx +5 -4
  118. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPreview/CometChatAudioPreview.tsx +15 -9
  119. package/src/shared/views/CometChatMediaRecorder/CometChatMediaRecorder.tsx +5 -4
  120. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +3 -2
  121. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +7 -6
  122. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +10 -7
  123. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +1 -0
  124. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +24 -47
  125. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +68 -73
  126. package/src/theme/type.ts +0 -2
  127. package/lib/theme/default/default.d.ts +0 -6
  128. package/lib/theme/default/default.js +0 -179
  129. package/lib/theme/default/default.js.map +0 -1
  130. package/src/shared/resources/CometChatLocalize/CometChatLocalize.ts +0 -183
  131. package/src/shared/resources/CometChatLocalize/index.ts +0 -3
  132. package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +0 -447
@@ -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",
package/src/theme/type.ts CHANGED
@@ -240,9 +240,7 @@ export interface CometChatTheme {
240
240
  dateSeparatorStyles: DateSeparatorStyle;
241
241
  mentionsStyle?: {
242
242
  textStyle: TextStyle;
243
- //textContainerStyle: ViewStyle; //alignment issue in bubble
244
243
  selfTextStyle: TextStyle;
245
- //selfTextContainerStyle: ViewStyle;
246
244
  };
247
245
  imageBubbleStyles?: {
248
246
  containerStyle: ViewStyle;
@@ -1,6 +0,0 @@
1
- import { CometChatTheme } from "../type";
2
- import { DeepPartial } from "../../shared/helper/types";
3
- export declare const lightThemeMaker: (spacing: CometChatTheme["spacing"], color: CometChatTheme["color"], typography: CometChatTheme["typography"]) => DeepPartial<CometChatTheme>;
4
- export declare const darkThemeMaker: (spacing: CometChatTheme["spacing"], color: CometChatTheme["color"], typography: CometChatTheme["typography"]) => DeepPartial<CometChatTheme>;
5
- export declare const defaultLightTheme: DeepPartial<CometChatTheme>;
6
- export declare const defaultDarkTheme: DeepPartial<CometChatTheme>;
@@ -1,179 +0,0 @@
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 { getConversationStyleDark, getConversationStyleLight, } from "../../CometChatConversations/style";
6
- import { getGroupMemberStyleDark, getGroupMemberStyleLight, } from "../../CometChatGroupMembers/style";
7
- import { getGroupListStyleLight, getUserGroupStyleDark } from "../../CometChatGroups/GroupsStyle";
8
- import { getComposerStyle } from "../../CometChatMessageComposer/styles";
9
- import { getMessageHeaderStyle } from "../../CometChatMessageHeader/styles";
10
- import { getMessageInormationListStyleDark, getMessageInormationListStyleLight, } from "../../CometChatMessageInformation/styles";
11
- import { getMessageListStylesDark, getMessageListStylesLight, } from "../../CometChatMessageList/style";
12
- import { getThreadHeaderStyleDark, getThreadHeaderStyleLight, } from "../../CometChatThreadHeader/style";
13
- import { getUserListStyleDark, getUserListStyleLight } from "../../CometChatUsers/style";
14
- import { getAvatarStyle } from "../../shared/views/CometChatAvatar/styles";
15
- import { getBadgeStyle } from "../../shared/views/CometChatBadge";
16
- import { getConfirmDialogStyleDark, getConfirmDialogStyleLight, } from "../../shared/views/CometChatConfirmDialog/style";
17
- import { getDateStyleDark, getDateStyleLight } from "../../shared/views/CometChatDate";
18
- import { getQuickReactionStyleDark, getQuickReactionStyleLight, } from "../../shared/views/CometChatQuickReactions/QuickReactionsStyle";
19
- import { getReactionListStyleDark, getReactionListStyleLight, } from "../../shared/views/CometChatReactionList/ReactionListStyle";
20
- import { getMessageReceiptStyle } from "../../shared/views/CometChatReceipt/style";
21
- import { getStatusIndicatorStyles } from "../../shared/views/CometChatStatusIndicator/styles";
22
- import { getMentionsListStyleDark, getMentionsListStyleLight, } from "../../shared/views/CometChatSuggestionList/style";
23
- import { defaultColorDark } from "./color/dark";
24
- import { defaultColorLight } from "./color/light";
25
- import { defaultSpacing } from "./spacing";
26
- import { defaultTypography } from "./typography";
27
- import { getMediaRecorderStyle } from "../../shared/views/CometChatMediaRecorder/style";
28
- import { getDateSeparatorStyleDark, getDateSeparatorStyleLight } from "../../shared/views/CometChatDateSeperator";
29
- const getActionSheetStyle = (color, spacing, typography) => {
30
- return {
31
- optionsItemStyle: {
32
- containerStyle: {
33
- paddingVertical: spacing.padding.p3,
34
- paddingHorizontal: spacing.padding.p8,
35
- backgroundColor: color.background1,
36
- flexDirection: "row",
37
- alignItems: "center",
38
- gap: 5,
39
- },
40
- titleStyle: {
41
- ...typography.body.regular,
42
- color: color.textPrimary,
43
- },
44
- iconStyle: {
45
- height: 24,
46
- width: 24,
47
- },
48
- iconContainerStyle: {},
49
- },
50
- };
51
- };
52
- // const getAttachmentOptionsStyle = (
53
- // color: CometChatTheme["color"],
54
- // spacing: CometChatTheme["spacing"],
55
- // typography: CometChatTheme["typography"]
56
- // ): ActionSheetStyle => {
57
- // return {
58
- // optionsItemStyle: {
59
- // containerStyle: {
60
- // paddingVertical: spacing.padding.p3,
61
- // paddingHorizontal: spacing.padding.p4,
62
- // backgroundColor: color.background1,
63
- // flexDirection: "row",
64
- // alignItems: "center",
65
- // gap: 5,
66
- // },
67
- // titleStyle: {
68
- // ...typography.body.regular,
69
- // color: color.textPrimary,
70
- // paddingLeft: spacing.padding.p1,
71
- // },
72
- // iconStyle: {
73
- // height: 24,
74
- // width: 24,
75
- // },
76
- // iconContainerStyle: {},
77
- // },
78
- // };
79
- // };
80
- const getAIOptionsStyle = (color, spacing, typography) => {
81
- return {
82
- optionsItemStyle: {
83
- containerStyle: {
84
- padding: spacing.padding.p4,
85
- backgroundColor: color.background1,
86
- flexDirection: "row",
87
- alignItems: "center",
88
- gap: 5,
89
- },
90
- titleStyle: {
91
- ...typography.body.regular,
92
- color: color.textPrimary,
93
- paddingLeft: spacing.padding.p1,
94
- },
95
- iconStyle: {
96
- height: 24,
97
- width: 24,
98
- },
99
- iconContainerStyle: {},
100
- },
101
- };
102
- };
103
- export const lightThemeMaker = (spacing, color, typography) => {
104
- return {
105
- mode: 'light',
106
- spacing: spacing,
107
- color: color,
108
- typography: typography,
109
- avatarStyle: getAvatarStyle(color, spacing, typography),
110
- receiptStyles: getMessageReceiptStyle(color, spacing, typography),
111
- statusIndicatorStyle: getStatusIndicatorStyles(color, spacing, typography),
112
- badgeStyle: getBadgeStyle(color, spacing, typography),
113
- dateStyles: getDateStyleLight(color, spacing, typography),
114
- dateSeparatorStyles: getDateSeparatorStyleLight(color, spacing, typography),
115
- conversationStyles: getConversationStyleLight(color, spacing, typography),
116
- confirmDialogStyles: getConfirmDialogStyleLight(color, spacing, typography),
117
- messageHeaderStyles: getMessageHeaderStyle(color, spacing, typography),
118
- messageComposerStyles: getComposerStyle(color, spacing, typography),
119
- userStyles: getUserListStyleLight(color, spacing, typography),
120
- groupStyles: getGroupListStyleLight(color, spacing, typography),
121
- groupMemberStyle: getGroupMemberStyleLight(color, spacing, typography),
122
- callButtonStyles: getCallButtonStyle(color, spacing, typography),
123
- messageListStyles: getMessageListStylesLight(color, spacing, typography),
124
- reactionListStyles: getReactionListStyleLight(color, spacing, typography),
125
- messageInformationStyles: getMessageInormationListStyleLight(color, spacing, typography),
126
- //messageOptionsStyles: getMessageOptionsStyle(color, spacing, typography),
127
- //attachmentOptionsStyles: getAttachmentOptionsStyle(color, spacing, typography),
128
- actionSheetStyle: getActionSheetStyle(color, spacing, typography),
129
- mentionsListStyle: getMentionsListStyleLight(color, spacing, typography),
130
- threadHeaderStyles: getThreadHeaderStyleLight(color, spacing, typography),
131
- aiOptionsStyle: getAIOptionsStyle(color, spacing, typography),
132
- quickReactionStyle: getQuickReactionStyleLight(color, spacing, typography),
133
- outgoingCallStyle: getOutgoingCallStyle(color, spacing, typography),
134
- incomingCallStyle: getIncomingCallStyle(color, spacing, typography),
135
- callLogsStyles: getCallLogsStyleLight(color, spacing, typography),
136
- callLogsItemStyle: getCallLogsItemStyle(color, spacing, typography),
137
- mediaRecorderStyle: getMediaRecorderStyle(color, spacing, typography),
138
- };
139
- };
140
- export const darkThemeMaker = (spacing, color, typography) => {
141
- return {
142
- mode: 'dark',
143
- spacing: spacing,
144
- color: color,
145
- typography: typography,
146
- avatarStyle: getAvatarStyle(color, spacing, typography),
147
- receiptStyles: getMessageReceiptStyle(color, spacing, typography),
148
- statusIndicatorStyle: getStatusIndicatorStyles(color, spacing, typography),
149
- badgeStyle: getBadgeStyle(color, spacing, typography),
150
- dateStyles: getDateStyleDark(color, spacing, typography),
151
- dateSeparatorStyles: getDateSeparatorStyleDark(color, spacing, typography),
152
- conversationStyles: getConversationStyleDark(color, spacing, typography),
153
- confirmDialogStyles: getConfirmDialogStyleDark(color, spacing, typography),
154
- messageHeaderStyles: getMessageHeaderStyle(color, spacing, typography),
155
- messageComposerStyles: getComposerStyle(color, spacing, typography),
156
- userStyles: getUserListStyleDark(color, spacing, typography),
157
- groupMemberStyle: getGroupMemberStyleDark(color, spacing, typography),
158
- groupStyles: getUserGroupStyleDark(color, spacing, typography),
159
- callButtonStyles: getCallButtonStyle(color, spacing, typography),
160
- messageListStyles: getMessageListStylesDark(color, spacing, typography),
161
- reactionListStyles: getReactionListStyleDark(color, spacing, typography),
162
- messageInformationStyles: getMessageInormationListStyleDark(color, spacing, typography),
163
- //messageOptionsStyles: getMessageOptionsStyle(color, spacing, typography),
164
- //attachmentOptionsStyles: getAttachmentOptionsStyle(color, spacing, typography),
165
- actionSheetStyle: getActionSheetStyle(color, spacing, typography),
166
- mentionsListStyle: getMentionsListStyleDark(color, spacing, typography),
167
- threadHeaderStyles: getThreadHeaderStyleDark(color, spacing, typography),
168
- aiOptionsStyle: getAIOptionsStyle(color, spacing, typography),
169
- quickReactionStyle: getQuickReactionStyleDark(color, spacing, typography),
170
- outgoingCallStyle: getOutgoingCallStyle(color, spacing, typography),
171
- incomingCallStyle: getIncomingCallStyle(color, spacing, typography),
172
- callLogsStyles: getCallLogsStyleDark(color, spacing, typography),
173
- callLogsItemStyle: getCallLogsItemStyle(color, spacing, typography),
174
- mediaRecorderStyle: getMediaRecorderStyle(color, spacing, typography),
175
- };
176
- };
177
- export const defaultLightTheme = lightThemeMaker(defaultSpacing, defaultColorLight, defaultTypography);
178
- export const defaultDarkTheme = darkThemeMaker(defaultSpacing, defaultColorDark, defaultTypography);
179
- //# sourceMappingURL=default.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"default.js","sourceRoot":"","sources":["../../../src/theme/default/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC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C;KACtE,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAgC,eAAe,CAC3E,cAAc,EACd,iBAAiB,EACjB,iBAAiB,CAClB,CAAC;AACF,MAAM,CAAC,MAAM,gBAAgB,GAAgC,cAAc,CACzE,cAAc,EACd,gBAAgB,EAChB,iBAAiB,CAClB,CAAC"}
@@ -1,183 +0,0 @@
1
- import { NativeModules, Platform } from "react-native";
2
- import translationAR from "./resources/ar/translation.json";
3
- import translationDE from "./resources/de/translation.json";
4
- import translationEN from "./resources/en/translation.json";
5
- import translationES from "./resources/es/translation.json";
6
- import translationFR from "./resources/fr/translation.json";
7
- import translationHI from "./resources/hi/translation.json";
8
- import translationHU from "./resources/hu/translation.json";
9
- import translationLT from "./resources/lt/translation.json";
10
- import translationMS from "./resources/ms/translation.json";
11
- import translationPT from "./resources/pt/translation.json";
12
- import translationRU from "./resources/ru/translation.json";
13
- import translationSV from "./resources/sv/translation.json";
14
- import translationZHTW from "./resources/zh-tw/translation.json";
15
- import translationZH from "./resources/zh/translation.json";
16
-
17
- /**
18
- * Type for Translation objects, each language contains key-value pairs
19
- */
20
- type Translation = { [key: string]: string };
21
-
22
- /**
23
- * Type for translations mapping language code to Translation
24
- */
25
- type Translations = { [languageCode: string]: Translation };
26
-
27
- class CometChatLocalize {
28
- /**Properties and constants */
29
- static fallbackLanguage: string = "en";
30
- static locale: string;
31
- static rtlLanguages: string[] = ["ar"];
32
- static direction = Object.freeze({
33
- ltr: "ltr",
34
- rtl: "rtl",
35
- });
36
-
37
- /** The translations object now has a more explicit type */
38
- static translations: Translations = {
39
- ar: translationAR,
40
- de: translationDE,
41
- en: translationEN,
42
- es: translationES,
43
- fr: translationFR,
44
- hi: translationHI,
45
- ms: translationMS,
46
- pt: translationPT,
47
- ru: translationRU,
48
- zh: translationZH,
49
- "zh-tw": translationZHTW,
50
- sv: translationSV,
51
- lt: translationLT,
52
- hu: translationHU,
53
- };
54
-
55
- /**
56
- * Needs to be called at the start of the application in order to set the language
57
- * @param {Object} - language & resources
58
- */
59
- static init = ({
60
- language,
61
- resources,
62
- }: {
63
- language?: string;
64
- resources?: Translations;
65
- }) => {
66
- if (language) {
67
- this.locale = language;
68
- } else {
69
- this.setDefaultLanguage();
70
- }
71
-
72
- /**Override resources */
73
- if (resources) {
74
- for (const resource in resources) {
75
- /**Add to the original array of translations if language code is not found */
76
- if (!this.translations[resource]) {
77
- this.translations[resource] = resources[resource];
78
- } else {
79
- for (const key in resources[resource]) {
80
- this.translations[resource][key] = resources[resource][key];
81
- }
82
- }
83
- }
84
- }
85
- };
86
-
87
- /**
88
- * Returns the native language
89
- * @returns {String} native language i.e. en-US
90
- */
91
- static getNativeLanguage = (): string => {
92
- return Platform.OS === "ios"
93
- ? NativeModules.SettingsManager.settings.AppleLocale ||
94
- NativeModules.SettingsManager.settings.AppleLanguages[0] //iOS 13
95
- : NativeModules.I18nManager.localeIdentifier.replace("_", "-");
96
- };
97
-
98
- /**
99
- * Returns the language code
100
- * @returns {String} language code i.e. en
101
- */
102
- static getLanguageCode = (): string => {
103
- const languageCode = this.getNativeLanguage().toLowerCase();
104
-
105
- // check if the language set in the native has hyphen(-), if yes split and take the first element of the array
106
- if (languageCode.indexOf("-") !== -1 && languageCode !== "zh-tw") {
107
- return languageCode.split("-")[0];
108
- }
109
-
110
- return languageCode;
111
- };
112
-
113
- /**
114
- * Returns the active language. Return fallback language if translation is not available for the active language
115
- * @returns {String} active language
116
- */
117
- static getLocale = (): string => {
118
- let language = this.locale;
119
-
120
- if (!Object.prototype.hasOwnProperty.call(this.translations, language)) {
121
- language = this.fallbackLanguage;
122
- }
123
- return language;
124
- };
125
-
126
- /**
127
- * Set the active language
128
- * @param {String} language
129
- */
130
- static setLocale = (language: string): void => {
131
- this.locale = language;
132
- };
133
-
134
- /**
135
- * Accepts the string to localize and return the localized string
136
- * @param {String} str
137
- * @returns {String} localized str
138
- */
139
- static localize = (str: string): string => {
140
- const language = this.getLocale();
141
- return this.translations[language]?.[str] ?? str; // Fallback to the key if translation is not found
142
- };
143
-
144
- /**
145
- * Sets the default language if no language is passed in init method
146
- */
147
- static setDefaultLanguage = (): void => {
148
- // get the active language
149
- const activeLanguage = this.getLocale();
150
- // get the native language code
151
- const nativeLanguageCode = this.getLanguageCode();
152
-
153
- // if there is no active language or active language is different from native language, update active language with native language
154
- if (!activeLanguage || activeLanguage !== nativeLanguageCode) {
155
- this.setLocale(nativeLanguageCode);
156
- }
157
- };
158
-
159
- /**
160
- * Returns true if the active language is rtl otherwise return false
161
- * @returns {Boolean} whether the language is rtl or not
162
- */
163
- static isRTL = (): boolean => {
164
- return this.rtlLanguages.includes(this.getLocale());
165
- };
166
-
167
- /**
168
- * Returns rtl or ltr based on the active language
169
- * @returns {String} the direction of the active language
170
- */
171
- static getDir = (): string => {
172
- return this.isRTL() ? this.direction.rtl : this.direction.ltr;
173
- };
174
- }
175
-
176
- /**
177
- * Returns localized string based on active language
178
- * @param {String} str
179
- * @returns {String} localized str
180
- */
181
- const localize = (str: string): string => CometChatLocalize.localize(str);
182
-
183
- export { CometChatLocalize, localize };
@@ -1,3 +0,0 @@
1
- import { CometChatLocalize, localize } from "./CometChatLocalize";
2
-
3
- export { CometChatLocalize, localize };