@cometchat/chat-uikit-react-native 4.3.2 → 4.3.4
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/AndroidManifest.xml +3 -4
- package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +0 -1
- package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +125 -7
- package/android/src/main/java/com/reactnativecometchatuikit/ImageManager.java +1 -1
- package/ios/CommonUtil.h +4 -0
- package/ios/CommonUtil.m +27 -0
- package/package.json +1 -1
- package/src/AI/AIAssistBot/AIAssistBotDecorator.tsx +0 -3
- package/src/CometChatConversations/CometChatConversations.tsx +151 -66
- package/src/CometChatConversations/ConversationsConfiguration.ts +25 -4
- package/src/CometChatConversations/style.ts +5 -1
- package/src/CometChatConversationsWithMessages/CometChatConversationsWithMessages.tsx +29 -29
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +598 -63
- package/src/CometChatMessageComposer/MessageComposerConfiguration.tsx +12 -1
- package/src/CometChatMessageComposer/resources/Info.png +0 -0
- package/src/CometChatMessageComposer/resources/index.ts +3 -1
- package/src/CometChatMessageHeader/listners.ts +0 -2
- package/src/CometChatMessageList/CometChatMessageList.tsx +139 -30
- package/src/CometChatMessageList/MessageListConfiguration.ts +19 -6
- package/src/CometChatMessages/CometChatMessages.tsx +16 -16
- package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +41 -3
- package/src/calls/CallingExtentionDecorator.tsx +5 -5
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +3 -3
- package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +2 -0
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +2 -0
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +3 -3
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +3 -3
- package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +51 -15
- package/src/extensions/LinkPreview/LinkPreviewExtentionDecorator.tsx +4 -4
- package/src/extensions/MessageTranslation/MessageTranslationBubble.tsx +31 -9
- package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +83 -6
- package/src/extensions/Polls/Polls.tsx +106 -70
- package/src/extensions/Polls/PollsDecorator.tsx +3 -2
- package/src/extensions/Stickers/CometChatStickerKeyboard/style.ts +3 -3
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +14 -6
- package/src/extensions/TextModeration/TextModerationExtensionDecorator.tsx +3 -3
- package/src/index.ts +29 -8
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +146 -24
- package/src/shared/CometChatUiKit/index.ts +1 -1
- package/src/shared/base/vars.ts +13 -0
- package/src/shared/constants/UIKitConstants.ts +6 -0
- package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +7 -0
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +11 -1
- package/src/shared/events/CometChatUIEvents.ts +3 -1
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +380 -0
- package/src/shared/formatters/CometChatMentionsFormatter/MentionTextStyle.ts +14 -0
- package/src/shared/formatters/CometChatMentionsFormatter/index.ts +7 -0
- package/src/shared/formatters/CometChatTextFormatter.ts +253 -0
- package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +146 -0
- package/src/shared/formatters/index.ts +11 -0
- package/src/shared/framework/DataSource.ts +21 -16
- package/src/shared/framework/DataSourceDecorator.tsx +29 -13
- package/src/shared/framework/MessageDataSource.tsx +215 -49
- package/src/shared/helper/useKeyboard.tsx +20 -2
- package/src/shared/index.ts +31 -11
- package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +1040 -0
- package/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx +223 -0
- package/src/shared/libs/ImageZoom/helper.ts +144 -0
- package/src/shared/libs/ImageZoom/index.tsx +13 -0
- package/src/shared/libs/ImageZoom/types/index.ts +186 -0
- package/src/shared/libs/VideoPlayer/Video.js +0 -24
- package/src/shared/libs/VideoPlayerControls/assets/img/back.png +0 -0
- package/src/shared/libs/VideoPlayerControls/components/Back/Back.tsx +1 -1
- package/src/shared/resources/CometChatLocalize/CometChatLocalize.ts +2 -0
- package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/de/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/en/translation.json +10 -1
- package/src/shared/resources/CometChatLocalize/resources/es/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +10 -1
- package/src/shared/resources/CometChatLocalize/resources/hu/translation.json +315 -0
- package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +12 -1
- package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +11 -1
- package/src/shared/resources/CometChatTheme/Palette.ts +16 -0
- package/src/shared/utils/InteractiveMessageUtils.ts +39 -1
- package/src/shared/utils/NetworkUtils.tsx +5 -0
- package/src/shared/utils/PermissionUtil.ts +142 -0
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -0
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +8 -6
- package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +5 -1
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +12 -11
- package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +70 -22
- package/src/shared/views/CometChatImageBubble/assets/index.ts +5 -0
- package/src/shared/views/CometChatImageBubble/assets/spineer.png +0 -0
- package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +106 -0
- package/src/shared/views/CometChatImageViewerModal/index.tsx +1 -0
- package/src/shared/views/CometChatImageViewerModal/resources/Back.png +0 -0
- package/src/shared/views/CometChatImageViewerModal/resources/index.ts +5 -0
- package/src/shared/views/CometChatList/CometChatList.tsx +10 -1
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +3 -2
- package/src/shared/views/{CometChatReactionsList/CometChatReactionsList.tsx → CometChatReactionList/CometChatReactionList.tsx} +17 -17
- package/src/shared/views/CometChatReactionList/ReactionListConfiguration.tsx +14 -0
- package/src/shared/views/CometChatReactionList/index.ts +12 -0
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +3 -3
- package/src/shared/views/CometChatSchedulerBubble/CometChatSchedulerBubble.tsx +12 -0
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +64 -0
- package/src/shared/views/CometChatSuggestionList/SuggestionItem.ts +48 -0
- package/src/shared/views/CometChatSuggestionList/SuggestionListConfiguration.ts +23 -0
- package/src/shared/views/CometChatSuggestionList/index.ts +11 -0
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +33 -46
- package/src/shared/views/CometChatTextBubble/TextBubbleStyle.ts +0 -14
- package/src/shared/views/CometChatTextBubble/index.ts +2 -3
- package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +6 -4
- package/src/shared/views/index.ts +14 -8
- package/android/src/main/java/com/reactnativecometchatuikit/VideoManager.java +0 -40
- package/src/shared/libs/VideoPlayerControls/assets/img/back@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/back@3x.png +0 -0
- package/src/shared/utils/PermissionUtilIOS.ts +0 -104
- package/src/shared/views/CometChatReactionsList/ReactionsListConfiguration.tsx +0 -14
- package/src/shared/views/CometChatReactionsList/index.ts +0 -12
- /package/src/shared/views/{CometChatReactionsList/ReactionsListStyle.tsx → CometChatReactionList/ReactionListStyle.tsx} +0 -0
- /package/src/shared/views/{CometChatReactionsList → CometChatReactionList}/resources/Spineer.png +0 -0
- /package/src/shared/views/{CometChatReactionsList → CometChatReactionList}/resources/index.ts +0 -0
|
@@ -53,7 +53,7 @@ const CometChatReactions = (props: CometChatReactionsInterface) => {
|
|
|
53
53
|
primaryBorder,
|
|
54
54
|
} = _style;
|
|
55
55
|
|
|
56
|
-
const reactionView = (reactionObj) => {
|
|
56
|
+
const reactionView = (reactionObj, index) => {
|
|
57
57
|
let count: number = reactionObj?.count;
|
|
58
58
|
let Emoji: string = reactionObj?.reaction;
|
|
59
59
|
let Count: JSX.Element = <Text
|
|
@@ -67,7 +67,7 @@ const CometChatReactions = (props: CometChatReactionsInterface) => {
|
|
|
67
67
|
</Text>;
|
|
68
68
|
|
|
69
69
|
return count >= 1 ? (
|
|
70
|
-
<View style={[
|
|
70
|
+
<View key={index} style={[
|
|
71
71
|
Styles.messageReactionsStyle,
|
|
72
72
|
{
|
|
73
73
|
backgroundColor: reactionObj?.reactedByMe ? primaryBackgroundColor : backgroundColor,
|
|
@@ -107,7 +107,7 @@ const CometChatReactions = (props: CometChatReactionsInterface) => {
|
|
|
107
107
|
let AllObj = new CometChat.ReactionCount("All", totalCount, false); // { reaction: "All", count: totalCount };
|
|
108
108
|
|
|
109
109
|
return (
|
|
110
|
-
<View style={[
|
|
110
|
+
<View key={new Date().getTime()} style={[
|
|
111
111
|
Styles.messageReactionsStyle,
|
|
112
112
|
{
|
|
113
113
|
paddingVertical: 0, paddingHorizontal: 0,
|
|
@@ -39,6 +39,7 @@ import CometChatQuickView from "../CometChatQuickView/CometChatQuickView";
|
|
|
39
39
|
import { localize } from "../../resources";
|
|
40
40
|
import { CometChatUIKit } from "../../CometChatUiKit";
|
|
41
41
|
import { CometChatUiKitConstants } from "../..";
|
|
42
|
+
import { InteractiveMessageUtils } from "../../utils/InteractiveMessageUtils";
|
|
42
43
|
|
|
43
44
|
const { TimeZoneCodeManager } = NativeModules;
|
|
44
45
|
export interface CometChatSchedulerBubbleInterface {
|
|
@@ -621,6 +622,17 @@ export const CometChatSchedulerBubble = memo(
|
|
|
621
622
|
useEffect(() => {
|
|
622
623
|
CometChat.getLoggedinUser()
|
|
623
624
|
.then((u) => {
|
|
625
|
+
let hasInteractionCompleted: boolean = InteractiveMessageUtils.checkHasInteractionCompleted({
|
|
626
|
+
interactedElements: message?.getInteractions() || [],
|
|
627
|
+
interactionGoal: message?.getInteractionGoal() || undefined
|
|
628
|
+
});
|
|
629
|
+
if(hasInteractionCompleted) {
|
|
630
|
+
setCurrentComp((prev) => ({
|
|
631
|
+
current: componentEnum.interacted,
|
|
632
|
+
previous: prev.current,
|
|
633
|
+
}));
|
|
634
|
+
return
|
|
635
|
+
}
|
|
624
636
|
TimeZoneCodeManager.getCurrentTimeZone((timeZone) => {
|
|
625
637
|
currentTimeZoneRef.current = timeZone;
|
|
626
638
|
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { View, Text, FlatList, ListRenderItemInfo, ActivityIndicator } from 'react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { SuggestionItem } from './SuggestionItem';
|
|
4
|
+
import { CometChatListItem, ListItemStyle } from '../CometChatListItem';
|
|
5
|
+
import { AvatarStyleInterface } from '../CometChatAvatar';
|
|
6
|
+
|
|
7
|
+
export interface CometChatSuggestionListInterface {
|
|
8
|
+
separatorColor?: string
|
|
9
|
+
/**
|
|
10
|
+
* Array of selection items
|
|
11
|
+
*/
|
|
12
|
+
data: Array<SuggestionItem>;
|
|
13
|
+
listItemStyle?: ListItemStyle;
|
|
14
|
+
avatarStyle?: AvatarStyleInterface;
|
|
15
|
+
onPress: (item: SuggestionItem) => void;
|
|
16
|
+
onEndReached?: () => void;
|
|
17
|
+
loading?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const CometChatSuggestionList = (props: CometChatSuggestionListInterface) => {
|
|
21
|
+
const { data, avatarStyle, listItemStyle, separatorColor, onPress, onEndReached, loading } = props;
|
|
22
|
+
|
|
23
|
+
const _render = ({ item, index }: ListRenderItemInfo<SuggestionItem>) => {
|
|
24
|
+
let shouldLoadAvatarName = item.hideLeadingIcon ? {} : { avatarName: item.name }
|
|
25
|
+
return (
|
|
26
|
+
<CometChatListItem
|
|
27
|
+
key={index}
|
|
28
|
+
id={item.id}
|
|
29
|
+
title={item.name}
|
|
30
|
+
avatarStyle={{ ...avatarStyle }}
|
|
31
|
+
avatarURL={item.leadingIconUrl ? { uri: item.leadingIconUrl } : undefined}
|
|
32
|
+
listItemStyle={{ ...listItemStyle }}
|
|
33
|
+
onPress={() => onPress(item)}
|
|
34
|
+
{...shouldLoadAvatarName}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<View>
|
|
41
|
+
<FlatList
|
|
42
|
+
data={data}
|
|
43
|
+
renderItem={_render}
|
|
44
|
+
onEndReached={({ distanceFromEnd }) => {
|
|
45
|
+
if (distanceFromEnd < 0) return;
|
|
46
|
+
onEndReached();
|
|
47
|
+
}}
|
|
48
|
+
ItemSeparatorComponent={() => <View style={{ height: 1, marginLeft: 5, backgroundColor: separatorColor }}></View>}
|
|
49
|
+
onEndReachedThreshold={0.3}
|
|
50
|
+
keyboardShouldPersistTaps={"always"}
|
|
51
|
+
style={{
|
|
52
|
+
paddingLeft: 5
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
<View style={{
|
|
56
|
+
position: 'absolute',
|
|
57
|
+
bottom: 0,
|
|
58
|
+
width: '100%',
|
|
59
|
+
}}>
|
|
60
|
+
{loading && <ActivityIndicator animating={loading} />}
|
|
61
|
+
</View>
|
|
62
|
+
</View>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
export class SuggestionItem {
|
|
3
|
+
/**
|
|
4
|
+
* Unique identifier of item
|
|
5
|
+
*/
|
|
6
|
+
id: string;
|
|
7
|
+
/**
|
|
8
|
+
* Name to be displayed in the list
|
|
9
|
+
*/
|
|
10
|
+
name: string;
|
|
11
|
+
/**
|
|
12
|
+
* Avatar Icon Url
|
|
13
|
+
*/
|
|
14
|
+
leadingIconUrl?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Hide leading icon
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
19
|
+
hideLeadingIcon?: boolean = true;
|
|
20
|
+
/**
|
|
21
|
+
* Presence Indicator
|
|
22
|
+
*/
|
|
23
|
+
status?: 'online' | 'offline';
|
|
24
|
+
/**
|
|
25
|
+
* Name to be displayed in the composer
|
|
26
|
+
*/
|
|
27
|
+
promptText: string;
|
|
28
|
+
/**
|
|
29
|
+
* underlying text
|
|
30
|
+
* @example <@uid:superhero1>
|
|
31
|
+
*/
|
|
32
|
+
underlyingText: string;
|
|
33
|
+
/**
|
|
34
|
+
* set a tracking character.
|
|
35
|
+
* @description string length has be 1.
|
|
36
|
+
* @example '@' | '#' etc.
|
|
37
|
+
*/
|
|
38
|
+
trackingCharacter: string
|
|
39
|
+
/**
|
|
40
|
+
* extra data to be passed in JSON format
|
|
41
|
+
*/
|
|
42
|
+
data?: JSON;
|
|
43
|
+
|
|
44
|
+
constructor(props: SuggestionItem) {
|
|
45
|
+
Object.assign(this, props);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AvatarStyleInterface } from "../CometChatAvatar";
|
|
2
|
+
import { ListItemStyle } from "../CometChatListItem";
|
|
3
|
+
import { CometChatSuggestionListInterface } from "./CometChatSuggestionList";
|
|
4
|
+
import { SuggestionItem } from "./SuggestionItem";
|
|
5
|
+
|
|
6
|
+
export interface SuggestionListConfigurationInterface extends CometChatSuggestionListInterface { }
|
|
7
|
+
|
|
8
|
+
export class SuggestionListConfiguration {
|
|
9
|
+
separatorColor: string
|
|
10
|
+
/**
|
|
11
|
+
* Array of selection items
|
|
12
|
+
*/
|
|
13
|
+
data: Array<SuggestionItem>;
|
|
14
|
+
listItemStyle?: ListItemStyle
|
|
15
|
+
avatarStyle?: AvatarStyleInterface
|
|
16
|
+
onPress: (item: SuggestionItem) => void
|
|
17
|
+
onEndReached?: () => void
|
|
18
|
+
loading?: boolean
|
|
19
|
+
|
|
20
|
+
constructor(props: SuggestionListConfigurationInterface) {
|
|
21
|
+
Object.assign(this, props);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CometChatSuggestionList, CometChatSuggestionListInterface } from './CometChatSuggestionList';
|
|
2
|
+
import { SuggestionItem } from './SuggestionItem';
|
|
3
|
+
import { SuggestionListConfiguration, SuggestionListConfigurationInterface } from './SuggestionListConfiguration';
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
CometChatSuggestionList,
|
|
7
|
+
CometChatSuggestionListInterface,
|
|
8
|
+
SuggestionItem,
|
|
9
|
+
SuggestionListConfiguration,
|
|
10
|
+
SuggestionListConfigurationInterface
|
|
11
|
+
}
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import React, {useContext} from "react";
|
|
1
|
+
import React, { useContext, useEffect, useState } from "react";
|
|
2
2
|
import { View, Text, Linking, StyleProp, ViewStyle } from "react-native";
|
|
3
3
|
import { CometChatContextType } from "../../base/Types";
|
|
4
4
|
import { CometChatContext } from "../../CometChatContext";
|
|
5
5
|
import { emailPattern, phoneNumPattern, urlPattern } from "../../constants/UIKitConstants";
|
|
6
6
|
import { TextBubbleStyle, TextBubbleStyleInterface } from "./TextBubbleStyle";
|
|
7
|
+
import { CometChatMentionsFormatter, CometChatTextFormatter, CometChatUrlsFormatter } from "../../formatters";
|
|
7
8
|
|
|
8
9
|
const Link = ({ text, url, style }) => {
|
|
9
|
-
return <Text style={{...style, textDecorationLine: "underline"}} onPress={() => {
|
|
10
|
+
return <Text style={{ ...style, textDecorationLine: "underline" }} onPress={() => {
|
|
10
11
|
let finalUrl = url.startsWith("http") ? url : `http://${url}`
|
|
11
12
|
Linking.canOpenURL(finalUrl)
|
|
12
13
|
.then(res => {
|
|
13
14
|
if (res) {
|
|
14
15
|
Linking.openURL(finalUrl);
|
|
15
16
|
return;
|
|
16
|
-
}
|
|
17
|
+
}
|
|
17
18
|
console.log("Can not open link", finalUrl);
|
|
18
19
|
})
|
|
19
20
|
.catch(err => {
|
|
20
|
-
console.log({url});
|
|
21
|
+
console.log({ url });
|
|
21
22
|
console.log("Error:", err);
|
|
22
23
|
})
|
|
23
24
|
}} >{text}</Text>
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
const getPatternGroup = (str: string):{phone?: string, email?: string, url?: string} => {
|
|
27
|
+
const getPatternGroup = (str: string): { phone?: string, email?: string, url?: string } => {
|
|
27
28
|
let result = {};
|
|
28
29
|
if (str.match(phoneNumPattern))
|
|
29
30
|
result['phone'] = str;
|
|
@@ -34,32 +35,6 @@ const getPatternGroup = (str: string):{phone?: string, email?: string, url?: str
|
|
|
34
35
|
return result;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
export const FormatTextForLinks = ({str, style}) => {
|
|
38
|
-
let res = str.matchAll(phoneNumPattern + "|" + emailPattern + "|" + urlPattern);
|
|
39
|
-
for (let resPart of res) {
|
|
40
|
-
let { email, phone } = getPatternGroup(resPart[0]);
|
|
41
|
-
let pre: string, post:string;
|
|
42
|
-
pre = str.substring(0, resPart.index);
|
|
43
|
-
post = str.substring(resPart.index + resPart[0].length);
|
|
44
|
-
let urlLink = "";
|
|
45
|
-
if (email)
|
|
46
|
-
urlLink = "mailto:";
|
|
47
|
-
if (phone)
|
|
48
|
-
urlLink = "tel:";
|
|
49
|
-
return (
|
|
50
|
-
<Text style={{...style.textFont, color: style.textColor}}>
|
|
51
|
-
<Text>
|
|
52
|
-
{pre}
|
|
53
|
-
</Text>
|
|
54
|
-
<Link text={resPart[0]} url={urlLink + resPart[0].trim()} style={{...style.linkTextFont, color: style.linkTextColor}} />
|
|
55
|
-
<FormatTextForLinks str={post} style={style} />
|
|
56
|
-
</Text>
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return <Text style={{...style.textFont, color: style.textColor}}>{str}</Text>;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
38
|
export interface CometChatTextBubbleInterface {
|
|
64
39
|
/**
|
|
65
40
|
* text tobe shown
|
|
@@ -73,17 +48,24 @@ export interface CometChatTextBubbleInterface {
|
|
|
73
48
|
* text container style
|
|
74
49
|
*/
|
|
75
50
|
textContainerStyle?: StyleProp<ViewStyle>
|
|
51
|
+
textFormatters?: Array<CometChatMentionsFormatter | CometChatUrlsFormatter | CometChatTextFormatter>;
|
|
76
52
|
}
|
|
77
53
|
|
|
78
54
|
export const CometChatTextBubble = (props: CometChatTextBubbleInterface) => {
|
|
79
|
-
|
|
80
|
-
const {
|
|
55
|
+
|
|
56
|
+
const {
|
|
57
|
+
text,
|
|
58
|
+
textContainerStyle,
|
|
59
|
+
textFormatters
|
|
60
|
+
} = props;
|
|
61
|
+
|
|
62
|
+
const { theme } = useContext<CometChatContextType>(CometChatContext);
|
|
63
|
+
const [formattedText, setFormattedText] = useState<string>();
|
|
81
64
|
|
|
82
65
|
const _style = new TextBubbleStyle({
|
|
83
66
|
backgroundColor: theme?.palette.getBackgroundColor(),
|
|
84
67
|
textColor: theme?.palette.getAccent(),
|
|
85
68
|
textFont: theme?.typography.body,
|
|
86
|
-
linkTextFont: theme?.typography.body,
|
|
87
69
|
...props.style
|
|
88
70
|
});
|
|
89
71
|
|
|
@@ -93,30 +75,35 @@ export const CometChatTextBubble = (props: CometChatTextBubbleInterface) => {
|
|
|
93
75
|
borderRadius,
|
|
94
76
|
textColor,
|
|
95
77
|
textFont,
|
|
96
|
-
linkTextColor,
|
|
97
|
-
linkTextFont,
|
|
98
78
|
height,
|
|
99
79
|
width
|
|
100
80
|
} = _style;
|
|
101
81
|
|
|
102
|
-
|
|
103
|
-
text
|
|
104
|
-
|
|
105
|
-
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
let finalText = text;
|
|
84
|
+
if (textFormatters && textFormatters.length) {
|
|
85
|
+
if (textFormatters) {
|
|
86
|
+
for (let i = 0; i < textFormatters.length; i++) {
|
|
87
|
+
(finalText as string | void) = textFormatters[i].getFormattedText(finalText);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
setFormattedText(finalText as string);
|
|
92
|
+
}, [])
|
|
106
93
|
|
|
107
94
|
return <View style={[
|
|
108
95
|
{
|
|
109
96
|
alignSelf: "flex-start",
|
|
110
97
|
},
|
|
111
98
|
{
|
|
112
|
-
backgroundColor,
|
|
99
|
+
backgroundColor, borderRadius, maxHeight: height, maxWidth: width,
|
|
113
100
|
overflow: "hidden", padding: 8, paddingBottom: 0
|
|
114
101
|
},
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
<
|
|
119
|
-
|
|
102
|
+
border,
|
|
103
|
+
textContainerStyle
|
|
104
|
+
]}>
|
|
105
|
+
<Text style={[{ color: textColor }, textFont]}>{formattedText}</Text>
|
|
106
|
+
|
|
120
107
|
</View>
|
|
121
108
|
}
|
|
122
109
|
|
|
@@ -9,21 +9,11 @@ export interface TextBubbleStyleInterface extends BaseStyleInterface {
|
|
|
9
9
|
* font style for text
|
|
10
10
|
*/
|
|
11
11
|
textFont?: FontStyle,
|
|
12
|
-
/**
|
|
13
|
-
* font syle for special text
|
|
14
|
-
*/
|
|
15
|
-
linkTextFont?: FontStyle,
|
|
16
|
-
/**
|
|
17
|
-
* color for special text
|
|
18
|
-
*/
|
|
19
|
-
linkTextColor?: string
|
|
20
12
|
}
|
|
21
13
|
|
|
22
14
|
export class TextBubbleStyle extends BaseStyle {
|
|
23
15
|
textColor: string
|
|
24
16
|
textFont: FontStyle
|
|
25
|
-
linkTextFont: FontStyle
|
|
26
|
-
linkTextColor: string
|
|
27
17
|
|
|
28
18
|
constructor({
|
|
29
19
|
width = "auto",
|
|
@@ -33,8 +23,6 @@ export class TextBubbleStyle extends BaseStyle {
|
|
|
33
23
|
borderRadius = 0,
|
|
34
24
|
textColor = "rgb(20, 20, 20)",
|
|
35
25
|
textFont = new FontStyle({fontSize: 17, fontWeight: "400"}),
|
|
36
|
-
linkTextColor = "blue",
|
|
37
|
-
linkTextFont = new FontStyle({fontSize: 17, fontWeight: "400"}),
|
|
38
26
|
}: TextBubbleStyleInterface) {
|
|
39
27
|
super({
|
|
40
28
|
width,
|
|
@@ -45,7 +33,5 @@ export class TextBubbleStyle extends BaseStyle {
|
|
|
45
33
|
});
|
|
46
34
|
this.textColor = textColor;
|
|
47
35
|
this.textFont = new FontStyle({...textFont});
|
|
48
|
-
this.linkTextColor = linkTextColor;
|
|
49
|
-
this.linkTextFont = new FontStyle({...linkTextFont});
|
|
50
36
|
}
|
|
51
37
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {CometChatTextBubble, CometChatTextBubbleInterface
|
|
1
|
+
import { CometChatTextBubble, CometChatTextBubbleInterface } from "./CometChatTextBubble";
|
|
2
2
|
|
|
3
|
-
import {TextBubbleStyle, TextBubbleStyleInterface} from "./TextBubbleStyle";
|
|
3
|
+
import { TextBubbleStyle, TextBubbleStyleInterface } from "./TextBubbleStyle";
|
|
4
4
|
|
|
5
5
|
export {
|
|
6
|
-
FormatTextForLinks,
|
|
7
6
|
CometChatTextBubble,
|
|
8
7
|
CometChatTextBubbleInterface,
|
|
9
8
|
TextBubbleStyle,
|
|
@@ -8,7 +8,7 @@ import { Style } from "./style";
|
|
|
8
8
|
import { CometChatContextType } from "../../base/Types";
|
|
9
9
|
import { CometChatVideoPlayer } from "../CometChatVideoPlayer";
|
|
10
10
|
|
|
11
|
-
const {
|
|
11
|
+
const { FileManager } = NativeModules;
|
|
12
12
|
const eventEmitter = new NativeEventEmitter(FileManager);
|
|
13
13
|
let statusListener: EmitterSubscription;
|
|
14
14
|
export interface CometChatVideoBubbleInterface {
|
|
@@ -133,7 +133,7 @@ export const CometChatVideoBubble = (props: CometChatVideoBubbleInterface) => {
|
|
|
133
133
|
};
|
|
134
134
|
|
|
135
135
|
const handleTouchEnd = () => {
|
|
136
|
-
|
|
136
|
+
if (pressTime.current === null && Platform.OS === "ios") return;
|
|
137
137
|
const endTime = Date.now();
|
|
138
138
|
const pressDuration = endTime - pressTime.current;
|
|
139
139
|
if (pressDuration < 500) {
|
|
@@ -142,7 +142,9 @@ export const CometChatVideoBubble = (props: CometChatVideoBubbleInterface) => {
|
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
const onTouchMove = () => {
|
|
145
|
-
|
|
145
|
+
if (Platform.OS === "ios") {
|
|
146
|
+
pressTime.current = null;
|
|
147
|
+
}
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
return (
|
|
@@ -169,7 +171,7 @@ export const CometChatVideoBubble = (props: CometChatVideoBubbleInterface) => {
|
|
|
169
171
|
<View
|
|
170
172
|
onTouchStart={handleTouchStart}
|
|
171
173
|
onTouchEnd={handleTouchEnd}
|
|
172
|
-
|
|
174
|
+
onTouchMove={onTouchMove}
|
|
173
175
|
style={[Style.playIconPosition, { backgroundColor: playIconBackgroundColor, borderRadius }]}>
|
|
174
176
|
{isLoading ? <ActivityIndicator size={"small"} color={playIconTint} />
|
|
175
177
|
: <Image source={playIcon || defaultPlayIcon} style={{ tintColor: playIconTint }} />
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
CometChatTextBubbleInterface,
|
|
17
17
|
TextBubbleStyle,
|
|
18
18
|
TextBubbleStyleInterface,
|
|
19
|
-
FormatTextForLinks,
|
|
20
19
|
} from './CometChatTextBubble';
|
|
21
20
|
import {
|
|
22
21
|
CometChatImageBubble,
|
|
@@ -89,11 +88,13 @@ import { CometChatCardBubble, CometChatCardBubbleInterface } from './CometChatCa
|
|
|
89
88
|
import { CometChatSchedulerBubble, CometChatSchedulerBubbleInterface } from './CometChatSchedulerBubble'
|
|
90
89
|
|
|
91
90
|
import { CometChatReactions, CometChatReactionsInterface, ReactionsConfiguration, ReactionsConfigurationInterface, ReactionsStyle, ReactionsStyleInterface } from './CometChatReactions';
|
|
92
|
-
import {
|
|
91
|
+
import { CometChatReactionList, CometChatReactionListInterface, ReactionListStyle, ReactionListStyleInterface, ReactionListConfiguration, ReactionListConfigurationInterface } from './CometChatReactionList';
|
|
93
92
|
import { CometChatQuickReactions, CometChatQuickReactionsInterface, QuickReactionsConfiguration, QuickReactionsConfigurationInterface, QuickReactionsStyle, QuickReactionsStyleInterface } from './CometChatQuickReactions';
|
|
94
93
|
|
|
95
94
|
import { CometChatEmojiKeyboard, EmojiKeyboardConfiguration, EmojiKeyboardStyle } from './CometChatEmojiKeyboard';
|
|
96
95
|
|
|
96
|
+
import { CometChatSuggestionList, CometChatSuggestionListInterface, SuggestionItem, SuggestionListConfiguration, SuggestionListConfigurationInterface } from './CometChatSuggestionList';
|
|
97
|
+
|
|
97
98
|
export {
|
|
98
99
|
CometChatMessageInputStyleInterface,
|
|
99
100
|
CometChatMessageInputInterface,
|
|
@@ -109,7 +110,6 @@ export {
|
|
|
109
110
|
BadgeConfigurationInterface,
|
|
110
111
|
BadgeStyleInterface,
|
|
111
112
|
AvatarConfigurationInterface,
|
|
112
|
-
FormatTextForLinks,
|
|
113
113
|
ActionItemInterface,
|
|
114
114
|
ActionSheetStylesInterface,
|
|
115
115
|
CometChatConfirmDialogInterface,
|
|
@@ -180,12 +180,12 @@ export {
|
|
|
180
180
|
ReactionsConfigurationInterface,
|
|
181
181
|
ReactionsStyle,
|
|
182
182
|
ReactionsStyleInterface,
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
CometChatReactionList,
|
|
184
|
+
CometChatReactionListInterface,
|
|
185
185
|
ReactionListStyle,
|
|
186
186
|
ReactionListStyleInterface,
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
ReactionListConfiguration,
|
|
188
|
+
ReactionListConfigurationInterface,
|
|
189
189
|
CometChatQuickReactions,
|
|
190
190
|
CometChatQuickReactionsInterface,
|
|
191
191
|
QuickReactionsConfiguration,
|
|
@@ -198,5 +198,11 @@ export {
|
|
|
198
198
|
EmojiKeyboardStyle,
|
|
199
199
|
|
|
200
200
|
CometChatSchedulerBubble,
|
|
201
|
-
CometChatSchedulerBubbleInterface
|
|
201
|
+
CometChatSchedulerBubbleInterface,
|
|
202
|
+
|
|
203
|
+
CometChatSuggestionList,
|
|
204
|
+
CometChatSuggestionListInterface,
|
|
205
|
+
SuggestionItem,
|
|
206
|
+
SuggestionListConfiguration,
|
|
207
|
+
SuggestionListConfigurationInterface,
|
|
202
208
|
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
package com.reactnativecometchatuikit;
|
|
2
|
-
|
|
3
|
-
import android.content.Intent;
|
|
4
|
-
import android.util.Log;
|
|
5
|
-
|
|
6
|
-
import androidx.annotation.NonNull;
|
|
7
|
-
|
|
8
|
-
import com.facebook.react.bridge.Callback;
|
|
9
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
11
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
12
|
-
|
|
13
|
-
public class VideoManager extends ReactContextBaseJavaModule {
|
|
14
|
-
public static final String TAG = "VideoManager";
|
|
15
|
-
|
|
16
|
-
VideoManager(ReactApplicationContext context) {
|
|
17
|
-
super(context);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@ReactMethod
|
|
21
|
-
public void openVideo(String url, Callback callback) {
|
|
22
|
-
try {
|
|
23
|
-
Intent i = new Intent(getReactApplicationContext(), CometChatVideoPlayer.class);
|
|
24
|
-
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
25
|
-
i.putExtra("videoUrl", url);
|
|
26
|
-
getReactApplicationContext().startActivity(i);
|
|
27
|
-
} catch (Exception ex) {
|
|
28
|
-
Log.e(TAG, "openVideo: " + ex.getMessage());
|
|
29
|
-
callback.invoke("error:" + ex.getMessage());
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
callback.invoke("success");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@NonNull
|
|
36
|
-
@Override
|
|
37
|
-
public String getName() {
|
|
38
|
-
return "VideoManager";
|
|
39
|
-
}
|
|
40
|
-
}
|
|
Binary file
|
|
Binary file
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { Alert, Linking, NativeModules, Platform } from 'react-native';
|
|
2
|
-
import { localize } from '../../shared/resources/CometChatLocalize/CometChatLocalize';
|
|
3
|
-
const { FileManager } = NativeModules;
|
|
4
|
-
|
|
5
|
-
let instance: PermissionUtilIOS;
|
|
6
|
-
const permissionStatus = {
|
|
7
|
-
'Not Determined': 0,
|
|
8
|
-
'Restricted': 1,
|
|
9
|
-
'Denied': 2,
|
|
10
|
-
'Authorized': 3,
|
|
11
|
-
'Unknown': -1,
|
|
12
|
-
} as const;
|
|
13
|
-
|
|
14
|
-
const permissibleResources = ['camera', 'mic'] as const;
|
|
15
|
-
type TPermissibleResources = (typeof permissibleResources)[number];
|
|
16
|
-
|
|
17
|
-
type ValueOf<T> = T[keyof T];
|
|
18
|
-
type TPermissionStatus = ValueOf<typeof permissionStatus>;
|
|
19
|
-
|
|
20
|
-
const permissionStore: Record<TPermissibleResources, TPermissionStatus> = {
|
|
21
|
-
camera: permissionStatus.Unknown,
|
|
22
|
-
mic: permissionStatus.Unknown,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
class PermissionUtilIOS {
|
|
26
|
-
status = permissionStatus;
|
|
27
|
-
constructor() {
|
|
28
|
-
if (instance) {
|
|
29
|
-
throw new Error('New instance cannot be created!!');
|
|
30
|
-
}
|
|
31
|
-
instance = this;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async init() {
|
|
35
|
-
try {
|
|
36
|
-
const res: Record<TPermissibleResources, TPermissionStatus> =
|
|
37
|
-
await FileManager.checkResourcesPermission(['mic', 'camera']);
|
|
38
|
-
for (const resourceType in res) {
|
|
39
|
-
permissionStore[resourceType as TPermissibleResources] =
|
|
40
|
-
res[resourceType as TPermissibleResources];
|
|
41
|
-
}
|
|
42
|
-
permissionStore.camera = res.camera;
|
|
43
|
-
permissionStore.mic = res.mic;
|
|
44
|
-
return true;
|
|
45
|
-
} catch (error: any) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async get(resources: TPermissibleResources[]) {
|
|
51
|
-
return resources.map((resource) => {
|
|
52
|
-
if (!permissibleResources.includes(resource)) {
|
|
53
|
-
throw new Error('Invalid resource type');
|
|
54
|
-
}
|
|
55
|
-
return permissionStore[resource];
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async request(resources: TPermissibleResources[]) {
|
|
60
|
-
for (const resource of resources) {
|
|
61
|
-
if (!permissibleResources.includes(resource)) {
|
|
62
|
-
throw new Error('Invalid resource type');
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const res: Record<TPermissibleResources, TPermissionStatus> =
|
|
66
|
-
await FileManager.requestResourcesPermission(resources);
|
|
67
|
-
for (const resourceType in res) {
|
|
68
|
-
permissionStore[resourceType as TPermissibleResources] =
|
|
69
|
-
res[resourceType as TPermissibleResources];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async startResourceBasedTask(resources: TPermissibleResources[]) {
|
|
74
|
-
if (Platform.OS === 'ios') {
|
|
75
|
-
const resourcePermStatuses = await this.get(resources);
|
|
76
|
-
for (let i = 0; i < resourcePermStatuses.length; i++) {
|
|
77
|
-
const resourcePermStatus = resourcePermStatuses[i];
|
|
78
|
-
if (resourcePermStatus === this.status['Not Determined']) {
|
|
79
|
-
await this.request([resources[i]]);
|
|
80
|
-
[resourcePermStatuses[i]] = await this.get([resources[i]]);
|
|
81
|
-
}
|
|
82
|
-
if (resourcePermStatuses[i] === this.status.Denied) {
|
|
83
|
-
Alert.alert(localize('RESOURCE_PERMISSION_REQUIRED'), undefined, [
|
|
84
|
-
{
|
|
85
|
-
style: 'cancel',
|
|
86
|
-
text: localize('CANCEL'),
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
style: 'default',
|
|
90
|
-
text: localize('SETTINGS'),
|
|
91
|
-
onPress: () => {
|
|
92
|
-
Linking.openSettings();
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
]);
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export const permissionUtilIOS = Object.freeze(new PermissionUtilIOS());
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { CometChatReactionsListInterface } from './CometChatReactionsList';
|
|
2
|
-
|
|
3
|
-
export interface ReactionsListConfigurationInterface extends Omit<CometChatReactionsListInterface,
|
|
4
|
-
'messageObject' | 'errorStateText'
|
|
5
|
-
> { }
|
|
6
|
-
|
|
7
|
-
export class ReactionsListConfiguration {
|
|
8
|
-
constructor(props: ReactionsListConfigurationInterface) {
|
|
9
|
-
if (props)
|
|
10
|
-
for (const [key, value] of Object.entries(props)) {
|
|
11
|
-
this[key] = value;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { CometChatReactionsList, CometChatReactionsListInterface } from './CometChatReactionsList';
|
|
2
|
-
import { ReactionListStyle, ReactionListStyleInterface } from './ReactionsListStyle';
|
|
3
|
-
import { ReactionsListConfiguration, ReactionsListConfigurationInterface } from './ReactionsListConfiguration';
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
CometChatReactionsList,
|
|
7
|
-
CometChatReactionsListInterface,
|
|
8
|
-
ReactionListStyle,
|
|
9
|
-
ReactionListStyleInterface,
|
|
10
|
-
ReactionsListConfiguration,
|
|
11
|
-
ReactionsListConfigurationInterface
|
|
12
|
-
}
|