@cometchat/chat-uikit-react-native 4.0.0 → 4.0.1
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/LICENSE.md +3 -0
- package/README.md +1 -1
- package/lib/AI/AIConversationStarter/AIConversationStarter.d.ts +12 -0
- package/lib/AI/AIConversationStarter/AIConversationStarter.js +31 -0
- package/lib/AI/AIConversationStarter/AIConversationStarter.js.map +1 -0
- package/lib/AI/AIConversationStarter/AIConversationStarterDecorator.d.ts +25 -0
- package/lib/AI/AIConversationStarter/AIConversationStarterDecorator.js +175 -0
- package/lib/AI/AIConversationStarter/AIConversationStarterDecorator.js.map +1 -0
- package/lib/AI/AIConversationStarter/AIConversationStarterStyle.d.ts +4 -0
- package/lib/AI/AIConversationStarter/AIConversationStarterStyle.js +8 -0
- package/lib/AI/AIConversationStarter/AIConversationStarterStyle.js.map +1 -0
- package/lib/AI/AIConversationStarter/configuration.d.ts +14 -0
- package/lib/AI/AIConversationStarter/configuration.js +16 -0
- package/lib/AI/AIConversationStarter/configuration.js.map +1 -0
- package/lib/AI/AIConversationStarter/style.d.ts +31 -0
- package/lib/AI/AIConversationStarter/style.js +62 -0
- package/lib/AI/AIConversationStarter/style.js.map +1 -0
- package/lib/AI/AIEnabler.d.ts +10 -0
- package/lib/AI/AIEnabler.js +102 -0
- package/lib/AI/AIEnabler.js.map +1 -0
- package/lib/AI/AIEnablerDecorator.d.ts +43 -0
- package/lib/AI/AIEnablerDecorator.js +251 -0
- package/lib/AI/AIEnablerDecorator.js.map +1 -0
- package/lib/AI/AIExtensionDataSource.d.ts +6 -0
- package/lib/AI/AIExtensionDataSource.js +10 -0
- package/lib/AI/AIExtensionDataSource.js.map +1 -0
- package/lib/AI/AISmartReplies/AISmartReplies.d.ts +10 -0
- package/lib/AI/AISmartReplies/AISmartReplies.js +23 -0
- package/lib/AI/AISmartReplies/AISmartReplies.js.map +1 -0
- package/lib/AI/AISmartReplies/AISmartRepliesDecorator.d.ts +7 -0
- package/lib/AI/AISmartReplies/AISmartRepliesDecorator.js +12 -0
- package/lib/AI/AISmartReplies/AISmartRepliesDecorator.js.map +1 -0
- package/lib/AI/AISmartReplies/AISmartRepliesStyle.d.ts +12 -0
- package/lib/AI/AISmartReplies/AISmartRepliesStyle.js +15 -0
- package/lib/AI/AISmartReplies/AISmartRepliesStyle.js.map +1 -0
- package/lib/AI/AISmartReplies/configuration.d.ts +14 -0
- package/lib/AI/AISmartReplies/configuration.js +16 -0
- package/lib/AI/AISmartReplies/configuration.js.map +1 -0
- package/lib/AI/CardView.d.ts +19 -0
- package/lib/AI/CardView.js +45 -0
- package/lib/AI/CardView.js.map +1 -0
- package/lib/AI/CardViewStyle.d.ts +29 -0
- package/lib/AI/CardViewStyle.js +36 -0
- package/lib/AI/CardViewStyle.js.map +1 -0
- package/lib/AI/configuration.d.ts +14 -0
- package/lib/AI/configuration.js +16 -0
- package/lib/AI/configuration.js.map +1 -0
- package/lib/AI/resources/index.d.ts +5 -0
- package/lib/AI/resources/index.js +6 -0
- package/lib/AI/resources/index.js.map +1 -0
- package/lib/AI/style.d.ts +115 -0
- package/lib/AI/style.js +139 -0
- package/lib/AI/style.js.map +1 -0
- package/lib/AI/utils.d.ts +38 -0
- package/lib/AI/utils.js +28 -0
- package/lib/AI/utils.js.map +1 -0
- package/lib/CometChatConversations/ConversationsConfiguration.d.ts +0 -1
- package/lib/CometChatDetails/DetailsConfiguration.d.ts +0 -1
- package/lib/CometChatGroupMembers/GroupMemberConfiguration.d.ts +0 -1
- package/lib/CometChatGroups/GroupsConfiguration.d.ts +0 -1
- package/lib/CometChatMessageComposer/CometChatMessageComposer.js +7 -1
- package/lib/CometChatMessageComposer/CometChatMessageComposer.js.map +1 -1
- package/lib/CometChatMessageHeader/MessageHeaderConfiguration.d.ts +0 -1
- package/lib/CometChatMessageList/CometChatMessageList.js +49 -18
- package/lib/CometChatMessageList/CometChatMessageList.js.map +1 -1
- package/lib/CometChatMessageList/MessageListConfiguration.d.ts +0 -1
- package/lib/CometChatMessages/MessagesConfiguration.d.ts +0 -1
- package/lib/CometChatTabs/TabItems.d.ts +0 -1
- package/lib/CometChatThreadedMessages/ThreadedMessagesConfiguration.d.ts +0 -1
- package/lib/calls/CometChatCallDetails/CallDetailsConfiguration.d.ts +0 -1
- package/lib/calls/CometChatCallHistory/CallHistoryConfiguration.d.ts +0 -1
- package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js +3 -3
- package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js.map +1 -1
- package/lib/extensions/ImageModeration/ImageModerationDecorator.d.ts +0 -1
- package/lib/extensions/ImageModeration/ImageModerationFilter.js +4 -4
- package/lib/extensions/ImageModeration/ImageModerationFilter.js.map +1 -1
- package/lib/extensions/LinkPreview/LinkPreviewExtentionDecorator.d.ts +0 -1
- package/lib/extensions/MessageTranslation/MessageTranslationDecorator.d.ts +0 -1
- package/lib/extensions/SmartReplies/SmartRepliesDecorator.js +1 -1
- package/lib/extensions/SmartReplies/SmartRepliesDecorator.js.map +1 -1
- package/lib/extensions/Stickers/StickersExtensionDecorator.d.ts +1 -1
- package/lib/extensions/Stickers/StickersExtensionDecorator.js +4 -2
- package/lib/extensions/Stickers/StickersExtensionDecorator.js.map +1 -1
- package/lib/extensions/TextModeration/TextModerationExtensionDecorator.d.ts +0 -1
- package/lib/index.d.ts +13 -0
- package/lib/index.js +14 -0
- package/lib/index.js.map +1 -1
- package/lib/shared/CometChatUiKit/CometChatUIKit.d.ts +2 -0
- package/lib/shared/CometChatUiKit/CometChatUIKit.js +13 -2
- package/lib/shared/CometChatUiKit/CometChatUIKit.js.map +1 -1
- package/lib/shared/CometChatUiKit/UIKitSettings.d.ts +5 -1
- package/lib/shared/CometChatUiKit/UIKitSettings.js +3 -1
- package/lib/shared/CometChatUiKit/UIKitSettings.js.map +1 -1
- package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js +2 -0
- package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js.map +1 -1
- package/lib/shared/events/CometChatUIEventHandler/Listener.d.ts +3 -1
- package/lib/shared/events/CometChatUIEventHandler/Listener.js +4 -1
- package/lib/shared/events/CometChatUIEventHandler/Listener.js.map +1 -1
- package/lib/shared/events/CometChatUIEvents.d.ts +2 -1
- package/lib/shared/events/CometChatUIEvents.js +1 -0
- package/lib/shared/events/CometChatUIEvents.js.map +1 -1
- package/lib/shared/framework/DataSource.d.ts +1 -2
- package/lib/shared/framework/DataSourceDecorator.d.ts +1 -2
- package/lib/shared/framework/DataSourceDecorator.js +2 -2
- package/lib/shared/framework/DataSourceDecorator.js.map +1 -1
- package/lib/shared/framework/MessageDataSource.d.ts +1 -1
- package/lib/shared/framework/MessageDataSource.js +2 -2
- package/lib/shared/framework/MessageDataSource.js.map +1 -1
- package/lib/shared/helper/types/index.d.ts +0 -1
- package/lib/shared/modals/CometChatDetailsOption.d.ts +0 -1
- package/lib/shared/modals/CometChatMessageOption.d.ts +0 -1
- package/lib/shared/modals/CometChatMessageTemplate.d.ts +0 -1
- package/lib/shared/resources/CometChatLocalize/CometChatLocalize.d.ts +230 -153
- package/lib/shared/resources/CometChatLocalize/resources/ar/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/de/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/en/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/es/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/fr/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/hi/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/lt/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/ms/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/pt/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/ru/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/sv/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/zh/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +4 -0
- package/package.json +3 -3
- package/src/AI/AIConversationStarter/AIConversationStarter.ts +33 -0
- package/src/AI/AIConversationStarter/AIConversationStarterDecorator.tsx +232 -0
- package/src/AI/AIConversationStarter/AIConversationStarterStyle.ts +8 -0
- package/src/AI/AIConversationStarter/configuration.ts +18 -0
- package/src/AI/AIConversationStarter/style.ts +76 -0
- package/src/AI/AIEnabler.ts +115 -0
- package/src/AI/AIEnablerDecorator.tsx +324 -0
- package/src/AI/AIExtensionDataSource.ts +12 -0
- package/src/AI/AISmartReplies/AISmartReplies.ts +28 -0
- package/src/AI/AISmartReplies/AISmartRepliesDecorator.ts +18 -0
- package/src/AI/AISmartReplies/AISmartRepliesStyle.ts +16 -0
- package/src/AI/AISmartReplies/configuration.ts +17 -0
- package/src/AI/CardView.tsx +81 -0
- package/src/AI/CardViewStyle.ts +37 -0
- package/src/AI/configuration.ts +17 -0
- package/src/AI/resources/ai-empty.png +0 -0
- package/src/AI/resources/ai-error.png +0 -0
- package/src/AI/resources/ai.png +0 -0
- package/src/AI/resources/index.ts +11 -0
- package/src/AI/resources/spineer.png +0 -0
- package/src/AI/style.ts +177 -0
- package/src/AI/utils.ts +39 -0
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +13 -4
- package/src/CometChatMessageList/CometChatMessageList.tsx +24 -17
- package/src/extensions/SmartReplies/SmartRepliesDecorator.tsx +1 -1
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +4 -2
- package/src/index.ts +15 -0
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +20 -7
- package/src/shared/CometChatUiKit/UIKitSettings.ts +8 -0
- package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +2 -0
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +5 -1
- package/src/shared/events/CometChatUIEvents.ts +1 -0
- package/src/shared/framework/DataSource.ts +1 -1
- package/src/shared/framework/DataSourceDecorator.tsx +2 -2
- package/src/shared/framework/MessageDataSource.tsx +2 -2
- package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/de/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/en/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/es/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +4 -0
- package/LICENSE +0 -21
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.4/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.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/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/.gitignore +0 -3
- package/android/.idea/gradle.xml +0 -13
- package/android/.idea/misc.xml +0 -9
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
- package/src/.DS_Store +0 -0
- package/src/CometChatMessageInformation/.DS_Store +0 -0
- package/src/calls/CometChatCallHistory/.DS_Store +0 -0
- package/src/shared/framework/.DS_Store +0 -0
- package/src/shared/views/.DS_Store +0 -0
- package/src/shared/views/CometChatAudioBubble/.DS_Store +0 -0
- package/src/shared/views/CometChatFileBubble/.DS_Store +0 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { ChatConfigurator, DataSource } from "../shared";
|
|
2
|
+
import { AIConversationStarterExtension } from "./AIConversationStarter/AIConversationStarter";
|
|
3
|
+
import { AIEnablerDecorator } from "./AIEnablerDecorator";
|
|
4
|
+
import { AIExtensionDataSource } from "./AIExtensionDataSource";
|
|
5
|
+
import { AISmartRepliesExtension } from "./AISmartReplies/AISmartReplies";
|
|
6
|
+
import {CometChat} from '@cometchat/chat-sdk-react-native'
|
|
7
|
+
import { AIEnablerConfiguration } from "./configuration";
|
|
8
|
+
export class AIEnabler extends AIExtensionDataSource {
|
|
9
|
+
defaultAIFeatures:AIExtensionDataSource[] | undefined;
|
|
10
|
+
configuration?:AIEnablerConfiguration = {}
|
|
11
|
+
constructor(defaultFeatures?:AIExtensionDataSource[], configuration?:AIEnablerConfiguration){
|
|
12
|
+
super()
|
|
13
|
+
this.configuration = configuration
|
|
14
|
+
this.defaultAIFeatures = defaultFeatures
|
|
15
|
+
}
|
|
16
|
+
override addExtension(): void {
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
override getExtensionId(): string {
|
|
20
|
+
return "ai-enabler";
|
|
21
|
+
}
|
|
22
|
+
override enable(): void {
|
|
23
|
+
let features = {}
|
|
24
|
+
if (this.defaultAIFeatures && this.defaultAIFeatures?.length >= 1) {
|
|
25
|
+
const promiseArray = this.defaultAIFeatures.map((feature) => {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
CometChat.isAIFeatureEnabled(feature.getExtensionId())
|
|
28
|
+
.then((response) => {
|
|
29
|
+
if (response) {
|
|
30
|
+
|
|
31
|
+
if (feature.getExtensionId() !== "conversation-starter") {
|
|
32
|
+
feature?.enable();
|
|
33
|
+
features[feature.getExtensionId()] = {
|
|
34
|
+
enabled: true,
|
|
35
|
+
configuration: feature.getConfiguration(),
|
|
36
|
+
enabler: feature,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
else{
|
|
40
|
+
feature.setConfiguration(this.configuration)
|
|
41
|
+
feature.enable();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
resolve(true);
|
|
45
|
+
})
|
|
46
|
+
.catch((err) => {
|
|
47
|
+
console.error(err);
|
|
48
|
+
reject(err);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
Promise.all(promiseArray)
|
|
54
|
+
.then(() => {
|
|
55
|
+
if (Object.keys(features).length > 0) {
|
|
56
|
+
ChatConfigurator.enable(
|
|
57
|
+
(dataSource: DataSource) =>
|
|
58
|
+
new AIEnablerDecorator(dataSource, features, this.configuration)
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
.catch((err) => {
|
|
63
|
+
console.error('An error occurred:', err);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
else if(this.defaultAIFeatures?.length == 0){
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
else{
|
|
70
|
+
let defaultFeatures: AIExtensionDataSource[] = [new AISmartRepliesExtension(), new AIConversationStarterExtension()];
|
|
71
|
+
|
|
72
|
+
const promiseArray = defaultFeatures.map((feature) => {
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
CometChat.isAIFeatureEnabled(feature.getExtensionId())
|
|
75
|
+
.then((response) => {
|
|
76
|
+
if (response) {
|
|
77
|
+
|
|
78
|
+
if (feature.getExtensionId() !== "conversation-starter") {
|
|
79
|
+
feature?.enable();
|
|
80
|
+
features[feature.getExtensionId()] = {
|
|
81
|
+
enabled: true,
|
|
82
|
+
configuration: feature.getConfiguration(),
|
|
83
|
+
enabler: feature,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
else{
|
|
87
|
+
feature.setConfiguration(this.configuration)
|
|
88
|
+
feature.enable();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
resolve(true);
|
|
92
|
+
})
|
|
93
|
+
.catch((err) => {
|
|
94
|
+
console.error(err);
|
|
95
|
+
reject(err);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
Promise.all(promiseArray)
|
|
101
|
+
.then(() => {
|
|
102
|
+
if (Object.keys(features).length > 0) {
|
|
103
|
+
ChatConfigurator.enable(
|
|
104
|
+
(dataSource: DataSource) =>
|
|
105
|
+
new AIEnablerDecorator(dataSource, features, this.configuration)
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
.catch((err) => {
|
|
110
|
+
console.error('An error occurred:', err);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
}
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
2
|
+
import { DataSourceDecorator, DataSource, CometChatTheme, CometChatUIEvents, localize, CometChatUIEventHandler, CometChatBottomSheet, FontStyleInterface, BorderStyleInterface, BaseStyle } from "../shared";
|
|
3
|
+
import { CometChatButton } from "../shared/views/CometChatButton";
|
|
4
|
+
|
|
5
|
+
import { CardView, Card } from "./CardView";
|
|
6
|
+
import { CardViewStyle } from "./CardViewStyle";
|
|
7
|
+
import { getRepliesWrapperStyle, getRepliesStyle, getCardViewStyle, getButtonStyles, getPopoverStyle, defaultViewStyle, viewContainerStyle, emptyLabelStyle, errorLabelStyle, getloadingStateStyle } from "./style";
|
|
8
|
+
import { ReceiverTypeConstants, ViewAlignment } from "../shared/constants/UIKitConstants";
|
|
9
|
+
import { Image, TouchableOpacity, View, Text, ScrollView, Keyboard } from "react-native";
|
|
10
|
+
import React, { useEffect, useRef, useState, JSX ,useContext} from "react";
|
|
11
|
+
import { AIBotIcon,loadingIcon,emptyIcon,errorIcon } from './resources';
|
|
12
|
+
import { CometChatContext } from "../shared/CometChatContext";
|
|
13
|
+
import { AIEnablerConfiguration } from "./configuration";
|
|
14
|
+
import { AIConfigurations, ICard, State } from "./utils";
|
|
15
|
+
import { AIConversationStarterConfiguration } from "./AIConversationStarter/configuration";
|
|
16
|
+
import { AISmartRepliesConfiguration } from "./AISmartReplies/configuration";
|
|
17
|
+
|
|
18
|
+
export class AIEnablerDecorator extends DataSourceDecorator {
|
|
19
|
+
smartReplyConfiguration: AISmartRepliesConfiguration = new AISmartRepliesConfiguration({});
|
|
20
|
+
conversationStarterConfiguration: AIConversationStarterConfiguration = new AIConversationStarterConfiguration({});
|
|
21
|
+
features?: AIConfigurations = {};
|
|
22
|
+
configuration?: AIEnablerConfiguration = new AIEnablerConfiguration({});
|
|
23
|
+
public newDataSource!: DataSource;
|
|
24
|
+
public showAiButton: boolean = false;
|
|
25
|
+
public theme!: CometChatTheme;
|
|
26
|
+
public id: any;
|
|
27
|
+
public user!: CometChat.User;
|
|
28
|
+
public group!: CometChat.Group;
|
|
29
|
+
public loggedInUser!: CometChat.User | null;
|
|
30
|
+
public cardViewStyle: CardViewStyle = {};
|
|
31
|
+
public buttonRef: any;
|
|
32
|
+
public setCallback: any;
|
|
33
|
+
public isPannelVisible:boolean = false;
|
|
34
|
+
public repliesView:JSX.Element;
|
|
35
|
+
public errorStateText:string = localize("SOMETHING_WRONG");
|
|
36
|
+
public emptyStateText:string = localize("NO_MESSAGES_FOUND");
|
|
37
|
+
public keyboardDidShowListener;
|
|
38
|
+
public keyboardDidHideListener;
|
|
39
|
+
onButtonClick = (id: string): void => {
|
|
40
|
+
if (id == "smart-replies") {
|
|
41
|
+
this.showDefaultPanel(State.loading)
|
|
42
|
+
this.getSmartReplies().then((replies) => {
|
|
43
|
+
if(!replies || (replies?.length && replies.length <= 0)){
|
|
44
|
+
this.showDefaultPanel(State.empty)
|
|
45
|
+
}
|
|
46
|
+
else{
|
|
47
|
+
this.repliesView = ( <View style={{ width: this.cardViewStyle?.width || "100%", height: this.cardViewStyle?.height || 200, backgroundColor: this.cardViewStyle?.backgroundColor, borderRadius:this.cardViewStyle?.borderRadius, ...this.cardViewStyle?.border, marginTop: 8 }}>
|
|
48
|
+
<ScrollView style={{ height: "100%", width: "100%" }}>
|
|
49
|
+
{replies}
|
|
50
|
+
</ScrollView>
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
</View>)
|
|
54
|
+
CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.showPanel, {
|
|
55
|
+
alignment: ViewAlignment.composerBottom,
|
|
56
|
+
child: () => this.repliesView,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
this.isPannelVisible = true
|
|
61
|
+
|
|
62
|
+
})
|
|
63
|
+
.catch((err) => {
|
|
64
|
+
this.showDefaultPanel(State.error,err)
|
|
65
|
+
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
public cardsData: ICard = {}
|
|
70
|
+
constructor(dataSource: DataSource, features?: AIConfigurations, configuration?: AIEnablerConfiguration) {
|
|
71
|
+
super(dataSource);
|
|
72
|
+
this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this.hideOnKeyboardShow);
|
|
73
|
+
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this.showOnKeyboardShow);
|
|
74
|
+
if (configuration) {
|
|
75
|
+
this.configuration = configuration;
|
|
76
|
+
}
|
|
77
|
+
this.newDataSource = dataSource;
|
|
78
|
+
this.features = features;
|
|
79
|
+
CometChat.getLoggedinUser().then(
|
|
80
|
+
(user: CometChat.User | null) => {
|
|
81
|
+
if (user) {
|
|
82
|
+
this.loggedInUser = user
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
getDataSource() {
|
|
88
|
+
return this.newDataSource;
|
|
89
|
+
}
|
|
90
|
+
getId(): string {
|
|
91
|
+
return "aienabler";
|
|
92
|
+
}
|
|
93
|
+
hideOnKeyboardShow = () => {
|
|
94
|
+
if(this.isPannelVisible){
|
|
95
|
+
CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, {
|
|
96
|
+
alignment: ViewAlignment.composerBottom,
|
|
97
|
+
child: () => (null),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
showOnKeyboardShow = () => {
|
|
102
|
+
if(this.isPannelVisible){
|
|
103
|
+
CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, {
|
|
104
|
+
alignment: ViewAlignment.composerBottom,
|
|
105
|
+
child: () => this.repliesView,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
editReply(reply: string) {
|
|
110
|
+
CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, {
|
|
111
|
+
alignment: ViewAlignment.composerBottom,
|
|
112
|
+
child: () => (null),
|
|
113
|
+
});
|
|
114
|
+
this.isPannelVisible = false;
|
|
115
|
+
CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.ccComposeMessage, { text: reply });
|
|
116
|
+
this.keyboardDidShowListener?.remove();
|
|
117
|
+
this.keyboardDidHideListener?.remove();
|
|
118
|
+
}
|
|
119
|
+
closeBottomsheet = () => {
|
|
120
|
+
if (this.setCallback) {
|
|
121
|
+
this.setCallback(false)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
getSmartReplies(): Promise<JSX.Element> {
|
|
126
|
+
return new Promise((resolve, reject) => {
|
|
127
|
+
let receiverId: string = this.user ? this.user?.getUid() : this.group?.getGuid();
|
|
128
|
+
let receiverType: string = this.user ? ReceiverTypeConstants.user : ReceiverTypeConstants.group;
|
|
129
|
+
if (this.smartReplyConfiguration?.customView) {
|
|
130
|
+
CometChat.getSmartReplies(receiverId, receiverType).then((response: any) => {
|
|
131
|
+
this.smartReplyConfiguration.customView(response, this.closeBottomsheet).then((res)=>{
|
|
132
|
+
return resolve((<View>{res}</View>))
|
|
133
|
+
|
|
134
|
+
})
|
|
135
|
+
.catch((err: CometChat.CometChatException) => {
|
|
136
|
+
return reject(err)
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
})
|
|
140
|
+
.catch((err: CometChat.CometChatException) => {
|
|
141
|
+
return reject(err)
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
else if (this.smartReplyConfiguration?.onClick) {
|
|
145
|
+
this.smartReplyConfiguration?.onClick(this.user, this.group).then((response: any) => {
|
|
146
|
+
return resolve((<View>{response}</View>))
|
|
147
|
+
})
|
|
148
|
+
.catch((err: CometChat.CometChatException) => {
|
|
149
|
+
return reject(err)
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
CometChat.getSmartReplies(receiverId, receiverType).then((response: any) => {
|
|
155
|
+
let view: JSX.Element[] = []
|
|
156
|
+
Object.keys(response).forEach((reply) => {
|
|
157
|
+
if (response[reply] && response[reply] != "") {
|
|
158
|
+
view.push(
|
|
159
|
+
(<TouchableOpacity
|
|
160
|
+
style={getRepliesWrapperStyle(this.theme, this.smartReplyConfiguration?.smartRepliesStyle, this.configuration?.listItemStyle)}
|
|
161
|
+
key={response[reply]} // Make sure to set a unique key for each item
|
|
162
|
+
onPress={() => this.editReply(response[reply])}
|
|
163
|
+
>
|
|
164
|
+
<Text style={getRepliesStyle(this.theme, this.smartReplyConfiguration?.smartRepliesStyle, this.configuration?.listItemStyle)}>{response[reply]}</Text>
|
|
165
|
+
</TouchableOpacity>)
|
|
166
|
+
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
})
|
|
173
|
+
return resolve((<View>{view}</View>))
|
|
174
|
+
|
|
175
|
+
})
|
|
176
|
+
.catch((err: CometChat.CometChatException) => {
|
|
177
|
+
return reject(err)
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
showDefaultPanel(state:State = State.loading, error?:CometChat.CometChatException) {
|
|
186
|
+
this.closeBottomsheet()
|
|
187
|
+
let LoadingView:JSX.Element = this.smartReplyConfiguration?.LoadingStateView || this.configuration.LoadingStateView
|
|
188
|
+
let EmptyView:JSX.Element = this.smartReplyConfiguration?.EmptyStateView || this.configuration.EmptyStateView
|
|
189
|
+
let ErrorView:JSX.Element = this.smartReplyConfiguration?.ErrorStateView || this.configuration.ErrorStateView
|
|
190
|
+
|
|
191
|
+
CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.showPanel, {
|
|
192
|
+
alignment: ViewAlignment.composerBottom,
|
|
193
|
+
child: () => (
|
|
194
|
+
<View style={{ width: this.cardViewStyle?.width || "100%", height: this.cardViewStyle?.height || 160, backgroundColor: this.cardViewStyle?.backgroundColor, borderRadius:this.cardViewStyle?.borderRadius, ...this.cardViewStyle?.border, justifyContent: "center", alignItems: "center" }}>
|
|
195
|
+
{state == State.loading ? LoadingView ? <LoadingView/> : <View style={{ width: this.cardViewStyle?.width || "100%", height: this.cardViewStyle?.height || 160, backgroundColor: this.cardViewStyle?.backgroundColor, borderRadius:this.cardViewStyle?.borderRadius, ...this.cardViewStyle?.border, justifyContent: "center", alignItems: "center" }}>
|
|
196
|
+
<Image
|
|
197
|
+
source={this.configuration?.loadingIconURL ?? loadingIcon}
|
|
198
|
+
style={{ height: 32, width: 32,tintColor:this.cardViewStyle?.loadingIconTint}}
|
|
199
|
+
/>
|
|
200
|
+
<Text style={getloadingStateStyle(this.theme,this.cardViewStyle, this.smartReplyConfiguration?.smartRepliesStyle)}> {localize("GENERATING_REPLIES")}</Text>
|
|
201
|
+
</View>
|
|
202
|
+
|
|
203
|
+
:
|
|
204
|
+
|
|
205
|
+
state == State.empty ?
|
|
206
|
+
EmptyView ? <EmptyView/> : <View style={{ width: this.cardViewStyle?.width || "100%", height: this.cardViewStyle?.height || 160, backgroundColor: this.cardViewStyle?.backgroundColor, borderRadius:this.cardViewStyle?.borderRadius, ...this.cardViewStyle?.border, justifyContent: "center", alignItems: "center" }}>
|
|
207
|
+
<Image
|
|
208
|
+
source={this.configuration?.emptyIconURL ?? emptyIcon}
|
|
209
|
+
style={{ height: 32, width: 32,tintColor:this.cardViewStyle?.emptyIconTint}}
|
|
210
|
+
/>
|
|
211
|
+
<Text style={emptyLabelStyle(this.cardViewStyle,this.smartReplyConfiguration.smartRepliesStyle)} > {this.emptyStateText}</Text>
|
|
212
|
+
</View>
|
|
213
|
+
: ErrorView ? ErrorView(error) :
|
|
214
|
+
<View style={{ width: this.cardViewStyle?.width || "100%", height: this.cardViewStyle?.height || 160, backgroundColor: this.cardViewStyle?.backgroundColor, borderRadius:this.cardViewStyle?.borderRadius, ...this.cardViewStyle?.border, justifyContent: "center", alignItems: "center" }}>
|
|
215
|
+
<Image
|
|
216
|
+
source={this.configuration?.errorIconURL ?? errorIcon}
|
|
217
|
+
style={{ height: 32, width: 32,tintColor:this.cardViewStyle?.errorIconTint}}
|
|
218
|
+
/>
|
|
219
|
+
<Text style={errorLabelStyle(this.cardViewStyle,this.smartReplyConfiguration.smartRepliesStyle)} >{this.errorStateText}</Text>
|
|
220
|
+
</View>
|
|
221
|
+
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
</View>
|
|
226
|
+
|
|
227
|
+
),
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
this.isPannelVisible = true;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
getAuxiliaryOptions(user?: CometChat.User, group?: CometChat.Group, id?: Map<string, any>, theme?: CometChatTheme) {
|
|
235
|
+
let contextTheme = useContext(CometChatContext)
|
|
236
|
+
if(contextTheme?.theme){
|
|
237
|
+
this.theme = contextTheme.theme
|
|
238
|
+
}
|
|
239
|
+
else{
|
|
240
|
+
this.theme = theme || new CometChatTheme({});
|
|
241
|
+
}
|
|
242
|
+
this.cardViewStyle = getCardViewStyle(this.theme, this.configuration?.listStyle,this.smartReplyConfiguration.smartRepliesStyle);
|
|
243
|
+
this.id = id;
|
|
244
|
+
this.user = user!;
|
|
245
|
+
this.group = group!;
|
|
246
|
+
let auxiliaryOptions = super.getAuxiliaryOptions(user, group, id, theme);
|
|
247
|
+
this.cardsData = {
|
|
248
|
+
smartReply: {
|
|
249
|
+
title: localize("SUGGEST_A_REPLIES"),
|
|
250
|
+
onClick: this.onButtonClick,
|
|
251
|
+
id: "smart-replies",
|
|
252
|
+
style: getButtonStyles(this.theme, this.smartReplyConfiguration?.smartRepliesStyle, this.configuration?.listItemStyle)
|
|
253
|
+
|
|
254
|
+
},
|
|
255
|
+
conversationStarter: {
|
|
256
|
+
title: "Conversation Starter",
|
|
257
|
+
onClick: this.onButtonClick,
|
|
258
|
+
id: "conversation-starter",
|
|
259
|
+
style: getButtonStyles(this.theme, this.conversationStarterConfiguration?.conversationStarterStyle)
|
|
260
|
+
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
if (!(id as any).parentMessageId || Number((id as any).parentMessageId) <= 0 || (id as any).parentMessageId == undefined) {
|
|
267
|
+
|
|
268
|
+
auxiliaryOptions.unshift(this.getAIAuxiliaryButton(id, user, group, theme));
|
|
269
|
+
}
|
|
270
|
+
return auxiliaryOptions;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
getAIAuxiliaryButton(id: Map<string, any>, user?: CometChat.User, group?: CometChat.Group, theme?: CometChatTheme): JSX.Element {
|
|
274
|
+
const [aiFeatures, setAiFeatures] = useState(false);
|
|
275
|
+
let cards: Card[] = []
|
|
276
|
+
this.setCallback = setAiFeatures
|
|
277
|
+
if (this.features && Object.keys(this.features).length > 0) {
|
|
278
|
+
|
|
279
|
+
if (this.features?.["smart-replies"]?.enabled) {
|
|
280
|
+
this.smartReplyConfiguration = this.features?.["smart-replies"]?.configuration ?? new AISmartRepliesConfiguration({})
|
|
281
|
+
cards.push(this.cardsData.smartReply!)
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return (<TouchableOpacity onPress={() => {
|
|
288
|
+
CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, {
|
|
289
|
+
alignment: ViewAlignment.composerBottom,
|
|
290
|
+
child: () => (null),
|
|
291
|
+
});
|
|
292
|
+
if(this.isPannelVisible){
|
|
293
|
+
setAiFeatures(false);
|
|
294
|
+
this.isPannelVisible = false;
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
setAiFeatures(true);
|
|
298
|
+
|
|
299
|
+
}} style={{ justifyContent: "center" }}>
|
|
300
|
+
<Image
|
|
301
|
+
source={this.configuration?.buttonIconURL || AIBotIcon}
|
|
302
|
+
style={{ height: 32, width: 32, marginLeft: 8, marginRight: 8 , color:'red'}}
|
|
303
|
+
/>
|
|
304
|
+
{
|
|
305
|
+
<CometChatBottomSheet
|
|
306
|
+
isOpen={aiFeatures}
|
|
307
|
+
sliderMaxHeight={this.cardViewStyle?.height || 350}
|
|
308
|
+
onClose={() => {
|
|
309
|
+
setAiFeatures(false)
|
|
310
|
+
}}
|
|
311
|
+
|
|
312
|
+
>
|
|
313
|
+
<CardView
|
|
314
|
+
cardViewStyle={this.cardViewStyle}
|
|
315
|
+
buttons={cards}
|
|
316
|
+
/>
|
|
317
|
+
</CometChatBottomSheet>
|
|
318
|
+
}
|
|
319
|
+
</TouchableOpacity>)
|
|
320
|
+
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
}
|
|
324
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ExtensionsDataSource } from "../shared/framework/ExtensionsDataSource";
|
|
2
|
+
import { AIEnablerConfiguration } from "./configuration";
|
|
3
|
+
|
|
4
|
+
export abstract class AIExtensionDataSource extends ExtensionsDataSource {
|
|
5
|
+
getConfiguration():any{
|
|
6
|
+
|
|
7
|
+
};
|
|
8
|
+
setConfiguration(config?:AIEnablerConfiguration):void{
|
|
9
|
+
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AISmartRepliesExtensionDecorator } from "./AISmartRepliesDecorator";
|
|
2
|
+
import { ChatConfigurator } from "../../shared";
|
|
3
|
+
import { AIExtensionDataSource } from "../AIExtensionDataSource";
|
|
4
|
+
import { AISmartRepliesConfiguration } from "./configuration";
|
|
5
|
+
export class AISmartRepliesExtension extends AIExtensionDataSource {
|
|
6
|
+
|
|
7
|
+
private configuration?: AISmartRepliesConfiguration;
|
|
8
|
+
|
|
9
|
+
constructor(configuration?: AISmartRepliesConfiguration) {
|
|
10
|
+
super();
|
|
11
|
+
this.configuration = configuration;
|
|
12
|
+
}
|
|
13
|
+
override addExtension(): void {
|
|
14
|
+
ChatConfigurator.enable((dataSource: any) => new AISmartRepliesExtensionDecorator(dataSource,this.configuration));
|
|
15
|
+
}
|
|
16
|
+
override getExtensionId(): string {
|
|
17
|
+
return "smart-replies";
|
|
18
|
+
}
|
|
19
|
+
override enable(): void {
|
|
20
|
+
this.addExtension()
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
override getConfiguration():AISmartRepliesConfiguration{
|
|
24
|
+
return this.configuration;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DataSource,DataSourceDecorator } from "../../shared";
|
|
2
|
+
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
3
|
+
import { AIButtonsStyle } from "../utils";
|
|
4
|
+
import { AISmartRepliesConfiguration } from "./configuration";
|
|
5
|
+
export class AISmartRepliesExtensionDecorator extends DataSourceDecorator {
|
|
6
|
+
public configuration?:AISmartRepliesConfiguration;
|
|
7
|
+
constructor(dataSource:DataSource,configuration?:AISmartRepliesConfiguration){
|
|
8
|
+
super(dataSource);
|
|
9
|
+
this.configuration = configuration;
|
|
10
|
+
}
|
|
11
|
+
override getId(): string {
|
|
12
|
+
return "aismartreply";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FontStyleInterface, BorderStyleInterface } from "../../shared";
|
|
2
|
+
import { AIButtonsStyle } from "../utils";
|
|
3
|
+
|
|
4
|
+
export class AISmartRepliesStyle extends AIButtonsStyle {
|
|
5
|
+
buttonTextColor?:string;
|
|
6
|
+
buttonTextFont?:FontStyleInterface;
|
|
7
|
+
buttonBorder?:BorderStyleInterface;
|
|
8
|
+
buttonBorderRadius?:string;
|
|
9
|
+
buttonHeight?:string;
|
|
10
|
+
buttonWidth?:string;
|
|
11
|
+
buttonBackgroundColor?:string;
|
|
12
|
+
constructor(props: Partial<AIButtonsStyle>) {
|
|
13
|
+
super({...props})
|
|
14
|
+
Object.assign(this, props);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {CometChat} from '@cometchat/chat-sdk-react-native'
|
|
2
|
+
import { AISmartRepliesStyle } from './AISmartRepliesStyle';
|
|
3
|
+
import { loadingIcon, errorIcon, emptyIcon } from '../resources';
|
|
4
|
+
export class AISmartRepliesConfiguration {
|
|
5
|
+
onClick?:(user?:CometChat.User,group?:CometChat.Group)=>Promise<Object>;
|
|
6
|
+
smartRepliesStyle?:AISmartRepliesStyle;
|
|
7
|
+
customView?:(response:Object,closeBottomsheet?:()=>void) => Promise<Object>;
|
|
8
|
+
ErrorStateView?: (e?: CometChat.CometChatException) => JSX.Element;
|
|
9
|
+
EmptyStateView?: () => JSX.Element;
|
|
10
|
+
LoadingStateView?: () => JSX.Element;
|
|
11
|
+
loadingIconURL?:string = loadingIcon;
|
|
12
|
+
errorIconURL?:string = errorIcon;
|
|
13
|
+
emptyIconURL?:string = emptyIcon;
|
|
14
|
+
constructor(props: Partial<AISmartRepliesConfiguration>) {
|
|
15
|
+
Object.assign(this, props);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { contentContainerStyle, getButtonStyles, getPopoverStyle } from './style';
|
|
3
|
+
import { CardViewStyle } from './CardViewStyle';
|
|
4
|
+
import { CometChatTheme } from '../shared';
|
|
5
|
+
import { TouchableOpacity,Text,ScrollView } from 'react-native';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { View } from 'react-native';
|
|
8
|
+
import { AIButtonsStyle } from './utils';
|
|
9
|
+
export type Card = {
|
|
10
|
+
title?: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
onClick?: (id: string) => void;
|
|
13
|
+
style?:AIButtonsStyle;
|
|
14
|
+
};
|
|
15
|
+
interface CardProps {
|
|
16
|
+
buttons?: Card[];
|
|
17
|
+
backCallback?:(callback:()=>void) => void;
|
|
18
|
+
cardViewStyle?:CardViewStyle;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const defaultProps:CardProps = {
|
|
22
|
+
buttons: undefined,
|
|
23
|
+
backCallback:undefined,
|
|
24
|
+
cardViewStyle:undefined
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
export const CardView = (props:CardProps) => {
|
|
29
|
+
const [currentSection, setCurrentSection] = useState<string | null>(null);
|
|
30
|
+
|
|
31
|
+
function fetchButtonContent(button:Card){
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
setCurrentSection(button?.id!)
|
|
35
|
+
if(button && button.onClick){
|
|
36
|
+
button.onClick(button.id!)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
function getButtons():JSX.Element | null{
|
|
43
|
+
return (
|
|
44
|
+
<View style={{
|
|
45
|
+
width:"100%",
|
|
46
|
+
backgroundColor: "transparent",
|
|
47
|
+
}}>
|
|
48
|
+
{props.buttons.map(item => (
|
|
49
|
+
<TouchableOpacity
|
|
50
|
+
key={item.id} // Make sure to set a unique key for each item
|
|
51
|
+
onPress={() => fetchButtonContent(item)}
|
|
52
|
+
|
|
53
|
+
>
|
|
54
|
+
<Text style={getButtonStyles(new CometChatTheme({}),item?.style)}>{item.title}</Text>
|
|
55
|
+
</TouchableOpacity>
|
|
56
|
+
|
|
57
|
+
))}
|
|
58
|
+
</View>)
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<View style={getPopoverStyle(props.cardViewStyle)}>
|
|
64
|
+
|
|
65
|
+
<View style={contentContainerStyle}>
|
|
66
|
+
{!currentSection && props.buttons && (
|
|
67
|
+
<ScrollView style={{height:"100%",width:"100%"}}>
|
|
68
|
+
|
|
69
|
+
{ getButtons()}
|
|
70
|
+
</ScrollView>
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
)}
|
|
74
|
+
|
|
75
|
+
</View>
|
|
76
|
+
</View>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
CardView.defaultProps = defaultProps
|
|
81
|
+
export default CardView;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BaseStyle, BorderStyleInterface, FontStyleInterface } from "../shared";
|
|
2
|
+
|
|
3
|
+
export class CardViewStyle extends BaseStyle{
|
|
4
|
+
emptyStateTextFont?: FontStyleInterface;
|
|
5
|
+
emptyStateTextColor?: string = "#bcbcbc";
|
|
6
|
+
errorStateTextFont?: FontStyleInterface;
|
|
7
|
+
errorStateTextColor?: string = "#bcbcbc";
|
|
8
|
+
loadingStateTextFont?: FontStyleInterface;
|
|
9
|
+
loadingStateTextColor?: string = "#bcbcbc";
|
|
10
|
+
loadingIconTint?: string = "#bcbcbc";
|
|
11
|
+
errorIconTint?: string = "#bcbcbc";
|
|
12
|
+
emptyIconTint?: string = "#bcbcbc";
|
|
13
|
+
boxShadow?:string;
|
|
14
|
+
constructor(props: Partial<CardViewStyle>) {
|
|
15
|
+
super({})
|
|
16
|
+
Object.assign(this, props);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class CardStyle extends BaseStyle{
|
|
21
|
+
buttonTextColor?:string;
|
|
22
|
+
buttonTextFont?:FontStyleInterface;
|
|
23
|
+
buttonBorder?:BorderStyleInterface;
|
|
24
|
+
buttonBorderRadius?:string;
|
|
25
|
+
buttonHeight?:string;
|
|
26
|
+
buttonWidth?:string;
|
|
27
|
+
buttonBackgroundColor?:string;
|
|
28
|
+
repliesTextFont?:FontStyleInterface;
|
|
29
|
+
repliesTextBorder?:BorderStyleInterface;
|
|
30
|
+
repliesTextBorderRadius?:string;
|
|
31
|
+
repliesTextColor?:string;
|
|
32
|
+
repliesTextBackgroundColor?:string;
|
|
33
|
+
constructor(props: Partial<CardViewStyle>) {
|
|
34
|
+
super({})
|
|
35
|
+
Object.assign(this, props);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CardStyle, CardViewStyle } from "./CardViewStyle";
|
|
2
|
+
import {CometChat} from '@cometchat/chat-sdk-react-native'
|
|
3
|
+
import { emptyIcon, errorIcon, loadingIcon } from "./resources";
|
|
4
|
+
export class AIEnablerConfiguration {
|
|
5
|
+
listStyle?: CardViewStyle;
|
|
6
|
+
listItemStyle?:CardStyle;
|
|
7
|
+
buttonIconURL?: string = "";
|
|
8
|
+
ErrorStateView?: (e?: CometChat.CometChatException) => JSX.Element;
|
|
9
|
+
EmptyStateView?: () => JSX.Element;
|
|
10
|
+
LoadingStateView?: () => JSX.Element;
|
|
11
|
+
loadingIconURL?:string = loadingIcon;
|
|
12
|
+
errorIconURL?:string = errorIcon;
|
|
13
|
+
emptyIconURL?:string = emptyIcon;
|
|
14
|
+
constructor(props: Partial<AIEnablerConfiguration>) {
|
|
15
|
+
Object.assign(this, props);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|