@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.
- package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +87 -49
- package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +10 -0
- package/ios/SoundPlayer.m +8 -0
- package/package.json +8 -9
- package/src/CometChatConversations/CometChatConversations.tsx +19 -14
- package/src/CometChatConversations/style.ts +6 -2
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +1 -0
- package/src/CometChatGroupMembers/style.ts +1 -0
- package/src/CometChatGroups/CometChatGroups.tsx +1 -0
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +227 -57
- package/src/CometChatMessageComposer/styles.tsx +3 -6
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +2 -2
- package/src/CometChatMessageHeader/styles.ts +1 -0
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +1 -1
- package/src/CometChatMessageList/CometChatMessageList.tsx +188 -111
- package/src/CometChatMessageList/style.ts +0 -16
- package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +1 -1
- package/src/CometChatUsers/CometChatUsers.tsx +1 -1
- package/src/calls/CallUtils.ts +18 -10
- package/src/calls/CallingExtensionDecorator.tsx +1 -1
- package/src/calls/CometChatCallBubble/CometChatCallBubble.tsx +8 -7
- package/src/calls/CometChatCallBubble/styles.ts +1 -0
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +6 -4
- package/src/calls/CometChatCallButtons/style.ts +2 -1
- package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +4 -3
- package/src/calls/CometChatCallLogs/style.ts +1 -0
- package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +4 -3
- package/src/calls/CometChatOngoingCall/CometChatOngoingCall.tsx +1 -0
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +3 -3
- package/src/calls/CometChatOutgoingCall/OutgoingCallConfiguration.ts +1 -0
- package/src/extensions/CollaborativeBubble/CometChatCollaborativeBubble.tsx +1 -1
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +1 -1
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +1 -1
- package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +15 -18
- package/src/extensions/LinkPreview/LinkPreviewExtensionDecorator.tsx +1 -1
- package/src/extensions/LinkPreview/style.ts +2 -2
- package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +20 -17
- package/src/extensions/Polls/Polls.tsx +45 -8
- package/src/extensions/Polls/PollsDecorator.tsx +1 -1
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +2 -4
- package/src/extensions/Stickers/style.ts +3 -3
- package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +1 -1
- package/src/imageresolver.d.ts +4 -0
- package/src/index.ts +2 -0
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +1 -2
- package/src/shared/base/Types.ts +1 -0
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +114 -32
- package/src/shared/formatters/CometChatTextFormatter.ts +1 -0
- package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +4 -4
- package/src/shared/framework/DataSource.ts +6 -2
- package/src/shared/framework/DataSourceDecorator.tsx +5 -4
- package/src/shared/framework/MessageDataSource.tsx +26 -28
- package/src/shared/helper/types/index.ts +1 -0
- package/src/shared/icons/Icon.tsx +1 -1
- package/src/shared/index.ts +41 -126
- package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +1 -1
- package/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx +4 -2
- package/src/shared/modals/CometChatMessageOption.ts +1 -0
- package/src/shared/modals/CometChatMessageTemplate.ts +1 -0
- package/src/shared/resources/CometChatSoundManager/index.ts +1 -0
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +0 -8
- package/src/shared/utils/CometChatMessagePreview/index.ts +1 -2
- package/src/shared/utils/CommonUtils.ts +2 -1
- package/src/shared/utils/MessageUtils.tsx +54 -62
- package/src/shared/utils/conversationUtils.ts +1 -0
- package/src/shared/utils/index.ts +1 -2
- package/src/shared/views/CometChatActionSheet/ActionItem.ts +1 -0
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -1
- package/src/shared/views/CometChatAudioBubble/AnimatedAudioWaves.tsx +1 -1
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +9 -6
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +1 -1
- package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +1 -1
- package/src/shared/views/CometChatConfirmDialog/style.ts +1 -0
- package/src/shared/views/CometChatDeletedBubble/styles.ts +1 -0
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +1 -1
- package/src/shared/views/CometChatList/CometChatList.tsx +2 -2
- package/src/shared/views/CometChatList/Header.tsx +1 -1
- package/src/shared/views/CometChatMediaRecorder/AnimatingMic.tsx +2 -2
- package/src/shared/views/CometChatMediaRecorder/CometChatAudioPreview/CometChatAudioPreview.tsx +16 -10
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +7 -8
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +1 -1
- package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +84 -70
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +1 -1
- package/src/shared/views/CometChatReactions/style.ts +5 -4
- package/src/shared/views/CometChatReceipt/style.ts +1 -0
- package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +1 -1
- package/src/shared/views/CometChatSuggestionList/style.ts +3 -2
- package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +1 -1
- package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +24 -47
- package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +68 -73
- package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +1 -0
- package/src/theme/CometChatThemeHelper.ts +69 -58
- package/src/theme/context.ts +2 -2
- package/src/theme/default/default.ts +204 -0
- package/src/theme/default/index.ts +0 -238
- package/src/theme/provider.tsx +7 -7
- package/src/theme/type.ts +5 -7
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/src/shared/utils/CometChatMessagePreview/MessagePreviewStyle.js +0 -42
|
@@ -23,6 +23,8 @@ import { CometChatOutgoingCall, OutgoingCallConfiguration } from "../CometChatOu
|
|
|
23
23
|
import { CallButtonStyle } from "./style";
|
|
24
24
|
import { DeepPartial } from "../../shared/helper/types";
|
|
25
25
|
import { CallingPackage } from "../CallingPackage";
|
|
26
|
+
import { JSX } from "react";
|
|
27
|
+
|
|
26
28
|
const CometChatCalls = CallingPackage.CometChatCalls;
|
|
27
29
|
|
|
28
30
|
const listenerId = "callEventListener_" + new Date().getTime();
|
|
@@ -111,10 +113,10 @@ export const CometChatCallButtons = (props: CometChatCallButtonsInterface): JSX.
|
|
|
111
113
|
const [showOutgoingCallScreen, setShowOutgoingCallScreen] = useState(false);
|
|
112
114
|
const [callReceived, setCallReceived] = useState<CometChat.Call>();
|
|
113
115
|
|
|
114
|
-
const outGoingCall = useRef<CometChat.Call | CometChat.CustomMessage>();
|
|
115
|
-
const callType = useRef<typeof CometChat.CALL_TYPE.AUDIO | typeof CometChat.CALL_TYPE.VIDEO>();
|
|
116
|
-
const incomingCall = useRef<CometChat.Call>();
|
|
117
|
-
const loggedInUser = useRef<CometChat.User>();
|
|
116
|
+
const outGoingCall = useRef<CometChat.Call | CometChat.CustomMessage>(undefined);
|
|
117
|
+
const callType = useRef<typeof CometChat.CALL_TYPE.AUDIO | typeof CometChat.CALL_TYPE.VIDEO>(undefined);
|
|
118
|
+
const incomingCall = useRef<CometChat.Call>(undefined);
|
|
119
|
+
const loggedInUser = useRef<CometChat.User>(undefined);
|
|
118
120
|
|
|
119
121
|
/**
|
|
120
122
|
* Checks if there is an active call.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ImageSourcePropType, ImageStyle, StyleSheet, ViewStyle } from "react-native";
|
|
2
2
|
import { CometChatTheme } from "../../theme/type";
|
|
3
|
+
import { JSX } from "react";
|
|
3
4
|
|
|
4
5
|
export type CallButtonStyle = {
|
|
5
6
|
containerStyle: ViewStyle;
|
|
@@ -33,4 +34,4 @@ export const getCallButtonStyle = (
|
|
|
33
34
|
height: spacing.spacing.s6,
|
|
34
35
|
width: spacing.spacing.s6,
|
|
35
36
|
},
|
|
36
|
-
});
|
|
37
|
+
}) as CometChatTheme['callButtonStyles'];
|
|
@@ -27,6 +27,7 @@ import { CometChatTheme } from "../../theme/type";
|
|
|
27
27
|
import { deepMerge } from "../../shared/helper/helperFunctions";
|
|
28
28
|
import { DeepPartial, ValueOf } from "../../shared/helper/types";
|
|
29
29
|
import { CometChatTooltipMenu, MenuItemInterface } from "../../shared/views/CometChatTooltipMenu";
|
|
30
|
+
import { JSX } from "react";
|
|
30
31
|
|
|
31
32
|
const listenerId = "callEventListener_" + new Date().getTime();
|
|
32
33
|
const CometChatCalls = CallingPackage.CometChatCalls;
|
|
@@ -146,9 +147,9 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
146
147
|
return deepMerge(theme.callLogsStyles, style ?? {});
|
|
147
148
|
}, [theme, style]);
|
|
148
149
|
|
|
149
|
-
const loggedInUser = useRef<CometChat.User>();
|
|
150
|
-
const callLogRequestBuilderRef = useRef<any>();
|
|
151
|
-
const outGoingCall = useRef<CometChat.Call | CometChat.CustomMessage>();
|
|
150
|
+
const loggedInUser = useRef<CometChat.User>(undefined);
|
|
151
|
+
const callLogRequestBuilderRef = useRef<any>(undefined);
|
|
152
|
+
const outGoingCall = useRef<CometChat.Call | CometChat.CustomMessage>(undefined);
|
|
152
153
|
|
|
153
154
|
// State for tooltip functionality
|
|
154
155
|
const [tooltipVisible, setTooltipVisible] = useState<boolean>(false);
|
|
@@ -10,6 +10,7 @@ import { AvatarStyle } from "../../shared/views/CometChatAvatar";
|
|
|
10
10
|
import { CometChatTheme } from "../../theme/type";
|
|
11
11
|
import { DeepPartial } from "../../shared/helper/types";
|
|
12
12
|
import { deepMerge } from "../../shared/helper/helperFunctions";
|
|
13
|
+
import { JSX } from "react";
|
|
13
14
|
|
|
14
15
|
export const Style = StyleSheet.create({
|
|
15
16
|
container: {
|
|
@@ -22,6 +22,7 @@ import { useTheme } from "../../theme";
|
|
|
22
22
|
import { IncomingCallStyle } from "./style";
|
|
23
23
|
import { deepMerge } from "../../shared/helper/helperFunctions";
|
|
24
24
|
import { DeepPartial } from "../../shared/helper/types";
|
|
25
|
+
import { JSX } from "react";
|
|
25
26
|
|
|
26
27
|
const listnerID = "CALL_LISTENER_" + new Date().getTime();
|
|
27
28
|
const CometChatCalls = CallingPackage.CometChatCalls;
|
|
@@ -89,12 +90,12 @@ export const CometChatIncomingCall = (props: CometChatIncomingCallInterface): JS
|
|
|
89
90
|
|
|
90
91
|
const theme = useTheme();
|
|
91
92
|
const [showCallScreen, setShowCallScreen] = useState(false);
|
|
92
|
-
const acceptedCall = useRef<CometChat.Call>();
|
|
93
|
+
const acceptedCall = useRef<CometChat.Call>(undefined);
|
|
93
94
|
|
|
94
95
|
/** Reference to the call listener */
|
|
95
|
-
const callListener = useRef<any>();
|
|
96
|
+
const callListener = useRef<any>(undefined);
|
|
96
97
|
/** Reference to the call settings builder instance */
|
|
97
|
-
const callSettings = useRef<any>();
|
|
98
|
+
const callSettings = useRef<any>(undefined);
|
|
98
99
|
|
|
99
100
|
// Merge the default and custom styles for incoming calls.
|
|
100
101
|
const incomingCallStyle = useMemo(() => {
|
|
@@ -3,6 +3,7 @@ import React, { useEffect, useRef, useState } from "react";
|
|
|
3
3
|
import { ActivityIndicator, View } from "react-native";
|
|
4
4
|
import { CallingPackage } from "../CallingPackage";
|
|
5
5
|
import { useTheme } from "../../theme";
|
|
6
|
+
import { JSX } from "react";
|
|
6
7
|
|
|
7
8
|
const CometChatCalls = CallingPackage.CometChatCalls;
|
|
8
9
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
2
|
-
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import React, { JSX, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { Modal, SafeAreaView, Text, TouchableOpacity, View } from "react-native";
|
|
4
4
|
import {
|
|
5
5
|
MessageCategoryConstants,
|
|
@@ -105,8 +105,8 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
|
|
|
105
105
|
// Controls visibility of this modal.
|
|
106
106
|
const [isModalVisible, setModalVisible] = useState(true);
|
|
107
107
|
|
|
108
|
-
const ongoingCall = useRef<CometChat.Call | CometChat.CustomMessage>();
|
|
109
|
-
const callSessionId = useRef<string>();
|
|
108
|
+
const ongoingCall = useRef<CometChat.Call | CometChat.CustomMessage>(undefined);
|
|
109
|
+
const callSessionId = useRef<string>(undefined);
|
|
110
110
|
const callListener = useRef<any>(null);
|
|
111
111
|
const callSettings = useRef<any>(null);
|
|
112
112
|
const isCallEnded = useRef<null | boolean>(undefined);
|
|
@@ -2,6 +2,7 @@ import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
|
2
2
|
import { CallingPackage } from "../CallingPackage";
|
|
3
3
|
import { OutgoingCallStyle } from ".";
|
|
4
4
|
import { DeepPartial } from "../../shared/helper/types";
|
|
5
|
+
import { JSX } from "react";
|
|
5
6
|
|
|
6
7
|
const CometChatCalls = CallingPackage.CometChatCalls;
|
|
7
8
|
export class OutgoingCallConfiguration {
|
package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import { localize } from "../../shared/resources/CometChatLocalize";
|
|
|
13
13
|
import { CometChatCollaborativeBubble } from "../CollaborativeBubble/CometChatCollaborativeBubble";
|
|
14
14
|
import { ExtensionConstants, ExtensionTypeConstants } from "../ExtensionConstants";
|
|
15
15
|
import { getExtensionData } from "../ExtensionModerator";
|
|
16
|
-
import React from "react";
|
|
16
|
+
import React, { JSX } from "react";
|
|
17
17
|
import { Text, View } from "react-native";
|
|
18
18
|
import { CometChatUIKit } from "../../shared";
|
|
19
19
|
import {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
1
|
+
import React, { JSX, useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
2
2
|
import {
|
|
3
3
|
Alert,
|
|
4
4
|
DimensionValue,
|
|
@@ -24,9 +24,12 @@ export interface LinkPreviewBubbleInterface {
|
|
|
24
24
|
description?: string;
|
|
25
25
|
/** Custom style object for the bubble */
|
|
26
26
|
style?: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
/** Custom body style */
|
|
28
|
+
bodyStyle?: (CometChatTheme["linkPreviewBubbleStyles"] & {})["bodyStyle"];
|
|
29
|
+
/** Custom header image style */
|
|
30
|
+
headerImageStyle?: (CometChatTheme["linkPreviewBubbleStyles"] & {})["headerImageStyle"];
|
|
31
|
+
/** Custom header image container style */
|
|
32
|
+
headerImageContainerStyle?: (CometChatTheme["linkPreviewBubbleStyles"] & {})["headerImageContainerStyle"];
|
|
30
33
|
};
|
|
31
34
|
/** URL of the link to preview */
|
|
32
35
|
link: string;
|
|
@@ -38,12 +41,6 @@ export interface LinkPreviewBubbleInterface {
|
|
|
38
41
|
image: string;
|
|
39
42
|
/** Favicon URL to display */
|
|
40
43
|
favicon: string;
|
|
41
|
-
/** Custom body style */
|
|
42
|
-
bodyStyle?: CometChatTheme["linkPreviewBubbleStyles"]["bodyStyle"];
|
|
43
|
-
/** Custom header image style */
|
|
44
|
-
headerImageStyle?: CometChatTheme["linkPreviewBubbleStyles"]["headerImageStyle"];
|
|
45
|
-
/** Custom header image container style */
|
|
46
|
-
headerImageContainerStyle?: CometChatTheme["linkPreviewBubbleStyles"]["headerImageContainerStyle"];
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
/**
|
|
@@ -156,15 +153,15 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
|
|
|
156
153
|
/>
|
|
157
154
|
</View>
|
|
158
155
|
|
|
159
|
-
<View style={style?.bodyStyle
|
|
156
|
+
<View style={style?.bodyStyle?.containerStyle}>
|
|
160
157
|
<View style={{ flexDirection: "row" }}>
|
|
161
|
-
<View style={style?.bodyStyle
|
|
162
|
-
<Text style={style?.bodyStyle
|
|
158
|
+
<View style={style?.bodyStyle?.titleContainerStyle}>
|
|
159
|
+
<Text style={style?.bodyStyle?.titleStyle} ellipsizeMode='tail'>
|
|
163
160
|
{title}
|
|
164
161
|
</Text>
|
|
165
162
|
</View>
|
|
166
163
|
|
|
167
|
-
<View style={style?.bodyStyle
|
|
164
|
+
<View style={style?.bodyStyle?.faviconContainerStyle}>
|
|
168
165
|
<Image
|
|
169
166
|
source={faviconSource}
|
|
170
167
|
style={style?.bodyStyle?.faviconStyle}
|
|
@@ -174,11 +171,11 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
|
|
|
174
171
|
/>
|
|
175
172
|
</View>
|
|
176
173
|
</View>
|
|
177
|
-
<View style={style?.bodyStyle
|
|
178
|
-
<Text style={style?.bodyStyle
|
|
174
|
+
<View style={style?.bodyStyle?.subtitleContainerStyle}>
|
|
175
|
+
<Text style={style?.bodyStyle?.subtitleTitle} numberOfLines={2} ellipsizeMode='tail'>
|
|
179
176
|
{description}
|
|
180
177
|
</Text>
|
|
181
|
-
<Text style={style?.bodyStyle
|
|
178
|
+
<Text style={style?.bodyStyle?.subtitleTitle} numberOfLines={2} ellipsizeMode='tail'>
|
|
182
179
|
{link}
|
|
183
180
|
</Text>
|
|
184
181
|
</View>
|
|
@@ -186,7 +183,7 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
|
|
|
186
183
|
<View
|
|
187
184
|
style={{
|
|
188
185
|
paddingVertical: theme.spacing.padding.p3,
|
|
189
|
-
paddingHorizontal: style?.bodyStyle
|
|
186
|
+
paddingHorizontal: style?.bodyStyle?.containerStyle.padding,
|
|
190
187
|
}}
|
|
191
188
|
>
|
|
192
189
|
{ChildView && <ChildView />}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
2
|
-
import React from "react";
|
|
2
|
+
import React, { JSX } from "react";
|
|
3
3
|
import { AdditionalParams, MessageBubbleAlignmentType } from "../../shared/base/Types";
|
|
4
4
|
import { DataSource, DataSourceDecorator } from "../../shared/framework";
|
|
5
5
|
import { BubbleStyles, CometChatTheme } from "../../theme/type";
|
|
@@ -63,7 +63,7 @@ export const getLinkPreviewBubbleStyleLight = (
|
|
|
63
63
|
outgoingBubbleStyle: CometChatTheme["linkPreviewBubbleStyles"];
|
|
64
64
|
} => {
|
|
65
65
|
return {
|
|
66
|
-
incomingBubbleStyle: deepMerge(getLinkPreviewBubbleStyle(color, spacing, typography)
|
|
66
|
+
incomingBubbleStyle: deepMerge(getLinkPreviewBubbleStyle(color, spacing, typography)!, {
|
|
67
67
|
bodyStyle: {
|
|
68
68
|
containerStyle: {
|
|
69
69
|
backgroundColor: color.neutral400,
|
|
@@ -78,7 +78,7 @@ export const getLinkPreviewBubbleStyleLight = (
|
|
|
78
78
|
headerImageContainerStyle: {
|
|
79
79
|
backgroundColor: color.neutral400,
|
|
80
80
|
},
|
|
81
|
-
}),
|
|
81
|
+
}) as CometChatTheme['linkPreviewBubbleStyles'],
|
|
82
82
|
outgoingBubbleStyle: getLinkPreviewBubbleStyle(color, spacing, typography),
|
|
83
83
|
};
|
|
84
84
|
};
|
|
@@ -3,16 +3,18 @@ import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
|
3
3
|
import { CometChatMessageOption } from "../../shared/modals";
|
|
4
4
|
import { CometChatLocalize, localize } from "../../shared/resources/CometChatLocalize";
|
|
5
5
|
import { ExtensionConstants, ExtensionURLs } from "../ExtensionConstants";
|
|
6
|
-
import React from "react";
|
|
6
|
+
import React, { JSX } from "react";
|
|
7
7
|
import {
|
|
8
8
|
CometChatMentionsFormatter,
|
|
9
9
|
CometChatTextFormatter,
|
|
10
10
|
CometChatUIKit,
|
|
11
11
|
CometChatUrlsFormatter,
|
|
12
|
-
MentionTextStyle,
|
|
13
12
|
} from "../../shared";
|
|
14
13
|
import { AdditionalParams, MessageBubbleAlignmentType } from "../../shared/base/Types";
|
|
15
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
MentionsTargetElement,
|
|
16
|
+
MessageOptionConstants,
|
|
17
|
+
} from "../../shared/constants/UIKitConstants";
|
|
16
18
|
import { CometChatUIEvents, MessageEvents } from "../../shared/events";
|
|
17
19
|
import { CometChatUIEventHandler } from "../../shared/events/CometChatUIEventHandler/CometChatUIEventHandler";
|
|
18
20
|
import { messageStatus } from "../../shared/utils/CometChatMessageHelper";
|
|
@@ -20,7 +22,7 @@ import { CommonUtils } from "../../shared/utils/CommonUtils";
|
|
|
20
22
|
import { MessageTranslationBubble } from "./MessageTranslationBubble";
|
|
21
23
|
import { CometChatTheme } from "../../theme/type";
|
|
22
24
|
import { Icon } from "../../shared/icons/Icon";
|
|
23
|
-
import {
|
|
25
|
+
import { MentionContext } from "../../shared/framework/MessageDataSource";
|
|
24
26
|
|
|
25
27
|
/**
|
|
26
28
|
* Decorator class for handling message translation in the chat application.
|
|
@@ -72,7 +74,8 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
|
|
|
72
74
|
additionalParams
|
|
73
75
|
);
|
|
74
76
|
// Add the translate option to the options list.
|
|
75
|
-
!additionalParams?.hideTranslateMessageOption &&
|
|
77
|
+
!additionalParams?.hideTranslateMessageOption &&
|
|
78
|
+
optionsList.push(this.getTranslateOption(messageObject, theme));
|
|
76
79
|
return optionsList;
|
|
77
80
|
}
|
|
78
81
|
|
|
@@ -289,31 +292,30 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
|
|
|
289
292
|
|
|
290
293
|
// Select the appropriate style based on the sender.
|
|
291
294
|
const _style: Partial<CometChatTheme["textBubbleStyles"]> = isMessageSentByLoggedInUser
|
|
292
|
-
? (theme.messageListStyles.outgoingMessageBubbleStyles
|
|
293
|
-
|
|
295
|
+
? (theme.messageListStyles.outgoingMessageBubbleStyles
|
|
296
|
+
.textBubbleStyles as CometChatTheme["textBubbleStyles"])
|
|
297
|
+
: (theme.messageListStyles.incomingMessageBubbleStyles
|
|
298
|
+
.textBubbleStyles as CometChatTheme["textBubbleStyles"]);
|
|
294
299
|
|
|
295
300
|
// Create URL formatter and set properties.
|
|
296
301
|
let linksTextFormatter = ChatConfigurator.getDataSource().getUrlsFormatter(loggedInUser!);
|
|
297
|
-
let mentionsTextFormatter = ChatConfigurator.getDataSource().getMentionsFormatter(
|
|
302
|
+
let mentionsTextFormatter = ChatConfigurator.getDataSource().getMentionsFormatter(
|
|
303
|
+
loggedInUser!,
|
|
304
|
+
theme
|
|
305
|
+
);
|
|
298
306
|
linksTextFormatter.setMessage(message);
|
|
299
307
|
linksTextFormatter.setId("ccDefaultUrlsFormatterId");
|
|
300
308
|
linksTextFormatter.setStyle({ linkTextColor: theme.color.receiveBubbleLink });
|
|
301
309
|
if (isMessageSentByLoggedInUser) {
|
|
302
310
|
linksTextFormatter.setStyle({ linkTextColor: theme.color.sendBubbleText });
|
|
303
311
|
}
|
|
312
|
+
mentionsTextFormatter.setContext(isMessageSentByLoggedInUser ? MentionContext.Outgoing : MentionContext.Incoming);
|
|
304
313
|
|
|
305
314
|
// Configure mentions formatter if mentioned users are present.
|
|
306
315
|
if (!additionalParams?.disableMentions && mentionedUsers && mentionedUsers.length) {
|
|
307
316
|
mentionsTextFormatter.setLoggedInUser(loggedInUser!);
|
|
308
317
|
mentionsTextFormatter.setMessage(message);
|
|
309
318
|
mentionsTextFormatter.setId("ccDefaultMentionFormatterId");
|
|
310
|
-
let isUserSentMessage = message.getSender().getUid() == loggedInUser!.getUid();
|
|
311
|
-
if (isUserSentMessage) {
|
|
312
|
-
mentionsTextFormatter.setMentionsStyle(_style?.mentionsStyle);
|
|
313
|
-
} else {
|
|
314
|
-
mentionsTextFormatter.setMentionsStyle(_style?.mentionsStyle);
|
|
315
|
-
}
|
|
316
|
-
mentionsTextFormatter.setTextStyle(_style?.textStyle);
|
|
317
319
|
}
|
|
318
320
|
|
|
319
321
|
let finalFormatters: CometChatTextFormatter[] = [];
|
|
@@ -330,6 +332,7 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
|
|
|
330
332
|
formatter.setMessage(message);
|
|
331
333
|
formatter.setTargetElement(MentionsTargetElement.textbubble);
|
|
332
334
|
formatter.setLoggedInUser(CometChatUIKit.loggedInUser!);
|
|
335
|
+
formatter.setContext(isMessageSentByLoggedInUser ? "outgoing" : "incoming");
|
|
333
336
|
}
|
|
334
337
|
formatter.setMessage(message);
|
|
335
338
|
finalFormatters.push(CommonUtils.clone(formatter));
|
|
@@ -358,8 +361,8 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
|
|
|
358
361
|
tempTranslatedMsg
|
|
359
362
|
? tempTranslatedMsg[message.getId()]
|
|
360
363
|
: this.translatedMessage[message.getId()]
|
|
361
|
-
|
|
362
|
-
|
|
364
|
+
? this.translatedMessage[message.getId()]
|
|
365
|
+
: ""
|
|
363
366
|
}
|
|
364
367
|
textStyle={_style?.textStyle}
|
|
365
368
|
textContainerStyle={_style?.textContainerStyle}
|
|
@@ -2,6 +2,7 @@ import React, { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
|
2
2
|
import {
|
|
3
3
|
ActivityIndicator,
|
|
4
4
|
FlatList,
|
|
5
|
+
InteractionManager,
|
|
5
6
|
Keyboard,
|
|
6
7
|
KeyboardAvoidingView,
|
|
7
8
|
NativeModules,
|
|
@@ -129,7 +130,8 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
|
|
|
129
130
|
const theme = useTheme();
|
|
130
131
|
const answerRefs = useRef<(TextInput | null)[]>([]);
|
|
131
132
|
const [lastRemovedIndex, setLastRemovedIndex] = useState<number | null>(null);
|
|
132
|
-
const [
|
|
133
|
+
const [newlyAddedIndex, setNewlyAddedIndex] = useState<number | null>(null);
|
|
134
|
+
const flatListRef = useRef<FlatList>(null);
|
|
133
135
|
|
|
134
136
|
/**
|
|
135
137
|
* Validates the poll question and answer inputs.
|
|
@@ -269,7 +271,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
|
|
|
269
271
|
let existingAnswers = [...answers];
|
|
270
272
|
existingAnswers.push("");
|
|
271
273
|
setAnswers(existingAnswers);
|
|
272
|
-
|
|
274
|
+
setNewlyAddedIndex(existingAnswers.length - 1);
|
|
273
275
|
} else {
|
|
274
276
|
setError("You can only add up to 12 options.");
|
|
275
277
|
}
|
|
@@ -294,8 +296,11 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
|
|
|
294
296
|
}}
|
|
295
297
|
>
|
|
296
298
|
<TextInput
|
|
297
|
-
ref={(el) =>
|
|
299
|
+
ref={(el) => {
|
|
300
|
+
answerRefs.current[index] = el;
|
|
301
|
+
}}
|
|
298
302
|
value={item}
|
|
303
|
+
autoFocus={index === newlyAddedIndex}
|
|
299
304
|
onChangeText={(text) => handleAnswerTextChange(text, index)}
|
|
300
305
|
placeholder={answerPlaceholderText}
|
|
301
306
|
placeholderTextColor={theme.color.textTertiary}
|
|
@@ -355,16 +360,43 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
|
|
|
355
360
|
}, [lastRemovedIndex]);
|
|
356
361
|
|
|
357
362
|
useEffect(() => {
|
|
358
|
-
if (
|
|
359
|
-
|
|
360
|
-
|
|
363
|
+
if (newlyAddedIndex !== null) {
|
|
364
|
+
const timer = setTimeout(() => {
|
|
365
|
+
if (answerRefs.current[newlyAddedIndex]) {
|
|
366
|
+
answerRefs.current[newlyAddedIndex]?.focus();
|
|
367
|
+
}
|
|
368
|
+
setNewlyAddedIndex(null);
|
|
369
|
+
}, 50);
|
|
370
|
+
|
|
371
|
+
return () => clearTimeout(timer);
|
|
361
372
|
}
|
|
362
|
-
|
|
373
|
+
return;
|
|
374
|
+
}, [newlyAddedIndex]);
|
|
363
375
|
|
|
364
376
|
useEffect(() => {
|
|
365
377
|
answerRefs.current = answers.map((_, i) => answerRefs.current[i] || null);
|
|
366
378
|
}, [answers]);
|
|
367
379
|
|
|
380
|
+
useEffect(() => {
|
|
381
|
+
let timer: ReturnType<typeof setTimeout>;
|
|
382
|
+
if (answers.length > 0 && flatListRef.current) {
|
|
383
|
+
timer = setTimeout(() => {
|
|
384
|
+
flatListRef.current?.scrollToEnd({ animated: true });
|
|
385
|
+
}, 50);
|
|
386
|
+
}
|
|
387
|
+
return () => {
|
|
388
|
+
if (timer) clearTimeout(timer);
|
|
389
|
+
};
|
|
390
|
+
}, [answers.length]);
|
|
391
|
+
|
|
392
|
+
useEffect(() => {
|
|
393
|
+
if (answers.length) {
|
|
394
|
+
InteractionManager.runAfterInteractions(() => {
|
|
395
|
+
flatListRef.current?.scrollToEnd({ animated: true });
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
}, [answers.length]);
|
|
399
|
+
|
|
368
400
|
useEffect(() => {
|
|
369
401
|
let answerslist = new Array(defaultAnswers).fill("");
|
|
370
402
|
setAnswers(answerslist);
|
|
@@ -453,10 +485,15 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
|
|
|
453
485
|
{/* Main Content: Answers list */}
|
|
454
486
|
<View style={{ flex: 1 }}>
|
|
455
487
|
<FlatList
|
|
488
|
+
ref={flatListRef}
|
|
456
489
|
data={answers}
|
|
457
490
|
keyExtractor={(item, index) => index.toString()}
|
|
458
491
|
renderItem={renderAnswerItem}
|
|
459
|
-
ListFooterComponent={
|
|
492
|
+
ListFooterComponent={
|
|
493
|
+
<View style={{ paddingBottom: 20 }}>
|
|
494
|
+
<AddAnswer />
|
|
495
|
+
</View>
|
|
496
|
+
}
|
|
460
497
|
removeClippedSubviews={false}
|
|
461
498
|
keyboardShouldPersistTaps="always"
|
|
462
499
|
keyboardDismissMode="interactive"
|
|
@@ -8,7 +8,7 @@ import { localize } from "../../shared/resources/CometChatLocalize";
|
|
|
8
8
|
import { ExtensionTypeConstants } from "../ExtensionConstants";
|
|
9
9
|
import { getExtensionData } from "../ExtensionModerator";
|
|
10
10
|
import { PollsConfigurationInterface } from "./PollsConfigurations";
|
|
11
|
-
import React from "react";
|
|
11
|
+
import React, { JSX } from "react";
|
|
12
12
|
import { View } from "react-native";
|
|
13
13
|
import { CometChatUIKit } from "../../shared";
|
|
14
14
|
import {
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
2
|
-
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import React, { JSX, useCallback, useEffect, useRef, useState } from "react";
|
|
3
3
|
import { Keyboard, KeyboardEventName, Platform, TouchableOpacity } from "react-native";
|
|
4
4
|
import {
|
|
5
5
|
AdditionalParams,
|
|
6
|
-
ChatConfigurator,
|
|
7
6
|
CometChatMessageTemplate,
|
|
8
7
|
CometChatUIEventHandler,
|
|
9
8
|
CometChatUIEvents,
|
|
10
|
-
DataSource,
|
|
11
|
-
DataSourceDecorator,
|
|
12
9
|
MessageBubbleAlignmentType,
|
|
13
10
|
} from "../../shared";
|
|
11
|
+
import { ChatConfigurator, DataSource, DataSourceDecorator } from "../../shared/framework";
|
|
14
12
|
import { CometChatUIKit } from "../../shared/CometChatUiKit/CometChatUIKit";
|
|
15
13
|
import { MessageCategoryConstants, ViewAlignment } from "../../shared/constants/UIKitConstants";
|
|
16
14
|
import { Icon } from "../../shared/icons/Icon";
|
|
@@ -10,7 +10,7 @@ export const getStickerStyleLight = (
|
|
|
10
10
|
containerStyle: {
|
|
11
11
|
height: 180,
|
|
12
12
|
width: 180,
|
|
13
|
-
backgroundColor:
|
|
13
|
+
backgroundColor: color.background2,
|
|
14
14
|
padding: spacing.padding.p0,
|
|
15
15
|
paddingBottom: spacing.padding.p0,
|
|
16
16
|
borderRadius: spacing.radius.r3,
|
|
@@ -35,8 +35,8 @@ export const getStickerStyleLight = (
|
|
|
35
35
|
imageStyle: {
|
|
36
36
|
minHeight: 150,
|
|
37
37
|
minWidth: 150,
|
|
38
|
-
alignSelf:
|
|
39
|
-
}
|
|
38
|
+
alignSelf: "center",
|
|
39
|
+
},
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
42
|
|
package/src/index.ts
CHANGED
|
@@ -11,8 +11,7 @@ import { StickersExtension } from "../../extensions/Stickers";
|
|
|
11
11
|
import { ThumbnailGenerationExtension } from "../../extensions/ThumbnailGeneration";
|
|
12
12
|
import { ListenerInitializer } from "../events/ListenerInitializer";
|
|
13
13
|
import { ChatConfigurator, ExtensionsDataSource } from "../framework";
|
|
14
|
-
import { CometChatLocalize } from "../resources";
|
|
15
|
-
import { CometChatSoundManager } from "../utils";
|
|
14
|
+
import { CometChatLocalize, CometChatSoundManager } from "../resources";
|
|
16
15
|
import { getUnixTimestampInMilliseconds, messageStatus } from "../utils/CometChatMessageHelper";
|
|
17
16
|
import { permissionUtil } from "../utils/PermissionUtil";
|
|
18
17
|
import { CometChatUIKitHelper } from "./CometChatUIKitHelper";
|
package/src/shared/base/Types.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ImageSourcePropType, ImageStyle, ImageURISource } from "react-native";
|
|
|
2
2
|
import { CometChatTextFormatter } from "../formatters";
|
|
3
3
|
import { CometChatTheme } from "../../theme/type";
|
|
4
4
|
import { DeepPartial } from "../helper/types";
|
|
5
|
+
import { JSX } from "react";
|
|
5
6
|
|
|
6
7
|
export type SelectionMode = "none" | "single" | "multiple";
|
|
7
8
|
|