From d9dffcb1c741b523fbfc7ce16dfbeddb528c0532 Mon Sep 17 00:00:00 2001 From: Rohit Ninawe Date: Tue, 4 Jun 2024 15:32:25 +0530 Subject: [PATCH] v4.1.0 --- README.md | 2 +- package.json | 6 +- src/AI/AIAssistBot/AIAssistBotDecorator.tsx | 164 ++++++ src/AI/AIAssistBot/AIAssistBotExtension.tsx | 22 + src/AI/AIAssistBot/AIAssistBotStyle.ts | 43 ++ src/AI/AIAssistBot/AIAssistBotView.tsx | 294 +++++++++++ src/AI/AIAssistBot/configuration.ts | 22 + .../AIAssistBot}/resources/CloseIcon.png | Bin src/AI/AIAssistBot/resources/index.ts | 5 + ...onfiguration.ts => AIBaseConfiguration.ts} | 9 +- src/AI/AIBaseStyle.ts | 58 +++ .../AIConversationStarter.ts | 24 +- .../AIConversationStarterDecorator.tsx | 274 +++++----- .../AIConversationStarterStyle.ts | 17 +- src/AI/AIConversationStarter/configuration.ts | 27 +- .../AIConversationSummaryDecorator.tsx | 175 +++++++ .../AIConversationSummaryExtension.ts | 21 + .../AIConversationSummaryStyle.tsx | 20 + .../AIConversationSummaryView.tsx | 190 +++++++ src/AI/AIConversationSummary/configuration.ts | 14 + .../AIConversationSummary/resources/close.png | Bin 0 -> 307 bytes .../AIConversationSummary/resources/index.ts | 5 + src/AI/AIEnabler.ts | 115 ----- src/AI/AIEnablerDecorator.tsx | 324 ------------ src/AI/AIExtensionDataSource.ts | 29 +- src/AI/AIOptionsStyle.ts | 14 + src/AI/AISmartReplies/AISmartReplies.ts | 21 +- .../AISmartReplies/AISmartRepliesDecorator.ts | 18 - .../AISmartRepliesDecorator.tsx | 302 +++++++++++ src/AI/AISmartReplies/AISmartRepliesStyle.ts | 2 +- src/AI/AISmartReplies/configuration.ts | 15 +- src/AI/resources/index.ts | 2 - src/AI/utils.ts | 6 +- .../CometChatMessageComposer.tsx | 123 ++++- .../MessageComposerConfiguration.tsx | 3 + .../resources/ai.png | Bin .../resources/index.ts | 2 + src/CometChatMessageComposer/styles.ts | 5 +- .../CometChatMessageList.tsx | 57 ++- src/CometChatMessages/CometChatMessages.tsx | 17 +- .../MessagesConfiguration.ts | 4 +- src/calls/CallUtils.ts | 151 ++++-- src/calls/CallingDetailsUtils.tsx | 148 +++++- src/calls/CallingPackage.ts | 18 +- .../CometChatCallButtons.tsx | 19 +- .../CallDetailsConfiguration.ts | 68 --- .../CometChatCallDetails/CallDetailsStyle.ts | 52 -- .../CometChatCallDetails.tsx | 268 ---------- src/calls/CometChatCallDetails/index.ts | 9 - .../CometChatCallHistory/CallHistoryStyle.ts | 34 -- .../CometChatCallHistory.tsx | 422 --------------- src/calls/CometChatCallHistory/index.ts | 9 - .../CometChatCallHistory/resources/index.ts | 17 - .../HistoryWithDetailsConfiguration.ts | 7 - .../HistoryWithDetailsStyle.ts | 3 - .../CometChatCallHistoryWithDetails/index.ts | 8 - .../CallLogDetailsConfiguration.ts | 116 +++++ .../CallLogDetailsStyle.ts | 36 ++ .../CometChatCallLogDetails.tsx | 308 +++++++++++ src/calls/CometChatCallLogDetails/index.ts | 12 + .../resources/CloseIcon.png | Bin 0 -> 650 bytes .../resources/index.ts | 0 .../style.ts | 1 + .../CallLogHistoryConfiguration.ts} | 42 +- .../CallLogHistoryStyle.ts | 46 ++ .../CometChatCallLogHistory.tsx | 337 ++++++++++++ src/calls/CometChatCallLogHistory/index.ts | 12 + .../resources/Back.png | Bin .../resources/Call.png | Bin .../resources/Info.png | Bin .../resources/Selection.png | Bin .../resources/Spineer.png | Bin .../resources/Video.png | Bin .../resources/check.png | Bin .../resources/incomingcall.png | Bin 0 -> 325 bytes .../resources/incomingvideo.png | Bin 0 -> 373 bytes .../resources/index.ts | 29 ++ .../resources/missedcall.png | Bin 0 -> 342 bytes .../resources/missedvideo.png | Bin 0 -> 413 bytes .../resources/outgoingcall.png | Bin 0 -> 324 bytes .../resources/outgoingvideo.png | Bin 0 -> 382 bytes .../style.ts | 3 +- .../CallLogParticipantsConfiguration.ts | 61 +++ .../CallLogParticipantsStyle.ts | 59 +++ .../CometChatCallLogParticipants.tsx | 220 ++++++++ .../CometChatCallLogParticipants/index.ts | 12 + .../resources/Back.png | Bin 0 -> 346 bytes .../resources/index.ts | 4 + .../CometChatCallLogParticipants/style.ts | 24 + .../CallLogRecordingsConfiguration.ts | 63 +++ .../CallLogRecordingsStyle.ts | 63 +++ .../CometChatCallLogRecordings.tsx | 253 +++++++++ src/calls/CometChatCallLogRecordings/index.ts | 12 + .../resources/Back.png | Bin 0 -> 346 bytes .../resources/download.png | Bin 0 -> 331 bytes .../resources/index.ts | 6 + src/calls/CometChatCallLogRecordings/style.ts | 24 + .../CallLogsConfiguration.ts | 87 ++++ src/calls/CometChatCallLogs/CallLogsStyle.ts | 95 ++++ .../CometChatCallLogs/CometChatCallLogs.tsx | 482 ++++++++++++++++++ src/calls/CometChatCallLogs/index.ts | 12 + .../CometChatCallLogs/resources/Back.png | Bin 0 -> 346 bytes .../CometChatCallLogs/resources/Info.png | Bin 0 -> 564 bytes .../CometChatCallLogs/resources/Selection.png | Bin 0 -> 381 bytes .../CometChatCallLogs/resources/Spinner.png | Bin 0 -> 1271 bytes .../CometChatCallLogs/resources/check.png | Bin 0 -> 1440 bytes .../resources/incomingcall.png | Bin 0 -> 325 bytes .../resources/incomingvideo.png | Bin 0 -> 373 bytes .../CometChatCallLogs/resources/index.ts | 25 + .../resources/missedcall.png | Bin 0 -> 342 bytes .../resources/missedvideo.png | Bin 0 -> 413 bytes .../resources/outgoingcall.png | Bin 0 -> 324 bytes .../resources/outgoingvideo.png | Bin 0 -> 382 bytes src/calls/CometChatCallLogs/style.ts | 24 + .../CallLogsWithDetailsConfiguration.ts | 9 + .../CometChatCallLogsWithDetails.tsx} | 33 +- .../CometChatCallLogsWithDetails/index.ts | 7 + .../style.ts | 0 src/calls/index.ts | 41 +- src/calls/resources/index.ts | 4 +- src/calls/resources/nextarrow.png | Bin 0 -> 227 bytes .../SmartReplies/SmartRepliesDecorator.tsx | 8 +- .../Stickers/StickersExtensionDecorator.tsx | 2 +- .../ThumbnailGenerationDecorator.tsx | 8 +- .../ThumbnailGeneration/resources/empty.png | Bin 0 -> 70 bytes .../ThumbnailGeneration/resources/index.ts | 5 + src/index.ts | 83 ++- src/shared/CometChatUiKit/CometChatUIKit.ts | 284 ++++++----- src/shared/CometChatUiKit/UIKitSettings.ts | 4 +- .../CometChatUIEventHandler.ts | 2 +- src/shared/framework/DataSource.ts | 4 + src/shared/framework/DataSourceDecorator.tsx | 5 + src/shared/framework/MessageDataSource.tsx | 5 +- src/shared/index.ts | 4 + .../modals/CometChatCallLogDetailsOptions.ts | 23 + .../modals/CometChatCallLogDetailsTemplate.ts | 16 + src/shared/modals/index.ts | 6 +- .../resources/ar/translation.json | 24 +- .../resources/de/translation.json | 24 +- .../resources/en/translation.json | 28 +- .../resources/es/translation.json | 24 +- .../resources/fr/translation.json | 24 +- .../resources/hi/translation.json | 24 +- .../resources/lt/translation.json | 24 +- .../resources/ms/translation.json | 24 +- .../resources/pt/translation.json | 24 +- .../resources/ru/translation.json | 24 +- .../resources/sv/translation.json | 24 +- .../resources/zh-tw/translation.json | 24 +- .../resources/zh/translation.json | 23 +- .../resources/CometChatTheme/Palette.ts | 16 + .../utils/DetailsUtils/DetailsUtils.tsx | 2 +- .../views/CometChatAICard/CometChatAICard.tsx | 71 +++ .../resources/errormessage.png | Bin 0 -> 1293 bytes .../views/CometChatAICard/resources/index.ts | 4 + .../CometChatAICard/resources/nomessage.png | Bin 0 -> 1329 bytes .../CometChatActionSheet/ActionSheetStyle.ts | 4 + .../CometChatActionSheet.tsx | 18 +- .../CometChatBottomSheet.tsx | 103 ++-- .../views/CometChatBottomSheet/style.ts | 2 - .../views/CometChatDate/CometChatDate.tsx | 10 +- .../views/CometChatDate/DateConfiguration.ts | 4 + src/shared/views/CometChatDate/style.ts | 2 +- .../CometChatListItem/CometChatListItem.tsx | 50 +- .../CometChatMessageInput.tsx | 3 +- .../views/CometChatPanel/CometChatPanel.tsx | 51 ++ .../views/CometChatPanel/PanelStyle.tsx | 43 ++ .../CometChatPanel/resources/CloseIcon.png | Bin 0 -> 650 bytes .../views/CometChatPanel/resources/index.ts | 5 + 169 files changed, 5366 insertions(+), 2042 deletions(-) create mode 100644 src/AI/AIAssistBot/AIAssistBotDecorator.tsx create mode 100644 src/AI/AIAssistBot/AIAssistBotExtension.tsx create mode 100644 src/AI/AIAssistBot/AIAssistBotStyle.ts create mode 100644 src/AI/AIAssistBot/AIAssistBotView.tsx create mode 100644 src/AI/AIAssistBot/configuration.ts rename src/{calls/CometChatCallDetails => AI/AIAssistBot}/resources/CloseIcon.png (100%) create mode 100644 src/AI/AIAssistBot/resources/index.ts rename src/AI/{configuration.ts => AIBaseConfiguration.ts} (63%) create mode 100644 src/AI/AIBaseStyle.ts create mode 100644 src/AI/AIConversationSummary/AIConversationSummaryDecorator.tsx create mode 100644 src/AI/AIConversationSummary/AIConversationSummaryExtension.ts create mode 100644 src/AI/AIConversationSummary/AIConversationSummaryStyle.tsx create mode 100644 src/AI/AIConversationSummary/AIConversationSummaryView.tsx create mode 100644 src/AI/AIConversationSummary/configuration.ts create mode 100644 src/AI/AIConversationSummary/resources/close.png create mode 100644 src/AI/AIConversationSummary/resources/index.ts delete mode 100755 src/AI/AIEnabler.ts delete mode 100755 src/AI/AIEnablerDecorator.tsx create mode 100644 src/AI/AIOptionsStyle.ts delete mode 100755 src/AI/AISmartReplies/AISmartRepliesDecorator.ts create mode 100755 src/AI/AISmartReplies/AISmartRepliesDecorator.tsx rename src/{AI => CometChatMessageComposer}/resources/ai.png (100%) delete mode 100644 src/calls/CometChatCallDetails/CallDetailsConfiguration.ts delete mode 100644 src/calls/CometChatCallDetails/CallDetailsStyle.ts delete mode 100644 src/calls/CometChatCallDetails/CometChatCallDetails.tsx delete mode 100644 src/calls/CometChatCallDetails/index.ts delete mode 100644 src/calls/CometChatCallHistory/CallHistoryStyle.ts delete mode 100644 src/calls/CometChatCallHistory/CometChatCallHistory.tsx delete mode 100644 src/calls/CometChatCallHistory/index.ts delete mode 100644 src/calls/CometChatCallHistory/resources/index.ts delete mode 100644 src/calls/CometChatCallHistoryWithDetails/HistoryWithDetailsConfiguration.ts delete mode 100644 src/calls/CometChatCallHistoryWithDetails/HistoryWithDetailsStyle.ts delete mode 100644 src/calls/CometChatCallHistoryWithDetails/index.ts create mode 100644 src/calls/CometChatCallLogDetails/CallLogDetailsConfiguration.ts create mode 100644 src/calls/CometChatCallLogDetails/CallLogDetailsStyle.ts create mode 100644 src/calls/CometChatCallLogDetails/CometChatCallLogDetails.tsx create mode 100644 src/calls/CometChatCallLogDetails/index.ts create mode 100644 src/calls/CometChatCallLogDetails/resources/CloseIcon.png rename src/calls/{CometChatCallDetails => CometChatCallLogDetails}/resources/index.ts (100%) rename src/calls/{CometChatCallDetails => CometChatCallLogDetails}/style.ts (89%) rename src/calls/{CometChatCallHistory/CallHistoryConfiguration.ts => CometChatCallLogHistory/CallLogHistoryConfiguration.ts} (60%) create mode 100644 src/calls/CometChatCallLogHistory/CallLogHistoryStyle.ts create mode 100644 src/calls/CometChatCallLogHistory/CometChatCallLogHistory.tsx create mode 100644 src/calls/CometChatCallLogHistory/index.ts rename src/calls/{CometChatCallHistory => CometChatCallLogHistory}/resources/Back.png (100%) rename src/calls/{CometChatCallHistory => CometChatCallLogHistory}/resources/Call.png (100%) rename src/calls/{CometChatCallHistory => CometChatCallLogHistory}/resources/Info.png (100%) rename src/calls/{CometChatCallHistory => CometChatCallLogHistory}/resources/Selection.png (100%) rename src/calls/{CometChatCallHistory => CometChatCallLogHistory}/resources/Spineer.png (100%) rename src/calls/{CometChatCallHistory => CometChatCallLogHistory}/resources/Video.png (100%) rename src/calls/{CometChatCallHistory => CometChatCallLogHistory}/resources/check.png (100%) create mode 100644 src/calls/CometChatCallLogHistory/resources/incomingcall.png create mode 100644 src/calls/CometChatCallLogHistory/resources/incomingvideo.png create mode 100644 src/calls/CometChatCallLogHistory/resources/index.ts create mode 100644 src/calls/CometChatCallLogHistory/resources/missedcall.png create mode 100644 src/calls/CometChatCallLogHistory/resources/missedvideo.png create mode 100644 src/calls/CometChatCallLogHistory/resources/outgoingcall.png create mode 100644 src/calls/CometChatCallLogHistory/resources/outgoingvideo.png rename src/calls/{CometChatCallHistory => CometChatCallLogHistory}/style.ts (88%) create mode 100644 src/calls/CometChatCallLogParticipants/CallLogParticipantsConfiguration.ts create mode 100644 src/calls/CometChatCallLogParticipants/CallLogParticipantsStyle.ts create mode 100644 src/calls/CometChatCallLogParticipants/CometChatCallLogParticipants.tsx create mode 100644 src/calls/CometChatCallLogParticipants/index.ts create mode 100644 src/calls/CometChatCallLogParticipants/resources/Back.png create mode 100644 src/calls/CometChatCallLogParticipants/resources/index.ts create mode 100644 src/calls/CometChatCallLogParticipants/style.ts create mode 100644 src/calls/CometChatCallLogRecordings/CallLogRecordingsConfiguration.ts create mode 100644 src/calls/CometChatCallLogRecordings/CallLogRecordingsStyle.ts create mode 100644 src/calls/CometChatCallLogRecordings/CometChatCallLogRecordings.tsx create mode 100644 src/calls/CometChatCallLogRecordings/index.ts create mode 100644 src/calls/CometChatCallLogRecordings/resources/Back.png create mode 100644 src/calls/CometChatCallLogRecordings/resources/download.png create mode 100644 src/calls/CometChatCallLogRecordings/resources/index.ts create mode 100644 src/calls/CometChatCallLogRecordings/style.ts create mode 100644 src/calls/CometChatCallLogs/CallLogsConfiguration.ts create mode 100644 src/calls/CometChatCallLogs/CallLogsStyle.ts create mode 100644 src/calls/CometChatCallLogs/CometChatCallLogs.tsx create mode 100644 src/calls/CometChatCallLogs/index.ts create mode 100644 src/calls/CometChatCallLogs/resources/Back.png create mode 100644 src/calls/CometChatCallLogs/resources/Info.png create mode 100644 src/calls/CometChatCallLogs/resources/Selection.png create mode 100644 src/calls/CometChatCallLogs/resources/Spinner.png create mode 100644 src/calls/CometChatCallLogs/resources/check.png create mode 100644 src/calls/CometChatCallLogs/resources/incomingcall.png create mode 100644 src/calls/CometChatCallLogs/resources/incomingvideo.png create mode 100644 src/calls/CometChatCallLogs/resources/index.ts create mode 100644 src/calls/CometChatCallLogs/resources/missedcall.png create mode 100644 src/calls/CometChatCallLogs/resources/missedvideo.png create mode 100644 src/calls/CometChatCallLogs/resources/outgoingcall.png create mode 100644 src/calls/CometChatCallLogs/resources/outgoingvideo.png create mode 100644 src/calls/CometChatCallLogs/style.ts create mode 100644 src/calls/CometChatCallLogsWithDetails/CallLogsWithDetailsConfiguration.ts rename src/calls/{CometChatCallHistoryWithDetails/CometChatCallHistoryWithDetails.tsx => CometChatCallLogsWithDetails/CometChatCallLogsWithDetails.tsx} (54%) create mode 100644 src/calls/CometChatCallLogsWithDetails/index.ts rename src/calls/{CometChatCallHistoryWithDetails => CometChatCallLogsWithDetails}/style.ts (100%) create mode 100644 src/calls/resources/nextarrow.png create mode 100644 src/extensions/ThumbnailGeneration/resources/empty.png create mode 100644 src/extensions/ThumbnailGeneration/resources/index.ts create mode 100644 src/shared/modals/CometChatCallLogDetailsOptions.ts create mode 100644 src/shared/modals/CometChatCallLogDetailsTemplate.ts create mode 100644 src/shared/views/CometChatAICard/CometChatAICard.tsx create mode 100644 src/shared/views/CometChatAICard/resources/errormessage.png create mode 100644 src/shared/views/CometChatAICard/resources/index.ts create mode 100644 src/shared/views/CometChatAICard/resources/nomessage.png create mode 100644 src/shared/views/CometChatPanel/CometChatPanel.tsx create mode 100644 src/shared/views/CometChatPanel/PanelStyle.tsx create mode 100644 src/shared/views/CometChatPanel/resources/CloseIcon.png create mode 100644 src/shared/views/CometChatPanel/resources/index.ts diff --git a/README.md b/README.md index 64e1e7c..63c641d 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ [![Platform](https://img.shields.io/badge/Platform-ReactNative-brightgreen.svg)](#) [![Platform](https://img.shields.io/badge/Language-TypeScript-yellowgreen.svg)](#) -![Version](https://shields.io/badge/version-v4.0.2-orange) +![Version](https://shields.io/badge/version-v4.1.0-orange) ![Twitter Follow](https://img.shields.io/twitter/follow/cometchat?style=social) ## Table of contents diff --git a/package.json b/package.json index aec3ad7..9de57ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cometchat/chat-uikit-react-native", - "version": "4.0.2", + "version": "4.1.0", "description": "CometChat React Native UI Kit is a collection of custom UI Components designed to build text , chat and calling features in your application. The UI Kit is developed to keep developers in mind and aims to reduce development efforts significantly", "main": "src/index", "module": "src/index", @@ -70,13 +70,13 @@ "@types/react": "17.0.21" }, "dependencies": { - "@cometchat/chat-sdk-react-native": "^4.0.3", "@react-native-async-storage/async-storage": "^1.17.10", "@react-native-community/clipboard": "^1.5.1" }, "peerDependencies": { "react": "*", - "react-native": "*" + "react-native": "*", + "@cometchat/chat-sdk-react-native": "*" }, "jest": { "preset": "react-native", diff --git a/src/AI/AIAssistBot/AIAssistBotDecorator.tsx b/src/AI/AIAssistBot/AIAssistBotDecorator.tsx new file mode 100644 index 0000000..c171f68 --- /dev/null +++ b/src/AI/AIAssistBot/AIAssistBotDecorator.tsx @@ -0,0 +1,164 @@ +import React from "react"; +import { CometChat } from "@cometchat/chat-sdk-react-native"; +import { CometChatMessageComposerActionInterface, CometChatTheme, CometChatUIEventHandler, CometChatUIEvents, DataSource, DataSourceDecorator, MessageEvents, localize } from "../../shared"; +import { AIAssistBotConfiguration } from "./configuration"; +import { AIOptionsStyle } from "../AIOptionsStyle"; +import AIAssistBotView from "./AIAssistBotView"; + +export class AIAssistBotDecorator extends DataSourceDecorator { + public configuration?: AIAssistBotConfiguration; + public user!: CometChat.User; + public group!: CometChat.Group; + public bots!: CometChat.User[]; + public theme: CometChatTheme = new CometChatTheme({}); + public loggedInUser!: CometChat.User | null; + public usersRequest: CometChat.UsersRequestBuilder; + + constructor( + dataSource: DataSource, + configuration?: AIAssistBotConfiguration + ) { + super(dataSource); + this.configuration = configuration!; + this.usersRequest = new CometChat.UsersRequestBuilder() + .setLimit(30) + .setTags(["aibot"]) + .build(); + this.fetchBots(); + setTimeout(() => { + this.addMessageListener(); + }, 1000); + } + + fetchBots() { + this.usersRequest.fetchNext().then((bots) => { + if (bots.length > 0) { + this.bots = [...(this.bots || []), ...bots]; + if (bots.length > 0) { + this.fetchBots(); + } + } + }) + + } + + override getId(): string { + return "bots"; + } + + override getAIOptions(user: CometChat.User | null, group: CometChat.Group | null, theme: CometChatTheme, id?: any, AIOptionsStyle?: AIOptionsStyle): CometChatMessageComposerActionInterface[] { + this.user = user!; + this.group = group!; + if (!id?.parentMessageId) { + const numberOfBots = this.bots?.length; + const titleName = numberOfBots > 1 ? localize("COMETCHAT_ASK_AI_BOT") : `${localize("COMETCHAT_ASK_BOT")} ${this.bots[0]?.getName()}`; + const messageComposerActions: CometChatMessageComposerActionInterface[] = super.getAIOptions(user, group, theme, id, AIOptionsStyle); + let newAction = { + title: titleName, + onPress: () => { + this.onOptionsClick(AIOptionsStyle) + }, + id: "ai-assist-bot", + iconURL: '', + iconTint: '', + titleColor: this.configuration?.style?.buttonTextColor || AIOptionsStyle.listItemTitleColor, + titleFont: this.configuration?.style?.buttonTextFont || AIOptionsStyle.listItemTitleFont, + background: this.configuration?.style?.backgroundColor || AIOptionsStyle.listItemBackground, + cornerRadius: this.configuration?.style?.buttonBorderRadius || AIOptionsStyle.listItemBorderRadius, + }; + messageComposerActions.push(newAction); + return messageComposerActions; + } else { + return super.getAIOptions(user, group, theme, id, AIOptionsStyle); + } + } + + onOptionsClick(AIOptionsStyle) { + if (this.bots?.length > 1) { + this.openBotList(AIOptionsStyle); + } else { + this.openBotChat(this.bots[0]); + } + } + + openBotList(AIOptionsStyle) { + const botList = this.bots.map((bot) => { + return ({ + title: bot.getName(), + onPress: () => { this.openBotChat(bot) }, + id: bot?.getUid(), + iconURL: '', + iconTint: '', + titleColor: this.configuration?.style?.buttonTextColor || AIOptionsStyle.listItemTitleColor, + titleFont: this.configuration?.style?.buttonTextFont || AIOptionsStyle.listItemTitleFont, + background: this.configuration?.style?.backgroundColor || AIOptionsStyle.listItemBackground, + cornerRadius: this.configuration?.style?.buttonBorderRadius || AIOptionsStyle.listItemBorderRadius, + }); + }); + + CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.ccToggleBottomSheet, { + bots: botList + }); + } + + openBotChat(bot) { + CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.ccToggleBottomSheet, { + botView: true, + child: () => + }); + } + + closeAIOption() { + CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.ccToggleBottomSheet, { + botView: true, + child: () => (null) + }); + } + + async getBotReply(question: string, bot: CometChat.User): Promise { + let configuration: any; + const receiverId = this.group?.getGuid() || this.user?.getUid(); + const receiverType = this.group?.getGuid() + ? CometChat.RECEIVER_TYPE.GROUP + : CometChat.RECEIVER_TYPE.USER; + + try { + configuration = await this.configuration.apiConfiguration(bot, this.user, this.group) || {} + } catch (err) { + configuration = {} + } + + const answer = await CometChat.askBot( + receiverId, + receiverType, + bot?.getUid(), + question, + configuration + ); + return answer; + } + + private addMessageListener(): void { + CometChat.getLoggedinUser().then((user: CometChat.User | null) => { + if (user) { + this.loggedInUser = user; + } + }); + + CometChatUIEventHandler.addMessageListener( + MessageEvents.ccActiveChatChanged, + { + ccActiveChatChanged: (data) => { + + }, + } + ); + } +} \ No newline at end of file diff --git a/src/AI/AIAssistBot/AIAssistBotExtension.tsx b/src/AI/AIAssistBot/AIAssistBotExtension.tsx new file mode 100644 index 0000000..98c84ca --- /dev/null +++ b/src/AI/AIAssistBot/AIAssistBotExtension.tsx @@ -0,0 +1,22 @@ +import { ChatConfigurator } from "../../shared"; +import { AIExtensionDataSource } from "../AIExtensionDataSource"; +import { AIAssistBotDecorator } from "./AIAssistBotDecorator"; +import { AIAssistBotConfiguration } from "./configuration"; +export class AIAssistBotExtension extends AIExtensionDataSource { + private configuration?: AIAssistBotConfiguration; + + constructor(configuration?: AIAssistBotConfiguration) { + super(); + this.configuration = configuration; + } + + override addExtension(): void { + ChatConfigurator.enable((dataSource: any) => new AIAssistBotDecorator(dataSource, this.configuration)); + } + + override getExtensionId(): string { + return "bots"; + } + + +} \ No newline at end of file diff --git a/src/AI/AIAssistBot/AIAssistBotStyle.ts b/src/AI/AIAssistBot/AIAssistBotStyle.ts new file mode 100644 index 0000000..3eb78e9 --- /dev/null +++ b/src/AI/AIAssistBot/AIAssistBotStyle.ts @@ -0,0 +1,43 @@ +import { FontStyle } from "../../shared"; +import { AIBaseStyle } from "../AIBaseStyle"; + +export class AIAssistBotStyle extends AIBaseStyle { + titleFont?: FontStyle; + titleColor?: string = ""; + subtitleFont: FontStyle; + subtitleColor: string; + closeIconTint?: string = ""; + sendIconTint?: string = ""; + buttonTextColor?: string = ""; + buttonTextFont?: FontStyle; + buttonBackground?: string = ""; + buttonBorderRadius?: number; + + constructor(props: Partial) { + super({}); + Object.assign(this, props); + } +} + +class AITextMessageBubbleStyle extends AIBaseStyle { + textFont?: string = ""; + textColor?: string = ""; + constructor(props: Partial) { + super({}); + Object.assign(this, props); + } +} + +export class AIBotMessageBubbleStyle extends AITextMessageBubbleStyle { + constructor(props: Partial) { + super({}); + Object.assign(this, props); + } +} + +export class AISenderMessageBubbleStyle extends AITextMessageBubbleStyle { + constructor(props: Partial) { + super({}); + Object.assign(this, props); + } +} \ No newline at end of file diff --git a/src/AI/AIAssistBot/AIAssistBotView.tsx b/src/AI/AIAssistBot/AIAssistBotView.tsx new file mode 100644 index 0000000..04d6692 --- /dev/null +++ b/src/AI/AIAssistBot/AIAssistBotView.tsx @@ -0,0 +1,294 @@ +import React, { useContext, useState, useEffect, useCallback } from 'react' +import { CometChat } from "@cometchat/chat-sdk-react-native"; +import { View, Text, TextInput, Dimensions, TouchableOpacity, Image, FlatList } from 'react-native' +import { AIAssistBotConfiguration } from './configuration'; +import { CometChatBottomSheet, CometChatContext, CometChatContextType, CometChatDate, CometChatListItem, CometChatReceipt, CometChatTextBubble, CometChatTheme, localize } from '../../shared'; +import { CloseIcon } from './resources'; +import { ICONS } from '../../shared/framework/resources'; +import { ICONS as MessageIcons } from '../../shared/assets/images'; +import { getUnixTimestamp } from '../../shared/utils/CometChatMessageHelper'; +import { CometChatMessageBubble } from '../../shared/views/CometChatMessageBubble'; +import { MessageBubbleAlignmentType, ReceiverTypeConstants } from '../../shared/constants/UIKitConstants'; +import { AIBotMessageBubbleStyle, AISenderMessageBubbleStyle } from './AIAssistBotStyle'; + +interface AIAssistBotViewProps { + title: string; + configuration: AIAssistBotConfiguration; + closeCallback: () => void, + bot: CometChat.User, + sender: CometChat.User, + onSend: (question: string, bot: CometChat.User) => Promise +} + +const AIAssistBotView = (props: AIAssistBotViewProps) => { + const { height } = Dimensions.get('window'); + const { title, bot, sender, closeCallback, configuration, onSend } = props; + const { theme } = useContext(CometChatContext); + + const [question, setQuestion] = useState(""); + const [messages, setMessages] = useState([]); + + const style = { + titleColor: configuration?.style?.titleColor || theme.palette.getAccent(), + titleFont: configuration?.style?.titleFont || theme.typography.name, + closeIconTint: configuration?.style?.closeIconTint || theme.palette.getAccent(), + sendIconTint: configuration?.style?.sendIconTint || question ? theme.palette.getPrimary() : theme.palette.getAccent600(), + messageInputStyle: configuration?.messageInputStyle || {}, + subtitleColor: configuration?.style?.subtitleColor || theme.palette.getAccent500(), + subtitleFont: configuration?.style?.subtitleFont || theme.typography.subtitle2, + ...configuration?.style + }; + + const { + titleColor, + titleFont, + closeIconTint, + sendIconTint, + subtitleColor, + subtitleFont + } = style; + + useEffect(() => { + let botFirstMessage = ""; + if (configuration?.botFirstMessageText) { + botFirstMessage = configuration.botFirstMessageText(bot); + } else { + botFirstMessage = localize("COMETCHAT_BOT_FIRST_MESSAGE"); + } + + const message = new CometChat.TextMessage( + sender?.getUid(), + botFirstMessage, + ReceiverTypeConstants.user + ); + message.setSentAt(getUnixTimestamp()); + message.setMuid(String(getUnixTimestamp())); + message.setSender(bot); + + let newMessages = [...messages]; + newMessages.unshift(message); + + setMessages(newMessages); + + }, []) + + const onClose = () => { + closeCallback && closeCallback() + } + + const onChangeText = (value: string) => { + setQuestion(value) + } + + const onMsgSend = () => { + if (!question) return; + if (messages[0]?.sender?.getUid() === sender?.getUid()) return; + + let newMessages = [...messages]; + + const MUID = String(getUnixTimestamp()); + const message = new CometChat.TextMessage( + bot.getUid(), + question, + ReceiverTypeConstants.user + ); + message.setSentAt(getUnixTimestamp()); + message.setMuid(MUID); + message.setSender(sender); + message.setStatus("WAIT"); + + newMessages.unshift(message); + setMessages(newMessages); + + onSend(question, bot) + .then(botReply => { + const message = new CometChat.TextMessage( + sender?.getUid(), + botReply, + ReceiverTypeConstants.user + ); + message.setSentAt(getUnixTimestamp()); + message.setMuid(String(getUnixTimestamp())); + message.setSender(bot); + message.setStatus(undefined); + + const messageList = newMessages.map((message) => { + if (message.getMuid() === MUID) { + message.setStatus(undefined); + } + return message; + }); + + messageList.unshift(message); + setMessages(messageList); + }) + .catch(err => { + const messageList = newMessages.map((message) => { + if (message.getMuid() === MUID) { + message.setStatus("ERROR"); + } + return message; + }); + setMessages(messageList); + }); + + setQuestion("") + } + + const RenderMessageItem = ({ item, index }) => { + const contentView = (message: any, + theme: CometChatTheme, + alignment: MessageBubbleAlignmentType, + configuration: AIAssistBotConfiguration): JSX.Element => { + let style: AIBotMessageBubbleStyle | AISenderMessageBubbleStyle = {}; + + if (alignment === "right") { + style = configuration?.senderMessageBubbleStyle || {}; + } else { + style = configuration?.botMessageBubbleStyle || {}; + } + + const defaultStyle: any = { + textFont: style?.textFont || theme.typography.text1, + borderRadius: style?.borderRadius || 12, + width: style?.width || "100%", + }; + if (alignment === "right") { + defaultStyle["textColor"] = style?.textColor || theme.palette.getSecondary(); + defaultStyle["backgroundColor"] = style?.backgroundColor || theme.palette.getPrimary() + } else { + defaultStyle["textColor"] = style?.textColor || theme.palette.getAccent(); + defaultStyle["backgroundColor"] = style?.backgroundColor || theme.palette.getSecondary() + } + + return ( + + ) + } + function getBubbleAlignment( + message: any, + sender: CometChat.User + ): MessageBubbleAlignmentType { + if (message.sender?.getUid() === sender?.getUid()) { + return "right"; + } else { + return "left"; + } + } + function getMessageBubbleStyle(message: CometChat.TextMessage, theme: CometChatTheme, sender: CometChat.User, configuration: AIAssistBotConfiguration): any { + if (message.sender?.getUid() === sender?.getUid()) { + const style = configuration?.senderMessageBubbleStyle || {}; + return { + background: style.backgroundColor || theme.palette.getPrimary(), + borderRadius: style.borderRadius || 12, + border: style.border || undefined, + } + } else { + const style = configuration?.botMessageBubbleStyle || {}; + if (configuration?.botMessageBubbleStyle) { + return configuration?.botMessageBubbleStyle; + } + return { + background: style.backgroundColor || theme.palette.getSecondary(), + borderRadius: style.borderRadius || 12, + border: style.border || undefined, + }; + } + }; + + const getFooterView = (item: CometChat.BaseMessage, bubbleAlignment: MessageBubbleAlignmentType): JSX.Element => { + + let isSender = (item.getSender()?.getUid() || item['sender']['uid']) == (sender?.getUid() || sender['uid']); + + return + + { + isSender ? + : + null + } + + } + + return ( + + contentView(item, theme, getBubbleAlignment(item, sender), configuration)} + FooterView={() => getFooterView(item, getBubbleAlignment(item, sender))} + alignment={getBubbleAlignment(item, sender)} + style={getMessageBubbleStyle(item, theme, sender, configuration)} + /> + + ) + } + + const keyExtractor = useCallback((item) => `${item.getMuid()}`, []) + + return ( + + + {localize("COMETCHAT_ASK_BOT_SUBTITLE")}} + TailView={() => + + } + listItemStyle={{ + titleColor, titleFont, + }} + /> + + + + + + + + + + + + ) +} + +export default AIAssistBotView \ No newline at end of file diff --git a/src/AI/AIAssistBot/configuration.ts b/src/AI/AIAssistBot/configuration.ts new file mode 100644 index 0000000..155496e --- /dev/null +++ b/src/AI/AIAssistBot/configuration.ts @@ -0,0 +1,22 @@ +import { CometChat } from '@cometchat/chat-sdk-react-native' +import { AIAssistBotStyle, AIBotMessageBubbleStyle, AISenderMessageBubbleStyle } from './AIAssistBotStyle'; +import { ICONS } from '../../shared/assets/images'; +import { AvatarStyle, CometChatMessageInputStyleInterface } from '../../shared'; + +export class AIAssistBotConfiguration { + apiConfiguration?: (bot: CometChat.User, user?: CometChat.User, group?: CometChat.Group) => Promise; + title: (bot: CometChat.User) => string; + botFirstMessageText: (bot: CometChat.User) => string; + closeIconURL: string; + sendIconURL: string; + botMessageBubbleStyle: AIBotMessageBubbleStyle; + senderMessageBubbleStyle: AISenderMessageBubbleStyle; + avatarStyle?: AvatarStyle; + messageInputStyle?: CometChatMessageInputStyleInterface; + style: AIAssistBotStyle; + loadingIconURL?: string = ICONS.WAITING; + errorIconURL?: string = ICONS.ERROR_TICK; + constructor(props: Partial) { + Object.assign(this, props); + } +} diff --git a/src/calls/CometChatCallDetails/resources/CloseIcon.png b/src/AI/AIAssistBot/resources/CloseIcon.png similarity index 100% rename from src/calls/CometChatCallDetails/resources/CloseIcon.png rename to src/AI/AIAssistBot/resources/CloseIcon.png diff --git a/src/AI/AIAssistBot/resources/index.ts b/src/AI/AIAssistBot/resources/index.ts new file mode 100644 index 0000000..6622ded --- /dev/null +++ b/src/AI/AIAssistBot/resources/index.ts @@ -0,0 +1,5 @@ +import CloseIcon from "./CloseIcon.png"; + +export { + CloseIcon +} \ No newline at end of file diff --git a/src/AI/configuration.ts b/src/AI/AIBaseConfiguration.ts similarity index 63% rename from src/AI/configuration.ts rename to src/AI/AIBaseConfiguration.ts index d37c939..44a9a79 100644 --- a/src/AI/configuration.ts +++ b/src/AI/AIBaseConfiguration.ts @@ -1,17 +1,14 @@ -import { CardStyle, CardViewStyle } from "./CardViewStyle"; import {CometChat} from '@cometchat/chat-sdk-react-native' import { emptyIcon, errorIcon, loadingIcon } from "./resources"; -export class AIEnablerConfiguration { - listStyle?: CardViewStyle; - listItemStyle?:CardStyle; - buttonIconURL?: string = ""; +export class AIBaseConfiguration { + apiConfiguration?: (user?: CometChat.User, group?: CometChat.Group) => Promise; ErrorStateView?: (e?: CometChat.CometChatException) => JSX.Element; EmptyStateView?: () => JSX.Element; LoadingStateView?: () => JSX.Element; loadingIconURL?:string = loadingIcon; errorIconURL?:string = errorIcon; emptyIconURL?:string = emptyIcon; - constructor(props: Partial) { + constructor(props: Partial) { Object.assign(this, props); } } \ No newline at end of file diff --git a/src/AI/AIBaseStyle.ts b/src/AI/AIBaseStyle.ts new file mode 100644 index 0000000..196783d --- /dev/null +++ b/src/AI/AIBaseStyle.ts @@ -0,0 +1,58 @@ +import { BaseStyle, FontStyle } from "../shared"; + +export interface AIBaseStyleInterface extends BaseStyle { + emptyStateTextFont?: FontStyle; + emptyStateTextColor?: string; + loadingStateTextFont?: FontStyle; + loadingStateTextColor?: string; + errorStateTextFont?: FontStyle; + errorStateTextColor?: string; + loadingIconTint?: string; + emptyIconTint?: string; + errorIconTint?: string; +} + +export class AIBaseStyle extends BaseStyle { + emptyStateTextFont?: FontStyle; + emptyStateTextColor?: string; + loadingStateTextFont?: FontStyle; + loadingStateTextColor?: string; + errorStateTextFont?: FontStyle; + errorStateTextColor?: string; + loadingIconTint?: string; + emptyIconTint?: string; + errorIconTint?: string; + constructor({ + emptyIconTint, + emptyStateTextColor, + emptyStateTextFont, + errorIconTint, + errorStateTextColor, + errorStateTextFont, + loadingIconTint, + loadingStateTextColor, + loadingStateTextFont, + backgroundColor, + border, + borderRadius, + height, + width + }: AIBaseStyleInterface) { + super({ + backgroundColor, + border, + borderRadius, + height, + width + }) + this.emptyIconTint = emptyIconTint; + this.emptyStateTextColor = emptyStateTextColor; + this.emptyStateTextFont = emptyStateTextFont; + this.errorIconTint = errorIconTint; + this.errorStateTextColor = errorStateTextColor; + this.errorStateTextFont = errorStateTextFont; + this.loadingIconTint = loadingIconTint; + this.loadingStateTextColor = loadingStateTextColor; + this.loadingStateTextFont = loadingStateTextFont; + } +} diff --git a/src/AI/AIConversationStarter/AIConversationStarter.ts b/src/AI/AIConversationStarter/AIConversationStarter.ts index 4aa12e1..cbc0087 100755 --- a/src/AI/AIConversationStarter/AIConversationStarter.ts +++ b/src/AI/AIConversationStarter/AIConversationStarter.ts @@ -1,33 +1,19 @@ -import { AIConversationStarterDecorator } from "./AIConversationStarterDecorator"; -import { ExtensionsDataSource,ChatConfigurator } from "../../shared"; +import { AIConversationStarterDecorator } from "./AIConversationStarterDecorator"; +import { ChatConfigurator } from "../../shared"; import { AIExtensionDataSource } from "../AIExtensionDataSource"; import { AIConversationStarterConfiguration } from "./configuration"; -import { AIEnablerConfiguration } from "../configuration"; export class AIConversationStarterExtension extends AIExtensionDataSource { - configuration?:AIConversationStarterConfiguration; - constructor(configuration?:AIConversationStarterConfiguration){ + configuration?: AIConversationStarterConfiguration; + constructor(configuration?: AIConversationStarterConfiguration) { super() this.configuration = configuration } override addExtension(): void { - ChatConfigurator.enable((dataSource: any) => new AIConversationStarterDecorator(dataSource,this.configuration)); + ChatConfigurator.enable((dataSource: any) => new AIConversationStarterDecorator(dataSource, this.configuration)); } override getExtensionId(): string { return "conversation-starter"; } - override enable(): void { - this.addExtension() - } - override getConfiguration():AIConversationStarterConfiguration{ -return this.configuration - } - override setConfiguration(config?:AIEnablerConfiguration):void{ - this.configuration = {...this.configuration,...config} - this.configuration.conversationStarterStyle = { - ...this.configuration.conversationStarterStyle, - ...(config?.listItemStyle || config?.listStyle) - }; - }; } \ No newline at end of file diff --git a/src/AI/AIConversationStarter/AIConversationStarterDecorator.tsx b/src/AI/AIConversationStarter/AIConversationStarterDecorator.tsx index a534c00..f8cf572 100755 --- a/src/AI/AIConversationStarter/AIConversationStarterDecorator.tsx +++ b/src/AI/AIConversationStarter/AIConversationStarterDecorator.tsx @@ -1,179 +1,156 @@ - -import { CometChatTheme, CometChatUIEventHandler, CometChatUIEvents, DataSource,DataSourceDecorator, MessageEvents, localize } from "../../shared"; +import React from "react"; +import { TouchableOpacity, View, Text, ScrollView } from "react-native"; import { CometChat } from "@cometchat/chat-sdk-react-native"; +import { CometChatTheme, CometChatUIEventHandler, CometChatUIEvents, DataSource, DataSourceDecorator, MessageEvents, localize } from "../../shared"; import { MessageStatusConstants, ReceiverTypeConstants, ViewAlignment } from "../../shared/constants/UIKitConstants"; -import { Image, TouchableOpacity,View,Text,ScrollView } from "react-native"; -import React from "react"; -import { loadingIcon,emptyIcon,errorIcon } from "../resources"; -import { emptyLabelStyle, errorLabelStyle } from "./style"; -import { getCardViewStyle , getRepliesWrapperStyle, getRepliesStyle,getloadingStateStyle} from "./style"; +import { getCardViewStyle, getRepliesWrapperStyle, getRepliesStyle } from "./style"; import { State } from "../utils"; import { AIConversationStarterConfiguration } from "./configuration"; import { CardViewStyle } from "../CardViewStyle"; +import CometChatAICard from "../../shared/views/CometChatAICard/CometChatAICard"; export class AIConversationStarterDecorator extends DataSourceDecorator { - public configuration?:AIConversationStarterConfiguration; - public currentMessage:CometChat.BaseMessage | null = null; - public loggedInUser!:CometChat.User | null; + public configuration?: AIConversationStarterConfiguration; + public currentMessage: CometChat.BaseMessage | null = null; + public loggedInUser!: CometChat.User | null; messageListenerId = 'message_' + new Date().getTime(); public user!: CometChat.User; public group!: CometChat.Group; - public cardViewStyle:CardViewStyle = {}; - public errorStateText:string = localize("SOMETHING_WRONG"); - public emptyStateText:string = localize("NO_MESSAGES_FOUND"); - public theme:CometChatTheme; - constructor(dataSource:DataSource, configuration?:AIConversationStarterConfiguration){ - - super(dataSource) - this.configuration = configuration; - -setTimeout(() => { - CometChat.getLoggedinUser() - .then((u) => { - this.loggedInUser = u; - }) - .catch((err) => console.log(err)); - - CometChatUIEventHandler.addMessageListener( - MessageEvents.ccActiveChatChanged, - { - ccActiveChatChanged: ({message,user,group,theme,parentMessageId}) => { - this.user = user; - this.group = group; - if(theme){ - this.theme = theme; - } - else{ - this.theme = new CometChatTheme({}); - } - if(!message && !parentMessageId){ - this.attachMessageListener() - this.showDefaultPanel(State.loading) - this.getConversationStarter().then((replies) => { - if(!replies || (replies?.length && replies.length <= 0)){ + public cardViewStyle: CardViewStyle = {}; + public errorStateText: string = localize("SOMETHING_WRONG"); + public emptyStateText: string = localize("NO_MESSAGES_FOUND"); + public theme: CometChatTheme; + constructor(dataSource: DataSource, configuration?: AIConversationStarterConfiguration) { + + super(dataSource); + + this.configuration = configuration; + + setTimeout(() => { + this.listeners(); + }, 1000); + } + override getId(): string { + return "aiconversationstarter"; + } + + private loadConversationStarter(): void { + this.getConversationStarter() + .then((replies) => { + if (!replies || (replies?.length && replies.length <= 0)) { this.showDefaultPanel(State.empty) - } - else{ + else { CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.showPanel, { alignment: ViewAlignment.composerTop, child: () => ( - + {replies} - - - ), }); } }) - .catch((err) => { - console.log(err); - this.showDefaultPanel(State.error) + .catch((err) => { + console.log(err); + this.showDefaultPanel(State.error) - }) - } - }, - ccMessageSent: ({ message, status }) => { - if(status == MessageStatusConstants.success && message?.sender?.uid == this.loggedInUser?.uid){ - this.closePanel(); - } - } - } - ); -}, 1000); -} - override getId(): string { - return "aiconversationstarter"; + }) + } + + private getLoadingView(): JSX.Element { + let LoadingView: JSX.Element = this.configuration?.LoadingStateView + return ( + + {LoadingView ? : null} + + ) + } + + private getEmptyView(): JSX.Element { + let EmptyView: JSX.Element = this.configuration?.EmptyStateView + return ( + + {EmptyView ? : null} + + ) + } + + private getErrorView(error?: CometChat.CometChatException): JSX.Element { + return ( + + {this.configuration?.ErrorStateView ? this.configuration?.ErrorStateView(error) : null} + + ) } - showDefaultPanel(state:State = State.loading,error?:CometChat.CometChatException) { - let LoadingView:JSX.Element = this.configuration?.LoadingStateView - let EmptyView:JSX.Element = this.configuration?.EmptyStateView + + showDefaultPanel(state: State = State.loading, error?: CometChat.CometChatException) { CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.showPanel, { alignment: ViewAlignment.composerTop, child: () => ( - - {state == State.loading ? LoadingView ? : - - {localize("GENERATIONG_ICEBREAKER")} - - - : - - state == State.empty ? EmptyView ? : - - {this.emptyStateText} - - : this.configuration?.ErrorStateView ? this.configuration?.ErrorStateView(error) : - - - {this.errorStateText} - - + + {state == State.loading ? this.getLoadingView() + : state == State.empty ? this.getEmptyView() : this.getErrorView(error) } + - - - ), }); } + editReply(reply: string) { -this.closePanel(); + this.closePanel(); CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.ccComposeMessage, { text: reply }); } + closePanel = () => { CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, { alignment: ViewAlignment.composerTop, child: () => (null), }); } - closeIfMessageReceived(message){ - if(message?.receiverId == this.loggedInUser?.uid){ + + closeIfMessageReceived(message) { + if (message?.receiverId == this.loggedInUser?.uid) { this.closePanel() } } + getConversationStarter(): Promise { return new Promise((resolve, reject) => { let receiverId: string = this.user ? this.user?.getUid() : this.group?.getGuid(); let receiverType: string = this.user ? ReceiverTypeConstants.user : ReceiverTypeConstants.group; if (this.configuration?.customView) { CometChat.getConversationStarter(receiverId, receiverType).then((response: any) => { - this.configuration.customView(response).then((res)=>{ + this.configuration.customView(response).then((res) => { return resolve(({res})) - }) - .catch((err: CometChat.CometChatException) => { - return reject(err) - }) - + .catch((err: CometChat.CometChatException) => { + return reject(err) + }) }) .catch((err: CometChat.CometChatException) => { return reject(err) }) } - else if (this.configuration?.onLoad) { - this.configuration?.onLoad(this.user, this.group).then((response: any) => { - return resolve(({response})) - }) - .catch((err: CometChat.CometChatException) => { - return reject(err) - }) - - } else { CometChat.getConversationStarter(receiverId, receiverType).then((response: any) => { let view: JSX.Element[] = []; @@ -182,19 +159,15 @@ this.closePanel(); view.push( ( this.editReply(response[reply])} > {response[reply]} ) - ) } - - }) return resolve(({view})) - }) .catch((err: CometChat.CometChatException) => { return reject(err) @@ -203,27 +176,68 @@ this.closePanel(); }) } - attachMessageListener(){ - this.cardViewStyle = getCardViewStyle(this.theme,this.configuration?.conversationStarterStyle) + attachMessageListener() { + this.cardViewStyle = getCardViewStyle(this.theme, this.configuration?.conversationStarterStyle) CometChatUIEventHandler.addMessageListener( this.messageListenerId, { onTextMessageReceived: (textMessage) => { this.closeIfMessageReceived(textMessage) - }, onMediaMessageReceived: (mediaMessage) => { this.closeIfMessageReceived(mediaMessage) - }, onCustomMessageReceived: (customMessage) => { this.closeIfMessageReceived(customMessage) - + }, + onFormMessageReceived: (formMessage) => { + this.closeIfMessageReceived(formMessage) + }, + onCardMessageReceived: (cardMessage) => { + this.closeIfMessageReceived(cardMessage) + }, + onCustomInteractiveMessageReceived: (customInteractiveMessage) => { + this.closeIfMessageReceived(customInteractiveMessage) } - }); - - + }) + } + + private listeners() { + + CometChat.getLoggedinUser() + .then((u) => { + this.loggedInUser = u; + }) + .catch((err) => console.log(err)); + + CometChatUIEventHandler.addMessageListener( + MessageEvents.ccActiveChatChanged + "_STARTER", + { + ccActiveChatChanged: ({ message, user, group, theme, parentMessageId }) => { + this.user = user; + this.group = group; + if (theme) { + this.theme = theme; + } + else { + this.theme = new CometChatTheme({}); + } + + if (!message && !parentMessageId) { + this.attachMessageListener() + this.showDefaultPanel(State.loading) + this.loadConversationStarter(); + } + }, + ccMessageSent: ({ message, status }) => { + if (status == MessageStatusConstants.success && message?.sender?.uid == this.loggedInUser?.uid) { + this.closePanel(); + } + } + } + ); + } } diff --git a/src/AI/AIConversationStarter/AIConversationStarterStyle.ts b/src/AI/AIConversationStarter/AIConversationStarterStyle.ts index 9be1643..861a014 100644 --- a/src/AI/AIConversationStarter/AIConversationStarterStyle.ts +++ b/src/AI/AIConversationStarter/AIConversationStarterStyle.ts @@ -1,8 +1,13 @@ -import { AIButtonsStyle } from "../utils"; +import { AIBaseStyle } from "../AIBaseStyle"; -export class AIConversationStarterStyle extends AIButtonsStyle { - constructor(props: Partial) { - super({...props}) +export class AIConversationStarterStyle extends AIBaseStyle { + repliesTextFont?: string; + repliesTextBorder?: string; + repliesTextBorderRadius?: string; + repliesTextColor?: string; + repliesTextBackground?: string; + constructor(props: Partial) { + super({}); Object.assign(this, props); - } - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/src/AI/AIConversationStarter/configuration.ts b/src/AI/AIConversationStarter/configuration.ts index cc665a2..be2e629 100644 --- a/src/AI/AIConversationStarter/configuration.ts +++ b/src/AI/AIConversationStarter/configuration.ts @@ -1,18 +1,11 @@ -import {CometChat} from '@cometchat/chat-sdk-react-native' import { AIConversationStarterStyle } from './AIConversationStarterStyle'; -import { loadingIcon, errorIcon, emptyIcon } from '../resources'; -export class AIConversationStarterConfiguration { - onLoad?:(user?:CometChat.User,group?:CometChat.Group)=>Promise; - conversationStarterStyle?:AIConversationStarterStyle; - customView?:(response:Object) => Promise; - ErrorStateView?: (e?: CometChat.CometChatException) => JSX.Element; - EmptyStateView?: () => JSX.Element; - LoadingStateView?: () => JSX.Element; - loadingIconURL?:string = loadingIcon; - errorIconURL?:string = errorIcon; - emptyIconURL?:string = emptyIcon; - constructor(props: Partial) { - Object.assign(this, props); - } - - } \ No newline at end of file +import { AIBaseConfiguration } from '../AIBaseConfiguration'; +export class AIConversationStarterConfiguration extends AIBaseConfiguration { + conversationStarterStyle?: AIConversationStarterStyle; + customView?: (response: Object) => Promise; + constructor(props: Partial) { + super({}) + Object.assign(this, props); + } + +} \ No newline at end of file diff --git a/src/AI/AIConversationSummary/AIConversationSummaryDecorator.tsx b/src/AI/AIConversationSummary/AIConversationSummaryDecorator.tsx new file mode 100644 index 0000000..743a899 --- /dev/null +++ b/src/AI/AIConversationSummary/AIConversationSummaryDecorator.tsx @@ -0,0 +1,175 @@ +import React from "react"; +import { CometChat } from "@cometchat/chat-sdk-react-native"; +import AIConversationSummaryView from "./AIConversationSummaryView"; +import { CometChatMessageComposerActionInterface, CometChatTheme, CometChatUIEventHandler, CometChatUIEvents, DataSource, DataSourceDecorator, MessageEvents, localize } from "../../shared"; +import { MessageStatusConstants, ReceiverTypeConstants, ViewAlignment } from "../../shared/constants/UIKitConstants"; +import { AIConversationSummaryConfiguration } from "./configuration"; +import { AIOptionsStyle } from "../AIOptionsStyle"; + +export class AIConversationSummaryDecorator extends DataSourceDecorator { + public configuration?: AIConversationSummaryConfiguration; + public newDataSource!: DataSource; + public currentMessage: CometChat.BaseMessage | null = null; + public unreadMessageCount: number = 0; + public loggedInUser!: CometChat.User | null; + public user!: CometChat.User; + public group!: CometChat.Group; + public theme: CometChatTheme = new CometChatTheme({}); + private LISTENER_ID: string = "aiconversationsummary__listener"; + + constructor( + dataSource: DataSource, + configuration?: AIConversationSummaryConfiguration + ) { + super(dataSource); + this.newDataSource = dataSource; + this.configuration = configuration!; + setTimeout(() => { + this.addMessageListener(); + }, 1000); + } + + override getId(): string { + return "aiconversationsummary"; + } + + editReply(reply: string) { + CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.ccComposeMessage, { text: reply }); + this.closePanel(); + } + + closePanel = () => { + CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, { + alignment: ViewAlignment.composerTop, + child: () => (null), + }); + }; + + closeIfMessageReceived(message: CometChat.BaseMessage) { + if (message?.getReceiverId() === this.loggedInUser?.getUid()) { + this.closePanel(); + } + } + + getConversationSummary = (theme?: CometChatTheme): Promise => { + this.theme = theme ?? new CometChatTheme({}); + return new Promise(async (resolve, reject) => { + try { + let receiverId: string = this.user + ? this.user?.getUid() + : this.group?.getGuid(); + let receiverType: string = this.user + ? ReceiverTypeConstants.user + : ReceiverTypeConstants.group; + let configuration; + if (this.configuration?.apiConfiguration) { + configuration = await this.configuration?.apiConfiguration( + this.user, + this.group + ); + } + const response = await CometChat.getConversationSummary( + receiverId, + receiverType, + configuration ? configuration : {} + ); + return resolve(response); + } catch (e) { + reject(e); + } + }); + }; + + private loadConversationSummary(): void { + this.onClose(); + CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.showPanel, { + alignment: ViewAlignment.messageListBottom, + child: () => ( + + ), + }); + } + + private onClose = () => { + CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, { + alignment: ViewAlignment.messageListBottom, + child: () => (null), + }); + } + + override getAIOptions(user: CometChat.User | null, group: CometChat.Group | null, theme: CometChatTheme, id?: any, AIOptionsStyle?: AIOptionsStyle): CometChatMessageComposerActionInterface[] { + this.user = user!; + this.group = group!; + if (!id?.parentMessageId) { + const messageComposerActions: CometChatMessageComposerActionInterface[] = super.getAIOptions(user, group, theme, id, AIOptionsStyle); + let newAction = { + title: localize("GENERATE_SUMMARY"), + onPress: () => { this.loadConversationSummary() }, + id: "ai-conversation-summary", + iconURL: '', + iconTint: '', + titleColor: this.configuration?.conversationSummaryStyle?.buttonTextColor || AIOptionsStyle.listItemTitleColor, + titleFont: this.configuration?.conversationSummaryStyle?.buttonTextFont || AIOptionsStyle.listItemTitleFont, + background: this.configuration?.conversationSummaryStyle?.backgroundColor || AIOptionsStyle.listItemBackground, + cornerRadius: this.configuration?.conversationSummaryStyle?.buttonBorderRadius || AIOptionsStyle.listItemBorderRadius, + }; + messageComposerActions.push(newAction); + return messageComposerActions; + } else { + return super.getAIOptions(user, group, theme, id, AIOptionsStyle); + } + } + + private addMessageListener(): void { + CometChat.getLoggedinUser().then((user: CometChat.User | null) => { + if (user) { + this.loggedInUser = user; + } + }); + + CometChatUIEventHandler.addMessageListener(this.LISTENER_ID, { + onTextMessageReceived: (message: CometChat.TextMessage) => { + this.closeIfMessageReceived(message); + }, + onCustomMessageReceived: (message: CometChat.CustomMessage) => { + this.closeIfMessageReceived(message); + }, + onMediaMessageReceived: (message: CometChat.MediaMessage) => { + this.closeIfMessageReceived(message); + }, + onFormMessageReceived: (formMessage) => { + this.closeIfMessageReceived(formMessage) + }, + onCardMessageReceived: (cardMessage) => { + this.closeIfMessageReceived(cardMessage) + }, + onCustomInteractiveMessageReceived: (customInteractiveMessage) => { + this.closeIfMessageReceived(customInteractiveMessage) + } + }); + + CometChatUIEventHandler.addMessageListener( + MessageEvents.ccActiveChatChanged, + { + ccActiveChatChanged: (data) => { + this.currentMessage = data.message!; + this.user = data.user!; + this.group = data.group!; + this.unreadMessageCount = data.unreadMessageCount ?? 0; + if (this.unreadMessageCount >= (this.configuration?.unreadMessageThreshold ?? 30)) { + this.loadConversationSummary(); + } + }, + ccMessageSent: ({ message, status }) => { + if (status == MessageStatusConstants.success && message?.sender?.uid == this.loggedInUser?.uid) { + this.closePanel(); + this.currentMessage = null; + this.unreadMessageCount = 0; + } + } + } + ); + + } +} \ No newline at end of file diff --git a/src/AI/AIConversationSummary/AIConversationSummaryExtension.ts b/src/AI/AIConversationSummary/AIConversationSummaryExtension.ts new file mode 100644 index 0000000..63bbc28 --- /dev/null +++ b/src/AI/AIConversationSummary/AIConversationSummaryExtension.ts @@ -0,0 +1,21 @@ +import { ChatConfigurator } from "../../shared"; +import { AIExtensionDataSource } from "../AIExtensionDataSource"; +import { AIConversationSummaryDecorator } from "./AIConversationSummaryDecorator"; +import { AIConversationSummaryConfiguration } from "./configuration"; + +export class AIConversationSummaryExtension extends AIExtensionDataSource { + private configuration?: AIConversationSummaryConfiguration; + + constructor(configuration?: AIConversationSummaryConfiguration) { + super(); + this.configuration = configuration; + } + + override addExtension(): void { + ChatConfigurator.enable((dataSource: any) => new AIConversationSummaryDecorator(dataSource, this.configuration)); + } + + override getExtensionId(): string { + return "conversation-summary"; + } +} \ No newline at end of file diff --git a/src/AI/AIConversationSummary/AIConversationSummaryStyle.tsx b/src/AI/AIConversationSummary/AIConversationSummaryStyle.tsx new file mode 100644 index 0000000..b0b7428 --- /dev/null +++ b/src/AI/AIConversationSummary/AIConversationSummaryStyle.tsx @@ -0,0 +1,20 @@ + +import { BorderStyle, FontStyle } from "../../shared"; +import { AIBaseStyle } from "../AIBaseStyle"; + +export class AIConversationSummaryStyle extends AIBaseStyle { + titleFont?: FontStyle; + titleColor?: string = ""; + textFont?: FontStyle; + textColor?: string = ""; + buttonTextColor?: string = ""; + buttonTextFont?: FontStyle; + buttonBackground?: string = ""; + buttonBorderRadius?: number; + buttonBorder?: BorderStyle; + closeIconTint?: string = ""; + constructor(props: Partial) { + super({}); + Object.assign(this, props); + } +} diff --git a/src/AI/AIConversationSummary/AIConversationSummaryView.tsx b/src/AI/AIConversationSummary/AIConversationSummaryView.tsx new file mode 100644 index 0000000..636a5bb --- /dev/null +++ b/src/AI/AIConversationSummary/AIConversationSummaryView.tsx @@ -0,0 +1,190 @@ + +import React, { useContext, useEffect, useState } from 'react'; +import { View } from 'react-native'; +import { CometChatContext, CometChatTheme, localize } from '../../shared'; +import { AIConversationSummaryConfiguration } from './configuration'; +import { CometChatPanel } from '../../shared/views/CometChatPanel/CometChatPanel'; +import CometChatAICard from '../../shared/views/CometChatAICard/CometChatAICard'; + +interface IAIConversationSummaryProps { + getConversationSummaryCallback?: (theme?: CometChatTheme) => Promise + editReplyCallback?: (reply: string) => void + configuration?: AIConversationSummaryConfiguration + theme?: CometChatTheme, + onPanelClose: () => void +}; + +const defaultProps: IAIConversationSummaryProps = { + getConversationSummaryCallback: undefined, + editReplyCallback: undefined, + configuration: undefined, + theme: new CometChatTheme({}), + onPanelClose: () => { } +} + +const enum States { + loading = "loading", + error = "error", + empty = "empty", + loaded = "loaded" +} + +let inProgress = false; +const AIConversationSummaryView = (props: IAIConversationSummaryProps) => { + + const [messageListState, setMessageListState] = useState(States.loading); + const [activeView, setActiveView] = useState(null); + + const { theme } = useContext(CometChatContext) + + const errorStateText: string = localize("SOMETHING_WRONG"); + const emptyStateText: string = localize("NO_MESSAGES_FOUND"); + const loadingStateText: string = localize("GENERATING_SUMMARY"); + const titleText: string = localize("CONVERSATION_SUMMARY") + + useEffect(() => { + fetchButtonContent(); + }, []); + + function fetchButtonContent() { + setMessageListState(States.loading); + if (props && props.getConversationSummaryCallback) { + props.getConversationSummaryCallback(theme) + .then((response) => { + if (response) { + inProgress = true; + getLoadedView(response) + .then(res => { + setMessageListState(States.loaded); + setActiveView(res); + }) + .catch(err => { + inProgress = false; + setMessageListState(States.empty); + }) + } else { + inProgress = false; + setMessageListState(States.empty); + } + }) + .catch((err) => { + inProgress = false; + setMessageListState(States.error); + }) + } + } + + /** + * Create a view based on the value of the `state` prop. + */ + function getStateView(): JSX.Element | null { + let res: JSX.Element | null = null; + switch (messageListState) { + case States.loading: + res = getLoadingView(); + break; + case States.error: + res = getErrorView(); + break; + case States.empty: + res = getEmptyView(); + break; + case States.loaded: + break; + default: + const x: never = messageListState; + } + return res; + } + + /** + * Creates the loading view + */ + function getLoadingView(): JSX.Element { + let LoadingView = props.configuration?.LoadingStateView; + return ( + + + {LoadingView ? : null} + + ); + } + + /** + * Creates the error view + */ + function getErrorView(): JSX.Element | null { + let ErrorView = props.configuration?.ErrorStateView; + return ( + + {ErrorView ? : null} + + ); + } + + /** + * Creates the empty view + */ + function getEmptyView(): JSX.Element { + let EmptyView = props.configuration?.EmptyStateView; + return ( + + {EmptyView ? : null} + + ); + } + + /** + * Creates the loaded view + */ + async function getLoadedView(conversationSummary: string): Promise { + return new Promise((resolve, reject) => { + try { + let CustomView = props.configuration?.customView; + + if (CustomView) { + props.configuration?.customView!(conversationSummary, props.onPanelClose).then((res: any) => { + return resolve(res); + }) + .catch((err: CometChat.CometChatException) => { + return reject(err) + }) + } else { + let conversationSummaryView = + return resolve(conversationSummaryView); + } + } catch (e) { + reject(e); + } + }) + } + + return ( + + {messageListState === States.loaded ? activeView : getStateView()} + + ); +}; + +AIConversationSummaryView.defaultProps = defaultProps +export default AIConversationSummaryView; diff --git a/src/AI/AIConversationSummary/configuration.ts b/src/AI/AIConversationSummary/configuration.ts new file mode 100644 index 0000000..864ba3e --- /dev/null +++ b/src/AI/AIConversationSummary/configuration.ts @@ -0,0 +1,14 @@ +import { AIBaseConfiguration } from "../AIBaseConfiguration"; +import { AIConversationSummaryStyle } from "./AIConversationSummaryStyle"; +import { closeIcon } from "./resources"; + +export class AIConversationSummaryConfiguration extends AIBaseConfiguration { + customView?: (response: string, onClose: Function) => Promise; + conversationSummaryStyle?: AIConversationSummaryStyle; + unreadMessageThreshold?: number = 30; + closeIconURL?: string = closeIcon; + constructor(props: Partial) { + super({}); + Object.assign(this, props); + } +} diff --git a/src/AI/AIConversationSummary/resources/close.png b/src/AI/AIConversationSummary/resources/close.png new file mode 100644 index 0000000000000000000000000000000000000000..a303d4534767b803c226e46a64d98cf34c410fb8 GIT binary patch literal 307 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|Tv8)E(|mmy zw18|52FCVG1{RPKAeI7R1_tH@j10^`nh_+nfC(-uv49!D1}S`GTDlfU&GmF~4DsMi zPLN<#He(5Dv|F!q@VmlR1zQ*932px!?)bOxO^})p6(qxACbmp)zUq+`2Vc9@usxW3 zI9p?vidpl9&V{d)JNt7KjApAib7;0n`s6%mKAWtRqP6!);yU(=CvsNZ=s)X_lavzK zc3z>T$R*OPhY@H_O*u(Jw= 1) { - const promiseArray = this.defaultAIFeatures.map((feature) => { - return new Promise((resolve, reject) => { - CometChat.isAIFeatureEnabled(feature.getExtensionId()) - .then((response) => { - if (response) { - - if (feature.getExtensionId() !== "conversation-starter") { - feature?.enable(); - features[feature.getExtensionId()] = { - enabled: true, - configuration: feature.getConfiguration(), - enabler: feature, - }; - } - else{ - feature.setConfiguration(this.configuration) - feature.enable(); - } - } - resolve(true); - }) - .catch((err) => { - console.error(err); - reject(err); - }); - }); - }); - - Promise.all(promiseArray) - .then(() => { - if (Object.keys(features).length > 0) { - ChatConfigurator.enable( - (dataSource: DataSource) => - new AIEnablerDecorator(dataSource, features, this.configuration) - ); - } - }) - .catch((err) => { - console.error('An error occurred:', err); - }); - } -else if(this.defaultAIFeatures?.length == 0){ -return; -} -else{ - let defaultFeatures: AIExtensionDataSource[] = [new AISmartRepliesExtension(), new AIConversationStarterExtension()]; - - const promiseArray = defaultFeatures.map((feature) => { - return new Promise((resolve, reject) => { - CometChat.isAIFeatureEnabled(feature.getExtensionId()) - .then((response) => { - if (response) { - - if (feature.getExtensionId() !== "conversation-starter") { - feature?.enable(); - features[feature.getExtensionId()] = { - enabled: true, - configuration: feature.getConfiguration(), - enabler: feature, - }; - } - else{ - feature.setConfiguration(this.configuration) - feature.enable(); - } - } - resolve(true); - }) - .catch((err) => { - console.error(err); - reject(err); - }); - }); - }); - - Promise.all(promiseArray) - .then(() => { - if (Object.keys(features).length > 0) { - ChatConfigurator.enable( - (dataSource: DataSource) => - new AIEnablerDecorator(dataSource, features, this.configuration) - ); - } - }) - .catch((err) => { - console.error('An error occurred:', err); - }); -} - } - -} \ No newline at end of file diff --git a/src/AI/AIEnablerDecorator.tsx b/src/AI/AIEnablerDecorator.tsx deleted file mode 100755 index 48098e0..0000000 --- a/src/AI/AIEnablerDecorator.tsx +++ /dev/null @@ -1,324 +0,0 @@ -import { CometChat } from "@cometchat/chat-sdk-react-native"; -import { DataSourceDecorator, DataSource, CometChatTheme, CometChatUIEvents, localize, CometChatUIEventHandler, CometChatBottomSheet, FontStyleInterface, BorderStyleInterface, BaseStyle } from "../shared"; -import { CometChatButton } from "../shared/views/CometChatButton"; - -import { CardView, Card } from "./CardView"; -import { CardViewStyle } from "./CardViewStyle"; -import { getRepliesWrapperStyle, getRepliesStyle, getCardViewStyle, getButtonStyles, getPopoverStyle, defaultViewStyle, viewContainerStyle, emptyLabelStyle, errorLabelStyle, getloadingStateStyle } from "./style"; -import { ReceiverTypeConstants, ViewAlignment } from "../shared/constants/UIKitConstants"; -import { Image, TouchableOpacity, View, Text, ScrollView, Keyboard } from "react-native"; -import React, { useEffect, useRef, useState, JSX ,useContext} from "react"; -import { AIBotIcon,loadingIcon,emptyIcon,errorIcon } from './resources'; -import { CometChatContext } from "../shared/CometChatContext"; -import { AIEnablerConfiguration } from "./configuration"; -import { AIConfigurations, ICard, State } from "./utils"; -import { AIConversationStarterConfiguration } from "./AIConversationStarter/configuration"; -import { AISmartRepliesConfiguration } from "./AISmartReplies/configuration"; - -export class AIEnablerDecorator extends DataSourceDecorator { - smartReplyConfiguration: AISmartRepliesConfiguration = new AISmartRepliesConfiguration({}); - conversationStarterConfiguration: AIConversationStarterConfiguration = new AIConversationStarterConfiguration({}); - features?: AIConfigurations = {}; - configuration?: AIEnablerConfiguration = new AIEnablerConfiguration({}); - public newDataSource!: DataSource; - public showAiButton: boolean = false; - public theme!: CometChatTheme; - public id: any; - public user!: CometChat.User; - public group!: CometChat.Group; - public loggedInUser!: CometChat.User | null; - public cardViewStyle: CardViewStyle = {}; - public buttonRef: any; - public setCallback: any; - public isPannelVisible:boolean = false; - public repliesView:JSX.Element; - public errorStateText:string = localize("SOMETHING_WRONG"); -public emptyStateText:string = localize("NO_MESSAGES_FOUND"); -public keyboardDidShowListener; -public keyboardDidHideListener; - onButtonClick = (id: string): void => { - if (id == "smart-replies") { - this.showDefaultPanel(State.loading) - this.getSmartReplies().then((replies) => { - if(!replies || (replies?.length && replies.length <= 0)){ - this.showDefaultPanel(State.empty) - } - else{ - this.repliesView = ( - - {replies} - - - - ) - CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.showPanel, { - alignment: ViewAlignment.composerBottom, - child: () => this.repliesView, - }); - } - - this.isPannelVisible = true - - }) - .catch((err) => { - this.showDefaultPanel(State.error,err) - - }) - } - } - public cardsData: ICard = {} - constructor(dataSource: DataSource, features?: AIConfigurations, configuration?: AIEnablerConfiguration) { - super(dataSource); - this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this.hideOnKeyboardShow); - this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this.showOnKeyboardShow); - if (configuration) { - this.configuration = configuration; - } - this.newDataSource = dataSource; - this.features = features; - CometChat.getLoggedinUser().then( - (user: CometChat.User | null) => { - if (user) { - this.loggedInUser = user - } - } - ); - } - getDataSource() { - return this.newDataSource; - } - getId(): string { - return "aienabler"; - } -hideOnKeyboardShow = () => { -if(this.isPannelVisible){ - CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, { - alignment: ViewAlignment.composerBottom, - child: () => (null), - }); -} -} -showOnKeyboardShow = () => { - if(this.isPannelVisible){ - CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, { - alignment: ViewAlignment.composerBottom, - child: () => this.repliesView, - }); - } -} - editReply(reply: string) { - CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, { - alignment: ViewAlignment.composerBottom, - child: () => (null), - }); - this.isPannelVisible = false; - CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.ccComposeMessage, { text: reply }); - this.keyboardDidShowListener?.remove(); - this.keyboardDidHideListener?.remove(); - } - closeBottomsheet = () => { - if (this.setCallback) { - this.setCallback(false) - } - } - - getSmartReplies(): Promise { - return new Promise((resolve, reject) => { - let receiverId: string = this.user ? this.user?.getUid() : this.group?.getGuid(); - let receiverType: string = this.user ? ReceiverTypeConstants.user : ReceiverTypeConstants.group; - if (this.smartReplyConfiguration?.customView) { - CometChat.getSmartReplies(receiverId, receiverType).then((response: any) => { - this.smartReplyConfiguration.customView(response, this.closeBottomsheet).then((res)=>{ - return resolve(({res})) - - }) - .catch((err: CometChat.CometChatException) => { - return reject(err) - }) - - }) - .catch((err: CometChat.CometChatException) => { - return reject(err) - }) - } - else if (this.smartReplyConfiguration?.onClick) { - this.smartReplyConfiguration?.onClick(this.user, this.group).then((response: any) => { - return resolve(({response})) - }) - .catch((err: CometChat.CometChatException) => { - return reject(err) - }) - - } - else { - CometChat.getSmartReplies(receiverId, receiverType).then((response: any) => { - let view: JSX.Element[] = [] - Object.keys(response).forEach((reply) => { - if (response[reply] && response[reply] != "") { - view.push( - ( this.editReply(response[reply])} - > - {response[reply]} - ) - - ) - } - - - - }) - return resolve(({view})) - - }) - .catch((err: CometChat.CometChatException) => { - return reject(err) - }) - } - - }) - - } - - showDefaultPanel(state:State = State.loading, error?:CometChat.CometChatException) { - this.closeBottomsheet() - let LoadingView:JSX.Element = this.smartReplyConfiguration?.LoadingStateView || this.configuration.LoadingStateView - let EmptyView:JSX.Element = this.smartReplyConfiguration?.EmptyStateView || this.configuration.EmptyStateView - let ErrorView:JSX.Element = this.smartReplyConfiguration?.ErrorStateView || this.configuration.ErrorStateView - - CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.showPanel, { - alignment: ViewAlignment.composerBottom, - child: () => ( - - {state == State.loading ? LoadingView ? : - - {localize("GENERATING_REPLIES")} - - - : - - state == State.empty ? - EmptyView ? : - - {this.emptyStateText} - - : ErrorView ? ErrorView(error) : - - - {this.errorStateText} - - - } - - - - - ), - }); - - this.isPannelVisible = true; - } - - - getAuxiliaryOptions(user?: CometChat.User, group?: CometChat.Group, id?: Map, theme?: CometChatTheme) { - let contextTheme = useContext(CometChatContext) - if(contextTheme?.theme){ - this.theme = contextTheme.theme - } - else{ - this.theme = theme || new CometChatTheme({}); - } - this.cardViewStyle = getCardViewStyle(this.theme, this.configuration?.listStyle,this.smartReplyConfiguration.smartRepliesStyle); - this.id = id; - this.user = user!; - this.group = group!; - let auxiliaryOptions = super.getAuxiliaryOptions(user, group, id, theme); - this.cardsData = { - smartReply: { - title: localize("SUGGEST_A_REPLIES"), - onClick: this.onButtonClick, - id: "smart-replies", - style: getButtonStyles(this.theme, this.smartReplyConfiguration?.smartRepliesStyle, this.configuration?.listItemStyle) - - }, - conversationStarter: { - title: "Conversation Starter", - onClick: this.onButtonClick, - id: "conversation-starter", - style: getButtonStyles(this.theme, this.conversationStarterConfiguration?.conversationStarterStyle) - - } - }; - - - - if (!(id as any).parentMessageId || Number((id as any).parentMessageId) <= 0 || (id as any).parentMessageId == undefined) { - - auxiliaryOptions.unshift(this.getAIAuxiliaryButton(id, user, group, theme)); - } - return auxiliaryOptions; - } - - getAIAuxiliaryButton(id: Map, user?: CometChat.User, group?: CometChat.Group, theme?: CometChatTheme): JSX.Element { - const [aiFeatures, setAiFeatures] = useState(false); - let cards: Card[] = [] - this.setCallback = setAiFeatures - if (this.features && Object.keys(this.features).length > 0) { - - if (this.features?.["smart-replies"]?.enabled) { - this.smartReplyConfiguration = this.features?.["smart-replies"]?.configuration ?? new AISmartRepliesConfiguration({}) - cards.push(this.cardsData.smartReply!) - } - - - } - - return ( { - CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, { - alignment: ViewAlignment.composerBottom, - child: () => (null), - }); - if(this.isPannelVisible){ - setAiFeatures(false); - this.isPannelVisible = false; - return; - } - setAiFeatures(true); - - }} style={{ justifyContent: "center" }}> - - { - { - setAiFeatures(false) - }} - - > - - - } - ) - - } - -} - diff --git a/src/AI/AIExtensionDataSource.ts b/src/AI/AIExtensionDataSource.ts index 24d5dd4..6396fe0 100644 --- a/src/AI/AIExtensionDataSource.ts +++ b/src/AI/AIExtensionDataSource.ts @@ -1,12 +1,17 @@ -import { ExtensionsDataSource } from "../shared/framework/ExtensionsDataSource"; -import { AIEnablerConfiguration } from "./configuration"; - -export abstract class AIExtensionDataSource extends ExtensionsDataSource { - getConfiguration():any{ - - }; - setConfiguration(config?:AIEnablerConfiguration):void{ - - }; - -} \ No newline at end of file +import { CometChat } from "@cometchat/chat-sdk-react-native"; + +abstract class AIExtensionDataSource { + abstract addExtension(): void; + abstract getExtensionId(): string; + + enable(): void { + CometChat.isAIFeatureEnabled(this.getExtensionId()).then( + (enabled: Boolean) => { + if (enabled) this.addExtension(); + } + ); + } + +} + +export { AIExtensionDataSource }; \ No newline at end of file diff --git a/src/AI/AIOptionsStyle.ts b/src/AI/AIOptionsStyle.ts new file mode 100644 index 0000000..8eda82d --- /dev/null +++ b/src/AI/AIOptionsStyle.ts @@ -0,0 +1,14 @@ +import { BaseStyle, FontStyle } from "../shared"; + +export class AIOptionsStyle extends BaseStyle { + listItemBackground?: string; + listItemTitleFont?: FontStyle; + listItemTitleColor?: string; + listItemBorderRadius?: number; + listItemBorder?: string; + optionsSeparatorTint?: string; + constructor(props: Partial) { + super({}); + Object.assign(this, props); + } +} diff --git a/src/AI/AISmartReplies/AISmartReplies.ts b/src/AI/AISmartReplies/AISmartReplies.ts index 6415e2f..db1177f 100755 --- a/src/AI/AISmartReplies/AISmartReplies.ts +++ b/src/AI/AISmartReplies/AISmartReplies.ts @@ -1,28 +1,19 @@ -import { AISmartRepliesExtensionDecorator } from "./AISmartRepliesDecorator"; +import { AISmartRepliesExtensionDecorator } from "./AISmartRepliesDecorator"; import { ChatConfigurator } from "../../shared"; import { AIExtensionDataSource } from "../AIExtensionDataSource"; import { AISmartRepliesConfiguration } from "./configuration"; export class AISmartRepliesExtension extends AIExtensionDataSource { - private configuration?: AISmartRepliesConfiguration; -constructor(configuration?: AISmartRepliesConfiguration) { - super(); - this.configuration = configuration; -} + constructor(configuration?: AISmartRepliesConfiguration) { + super(); + this.configuration = configuration; + } override addExtension(): void { - ChatConfigurator.enable((dataSource: any) => new AISmartRepliesExtensionDecorator(dataSource,this.configuration)); + ChatConfigurator.enable((dataSource: any) => new AISmartRepliesExtensionDecorator(dataSource, this.configuration)); } override getExtensionId(): string { return "smart-replies"; } - override enable(): void { - this.addExtension() - - } - override getConfiguration():AISmartRepliesConfiguration{ - return this.configuration; - } - } diff --git a/src/AI/AISmartReplies/AISmartRepliesDecorator.ts b/src/AI/AISmartReplies/AISmartRepliesDecorator.ts deleted file mode 100755 index f54a60d..0000000 --- a/src/AI/AISmartReplies/AISmartRepliesDecorator.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { DataSource,DataSourceDecorator } from "../../shared"; -import { CometChat } from "@cometchat/chat-sdk-react-native"; -import { AIButtonsStyle } from "../utils"; -import { AISmartRepliesConfiguration } from "./configuration"; -export class AISmartRepliesExtensionDecorator extends DataSourceDecorator { - public configuration?:AISmartRepliesConfiguration; - constructor(dataSource:DataSource,configuration?:AISmartRepliesConfiguration){ - super(dataSource); - this.configuration = configuration; -} - override getId(): string { - return "aismartreply"; - } -} - - - - diff --git a/src/AI/AISmartReplies/AISmartRepliesDecorator.tsx b/src/AI/AISmartReplies/AISmartRepliesDecorator.tsx new file mode 100755 index 0000000..9017dc6 --- /dev/null +++ b/src/AI/AISmartReplies/AISmartRepliesDecorator.tsx @@ -0,0 +1,302 @@ +import React from "react"; +import { CometChatMessageComposerActionInterface, CometChatTheme, CometChatUIEventHandler, CometChatUIEvents, DataSource, DataSourceDecorator, MessageEvents, localize } from "../../shared"; +import { CometChat } from "@cometchat/chat-sdk-react-native"; +import { State } from "../utils"; +import { AISmartRepliesConfiguration } from "./configuration"; +import { AIOptionsStyle } from "../AIOptionsStyle"; +import { MessageStatusConstants, ReceiverTypeConstants, ViewAlignment } from "../../shared/constants/UIKitConstants"; +import { TouchableOpacity, View, Text, ScrollView, Keyboard } from "react-native"; +import CometChatAICard from "../../shared/views/CometChatAICard/CometChatAICard"; +import { CardViewStyle } from "../CardViewStyle"; +import { getCardViewStyle, getRepliesStyle, getRepliesWrapperStyle } from "../style"; +export class AISmartRepliesExtensionDecorator extends DataSourceDecorator { + public configuration?: AISmartRepliesConfiguration; + public user!: CometChat.User; + public group!: CometChat.Group; + public theme: CometChatTheme = new CometChatTheme({}); + public isPannelVisible: boolean = false; + public repliesView: JSX.Element; + public loadingStateText: string = localize("GENERATING_REPLIES"); + public errorStateText: string = localize("SOMETHING_WRONG"); + public emptyStateText: string = localize("NO_MESSAGES_FOUND"); + public cardViewStyle: CardViewStyle = {}; + public keyboardDidShowListener; + public keyboardDidHideListener; + public loggedInUser!: CometChat.User | null; + private LISTENER_ID: string = "aismartlistener__listener"; + + constructor(dataSource: DataSource, configuration?: AISmartRepliesConfiguration) { + super(dataSource); + this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this.hideOnKeyboardShow); + // this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this.showOnKeyboardShow); + this.configuration = configuration; + this.cardViewStyle = getCardViewStyle(this.theme, this.configuration?.smartRepliesStyle) + setTimeout(() => { + this.addMessageListener(); + }, 1000); + } + override getId(): string { + return "aismartreply"; + } + + override getAIOptions(user: CometChat.User | null, group: CometChat.Group | null, theme: CometChatTheme, id?: any, AIOptionsStyle?: AIOptionsStyle): CometChatMessageComposerActionInterface[] { + this.user = user!; + this.group = group!; + if (!id?.parentMessageId) { + const messageComposerActions: CometChatMessageComposerActionInterface[] = super.getAIOptions(user, group, theme, id, AIOptionsStyle); + let newAction = { + title: localize("SUGGEST_A_REPLY"), + onPress: () => { + this.onButtonClick() + }, + id: "smart-replies", + iconURL: '', + iconTint: '', + titleColor: this.configuration?.smartRepliesStyle?.buttonTextColor || AIOptionsStyle.listItemTitleColor, + titleFont: this.configuration?.smartRepliesStyle?.buttonTextFont || AIOptionsStyle.listItemTitleFont, + background: this.configuration?.smartRepliesStyle?.backgroundColor || AIOptionsStyle.listItemBackground, + cornerRadius: this.configuration?.smartRepliesStyle?.buttonBorderRadius || AIOptionsStyle.listItemBorderRadius, + }; + messageComposerActions.push(newAction); + return messageComposerActions; + } else { + return super.getAIOptions(user, group, theme, id, AIOptionsStyle); + } + } + + + private getLoadingView(): JSX.Element { + let LoadingView: JSX.Element = this.configuration?.LoadingStateView; + return ( + + {LoadingView ? : null} + + ) + } + + private getEmptyView(): JSX.Element { + let EmptyView: JSX.Element = this.configuration?.EmptyStateView + return ( + + {EmptyView ? : null} + + ) + } + + private getErrorView(error?: CometChat.CometChatException): JSX.Element { + return ( + + {this.configuration?.ErrorStateView ? this.configuration?.ErrorStateView(error) : null} + + ) + } + + editReply(reply: string) { + CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, { + alignment: ViewAlignment.composerBottom, + child: () => (null), + }); + this.isPannelVisible = false; + CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.ccComposeMessage, { text: reply }); + this.keyboardDidShowListener?.remove(); + this.keyboardDidHideListener?.remove(); + } + + hideOnKeyboardShow = () => { + if (this.isPannelVisible) { + CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, { + alignment: ViewAlignment.composerBottom, + child: () => (null), + }); + } + } + + showOnKeyboardShow = () => { + if (this.isPannelVisible) { + CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, { + alignment: ViewAlignment.composerBottom, + child: () => this.repliesView, + }); + } + } + + getSmartReplies(): Promise { + return new Promise((resolve, reject) => { + let receiverId: string = this.user ? this.user?.getUid() : this.group?.getGuid(); + let receiverType: string = this.user ? ReceiverTypeConstants.user : ReceiverTypeConstants.group; + if (this.configuration?.customView) { + CometChat.getSmartReplies(receiverId, receiverType).then((response: any) => { + this.configuration.customView(response).then((res) => { + return resolve(({res})) + + }) + .catch((err: CometChat.CometChatException) => { + return reject(err) + }) + + }) + .catch((err: CometChat.CometChatException) => { + return reject(err) + }) + } + else { + CometChat.getSmartReplies(receiverId, receiverType).then((response: any) => { + let view: JSX.Element[] = [] + Object.keys(response).forEach((reply) => { + if (response[reply] && response[reply] != "") { + view.push( + ( this.editReply(response[reply])} + > + {response[reply]} + ) + ) + } + }) + return resolve(({view})) + + }) + .catch((err: CometChat.CometChatException) => { + return reject(err) + }) + } + + }) + + } + + onButtonClick = (): void => { + this.showDefaultPanel(State.loading) + this.getSmartReplies().then((replies) => { + if (!replies || (replies?.length && replies.length <= 0)) { + this.showDefaultPanel(State.empty) + } + else { + this.repliesView = ( + + {replies} + + + + ) + CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.showPanel, { + alignment: ViewAlignment.composerBottom, + child: () => this.repliesView, + }); + } + + this.isPannelVisible = true + + }) + .catch((err) => { + this.showDefaultPanel(State.error, err) + + }) + } + + showDefaultPanel(state: State = State.loading, error?: CometChat.CometChatException) { + CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.showPanel, { + alignment: ViewAlignment.composerBottom, + child: () => ( + + {state == State.loading ? this.getLoadingView() : (state == State.empty ? this.getEmptyView() : this.getErrorView(error))} + + ) + }); + + this.isPannelVisible = true; + } + + closePanel = () => { + CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, { + alignment: ViewAlignment.composerBottom, + child: () => (null), + }); + }; + + closeIfMessageReceived(message: CometChat.BaseMessage) { + if (message?.getReceiverId() === this.loggedInUser?.getUid()) { + this.closePanel(); + } + } + + private addMessageListener(): void { + CometChat.getLoggedinUser().then((user: CometChat.User | null) => { + if (user) { + this.loggedInUser = user; + } + }); + + CometChatUIEventHandler.addMessageListener(this.LISTENER_ID, { + onTextMessageReceived: (message: CometChat.TextMessage) => { + this.closeIfMessageReceived(message); + }, + onCustomMessageReceived: (message: CometChat.CustomMessage) => { + this.closeIfMessageReceived(message); + }, + onMediaMessageReceived: (message: CometChat.MediaMessage) => { + this.closeIfMessageReceived(message); + }, + onFormMessageReceived: (formMessage) => { + this.closeIfMessageReceived(formMessage) + }, + onCardMessageReceived: (cardMessage) => { + this.closeIfMessageReceived(cardMessage) + }, + onCustomInteractiveMessageReceived: (customInteractiveMessage) => { + this.closeIfMessageReceived(customInteractiveMessage) + } + }); + + CometChatUIEventHandler.addMessageListener( + MessageEvents.ccActiveChatChanged + "_AISmartReplies", + { + ccActiveChatChanged: (data) => { + // console.log("_________ACTIVE CHAT CHANGED IN AI CONVERSATION SUMMARY") + // this.currentMessage = data.message!; + // this.user = data.user!; + // this.group = data.group!; + // this.unreadMessageCount = data.unreadMessageCount ?? 0; + // if (this.unreadMessageCount >= (this.configuration?.unreadMessageThreshold ?? 30)) { + // this.loadConversationSummary(); + // } + }, + ccMessageSent: ({ message, status }) => { + if (status == MessageStatusConstants.success && message?.sender?.uid == this.loggedInUser?.uid) { + this.closePanel(); + } + } + } + ); + + } + +} + + + + diff --git a/src/AI/AISmartReplies/AISmartRepliesStyle.ts b/src/AI/AISmartReplies/AISmartRepliesStyle.ts index 3db17fb..621b494 100644 --- a/src/AI/AISmartReplies/AISmartRepliesStyle.ts +++ b/src/AI/AISmartReplies/AISmartRepliesStyle.ts @@ -5,7 +5,7 @@ export class AISmartRepliesStyle extends AIButtonsStyle { buttonTextColor?:string; buttonTextFont?:FontStyleInterface; buttonBorder?:BorderStyleInterface; - buttonBorderRadius?:string; + buttonBorderRadius?:number; buttonHeight?:string; buttonWidth?:string; buttonBackgroundColor?:string; diff --git a/src/AI/AISmartReplies/configuration.ts b/src/AI/AISmartReplies/configuration.ts index 679faef..14f8818 100644 --- a/src/AI/AISmartReplies/configuration.ts +++ b/src/AI/AISmartReplies/configuration.ts @@ -1,17 +1,10 @@ -import {CometChat} from '@cometchat/chat-sdk-react-native' import { AISmartRepliesStyle } from './AISmartRepliesStyle'; -import { loadingIcon, errorIcon, emptyIcon } from '../resources'; -export class AISmartRepliesConfiguration { - onClick?:(user?:CometChat.User,group?:CometChat.Group)=>Promise; - smartRepliesStyle?:AISmartRepliesStyle; +import { AIBaseConfiguration } from '../AIBaseConfiguration'; +export class AISmartRepliesConfiguration extends AIBaseConfiguration { customView?:(response:Object,closeBottomsheet?:()=>void) => Promise; - ErrorStateView?: (e?: CometChat.CometChatException) => JSX.Element; - EmptyStateView?: () => JSX.Element; - LoadingStateView?: () => JSX.Element; - loadingIconURL?:string = loadingIcon; - errorIconURL?:string = errorIcon; - emptyIconURL?:string = emptyIcon; + smartRepliesStyle?:AISmartRepliesStyle; constructor(props: Partial) { + super({}); Object.assign(this, props); } } \ No newline at end of file diff --git a/src/AI/resources/index.ts b/src/AI/resources/index.ts index ae8c003..9dcde93 100644 --- a/src/AI/resources/index.ts +++ b/src/AI/resources/index.ts @@ -1,10 +1,8 @@ -import AIBotIcon from "./ai.png"; import loadingIcon from './spineer.png' import errorIcon from './ai-error.png' import emptyIcon from './ai-empty.png' export { - AIBotIcon, loadingIcon, errorIcon, emptyIcon diff --git a/src/AI/utils.ts b/src/AI/utils.ts index 6aac8e9..b5d5470 100644 --- a/src/AI/utils.ts +++ b/src/AI/utils.ts @@ -33,7 +33,7 @@ export interface AIConfigurations { export enum State { - loading, - error, - empty + loading = "loading", + error = "error", + empty = "empty", } \ No newline at end of file diff --git a/src/CometChatMessageComposer/CometChatMessageComposer.tsx b/src/CometChatMessageComposer/CometChatMessageComposer.tsx index 9399d8b..9c92ea8 100644 --- a/src/CometChatMessageComposer/CometChatMessageComposer.tsx +++ b/src/CometChatMessageComposer/CometChatMessageComposer.tsx @@ -49,6 +49,7 @@ import { CometChatContextType } from '../shared/base/Types'; import { CometChatUIEventHandler } from '../shared/events/CometChatUIEventHandler/CometChatUIEventHandler'; import { CometChatMessageComposerActionInterface } from '../shared/helper/types'; import { CometChatMediaRecorder, MediaRecorderStyle } from '../shared/views/CometChatMediaRecorder'; +import { AIOptionsStyle } from '../AI/AIOptionsStyle'; const { FileManager } = NativeModules; const uiEventListenerShow = 'uiEvent_show_' + new Date().getTime(); @@ -175,6 +176,35 @@ const RecordAudio = (props: any) => { ) : null; } +const AIOptions = (props: any) => { + const { + aiStyle, + shouldShow = false, + onClose = () => { }, + cometChatBottomSheetStyle = { backgroundColor: aiStyle.backgroundColor, paddingHorizontal: 0 }, + sheetRef, + aiOptions, + ...otherProps + } = props; + + return shouldShow ? ( + + + + + ) : null; +} + const LiveReaction = (props: any) => { const { show = false, reaction } = props; if (show) { @@ -464,6 +494,14 @@ export interface CometChatMessageComposerInterface { * @description callback(error)→ void */ onError?: (error: any) => void; + /** + * AI Icon URL. + */ + AIIconURL?: string; + /** + * AI Options Style. + */ + aiOptionsStyle?: AIOptionsStyle; } export const CometChatMessageComposer = React.forwardRef( (props: CometChatMessageComposerInterface, ref) => { @@ -505,20 +543,21 @@ export const CometChatMessageComposer = React.forwardRef( deleteIconUrl, stopIconUrl, submitIconUrl, + AIIconURL, + aiOptionsStyle } = props; const defaultAttachmentOptions = ChatConfigurator.dataSource.getAttachmentOptions(user, group, id); const composerIdMap = new Map().set('parentMessageId', parentMessageId); - const defaultAuxiliaryButtonOptions = + const defaultAuxiliaryButtonOptions = ChatConfigurator.getDataSource().getAuxiliaryOptions( user, group, composerIdMap, theme ); - const loggedInUser = React.useRef({}); const chatWith = React.useRef(null); @@ -531,6 +570,9 @@ export const CometChatMessageComposer = React.forwardRef( const [showEmojiboard, setShowEmojiboard] = React.useState(false); const [showActionSheet, setShowActionSheet] = React.useState(false); const [showRecordAudio, setShowRecordAudio] = React.useState(false); + const [showAIOptions, setShowAIOptions] = React.useState(false); + const [AIOptionItems, setAIOptionItems] = React.useState([]); + const [rootAIOptionItems, setRootAIOptionItems] = React.useState([]); const [actionSheetItems, setActionSheetItems] = React.useState([]); const [messagePreview, setMessagePreview] = React.useState(null); const [CustomView, setCustomView] = React.useState(null); @@ -540,6 +582,18 @@ export const CometChatMessageComposer = React.forwardRef( const bottomSheetRef = React.useRef(null); + const AIStyles = new AIOptionsStyle({ + //NEED TO ADD DEFAULT STYLE HERE + backgroundColor: theme.palette.getBackgroundColor(), + listItemBackground: theme.palette.getBackgroundColor(), + listItemTitleFont: theme.typography.subtitle1, + listItemTitleColor: theme.palette.getAccent(), + listItemBorderRadius: 0, + optionsSeparatorTint: theme.palette.getAccent200(), + borderRadius: 0, + ...aiOptionsStyle, + }) + let isTyping = null; /** @@ -898,6 +952,10 @@ export const CometChatMessageComposer = React.forwardRef( ); }; + const shouldShowAIOptions = () => { + return AIOptionItems.length > 0; + } + const AuxiliaryButtonViewElem = () => { if (AuxiliaryButtonView) return ( @@ -906,6 +964,7 @@ export const CometChatMessageComposer = React.forwardRef( else if (defaultAuxiliaryButtonOptions) return {defaultAuxiliaryButtonOptions} + {shouldShowAIOptions() && } {!hideVoiceRecording && } ; @@ -976,6 +1035,16 @@ export const CometChatMessageComposer = React.forwardRef( onClick={() => setShowRecordAudio(true)} /> } + const AIOptionsButtonView = () => { + return { + setShowAIOptions(true) + setAIOptionItems(rootAIOptionItems) + }} + /> + } //fetch logged in user useEffect(() => { @@ -1059,21 +1128,55 @@ export const CometChatMessageComposer = React.forwardRef( }; }) ); + + const aiOptions = ChatConfigurator.dataSource.getAIOptions(user, group, theme, composerIdMap, AIStyles); + let newAiOptions = _getAIOptions(aiOptions); + setAIOptionItems(newAiOptions); + setRootAIOptionItems(newAiOptions); }, [user, group, id, parentMessageId]); + const _getAIOptions = (options) => { + let newOptions = [...options]; + let newAiOptions = newOptions.map((item) => { + if (typeof item.onPress === 'function') + return { + ...item, + onPress: () => { + setShowAIOptions(false) + item.onPress(user) + }, + }; + return { + ...item, + onPress: () => { }, + }; + }) + return newAiOptions; + + } + useEffect(() => { CometChatUIEventHandler.addMessageListener(editMessageListenerID, { ccMessageEdited: (item) => previewMessage(item), }); CometChatUIEventHandler.addUIListener(UiEventListenerID, { ccToggleBottomSheet: (item) => { + if (item?.bots) { + let newAiOptions = _getAIOptions(item.bots) + setAIOptionItems(newAiOptions); + setShowAIOptions(true) + return; + } else if (item?.botView) { + setCustomView(() => item.child); + return; + } setIsVisible(false); bottomSheetRef.current?.togglePanel(); }, - ccComposeMessage: (text)=>{ + ccComposeMessage: (text) => { setIsVisible(false); bottomSheetRef.current?.togglePanel(); - + setInputMessage(text?.text) } @@ -1129,7 +1232,9 @@ export const CometChatMessageComposer = React.forwardRef( return ( <> + {!isVisible && CustomView && } { setIsVisible(false); @@ -1147,7 +1252,6 @@ export const CometChatMessageComposer = React.forwardRef( style={[ Style.container, { - backgroundColor: theme.palette.getAccent100(), paddingTop: CustomViewHeader ? 0 : 8 }, messageComposerStyle, @@ -1218,6 +1322,15 @@ export const CometChatMessageComposer = React.forwardRef( stopIconUrl={stopIconUrl} submitIconUrl={submitIconUrl} /> + { + setShowAIOptions(false) + }} + aiOptions={AIOptionItems} + aiStyle={AIStyles} + /> {HeaderView ? ( ) : ( diff --git a/src/CometChatMessageComposer/MessageComposerConfiguration.tsx b/src/CometChatMessageComposer/MessageComposerConfiguration.tsx index f34cace..2e4bda1 100644 --- a/src/CometChatMessageComposer/MessageComposerConfiguration.tsx +++ b/src/CometChatMessageComposer/MessageComposerConfiguration.tsx @@ -7,6 +7,7 @@ import { //@ts-ignore import { CometChat } from '@cometchat/chat-sdk-react-native'; import { MediaRecorderStyle } from '../shared/views/CometChatMediaRecorder'; +import { AIOptionsStyle } from '../AI/AIOptionsStyle'; export interface MessageComposerConfigurationInterface extends Omit< CometChatMessageComposerInterface, @@ -72,6 +73,8 @@ export class MessageComposerConfiguration { composerId: string | number; }) => JSX.Element; text?: string; + AIIconURL?: string; + AIOptionsStyle?: AIOptionsStyle; constructor(props: MessageComposerConfigurationInterface) { if (props) for (const [key, value] of Object.entries(props)) { diff --git a/src/AI/resources/ai.png b/src/CometChatMessageComposer/resources/ai.png similarity index 100% rename from src/AI/resources/ai.png rename to src/CometChatMessageComposer/resources/ai.png diff --git a/src/CometChatMessageComposer/resources/index.ts b/src/CometChatMessageComposer/resources/index.ts index 7b6cbf6..2c07e48 100644 --- a/src/CometChatMessageComposer/resources/index.ts +++ b/src/CometChatMessageComposer/resources/index.ts @@ -6,6 +6,7 @@ import IMAGE from './image.png' import CLOSE from './close.png'; import STICKER from "./stickers.png"; import MICROPHONE from "./microphone.png"; +import AI from './ai.png' export const ICONS ={ HEART, @@ -16,4 +17,5 @@ export const ICONS ={ CLOSE, STICKER, MICROPHONE, + AI } \ No newline at end of file diff --git a/src/CometChatMessageComposer/styles.ts b/src/CometChatMessageComposer/styles.ts index d4f9ff6..7321721 100644 --- a/src/CometChatMessageComposer/styles.ts +++ b/src/CometChatMessageComposer/styles.ts @@ -1,11 +1,8 @@ -import React from 'react'; import { StyleSheet } from 'react-native'; export const Style = StyleSheet.create({ container: { - borderRadius: 8, - paddingTop: 8, - marginTop: 10, + paddingVertical: 8, }, padding: { paddingStart: 8, diff --git a/src/CometChatMessageList/CometChatMessageList.tsx b/src/CometChatMessageList/CometChatMessageList.tsx index 834a1b8..ed3d295 100644 --- a/src/CometChatMessageList/CometChatMessageList.tsx +++ b/src/CometChatMessageList/CometChatMessageList.tsx @@ -308,16 +308,16 @@ export const CometChatMessageList = forwardRef< .then(msgs => { let reversed = msgs.reverse(); if (messagesList.length === 0 && msgs?.length > 0) { - CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccActiveChatChanged, { message: reversed[0],user:user,group:group,theme:theme,parentMessageId:parentMessageId }); + CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccActiveChatChanged, { message: reversed[0], user: user, group: group, theme: theme, parentMessageId: parentMessageId }); if (conversationId.current == null) conversationId.current = reversed[0].getConversationId(); - + } - else if(messagesList.length === 0 && !props?.parentMessageId){ - CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccActiveChatChanged, { message: reversed[0],user:user,group:group,theme:theme,parentMessageId:parentMessageId }); + else if (messagesList.length === 0 && !props?.parentMessageId) { + CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccActiveChatChanged, { message: reversed[0], user: user, group: group, theme: theme, parentMessageId: parentMessageId }); } - + for (let index = 0; index < reversed.length; index++) { const message: CometChat.BaseMessage = reversed[index]; if (message && !disableReceipt && !message.hasOwnProperty("readAt") && loggedInUser.current.getUid() != message['sender']['uid']) { @@ -925,6 +925,7 @@ export const CometChatMessageList = forwardRef< style={messageBubbleDateStyle} pattern={"timeFormat"} customDateString={datePattern && datePattern(item)} + dateAlignment="center" /> } @@ -954,6 +955,7 @@ export const CometChatMessageList = forwardRef< style={messageBubbleDateStyle} pattern={"timeFormat"} customDateString={datePattern && datePattern(item)} + dateAlignment="center" /> { !disableReceipt && isSender ? @@ -1101,7 +1103,7 @@ export const CometChatMessageList = forwardRef< // textMessage.setMuid(`${getUnixTimestamp()}`); // textMessage['_composedAt'] = getUnixTimestamp(); // textMessage.setReceiverType(receiverType); - // CometChatUIKit.sendTextMessage(textMessage, resolve, reject) + // CometChatUIKit.sendTextMessage(textMessage).then(resolve).catch(reject) // break; // case MessageTypeConstants.image: // case MessageTypeConstants.video: @@ -1126,7 +1128,7 @@ export const CometChatMessageList = forwardRef< // mediaMessage.setData(messageToForward.current['data']); - // CometChatUIKit.sendMediaMessage(mediaMessage, resolve, reject) + // CometChatUIKit.sendMediaMessage(mediaMessage).then(resolve).catch(reject); // break; // default: // break; @@ -1239,7 +1241,7 @@ export const CometChatMessageList = forwardRef< const RenderMessageItem = ({ item, index }) => { let seperatorView = null; - const previousMessageDate = messagesList[index + 1] ? new Date(getSentAtTimestamp(messagesList[index + 1])) : null; + const previousMessageDate = messagesList[index - 1] ? new Date(getSentAtTimestamp(messagesList[index - 1])) : null; const currentMessageDate = new Date(getSentAtTimestamp(item)); const currentDate = isNaN(currentMessageDate.getDate()) ? undefined : `${currentMessageDate.getDate()}-${currentMessageDate.getMonth()}-${currentMessageDate.getFullYear()}`; @@ -1254,6 +1256,7 @@ export const CometChatMessageList = forwardRef< pattern={"dayDateFormat"} style={_dateSeperatorStyle} customDateString={dateSeperatorPattern ? dateSeperatorPattern(item['sentAt']) : undefined} + dateAlignment="center" /> ) @@ -1261,8 +1264,8 @@ export const CometChatMessageList = forwardRef< lastMessageDate.current = getSentAtTimestamp(item); return - {seperatorView} + }; @@ -1273,20 +1276,22 @@ export const CometChatMessageList = forwardRef< const getEmptyTextView = useCallback(() => { if (EmptyStateView) return - return undefined; - // return ( - // - // - // {emptyStateText} - // - // - // ) + return ( + <> + + + {emptyStateText} + + + {CustomListHeader && } + + ) }, []) const getErrorStateView = useCallback(() => { @@ -1353,7 +1358,10 @@ export const CometChatMessageList = forwardRef< } = _messageListStyle; return ( - + { listState == "loading" && messagesList.length == 0 ? getLoadingStateView() : @@ -1410,6 +1418,7 @@ export const CometChatMessageList = forwardRef< )} + {CustomListHeader && } { FooterView && { const { theme } = useContext(CometChatContext); //calcualted styles and configurations - const _messageStyles = new MessageStyle({ + const _messagesStyles = new MessageStyle({ backgroundColor: theme.palette.getBackgroundColor(), ...messagesStyle }); @@ -210,10 +210,8 @@ export const CometChatMessages = (props: CometChatMessagesInterface) => { return ( { - ChatConfigurator.dataSource.getAuxiliaryHeaderAppbarOptions(user, group, theme) - } - { - AuxilaryAppBarOptions && + AuxilaryAppBarOptions ? + : ChatConfigurator.dataSource.getAuxiliaryHeaderAppbarOptions(user, group, theme) } { !hideDetails && ( @@ -235,17 +233,10 @@ export const CometChatMessages = (props: CometChatMessagesInterface) => { width, border, borderRadius - } = _messageStyles; + } = _messagesStyles; return diff --git a/src/CometChatMessages/MessagesConfiguration.ts b/src/CometChatMessages/MessagesConfiguration.ts index 377c0f5..67ecde2 100644 --- a/src/CometChatMessages/MessagesConfiguration.ts +++ b/src/CometChatMessages/MessagesConfiguration.ts @@ -21,7 +21,7 @@ export interface MessagesConfigurationInterface { disableSoundForMessages?: boolean, customSoundForIncomingMessage?: string, customSoundForOutgoingMessage?: string, - messageStyle?: MessageStyleInterface, + messagesStyle?: MessageStyleInterface, AuxilaryAppBarOptions?: (props:{user?: CometChat.User, group?: CometChat.Group}) => JSX.Element } @@ -41,7 +41,7 @@ export class MessagesConfiguration implements MessagesConfigurationInterface { disableSoundForMessages?: boolean customSoundForIncomingMessage?: string customSoundForOutgoingMessage?: string - messageStyle?: MessageStyleInterface + messagesStyle?: MessageStyleInterface AuxilaryAppBarOptions?: (props:{user?: CometChat.User, group?: CometChat.Group}) => JSX.Element constructor(props: MessagesConfigurationInterface) { diff --git a/src/calls/CallUtils.ts b/src/calls/CallUtils.ts index ca6ba54..653a409 100644 --- a/src/calls/CallUtils.ts +++ b/src/calls/CallUtils.ts @@ -15,57 +15,118 @@ export class CallUtils { initiator: CometChat.User, loggedInUser: CometChat.User ): boolean { - return initiator.getUid() == loggedInUser.getUid(); + return initiator.getUid() == loggedInUser?.getUid(); } static getCallStatus( message: CometChat.BaseMessage, loggedInUser: CometChat.User ): string { - if (!(message instanceof CometChat.Call)) return ''; - let call = message as CometChat.Call; - let callMessageText = ''; - let initiator = call.getCallInitiator(); - switch (call.getStatus()) { - case CALL_INITIATED: - if (this.isInitiator(initiator, loggedInUser)) { - callMessageText = `${localize('OUTGOING_CALL')}`; - } else { - callMessageText = `${localize('INCOMING_CALL')}`; - } - break; - case CALL_ONGOING: - callMessageText = `${localize('CALL_ACCEPTED')}`; - break; - case CALL_ENDED: - callMessageText = `${localize('CALL_ENDED')}`; - break; - case CALL_UNANSWERED: - if (this.isInitiator(initiator, loggedInUser)) { - callMessageText = `${localize('CALL_UNANSWERED')}`; - } else { - callMessageText = `${localize('CALL_MISSED')}`; - } - break; - case CALL_CANCELLED: - if (this.isInitiator(initiator, loggedInUser)) { - callMessageText = `${localize('CALL_CANCELLED')}`; - } else { - callMessageText = `${localize('CALL_MISSED')}`; - } - break; - case CALL_REJECTED: - case CALL_BUSY: - if (this.isInitiator(initiator, loggedInUser)) { - callMessageText = `${localize('CALL_REJECTED')}`; - } else { - callMessageText = `${localize('CALL_MISSED')}`; - } - break; - } - if (callMessageText == undefined || callMessageText == "undefined") + try { + // if (!(message instanceof CometChat.Call)) return ''; + let call = message as CometChat.Call; + let callMessageText = ''; + let initiator = (call?.getCallInitiator && call?.getCallInitiator()) || call.getInitiator(); + switch (call.getStatus()) { + case CALL_INITIATED: + if (this.isInitiator(initiator, loggedInUser)) { + callMessageText = `${localize(`OUTGOING_CALL`)}`; + } else { + callMessageText = `${localize(`INCOMING_CALL`)}`; + } + break; + case CALL_ONGOING: + callMessageText = `${localize(`ONGOING_CALL`)}`; + break; + case CALL_ENDED: + if (this.isInitiator(initiator, loggedInUser)) { + callMessageText = `${localize(`OUTGOING_CALL`)}`; + } else { + callMessageText = `${localize(`INCOMING_CALL`)}`; + } + break; + case CALL_BUSY: + case CALL_UNANSWERED: + if (this.isInitiator(initiator, loggedInUser)) { + callMessageText = `${localize('UNANSWERED_CALL')}`; + } else { + callMessageText = `${localize('MISSED_CALL')}`; + } + break; + case CALL_CANCELLED: + if (this.isInitiator(initiator, loggedInUser)) { + callMessageText = `${localize('CANCELLED_CALL')}`; + } else { + callMessageText = `${localize('MISSED_CALL')}`; + } + break; + case CALL_REJECTED: + if (this.isInitiator(initiator, loggedInUser)) { + callMessageText = `${localize('REJECTED_CALL')}`; + } else { + callMessageText = `${localize('MISSED_CALL')}`; + } + break; + } + if (callMessageText == undefined || callMessageText == "undefined") console.log(message, loggedInUser); - - return callMessageText; + + return callMessageText; + } catch (e) { + console.log("__CATCH", e) + return ""; + } + } + + static isMissedCall(call: CometChat.Call, loggedInUser: CometChat.User) { + const callStatus: any = call.getStatus(); + if (this.isInitiator(call.getInitiator(), loggedInUser)) { + return callStatus === CALL_UNANSWERED; + } else { + return [ + CALL_BUSY, + CALL_UNANSWERED, + CALL_REJECTED, + CALL_CANCELLED, + ].includes(callStatus); + } + } + + static convertMinutesToHoursMinutesSeconds(minutes: number): string { + const hours = Math.floor(minutes / 60); + const remainingMinutes = Math.floor(minutes % 60); + const seconds = Math.floor((minutes - Math.floor(minutes)) * 60); + let hoursString = ""; + let minutesString = ""; + let secondsString = ""; + if (hours > 0) { + hoursString = `${hours}h`; + } + if (remainingMinutes > 0) { + minutesString = `${remainingMinutes}m`; + } + if (seconds >= 0) { + secondsString = `${seconds}s`; + } + return hoursString ? `${hoursString} ${minutesString} ${secondsString}` : minutesString ? `${minutesString} ${secondsString}` : secondsString; + } + static convertSecondsToHoursMinutesSeconds(seconds: number): string { + const hours = Math.floor(seconds / 3600); + const remainingMinutes = Math.floor((seconds % 3600) / 60); + const remainingSeconds = Math.floor((seconds % 3600) % 60); + let hoursString = ""; + let minutesString = ""; + let secondsString = ""; + if (hours > 0) { + hoursString = `${hours}h`; + } + if (remainingMinutes > 0) { + minutesString = `${remainingMinutes}m`; + } + if (remainingSeconds >= 0) { + secondsString = `${remainingSeconds}s`; + } + return hoursString ? `${hoursString} ${minutesString} ${secondsString}` : minutesString ? `${minutesString} ${secondsString}` : secondsString; } + } diff --git a/src/calls/CallingDetailsUtils.tsx b/src/calls/CallingDetailsUtils.tsx index d4d0ff0..a5fde91 100644 --- a/src/calls/CallingDetailsUtils.tsx +++ b/src/calls/CallingDetailsUtils.tsx @@ -1,39 +1,157 @@ import React from "react"; +import { View, Text, Image } from "react-native"; import { CometChat } from "@cometchat/chat-sdk-react-native" -import { CometChatDetailsTemplate } from "../shared" +import { CometChatCallLogDetailsTemplate, CometChatDate, CometChatListItem, CometChatTheme, localize } from "../shared" import { CometChatCallButtons } from "./CometChatCallButtons"; +import { CallUtils } from "./CallUtils"; +import { NextArrowIcon } from "./resources"; export class CallingDetailsUtils { - static getDefaultDetailsTemplates(message: CometChat.BaseMessage, loggedInUser: CometChat.User, user?: CometChat.User, group?: CometChat.Group): Array { + static getDefaultDetailsTemplates(callLog: any, loggedInUser: CometChat.User, theme: CometChatTheme): Array { + return [ - this.getPrimaryDetailsTemplate(message, loggedInUser, user, group) + this.getPrimaryDetailsTemplate(callLog, loggedInUser, theme) ] } - static getPrimaryDetailsTemplate(message: CometChat.BaseMessage, loggedInUser: CometChat.User, user?: CometChat.User, group?: CometChat.Group): CometChatDetailsTemplate { + static getPrimaryDetailsTemplate(callLog: any, loggedInUser: CometChat.User, theme: CometChatTheme): CometChatCallLogDetailsTemplate { + + let user = callLog?.getReceiverType() == "user" ? loggedInUser?.getUid() === callLog?.getInitiator()?.getUid() ? callLog.getReceiver() : callLog?.getInitiator() : undefined + let group = callLog?.getReceiverType() == "group" ? loggedInUser?.getUid() === callLog?.getInitiator()?.getUid() ? callLog.getReceiver() : callLog?.getInitiator() : undefined + + + function subtitleView(): JSX.Element { + return ( + + + + + + + { + CallUtils.getCallStatus(callLog as CometChat.Call, loggedInUser) + } + + + {CallUtils.convertMinutesToHoursMinutesSeconds(callLog['totalDurationInMinutes'])} + + + ) + } + + let options = [{ + id: 'lastCall', + CustomView: () => ( + + subtitleView()} + listItemStyle={{ backgroundColor: theme.palette.getAccent100(), borderRadius: 10 }} + /> + + ) + } + ]; + + user && options.unshift({ + id: "controls", + CustomView: () => + + + }); + return { id: "callControls", hideItemSeparator: true, hideSectionSeparator: true, - options: [ - { - id: "controls", - CustomView: () => - } - ] + options: [...options] } } - static getSecondaryDetailsTemplate(message: CometChat.BaseMessage, loggedInUser: CometChat.User, user?: CometChat.User, group?: CometChat.Group): CometChatDetailsTemplate { + static getSecondaryDetailsTemplate(callLog: any, loggedInUser: CometChat.User, theme: CometChatTheme): CometChatCallLogDetailsTemplate { + let options = [{ + title: localize("CALL_HISTORY"), + id: 'history', + CustomView: () => ( + + ( + + {localize("CALL_HISTORY")} + + + )} + listItemStyle={{ backgroundColor: theme.palette.getAccent100(), height: 50 }} + /> + + ) + }]; + + let recordingObj = { + title: localize("RECORDINGS"), + id: 'recordings', + CustomView: () => ( + + ( + + {localize("RECORDINGS")} + + {callLog?.recordings?.length} + + + + )} + listItemStyle={{ backgroundColor: theme.palette.getAccent100(), height: 50 }} + /> + + ) + } + callLog?.recordings?.length && options.unshift(recordingObj); + + let participantsObj = { + title: localize("PARTICIPANTS"), + id: 'participants', + CustomView: () => ( + + ( + + {localize("PARTICIPANTS")} + + {callLog?.participants?.length} + + + + )} + listItemStyle={{ backgroundColor: theme.palette.getAccent100(), height: 50 }} + /> + + ) + } + options.unshift(participantsObj); + return { id: "callInfo", hideItemSeparator: true, hideSectionSeparator: true, - options: [] + options: [...options] }; } } \ No newline at end of file diff --git a/src/calls/CallingPackage.ts b/src/calls/CallingPackage.ts index 76cbb1e..9f0cd3a 100644 --- a/src/calls/CallingPackage.ts +++ b/src/calls/CallingPackage.ts @@ -1,6 +1,20 @@ +declare const require: any; -const isCallingPackageInstalled = window["CometChatCalling"]?.["isCallingComponentInstalled"]; -const CometChatCalls = window["CometChatCalling"]?.['CometChatCalls']; +let isCallingPackageInstalled, CometChatCalls; + +try { + // Attempt to require the package + CometChatCalls = require('@cometchat/calls-sdk-react-native')?.CometChatCalls; + isCallingPackageInstalled = true; + + // If no error is thrown, the package is installed + // console.log('calls sdk is installed.'); + +} catch (error) { + isCallingPackageInstalled = false; + // If an error is thrown, the package is not installed + // console.log('calls sdk is not installed.'); +} export const CallingPackage = { isCallingPackageInstalled, diff --git a/src/calls/CometChatCallButtons/CometChatCallButtons.tsx b/src/calls/CometChatCallButtons/CometChatCallButtons.tsx index 29a5e02..d26be5c 100644 --- a/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +++ b/src/calls/CometChatCallButtons/CometChatCallButtons.tsx @@ -131,10 +131,10 @@ export const CometChatCallButtons = (props: CometChatCallButtonsInterface) => { } const checkActiveCallAndDoAction = () => { - - setDisableButton(true); - - return true; + + setDisableButton(true); + + return true; } const makeCall = (type) => { @@ -164,17 +164,16 @@ export const CometChatCallButtons = (props: CometChatCallButtonsInterface) => { }) customMessage.setCustomData(customData); CometChatUIKit.sendCustomMessage( - customMessage, - (res) => { + customMessage) + .then((res) => { outGoingCall.current = res as CometChat.CustomMessage setShowOutgoingCallScreen(true); CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccOutgoingCall, { call: res }); - }, - (rej) => { + }) + .catch((rej) => { console.log("custom msg error", rej); onError && onError(rej); - } - ); + }); } else { var receiverType = user ? CometChat.RECEIVER_TYPE.USER : group ? CometChat.RECEIVER_TYPE.GROUP : undefined if (!receiverID || !receiverType) diff --git a/src/calls/CometChatCallDetails/CallDetailsConfiguration.ts b/src/calls/CometChatCallDetails/CallDetailsConfiguration.ts deleted file mode 100644 index a1d836b..0000000 --- a/src/calls/CometChatCallDetails/CallDetailsConfiguration.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { AvatarStyleInterface, CometChatDetailsTemplate, ImageType, ListItemStyleInterface } from "../../shared" -import { AvatarConfigurationInterface } from "../../shared/views/CometChatAvatar/AvatarConfiguration" -import { StatusIndicatorStyleInterface } from "../../shared/views/CometChatStatusIndicator/StatusIndicatorStyle" -// import { CometChatCallDetailsInterface } from "./CometChatCallDetails" -import { CometChat } from '@cometchat/chat-sdk-react-native' -import { CallDetailsStyleInterface } from "./CallDetailsStyle" - -export interface CallDetailsConfigurationInterface { - showCloseButton?: boolean - closeButtonIconImage?: ImageType - hideProfile?: boolean - SubtitleView?: (props: { user?: CometChat.User, group?: CometChat.Group }) => JSX.Element - CustomProfileView?: (props: { user?: CometChat.User }) => JSX.Element - data?: (props: { message: CometChat.BaseMessage, user?: CometChat.User, group?: CometChat.Group }) => CometChatDetailsTemplate[] - disableUsersPresence?: boolean - onError?: (e: CometChat.CometChatException) => void - onBack?: () => void - avatarStyle?: AvatarStyleInterface - statusIndicatorStyle?: StatusIndicatorStyleInterface - listItemStyle?: ListItemStyleInterface - callDetailsStyle?: CallDetailsStyleInterface -} - -export class CallDetailsConfiguration implements CallDetailsConfigurationInterface { - showCloseButton?: boolean - closeButtonIconImage?: ImageType - hideProfile: boolean - SubtitleView: (props: { user?: CometChat.User; group?: CometChat.Group }) => JSX.Element - CustomProfileView: (props: { user?: CometChat.User }) => JSX.Element - data: (props: { message: CometChat.BaseMessage; user?: CometChat.User; group?: CometChat.Group }) => CometChatDetailsTemplate[] - disableUsersPresence: boolean - onError: (e: CometChat.CometChatException) => void - onBack: () => void - avatarStyle: AvatarStyleInterface - statusIndicatorStyle: StatusIndicatorStyleInterface - listItemStyle: ListItemStyleInterface - callDetailsStyle: CallDetailsStyleInterface - - constructor({ - showCloseButton, - closeButtonIconImage, - hideProfile, - SubtitleView, - CustomProfileView, - data, - disableUsersPresence, - onError, - onBack, - avatarStyle, - statusIndicatorStyle, - listItemStyle, - callDetailsStyle, - }: CallDetailsConfigurationInterface) { - this.showCloseButton = showCloseButton; - this.closeButtonIconImage = closeButtonIconImage; - this.hideProfile = hideProfile; - this.SubtitleView = SubtitleView; - this.CustomProfileView = CustomProfileView; - this.data = data; - this.disableUsersPresence = disableUsersPresence; - this.onError = onError; - this.onBack = onBack; - this.avatarStyle = avatarStyle; - this.statusIndicatorStyle = statusIndicatorStyle; - this.listItemStyle = listItemStyle; - this.callDetailsStyle = callDetailsStyle; - } -} \ No newline at end of file diff --git a/src/calls/CometChatCallDetails/CallDetailsStyle.ts b/src/calls/CometChatCallDetails/CallDetailsStyle.ts deleted file mode 100644 index 6398497..0000000 --- a/src/calls/CometChatCallDetails/CallDetailsStyle.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { BaseStyle, BaseStyleInterface, FontStyleInterface } from "../../shared"; - -export interface CallDetailsStyleInterface extends BaseStyleInterface { - titleFont?: FontStyleInterface, - titleColor?: string, - backIconTint?: string, - closeIconTint?: string, - onlineStatusColor?: string, - privateGroupIconBackground?: string, - protectedGroupIconBackground?: string, -} - -export class CallDetailsStyle extends BaseStyle { - titleFont?: FontStyleInterface - titleColor?: string - backIconTint?: string - closeIconTint?: string - onlineStatusColor?: string - privateGroupIconBackground?: string - protectedGroupIconBackground?: string - - constructor({ - titleFont, - titleColor, - backIconTint, - closeIconTint, - onlineStatusColor, - privateGroupIconBackground, - protectedGroupIconBackground, - backgroundColor, - border, - borderRadius, - height, - width, - }: CallDetailsStyleInterface) { - super({ - backgroundColor, - border, - borderRadius, - height, - width, - }); - this.titleFont = titleFont; - this.titleColor = titleColor; - this.backIconTint = backIconTint; - this.closeIconTint = closeIconTint; - this.onlineStatusColor = onlineStatusColor; - this.privateGroupIconBackground = privateGroupIconBackground; - this.protectedGroupIconBackground = protectedGroupIconBackground; - - } -} \ No newline at end of file diff --git a/src/calls/CometChatCallDetails/CometChatCallDetails.tsx b/src/calls/CometChatCallDetails/CometChatCallDetails.tsx deleted file mode 100644 index d94cd80..0000000 --- a/src/calls/CometChatCallDetails/CometChatCallDetails.tsx +++ /dev/null @@ -1,268 +0,0 @@ -import React, { useEffect, useRef, useState } from 'react' -import { View, TouchableOpacity, Image, Text, FlatList, SectionList } from 'react-native' -import { CometChat } from '@cometchat/chat-sdk-react-native' -import { AvatarStyle, AvatarStyleInterface, CometChatContext, CometChatDetailsTemplate, CometChatListItem, ImageType, ListItemStyle, ListItemStyleInterface, localize } from '../../shared' -import { AvatarConfigurationInterface } from '../../shared/views/CometChatAvatar/AvatarConfiguration' -import { StatusIndicatorStyle, StatusIndicatorStyleInterface } from '../../shared/views/CometChatStatusIndicator/StatusIndicatorStyle' -import { CometChatCallButtonConfigurationInterface, CometChatCallButtons } from '../CometChatCallButtons' -import { Style } from './style' -import { CloseIcon } from './resources' -import { useContext } from 'react' -import { CallDetailsStyle } from './CallDetailsStyle' -import { CallDetailsStyleInterface } from './CallDetailsStyle' -import { CallingDetailsUtils } from '../CallingDetailsUtils' -import { PASSWORD_GROUP_COLOR, PRIVATE_GROUP_COLOR } from '../../shared/constants/UIKitConstants' - -interface CometChatCallDetailsInterface { - /** - * Pass CometChat.Call object. This parameter is required - */ - call: CometChat.Call, - /** - * title sets the string in top navigation bar. - */ - title?: string, - /** - * toggle visibility of close button - */ - showCloseButton?: boolean, - /** - * This will change the close button icon - */ - closeButtonIconImage?: ImageType, - /** - * toggle the profile view - */ - hideProfile?: boolean, - /** - * customize the subtitle view as per your need. - */ - SubtitleView?: (props: { user?: CometChat.User, group?: CometChat.Group }) => JSX.Element, - /** - * Pass the custom profile view here. - */ - CustomProfileView?: (props: { user?: CometChat.User }) => JSX.Element, - /** - * List of templates tobe shown - */ - data?: (props: { message: CometChat.BaseMessage, user?: CometChat.User, group?: CometChat.Group }) => CometChatDetailsTemplate[], - /** - * toggle user presence - */ - disableUsersPresence?: boolean, - /** - * call back for error - */ - onError?: (e: CometChat.CometChatException) => void, - /** - * custom functionality on back press - */ - onBack?: () => void, - /** - * Style object for Avatar - */ - avatarStyle?: AvatarStyleInterface, - /** - * Style object for StatusIndicator - */ - statusIndicatorStyle?: StatusIndicatorStyleInterface, - /** - * Style object for ListItem - */ - listItemStyle?: ListItemStyleInterface, - /** - * Style object for CallDetails - */ - callDetailsStyle?: CallDetailsStyleInterface, -} - -const listenerId = "userListener_" + new Date().getTime(); - -const CometChatCallDetails = (props: CometChatCallDetailsInterface) => { - - const { - onBack, - onError, - CustomProfileView, - SubtitleView, - data, - disableUsersPresence, - hideProfile, - call, - closeButtonIconImage, - showCloseButton = true, - title = localize("CALL_DETAILS"), - avatarStyle, - callDetailsStyle, - listItemStyle, - statusIndicatorStyle, - } = props; - - const { theme } = useContext(CometChatContext); - const [tempates, setTemplates] = useState([]); - const [group, setGroup] = useState(undefined); - const [user, setUser] = useState(undefined); - const [error, setError] = useState(undefined); - const loggedInUser = useRef(null); - - const _avatarStyle = new AvatarStyle({ - nameTextColor: theme.palette.getAccent(), - backgroundColor: theme.palette.getBackgroundColor(), - nameTextFont: theme.typography.heading, - ...avatarStyle - }); - - const _listStyle = new ListItemStyle({ - backgroundColor: theme.palette.getBackgroundColor(), - titleColor: theme.palette.getAccent(), - titleFont: theme.typography.body, - ...listItemStyle - }); - - const _statusStyle = new StatusIndicatorStyle({ - ...statusIndicatorStyle - }); - - const _callDetailsStyle = new CallDetailsStyle({ - backIconTint: theme.palette.getPrimary(), - titleColor: theme.palette.getAccent(), - titleFont: theme.typography.heading, - closeIconTint: theme.palette.getPrimary(), - backgroundColor: theme.palette.getBackgroundColor(), - ...callDetailsStyle - }); - - useEffect(() => { - CometChat.getLoggedinUser().then( - (loggedUser: CometChat.User) => { - let tmpList: CometChatDetailsTemplate[]; - loggedInUser.current = loggedUser; - let user = call?.getReceiverType() == "user" ? call.getReceiver() as CometChat.User : undefined - let group = call?.getReceiverType() == "group" ? call['receiver'] as CometChat.Group : undefined - if (data) { - tmpList = data({ message: call, user, group }); - } else { - tmpList = CallingDetailsUtils.getDefaultDetailsTemplates(call, loggedUser, user, group) - } - setTemplates(tmpList.map(item => { - item['data'] = item.options; - return item; - })) - setUser(user); - setGroup(group); - }, - (error: CometChat.CometChatException) => { - setError(localize("SOMETHING_WRONG")); - onError && onError(error); - } - ); - CometChat.addUserListener( - listenerId, - new CometChat.UserListener({ - onUserOnline: (user) => { - setUser(user); - }, - onUserOffline: (user) => { - setUser(user); - }, - }) - ); - return () => { - CometChat.removeUserListener(listenerId); - } - }, []); - - const getStatusColor = () => { - if (disableUsersPresence) - return "transparent"; - if (user && user['status'] == "online") - return theme.palette.getSuccess(); - if (group) { - if (group['type'] == "password") - return PASSWORD_GROUP_COLOR; - if (group['type'] == "private") - return PRIVATE_GROUP_COLOR; - } - return "transparent"; - } - - const subtitleView = () => { - if (SubtitleView) - return - return - { - user ? - user['status'] : - group ? - `${group['membersCount']} ${localize("MEMBERS")}` - : - undefined - } - - } - - const _render = ({ item }) => { - return item.CustomView && item.CustomView() - } - - return ( - - { - !hideProfile && - - { - CustomProfileView && - } - { - showCloseButton && - - - - } - {title} - - } - { - error && - - {error} - || - <> - subtitleView()} - avatarName={user ? user['name'] : group ? group['name'] : undefined} - title={user ? user['name'] : group ? group['name'] : undefined} - avatarStyle={_avatarStyle} - statusIndicatorStyle={_statusStyle} - listItemStyle={_listStyle} - /> - item + index} - renderItem={_render} - renderSectionHeader={({ section }) => { - const { title, titleColor, titleFont, titleStyle } = section; - if (!title) - return null; - - return ( - - {title} - - ); - }} - /> - - } - - ) -} \ No newline at end of file diff --git a/src/calls/CometChatCallDetails/index.ts b/src/calls/CometChatCallDetails/index.ts deleted file mode 100644 index 83d27cb..0000000 --- a/src/calls/CometChatCallDetails/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { CallDetailsConfiguration, CallDetailsConfigurationInterface } from "./CallDetailsConfiguration"; -import { CallDetailsStyle, CallDetailsStyleInterface } from "./CallDetailsStyle"; - -export { - CallDetailsConfiguration, - CallDetailsConfigurationInterface, - CallDetailsStyle, - CallDetailsStyleInterface -} \ No newline at end of file diff --git a/src/calls/CometChatCallHistory/CallHistoryStyle.ts b/src/calls/CometChatCallHistory/CallHistoryStyle.ts deleted file mode 100644 index c22a303..0000000 --- a/src/calls/CometChatCallHistory/CallHistoryStyle.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { BaseStyle, BaseStyleInterface, FontStyle, FontStyleInterface } from "../../shared"; - -export interface CallHistoryStyleInterface extends BaseStyleInterface { - titleFont?: FontStyleInterface, - titleColor?: string, -} - -export class CallHistoryStyle extends BaseStyle implements CallHistoryStyleInterface { - titleFont?: FontStyleInterface; - titleColor?: string; - loadingTint?: string; - emptyTextFont?: FontStyleInterface; - emptyTextColor?: string - - constructor({ - titleFont = { fontSize: 20, fontWeight: "600"}, - backgroundColor = "white", - border, - borderRadius, - height, - titleColor = "#000", - width - }: CallHistoryStyleInterface) { - super({ - backgroundColor: backgroundColor, - border: border, - borderRadius: borderRadius, - height: height, - width: width - }); - this.titleColor = titleColor; - this.titleFont = titleFont; - } -} \ No newline at end of file diff --git a/src/calls/CometChatCallHistory/CometChatCallHistory.tsx b/src/calls/CometChatCallHistory/CometChatCallHistory.tsx deleted file mode 100644 index b3c53cf..0000000 --- a/src/calls/CometChatCallHistory/CometChatCallHistory.tsx +++ /dev/null @@ -1,422 +0,0 @@ -import { CometChat } from '@cometchat/chat-sdk-react-native' -import React, { useContext, useEffect, useRef, useState } from 'react' -import { FlatList, Image, ImageStyle, StyleProp, Text, TouchableOpacity, View, ViewStyle } from 'react-native' -import { ImageType, SelectionMode } from '../../shared/base/Types' -import { AvatarStyleInterface, CometChatContext, CometChatDate, CometChatList, CometChatListItem, CometChatOptions, ListItemStyleInterface, localize } from '../../shared' -import { StatusIndicatorStyleInterface } from '../../shared/views/CometChatStatusIndicator/StatusIndicatorStyle' -import { CallHistoryStyle, CallHistoryStyleInterface } from './CallHistoryStyle' -import { CometChatUIEventHandler } from '../../shared/events/CometChatUIEventHandler/CometChatUIEventHandler' -import { AudioCallIcon, VideoCallIcon, LoadingIcon, DetailIcon, BackIcon, CheckIcon, SelectionIcon } from "./resources"; -import { CallContstatnts } from '../../shared/constants/UIKitConstants' -import { Style } from './style' -import { messageStatus } from '../../shared/utils/CometChatMessageHelper' -import { MessageCategoryConstants } from '../../shared/constants/UIKitConstants' -import { MessageTypeConstants } from '../../shared/constants/UIKitConstants' - -const callListenerId = "uiEvents_" + new Date().getTime(); - -interface CometChatCallHistoryInterface { - title?: string, - SubtitleView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element, - ListItemView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element, - AppBarOptions?: () => JSX.Element, - options?: (param: { message: CometChat.BaseMessage }) => CometChatOptions[], - messageRequestBuilder?: CometChat.MessagesRequestBuilder, - hideSeperator?: boolean, - BackButton?: JSX.Element, - showBackButton?: boolean, - selectionMode?: SelectionMode, - onSelection?: (items: Array) => void, - EmptyStateView?: () => JSX.Element, - emptyStateText?: string, - ErrorStateView?: () => JSX.Element, - errorStateText?: string, - loadingIcon?: ImageType, - LoadingStateView?: () => JSX.Element, - hideError?: boolean, - onItemPress?: (item: CometChat.BaseMessage) => void, - onItemLongPress?: (item: CometChat.BaseMessage) => void, - onError?: (e: CometChat.CometChatException) => void, - onBack?: () => void, - onInfoIconPress?: (prop: { call: CometChat.BaseMessage }) => void, - infoIcon?: ImageStyle, - avatarStyle?: AvatarStyleInterface, - statusIndicatorStyle?: StatusIndicatorStyleInterface, - listItemStyle?: ListItemStyleInterface, - callHistoryStyle?: CallHistoryStyleInterface, - headViewContainerStyle?: StyleProp, - bodyViewContainerStyle?: StyleProp, - tailViewContainerStyle?: StyleProp, -} - -const CometChatCallHistory = (props: CometChatCallHistoryInterface) => { - - const { - title = localize("CALL_HISTORY"), - SubtitleView, - ListItemView, - AppBarOptions, - options, - messageRequestBuilder, - hideSeperator = false, - BackButton, - showBackButton = true, - selectionMode = "multiple", - onSelection, - EmptyStateView, - emptyStateText, - ErrorStateView, - errorStateText, - loadingIcon, - LoadingStateView, - hideError, - onItemPress, - onItemLongPress, - onInfoIconPress, - infoIcon, - onError, - onBack, - avatarStyle, - statusIndicatorStyle, - listItemStyle, - callHistoryStyle, - headViewContainerStyle, - bodyViewContainerStyle, - tailViewContainerStyle, - } = props; - - const { theme } = useContext(CometChatContext); - - const _style = new CallHistoryStyle({ - titleFont: theme.typography.heading, - titleColor: theme.palette.getAccent(), - backgroundColor: theme.palette.getBackgroundColor(), - ...callHistoryStyle - }); - - const { - backgroundColor, - height, - width, - border, - borderRadius, - titleColor, - titleFont, - loadingTint, - } = _style; - - const [list, setList] = useState([]); - const [listState, setListState] = useState<"loading" | "error" | "done">("loading"); - const [selecting, setSelecting] = useState(false); - const [selectedItems, setSelectedItems] = useState({}); - - const loggedInUser = useRef(null); - const callRequestBuilderRef = useRef((messageRequestBuilder && messageRequestBuilder.build()) ?? new CometChat.MessagesRequestBuilder() - .setCategories([MessageCategoryConstants.call, MessageCategoryConstants.custom]) - .setTypes([MessageTypeConstants.audio, MessageTypeConstants.video, MessageTypeConstants.meeting]) - .setLimit(30) - .build()); - - const fetchCallHistory = () => { - setListState("loading"); - callRequestBuilderRef.current.fetchPrevious() - .then(callLogs => { - console.log(callLogs.length); - setList([...list, ...callLogs.reverse()]); - setListState("done"); - }) - .catch(err => { - onError && onError(err); - setListState("error"); - }); - } - - useEffect(() => { - CometChat.getLoggedinUser() - .then(u => { - loggedInUser.current = u; - fetchCallHistory(); - }) - .catch(e => { - onError(e); - }); - CometChat.addCallListener( - callListenerId, - new CometChat.CallListener({ - onIncomingCallReceived: (call) => { - addNewCall(call); - }, - onOutgoingCallAccepted: (call) => { - addNewCall(call); - }, - onOutgoingCallRejected: (call) => { - addNewCall(call); - }, - onIncomingCallCancelled: (call) => { - addNewCall(call); - } - }) - ); - - CometChatUIEventHandler.addMessageListener( - callListenerId, - { - ccMessageSent: ({ message, status }) => { - status == messageStatus.success && addNewCall(message) - } - } - ) - - CometChatUIEventHandler.addCallListener( - callListenerId, - { - ccOutgoingCall: ({ call }) => { addNewCall(call) }, - ccCallAccepted: ({ call }) => { addNewCall(call) }, - ccCallRejected: ({ call }) => { addNewCall(call) }, - ccCallEnded: ({ call }) => { addNewCall(call) } - } - ) - - return () => { - CometChat.removeCallListener(callListenerId); - CometChatUIEventHandler.removeMessageListener(callListenerId); - } - }, []); - - const addNewCall = (call) => { - setList([call, ...list]); - } - - const DefaultSubtitleView = ({ call }) => { - if (SubtitleView) - return SubtitleView(call); - return ( - - - - { - call['type'] == "meeting" ? - "conference call" : - call['status'] - } - - - ); - } - - const TailView = ({ call }) => { - return ( - - - onInfoIconPress && onInfoIconPress({ call })} style={{ marginStart: 8 }}> - - - - ) - } - - //returns index from selected items - const isSelected = (item) => { - return Object.keys(selectedItems).includes(item.id); - } - - const longPress = (item) => { - if (onItemLongPress) { - onItemLongPress(item); - return; - } - - setSelecting(true); - if (selectionMode == "none") return; - - if (selectionMode == "single") - setSelectedItems({ [item['id']]: item }); - else { - // let index = isSelected(item); - if (isSelected(item)) { - let tmp = { ...selectedItems }; - delete tmp[item.id]; - setSelectedItems({ [tmp['id']]: tmp }); - } else { - setSelectedItems({ - ...selectedItems, - [item['id']]: item - }); - } - } - } - - const onPress = (item) => { - if (!selecting) { - onItemPress && onItemPress(item); - return; - } - //add to selected - switch (selectionMode) { - case "single": - setSelectedItems({ [item['id']]: item }); - break; - case "multiple": - if (isSelected(item)) { - let tmp = { ...selectedItems }; - delete tmp[item.id]; - setSelectedItems(tmp); - } else { - setSelectedItems({ - ...selectedItems, - [item['id']]: item - }); - } - break; - } - } - - const getCallDetails = (call) => { - const { category, type, callInitiator, callReceiver, receiverId, receiver } = call; - - if (category == "custom" && type == "meeting") { - return { - title: receiver['name'], - avatarUrl: receiver['icon'] - } - } else if (category == "call") { - return { - title: loggedInUser.current['uid'] == receiverId ? callInitiator['name'] : callReceiver['name'], - avatarUrl: loggedInUser.current['uid'] == receiverId ? callInitiator['avatar'] : callReceiver['avatar'], - } - } - return { title: "", avatarUrl: undefined } - } - - const _render = ({ item, index }) => { - - if (ListItemView) - return - - const { title, avatarUrl } = getCallDetails(item); - - return - SubtitleView ? : - } - TailView={TailView ? () => : null} - statusIndicatorStyle={ - selectedItems[item.id] - ? { - ...(statusIndicatorStyle as object), - borderRadius: 10, - height: 20, - width: 20, - } - : statusIndicatorStyle - } - avatarStyle={avatarStyle} - options={() => options && options(item)} - onPress={() => onPress(item)} - onLongPress={() => longPress(item)} - hideSeparator={hideSeperator} - /> - } - - const EmptyView = () => { - if (EmptyStateView) - return - return ( - - {emptyStateText || localize("NO_CALL_HISTORY")} - - ) - } - - const ErrorView = () => { - if (hideError) return null; - if (ErrorStateView) - return - return - {errorStateText || localize("SOMETHING_WRONG")} - - } - - const LoadingView = () => { - if (LoadingStateView) - return - return - - - } - - const selection = () => { - if (onSelection) - onSelection(Object.values(selectedItems)); - setSelecting(false); - setSelectedItems({}); - } - - return ( - - - - { - showBackButton ? - BackButton ?? - - - : null - } - {title} - - - { - AppBarOptions && - } - { - selecting ? - - - : null - } - - - { - listState == "loading" && list.length == 0 ? - : - listState == "error" && list.length == 0 ? - : - list.length == 0 ? - : - item.id} - renderItem={_render} - onEndReached={fetchCallHistory} - /> - } - - ) -} diff --git a/src/calls/CometChatCallHistory/index.ts b/src/calls/CometChatCallHistory/index.ts deleted file mode 100644 index 51d2558..0000000 --- a/src/calls/CometChatCallHistory/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { CallHistoryConfiguration, CallHistoryConfigurationInterface } from "./CallHistoryConfiguration"; -import { CallHistoryStyle, CallHistoryStyleInterface } from "./CallHistoryStyle"; - -export { - CallHistoryConfiguration, - CallHistoryConfigurationInterface, - CallHistoryStyle, - CallHistoryStyleInterface -} \ No newline at end of file diff --git a/src/calls/CometChatCallHistory/resources/index.ts b/src/calls/CometChatCallHistory/resources/index.ts deleted file mode 100644 index cbd9de6..0000000 --- a/src/calls/CometChatCallHistory/resources/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -import AudioCallIcon from "./Call.png"; -import VideoCallIcon from "./Video.png"; -import LoadingIcon from "./Spineer.png"; -import DetailIcon from "./Info.png"; -import BackIcon from "./Back.png"; -import CheckIcon from "./check.png"; -import SelectionIcon from "./Selection.png"; - -export { - SelectionIcon, - CheckIcon, - DetailIcon, - AudioCallIcon, - VideoCallIcon, - LoadingIcon, - BackIcon -} \ No newline at end of file diff --git a/src/calls/CometChatCallHistoryWithDetails/HistoryWithDetailsConfiguration.ts b/src/calls/CometChatCallHistoryWithDetails/HistoryWithDetailsConfiguration.ts deleted file mode 100644 index 0442fb8..0000000 --- a/src/calls/CometChatCallHistoryWithDetails/HistoryWithDetailsConfiguration.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { CallDetailsConfigurationInterface } from "../CometChatCallDetails"; -import { CallHistoryConfigurationInterface } from "../CometChatCallHistory/CallHistoryConfiguration"; - -export interface HistoryWithDetailsConfigurationInterface { - callHistoryConfiguration?: CallHistoryConfigurationInterface, - callDetailsConfiguration?: CallDetailsConfigurationInterface, -} \ No newline at end of file diff --git a/src/calls/CometChatCallHistoryWithDetails/HistoryWithDetailsStyle.ts b/src/calls/CometChatCallHistoryWithDetails/HistoryWithDetailsStyle.ts deleted file mode 100644 index 542c08e..0000000 --- a/src/calls/CometChatCallHistoryWithDetails/HistoryWithDetailsStyle.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface HistoryWithDetailsStyleInterface { - -} \ No newline at end of file diff --git a/src/calls/CometChatCallHistoryWithDetails/index.ts b/src/calls/CometChatCallHistoryWithDetails/index.ts deleted file mode 100644 index 2f5e656..0000000 --- a/src/calls/CometChatCallHistoryWithDetails/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { HistoryWithDetailsConfigurationInterface } from "./HistoryWithDetailsConfiguration"; -import { HistoryWithDetailsStyleInterface } from "./HistoryWithDetailsStyle"; - -export -{ - HistoryWithDetailsConfigurationInterface, - HistoryWithDetailsStyleInterface, -} \ No newline at end of file diff --git a/src/calls/CometChatCallLogDetails/CallLogDetailsConfiguration.ts b/src/calls/CometChatCallLogDetails/CallLogDetailsConfiguration.ts new file mode 100644 index 0000000..e09f09c --- /dev/null +++ b/src/calls/CometChatCallLogDetails/CallLogDetailsConfiguration.ts @@ -0,0 +1,116 @@ +import { AvatarStyleInterface, CometChatDetailsTemplate, ImageType } from "../../shared" +import { CometChat } from '@cometchat/chat-sdk-react-native' +import { CallLogDetailsStyleInterface } from "./CallLogDetailsStyle" +import { CallLogHistoryConfiguration } from "../CometChatCallLogHistory"; +import { CallLogParticipantsConfiguration } from "../CometChatCallLogParticipants"; +import { CallLogRecordingsConfiguration } from "../CometChatCallLogRecordings/CallLogRecordingsConfiguration"; + +export interface CallLogDetailsConfigurationInterface { + /** + * toggle visibility of close button + */ + showCloseButton?: boolean, + /** + * This will change the close button icon + */ + closeButtonIconImage?: ImageType, + /** + * toggle the profile view + */ + hideProfile?: boolean, + /** + * Pass the custom profile view here. + */ + CustomProfileView?: (props: { user?: CometChat.User }) => JSX.Element, + /** + * List of templates tobe shown + */ + data?: (props: { message: CometChat.BaseMessage, user?: CometChat.User, group?: CometChat.Group }) => CometChatDetailsTemplate[], + /** + * call back for error + */ + onError?: (e: CometChat.CometChatException) => void, + /** + * custom functionality on back press + */ + onBack?: () => void, + /** + * Style object for Avatar + */ + avatarStyle?: AvatarStyleInterface, + /** + * Style object for CallLogDetails + */ + callLogDetailsStyle?: CallLogDetailsStyleInterface, + /** + * Configuration for call history. + */ + callLogHistoryConfiguration?: CallLogHistoryConfiguration; + /** + * Configuration for call log participants. + */ + callLogParticipantsConfiguration?: CallLogParticipantsConfiguration; + /** + * Configuration for call log recordings. + */ + callLogRecordingsConfiguration?: CallLogRecordingsConfiguration; +} + +export class CallLogDetailsConfiguration implements CallLogDetailsConfigurationInterface { + /** + * toggle visibility of close button + */ + showCloseButton?: boolean + /** + * This will change the close button icon + */ + closeButtonIconImage?: ImageType + /** + * toggle the profile view + */ + hideProfile?: boolean + /** + * Pass the custom profile view here. + */ + CustomProfileView?: (props: { user?: CometChat.User }) => JSX.Element + /** + * List of templates tobe shown + */ + data?: (props: { message: CometChat.BaseMessage; user?: CometChat.User; group?: CometChat.Group }) => CometChatDetailsTemplate[] + /** + * call back for error + */ + onError?: (e: CometChat.CometChatException) => void + /** + * custom functionality on back press + */ + onBack?: () => void + /** + * Style object for Avatar + */ + avatarStyle?: AvatarStyleInterface + /** + * Style object for CallLogDetails + */ + callLogDetailsStyle?: CallLogDetailsStyleInterface + /** + * Configuration for call history. + */ + callLogHistoryConfiguration?: CallLogHistoryConfiguration + /** + * Configuration for call log participants. + */ + callLogParticipantsConfiguration?: CallLogParticipantsConfiguration + /** + * Configuration for call log recordings. + */ + callLogRecordingsConfiguration?: CallLogRecordingsConfiguration + + constructor(props: CallLogDetailsConfigurationInterface) { + if (props) { + for (const [key, value] of Object.entries(props)) { + this[key] = value; + } + } + } +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogDetails/CallLogDetailsStyle.ts b/src/calls/CometChatCallLogDetails/CallLogDetailsStyle.ts new file mode 100644 index 0000000..55c2883 --- /dev/null +++ b/src/calls/CometChatCallLogDetails/CallLogDetailsStyle.ts @@ -0,0 +1,36 @@ +import { BaseStyle, BaseStyleInterface, FontStyleInterface } from "../../shared"; + +export interface CallLogDetailsStyleInterface extends BaseStyleInterface { + titleFont?: FontStyleInterface, + titleColor?: string, + closeIconTint?: string, +} + +export class CallLogDetailsStyle extends BaseStyle { + titleFont?: FontStyleInterface + titleColor?: string + closeIconTint?: string + + constructor({ + titleFont, + titleColor, + closeIconTint, + backgroundColor, + border, + borderRadius, + height, + width, + }: CallLogDetailsStyleInterface) { + super({ + backgroundColor, + border, + borderRadius, + height, + width, + }); + this.titleFont = titleFont; + this.titleColor = titleColor; + this.closeIconTint = closeIconTint; + + } +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogDetails/CometChatCallLogDetails.tsx b/src/calls/CometChatCallLogDetails/CometChatCallLogDetails.tsx new file mode 100644 index 0000000..489cce6 --- /dev/null +++ b/src/calls/CometChatCallLogDetails/CometChatCallLogDetails.tsx @@ -0,0 +1,308 @@ +import React, { useEffect, useRef, useState } from 'react' +import { View, TouchableOpacity, Image, Text, SectionList } from 'react-native' +import { CometChat } from '@cometchat/chat-sdk-react-native' +import { AvatarStyle, AvatarStyleInterface, CometChatAvatar, CometChatContext, CometChatDetailsTemplate, ImageType, localize } from '../../shared' +import { Style } from './style' +import { CloseIcon } from './resources' +import { useContext } from 'react' +import { CallLogDetailsStyle, CallLogDetailsStyleInterface } from './CallLogDetailsStyle' +import { CallingDetailsUtils } from '../CallingDetailsUtils' +import { CometChatParticipants } from '../CometChatCallLogParticipants/CometChatCallLogParticipants' +import { CometChatRecordings } from '../CometChatCallLogRecordings/CometChatCallLogRecordings' +import { CallLogHistoryConfiguration, CometChatCallLogHistory } from '../CometChatCallLogHistory' +import { CallLogParticipantsConfiguration } from '../CometChatCallLogParticipants' +import { CallLogRecordingsConfiguration } from '../CometChatCallLogRecordings/CallLogRecordingsConfiguration' + +const listenerId = "userListener_" + new Date().getTime(); +const SCREEN = { + DETAILS: "details", + PARTICIPANTS: "participants", + RECORDINGS: "recordings", + HISTORY: "history", +} +export interface CometChatCallLogDetailsConfigurationInterface { + /** + * Pass CometChatCalls.CallUser || CometChatCalls.CallGroup object. This parameter is required + */ + call: any, + /** + * title sets the string in top navigation bar. + */ + title?: string, + /** + * toggle visibility of close button + */ + showCloseButton?: boolean, + /** + * This will change the close button icon + */ + closeButtonIconImage?: ImageType, + /** + * toggle the profile view + */ + hideProfile?: boolean, + /** + * Pass the custom profile view here. + */ + CustomProfileView?: (props: { user?: CometChat.User }) => JSX.Element, + /** + * List of templates tobe shown + */ + data?: (props: { message: CometChat.BaseMessage, user?: CometChat.User, group?: CometChat.Group }) => CometChatDetailsTemplate[], + /** + * call back for error + */ + onError?: (e: CometChat.CometChatException) => void, + /** + * custom functionality on back press + */ + onBack?: () => void, + /** + * Style object for Avatar + */ + avatarStyle?: AvatarStyleInterface, + /** + * Style object for CallLogDetails + */ + callLogDetailsStyle?: CallLogDetailsStyleInterface, + /** + * Configuration for call history. + */ + callLogHistoryConfiguration?: CallLogHistoryConfiguration; + /** + * Configuration for call log participants. + */ + callLogParticipantsConfiguration?: CallLogParticipantsConfiguration; + /** + * Configuration for call log recordings. + */ + callLogRecordingsConfiguration?: CallLogRecordingsConfiguration; +} + +export const CometChatCallLogDetails = (props: CometChatCallLogDetailsConfigurationInterface) => { + + const { + onBack, + onError, + CustomProfileView, + data, + hideProfile, + call, + closeButtonIconImage, + showCloseButton = true, + title = localize("CALL_DETAILS"), + avatarStyle, + callLogDetailsStyle, + callLogHistoryConfiguration, + callLogParticipantsConfiguration, + callLogRecordingsConfiguration + } = props; + + const { theme } = useContext(CometChatContext); + const [tempates, setTemplates] = useState([]); + const [group, setGroup] = useState(undefined); + const [user, setUser] = useState(undefined); + const [error, setError] = useState(undefined); + const [screen, setScreen] = useState(SCREEN.DETAILS); + const [participantsData, setParticipantsData] = useState([]); + const [recordingsData, setRecordingsData] = useState([]); + const [callData, setCallData] = useState(call); + const loggedInUser = useRef(null); + + const _avatarStyle = new AvatarStyle({ + nameTextColor: theme.palette.getAccent(), + backgroundColor: theme.palette.getBackgroundColor(), + nameTextFont: theme.typography.heading, + height: 100, + width: 100, + borderRadius: 50, + ...avatarStyle + }); + + const _callLogDetailsStyle = new CallLogDetailsStyle({ + titleColor: theme.palette.getAccent(), + titleFont: theme.typography.heading, + closeIconTint: theme.palette.getPrimary(), + backgroundColor: theme.palette.getBackgroundColor(), + ...callLogDetailsStyle + }); + + useEffect(() => { + CometChat.getLoggedinUser().then( + (loggedUser: CometChat.User) => { + let tmpList: CometChatDetailsTemplate[]; + loggedInUser.current = loggedUser; + console.log({ callData }) + let user = callData?.getReceiverType() == "user" ? loggedInUser.current?.getUid() === callData?.getInitiator()?.getUid() ? callData.getReceiver() : callData?.getInitiator() : undefined + let group = callData?.getReceiverType() == "group" ? loggedInUser.current?.getUid() === callData?.getInitiator()?.getUid() ? callData.getReceiver() : callData?.getInitiator() : undefined + console.log({ user }) + if (data) { + tmpList = data({ message: callData, user, group }); + } else { + let detailsTemplate = CallingDetailsUtils.getDefaultDetailsTemplates(callData, loggedInUser.current, theme); + detailsTemplate.push(CallingDetailsUtils.getSecondaryDetailsTemplate(callData, loggedInUser.current, theme)); + tmpList = [...detailsTemplate]; + } + setTemplates(tmpList.map(item => { + item['data'] = item.options; + return item; + })) + setUser(user); + setGroup(group); + }, + (error: CometChat.CometChatException) => { + setError(localize("SOMETHING_WRONG")); + onError && onError(error); + } + ); + CometChat.addUserListener( + listenerId, + new CometChat.UserListener({ + onUserOnline: (user) => { + setUser(user); + }, + onUserOffline: (user) => { + setUser(user); + }, + }) + ); + return () => { + CometChat.removeUserListener(listenerId); + } + }, [callData]); + + const _render = ({ item, onClick }) => { + function _onPress() { + if (onClick) { + onClick(item); + return; + } else { + if (item.id == SCREEN.PARTICIPANTS) { + setScreen(SCREEN.PARTICIPANTS); + setParticipantsData(callData?.getParticipants()); + return; + } else if (item.id == SCREEN.RECORDINGS) { + setScreen(SCREEN.RECORDINGS); + setRecordingsData(callData?.getRecordings()); + return; + } else if (item.id == SCREEN.HISTORY) { + setScreen(SCREEN.HISTORY); + return; + } + } + console.log("onClicked", item) + } + const { CustomView } = item; + if (item.CustomView) { + return + + + } + return <>; + } + + console.log({user, group}) + + return ( + + {screen === SCREEN.DETAILS ? <> + { + !hideProfile && + + { + CustomProfileView && + } + { + showCloseButton && + + + + } + {title} + + } + { + (error && + + {error} + ) || + <> + + + {user ? user['name'] : group ? group['name'] : undefined} + + item + index} + renderItem={_render} + renderSectionHeader={({ section }) => { + const { title, titleColor, titleFont, titleStyle } = section; + if (!title) + return null; + + return ( + + {title} + + ); + }} + /> + + } + + : screen === SCREEN.PARTICIPANTS ? + <> + { + setScreen(SCREEN.DETAILS); + setParticipantsData([]); + }} + {...callLogParticipantsConfiguration} + /> + + : screen === SCREEN.RECORDINGS ? + <> + { + setScreen(SCREEN.DETAILS); + setRecordingsData([]); + }} + {...callLogRecordingsConfiguration} + /> + + : screen === SCREEN.HISTORY ? + <> + { + setScreen(SCREEN.DETAILS); + }} + onItemPress={(item) => { + console.log("item", item) + setCallData(item); + setScreen(SCREEN.DETAILS); + }} + {...callLogHistoryConfiguration} + /> + + : null} + + ) +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogDetails/index.ts b/src/calls/CometChatCallLogDetails/index.ts new file mode 100644 index 0000000..f66f1f4 --- /dev/null +++ b/src/calls/CometChatCallLogDetails/index.ts @@ -0,0 +1,12 @@ +import { CallLogDetailsConfiguration, CallLogDetailsConfigurationInterface } from "./CallLogDetailsConfiguration"; +import { CallLogDetailsStyle, CallLogDetailsStyleInterface } from "./CallLogDetailsStyle"; +import { CometChatCallLogDetails, CometChatCallLogDetailsConfigurationInterface } from "./CometChatCallLogDetails"; + +export { + CallLogDetailsConfiguration, + CallLogDetailsConfigurationInterface, + CallLogDetailsStyle, + CallLogDetailsStyleInterface, + CometChatCallLogDetails, + CometChatCallLogDetailsConfigurationInterface +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogDetails/resources/CloseIcon.png b/src/calls/CometChatCallLogDetails/resources/CloseIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..6c7315d396f3f817cc016daa9a5353c291d2a568 GIT binary patch literal 650 zcmeAS@N?(olHy`uVBq!ia0vp^DIm?0yMnwlmrj8YCz zZdxMulDD}2WKm}2nxDMIF|tums`aYGrNs|Km6f>e87eIlU{z+~x@cgtSU~i!GS@{zn}rit z4>NP!G|*W*LG-W^*G)s6g$g{@8XSlDxDIV-ZZdeY02kMweEI{M$9JbpQ&;`o>eQ|= z7pS%bsOJ*rVLmVQ9zkb?GN<^+GAH&@>xGx&tQX3+X$Q;SQo2JnSXEx zd)m`>p;NzQH{Ip}3S5`?ADwjN(qf(?JEVn`ZM$51woFcvRF*v@ZontC&eV)+!(&!u zn=bdB4I1+d4=r>#z|kzkdD!-p@UgE9J%1mm>{-ZgJJ9gX!juCA%|-%`uNk*hPHANS zaCGUny_3H8uh^_9wv{m^b!Jb#&neXnam!Y)pJIBP&ndM!aM|G(jY3k3*-w3u@D2z{ z&~eOc|H$a2)x#ffEBQ*p*`qhZJ*5no>$b+VBgJ^?Avwmx2__;Oo~2uXiHpJ0)z4*} HQ$iB} JSX.Element, + TailView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element, ListItemView?: (param: { call?: CometChat.Call }) => JSX.Element, AppBarOptions?: () => JSX.Element, options?: (param: { message: CometChat.BaseMessage }) => CometChatOptions[], - messageRequestBuilder?: CometChat.MessagesRequestBuilder, + callLogHistoryRequestBuilder?: any, hideSeperator?: boolean, + datePattern?: DatePattern, + dateSeparatorPattern?: DatePattern, BackButton?: JSX.Element, showBackButton?: boolean, - selectionMode?: SelectionMode, - onSelection?: (items: Array) => void, EmptyStateView?: () => JSX.Element, - emptyStateText?: string, ErrorStateView?: () => JSX.Element, - errorStateText?: string, loadingIcon?: ImageType, LoadingStateView?: () => JSX.Element, hideError?: boolean, onItemPress?: (item: CometChat.Call) => void, - onItemLongPress?: (item: CometChat.Call) => void, onError?: (e: CometChat.CometChatException) => void, onBack?: () => void, - onInfoIconPress?: (prop: { call: CometChat.Call }) => void, - avatarStyle?: AvatarStyleInterface, - statusIndicatorStyle?: StatusIndicatorStyleInterface, listItemStyle?: ListItemStyleInterface, - callHistoryStyle?: CallHistoryStyleInterface, - headViewContainerStyle?: StyleProp, + CallLogHistoryStyle?: CallLogHistoryStyleInterface, bodyViewContainerStyle?: StyleProp, tailViewContainerStyle?: StyleProp, } -export class CallHistoryConfiguration implements CallHistoryConfigurationInterface { +export class CallLogHistoryConfiguration implements CallLogHistoryConfigurationInterface { SubtitleView?: (param: { call?: CometChat.Call }) => JSX.Element + TailView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element ListItemView?: (param: { call?: CometChat.Call }) => JSX.Element AppBarOptions?: () => JSX.Element options?: (param: { message: CometChat.BaseMessage }) => CometChatOptions[] - messageRequestBuilder?: CometChat.MessagesRequestBuilder + callLogHistoryRequestBuilder?: any hideSeperator?: boolean + datePattern?: DatePattern + dateSeparatorPattern?: DatePattern BackButton?: JSX.Element showBackButton?: boolean - selectionMode?: SelectionMode - onSelection?: (items: Array) => void EmptyStateView?: () => JSX.Element - emptyStateText?: string ErrorStateView?: () => JSX.Element - errorStateText?: string loadingIcon?: ImageType LoadingStateView?: () => JSX.Element hideError?: boolean onItemPress?: (item: CometChat.Call) => void - onItemLongPress?: (item: CometChat.Call) => void onError?: (e: CometChat.CometChatException) => void onBack?: () => void - onInfoIconPress?: (prop: { call: CometChat.Call }) => void - avatarStyle?: AvatarStyleInterface - statusIndicatorStyle?: StatusIndicatorStyleInterface listItemStyle?: ListItemStyleInterface - callHistoryStyle?: CallHistoryStyleInterface - headViewContainerStyle?: StyleProp + CallLogHistoryStyle?: CallLogHistoryStyleInterface bodyViewContainerStyle?: StyleProp tailViewContainerStyle?: StyleProp - constructor(props: CallHistoryConfigurationInterface) { + constructor(props: CallLogHistoryConfigurationInterface) { if (props) { for (const [key, value] of Object.entries(props)) { this[key] = value; diff --git a/src/calls/CometChatCallLogHistory/CallLogHistoryStyle.ts b/src/calls/CometChatCallLogHistory/CallLogHistoryStyle.ts new file mode 100644 index 0000000..932cd41 --- /dev/null +++ b/src/calls/CometChatCallLogHistory/CallLogHistoryStyle.ts @@ -0,0 +1,46 @@ +import { BaseStyle, BaseStyleInterface, FontStyle, FontStyleInterface } from "../../shared"; + +export interface CallLogHistoryStyleInterface extends BaseStyleInterface { + titleFont?: FontStyleInterface; + titleColor?: string; + loadingTint?: string; + emptyTextFont?: FontStyleInterface; + emptyTextColor?: string + errorTextFont?: FontStyleInterface; + errorTextColor?: string; + backIconTint?: string; + dateTextFont?: FontStyleInterface; + dateTextColor?: string; + dateSeparatorTextFont?: FontStyleInterface; + dateSeparatorTextColor?: string; + callDurationTextFont?: FontStyleInterface; + callDurationTextColor?: string; + callStatusTextFont?: FontStyleInterface; + callStatusTextColor?: string; + separatorColor?: string; +} + +export class CallLogHistoryStyle extends BaseStyle { + titleFont?: FontStyleInterface; + titleColor?: string; + loadingTint?: string; + emptyTextFont?: FontStyleInterface; + emptyTextColor?: string + errorTextFont?: FontStyleInterface; + errorTextColor?: string; + backIconTint?: string; + dateTextFont?: FontStyleInterface; + dateTextColor?: string; + dateSeparatorTextFont?: FontStyleInterface; + dateSeparatorTextColor?: string; + callDurationTextFont?: FontStyleInterface; + callDurationTextColor?: string; + callStatusTextFont?: FontStyleInterface; + callStatusTextColor?: string; + separatorColor?: string; + + constructor(style: Partial) { + super({}); + Object.assign(this, style); + } +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogHistory/CometChatCallLogHistory.tsx b/src/calls/CometChatCallLogHistory/CometChatCallLogHistory.tsx new file mode 100644 index 0000000..f46255f --- /dev/null +++ b/src/calls/CometChatCallLogHistory/CometChatCallLogHistory.tsx @@ -0,0 +1,337 @@ +import { CometChat } from '@cometchat/chat-sdk-react-native' +import React, { useContext, useEffect, useRef, useState } from 'react' +import { FlatList, Image, StyleProp, Text, TouchableOpacity, View, ViewStyle } from 'react-native' +import { DatePattern, ImageType } from '../../shared/base/Types' +import { CometChatContext, CometChatDate, CometChatListItem, CometChatOptions, ListItemStyleInterface, localize } from '../../shared' +import { CallLogHistoryStyle, CallLogHistoryStyleInterface } from './CallLogHistoryStyle' +import { LoadingIcon, BackIcon } from "./resources"; +import { Style } from './style' +import { CallingPackage } from '../CallingPackage' +import { CallUtils } from '../CallUtils' + +const CometChatCalls = CallingPackage.CometChatCalls; + +export interface CometChatCallLogHistoryInterface { + title?: string, + SubtitleView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element, + TailView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element, + ListItemView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element, + AppBarOptions?: () => JSX.Element, + options?: (param: { message: CometChat.BaseMessage }) => CometChatOptions[], + callLogHistoryRequestBuilder?: any, + user?: any, + group?: any, + hideSeperator?: boolean, + datePattern?: DatePattern, + dateSeparatorPattern?: DatePattern, + BackButton?: JSX.Element, + showBackButton?: boolean, + EmptyStateView?: () => JSX.Element, + emptyStateText?: string, + ErrorStateView?: () => JSX.Element, + errorStateText?: string, + loadingIcon?: ImageType, + LoadingStateView?: () => JSX.Element, + hideError?: boolean, + onItemPress?: (item: CometChat.BaseMessage) => void, + onError?: (e: CometChat.CometChatException) => void, + onBack?: () => void, + listItemStyle?: ListItemStyleInterface, + callLogHistoryStyle?: CallLogHistoryStyleInterface, + bodyViewContainerStyle?: StyleProp, + tailViewContainerStyle?: StyleProp, +} + +export const CometChatCallLogHistory = (props: CometChatCallLogHistoryInterface) => { + + const { + title = localize("CALL_HISTORY"), + SubtitleView, + TailView, + ListItemView, + AppBarOptions, + options, + callLogHistoryRequestBuilder, + user, + group, + hideSeperator, + datePattern, + dateSeparatorPattern, + BackButton, + showBackButton, + EmptyStateView, + emptyStateText, + ErrorStateView, + errorStateText, + loadingIcon, + LoadingStateView, + hideError, + onItemPress, + onError, + onBack, + listItemStyle, + callLogHistoryStyle, + bodyViewContainerStyle, + tailViewContainerStyle, + } = props; + + const { theme } = useContext(CometChatContext); + + const _style = new CallLogHistoryStyle({ + titleFont: theme.typography.heading, + titleColor: theme.palette.getAccent(), + backgroundColor: theme.palette.getBackgroundColor(), + emptyTextColor: theme?.palette?.getAccent400(), + emptyTextFont: theme?.typography?.subtitle1, + errorTextColor: theme?.palette?.getError(), + errorTextFont: theme?.typography?.subtitle1, + backIconTint: theme.palette.getPrimary(), + callDurationTextColor: theme.palette.getAccent(), + callDurationTextFont: theme.typography.text1, + dateTextColor: theme.palette.getAccent(), + dateTextFont: theme.typography.subtitle1, + loadingTint: theme.palette.getPrimary(), + dateSeparatorTextColor: theme.palette.getAccent600(), + dateSeparatorTextFont: theme.typography.text2, + callStatusTextColor: theme.palette.getAccent(), + callStatusTextFont: theme.typography.text1, + ...callLogHistoryStyle + }); + + const { + backgroundColor, + height, + width, + border, + borderRadius, + titleColor, + titleFont, + loadingTint, + backIconTint, + callDurationTextColor, + callDurationTextFont, + callStatusTextColor, + callStatusTextFont, + dateSeparatorTextColor, + dateSeparatorTextFont, + dateTextColor, + dateTextFont, + emptyTextColor, + emptyTextFont, + errorTextColor, + errorTextFont, + separatorColor + } = _style; + + const [list, setList] = useState([]); + const [listState, setListState] = useState<"loading" | "error" | "done">("loading"); + + const loggedInUser = useRef(null); + const callRequestBuilderRef = useRef(null); + + function setRequestBuilder() { + callRequestBuilderRef.current + let builder = callLogHistoryRequestBuilder ?? new CometChatCalls.CallLogRequestBuilder() + .setLimit(30) + // .setUid("superhero2") + .setAuthToken(loggedInUser.current.getAuthToken() || "") + // .setHasRecording(true) + .setCallCategory("call") + // .setCallDirection("outgoing") + // .setCallStatus("rejected") + // .setCallType("video") + // .setGuid("group_123456") + ; + if (user) { + builder = builder.setUid(user?.getUid()); + } else if (group) { + builder = builder.setGuid(group?.getGuid()); + } + callRequestBuilderRef.current = builder.build(); + } + + const fetchCallLogHistory = () => { + setListState("loading"); + callRequestBuilderRef.current.fetchNext() + .then(CallLogHistory => { + console.log(CallLogHistory.length); + if (CallLogHistory.length > 0) { + setList([...list, ...CallLogHistory]); + } + setListState("done"); + }) + .catch(err => { + onError && onError(err); + setListState("error"); + }); + } + + useEffect(() => { + CometChat.getLoggedinUser() + .then(u => { + loggedInUser.current = u; + setRequestBuilder(); + fetchCallLogHistory(); + }) + .catch(e => { + onError(e); + }); + }, []); + + const DefaultSubtitleView = ({ call }) => { + + if (SubtitleView) + return SubtitleView(call); + return ( + + + + + + { + CallUtils.getCallStatus(call as CometChat.Call, loggedInUser.current) + } + + + ); + } + + const DefaultTailView = ({ call }) => { + return ( + + + { + CallUtils.convertMinutesToHoursMinutesSeconds(call['totalDurationInMinutes']) + } + + + ) + } + + const onPress = (item) => { + onItemPress && onItemPress(item); + return; + } + + const getInitiatedAtTimestamp = (item) => { + return item['initiatedAt'] * 1000; + } + + const _render = ({ item, index }) => { + + if (ListItemView) + return + + let seperatorView = null; + const previousMessageDate = list[index - 1] ? new Date(getInitiatedAtTimestamp(list[index - 1])) : null; + const currentMessageDate = new Date(getInitiatedAtTimestamp(item)); + + const currentDate = isNaN(currentMessageDate.getDate()) ? undefined : `${currentMessageDate.getDate()}-${currentMessageDate.getMonth()}-${currentMessageDate.getFullYear()}`; + + const previousDate = `${previousMessageDate?.getDate()}-${previousMessageDate?.getMonth()}-${previousMessageDate?.getFullYear()}`; + + if (currentDate != undefined && previousDate !== currentDate) { + seperatorView = ( + + + + ) + } + + return + {seperatorView} + + SubtitleView ? : + } + TailView={TailView ? () => : () => } + options={() => options && options(item)} + onPress={() => onPress(item)} + hideSeparator={hideSeperator} + separatorColor={separatorColor} + /> + + } + + const EmptyView = () => { + if (EmptyStateView) + return + return ( + + {emptyStateText || localize("NO_CALL_HISTORY")} + + ) + } + + const ErrorView = () => { + if (hideError) return null; + if (ErrorStateView) + return + return + {errorStateText || localize("SOMETHING_WRONG")} + + } + + const LoadingView = () => { + if (LoadingStateView) + return + return + + + } + + return ( + + + + { + showBackButton ? + BackButton ?? + + + : null + } + {title} + + + { + AppBarOptions && + } + + + { + listState == "loading" && list.length == 0 ? + : + listState == "error" && list.length == 0 ? + : + list.length == 0 ? + : + item.sessionId} + renderItem={_render} + onEndReached={fetchCallLogHistory} + /> + } + + ) +} diff --git a/src/calls/CometChatCallLogHistory/index.ts b/src/calls/CometChatCallLogHistory/index.ts new file mode 100644 index 0000000..770e426 --- /dev/null +++ b/src/calls/CometChatCallLogHistory/index.ts @@ -0,0 +1,12 @@ +import { CallLogHistoryConfiguration, CallLogHistoryConfigurationInterface } from "./CallLogHistoryConfiguration"; +import { CallLogHistoryStyle, CallLogHistoryStyleInterface } from "./CallLogHistoryStyle"; +import { CometChatCallLogHistory, CometChatCallLogHistoryInterface } from "./CometChatCallLogHistory"; + +export { + CallLogHistoryConfiguration, + CallLogHistoryConfigurationInterface, + CallLogHistoryStyle, + CallLogHistoryStyleInterface, + CometChatCallLogHistory, + CometChatCallLogHistoryInterface +} \ No newline at end of file diff --git a/src/calls/CometChatCallHistory/resources/Back.png b/src/calls/CometChatCallLogHistory/resources/Back.png similarity index 100% rename from src/calls/CometChatCallHistory/resources/Back.png rename to src/calls/CometChatCallLogHistory/resources/Back.png diff --git a/src/calls/CometChatCallHistory/resources/Call.png b/src/calls/CometChatCallLogHistory/resources/Call.png similarity index 100% rename from src/calls/CometChatCallHistory/resources/Call.png rename to src/calls/CometChatCallLogHistory/resources/Call.png diff --git a/src/calls/CometChatCallHistory/resources/Info.png b/src/calls/CometChatCallLogHistory/resources/Info.png similarity index 100% rename from src/calls/CometChatCallHistory/resources/Info.png rename to src/calls/CometChatCallLogHistory/resources/Info.png diff --git a/src/calls/CometChatCallHistory/resources/Selection.png b/src/calls/CometChatCallLogHistory/resources/Selection.png similarity index 100% rename from src/calls/CometChatCallHistory/resources/Selection.png rename to src/calls/CometChatCallLogHistory/resources/Selection.png diff --git a/src/calls/CometChatCallHistory/resources/Spineer.png b/src/calls/CometChatCallLogHistory/resources/Spineer.png similarity index 100% rename from src/calls/CometChatCallHistory/resources/Spineer.png rename to src/calls/CometChatCallLogHistory/resources/Spineer.png diff --git a/src/calls/CometChatCallHistory/resources/Video.png b/src/calls/CometChatCallLogHistory/resources/Video.png similarity index 100% rename from src/calls/CometChatCallHistory/resources/Video.png rename to src/calls/CometChatCallLogHistory/resources/Video.png diff --git a/src/calls/CometChatCallHistory/resources/check.png b/src/calls/CometChatCallLogHistory/resources/check.png similarity index 100% rename from src/calls/CometChatCallHistory/resources/check.png rename to src/calls/CometChatCallLogHistory/resources/check.png diff --git a/src/calls/CometChatCallLogHistory/resources/incomingcall.png b/src/calls/CometChatCallLogHistory/resources/incomingcall.png new file mode 100644 index 0000000000000000000000000000000000000000..ea59bbf61f72d38197e3edc545c9332b26c597b5 GIT binary patch literal 325 zcmV-L0lNN)P)sZ;0aOAC`6}B0}CT{SGQ!I3A)+3D{ Xs(ms){Sa^H00000NkvXXu0mjfEbx&o literal 0 HcmV?d00001 diff --git a/src/calls/CometChatCallLogHistory/resources/incomingvideo.png b/src/calls/CometChatCallLogHistory/resources/incomingvideo.png new file mode 100644 index 0000000000000000000000000000000000000000..a3a499a448a22ad6c452d6e8c3fb8dd8c5660030 GIT binary patch literal 373 zcmV-*0gC>KP)o{EHxWUW_m?`99VyO(;WnmL*C&2Q$M8CuRVfj^8%w58lB;|!H% zz$u*I0-q_sL3CmU?~RfUu$=-5?H1!f++A~O<@Mqz1u_u$kLbfZuHtwDvVT;xhiNRv zaToTH!w!0|jH9Fn$RZ!ayI8?ya5jPx#&9g^dxqo}T@v-Q23y4f9)g?>T%-E?awCQ9 zO<+x}Q4b3kZ33%eB3AlCWs<_~7*@bNE)#M}qCVbXE#`cM35VEfpf<_QF{l1*Ua?NS zG6>%yWy^j=FJ{B@7Vf4b~FcgE+mcxr^IlQIhwTgWMD+e>E TYkNU!00000NkvXXu0mjf8&aXo literal 0 HcmV?d00001 diff --git a/src/calls/CometChatCallLogHistory/resources/index.ts b/src/calls/CometChatCallLogHistory/resources/index.ts new file mode 100644 index 0000000..97f1b7c --- /dev/null +++ b/src/calls/CometChatCallLogHistory/resources/index.ts @@ -0,0 +1,29 @@ +import AudioCallIcon from "./Call.png"; +import VideoCallIcon from "./Video.png"; +import LoadingIcon from "./Spineer.png"; +import DetailIcon from "./Info.png"; +import BackIcon from "./Back.png"; +import CheckIcon from "./check.png"; +import SelectionIcon from "./Selection.png"; +import IncomingCallIcon from './incomingcall.png'; +import OutgoingCallIcon from './outgoingcall.png'; +import MissedCallIcon from './missedcall.png'; +import MissedVideoIcon from './missedvideo.png'; +import IncomingVideoIcon from './incomingvideo.png'; +import OutgoingVideoIcon from './outgoingvideo.png'; + +export { + SelectionIcon, + CheckIcon, + DetailIcon, + AudioCallIcon, + VideoCallIcon, + LoadingIcon, + BackIcon, + IncomingCallIcon, + OutgoingCallIcon, + MissedCallIcon, + MissedVideoIcon, + IncomingVideoIcon, + OutgoingVideoIcon +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogHistory/resources/missedcall.png b/src/calls/CometChatCallLogHistory/resources/missedcall.png new file mode 100644 index 0000000000000000000000000000000000000000..4a620e75e8fb8a57b1be1b3323ac76e5d21d89f1 GIT binary patch literal 342 zcmV-c0jd6pP)mm;yq@I0a)$NBwO&$T`GeLvr>`?((KN+^djY-0n3{{r)P z#VJP7@})O|y)=*lN@$3{JIvw`opELW*BGt^>%tWduoN9l$6h5u$8dw8H11}wAiUis z78Csnp3=f#U04@7@Qn7vO#U}OW8(aRGJ3IsRXikS?$f%131OvuA&90dmw!?#&QVO% zi#Wo(?_1T>ATE7=;vON@61If&GegU`K);asRIKN)gUM|*?{u)5Oe9amK`pBgD8l>h($07*qoM6N<$g7^)WSpWb4 literal 0 HcmV?d00001 diff --git a/src/calls/CometChatCallLogHistory/resources/missedvideo.png b/src/calls/CometChatCallLogHistory/resources/missedvideo.png new file mode 100644 index 0000000000000000000000000000000000000000..1f2b611dc9b8e72fcead593cebfbf8e43a8894f9 GIT binary patch literal 413 zcmV;O0b>4%P)%t(1U4Q z#e5r9#<366xJlqLQ>#9&c7Is6u^mf7YEGx>r&j6Ra=iQvWdT&^Pv zvX&RIj4fd>jWB{0{LSV59Y_90FpOuyR2$)|V40#j-z>NV(d$E$goUHl00000NkvXX Hu0mjfe`UG^ literal 0 HcmV?d00001 diff --git a/src/calls/CometChatCallLogHistory/resources/outgoingcall.png b/src/calls/CometChatCallLogHistory/resources/outgoingcall.png new file mode 100644 index 0000000000000000000000000000000000000000..8f2609d0507854c4ba0fc0c3dff66a1f7ef39d0c GIT binary patch literal 324 zcmV-K0lWT*P)L_rjX@!ztIjR*=fTo7uZczVc+wH~%wd_;ZvBo*%$I%ILu`#(x_i z!#tkw(N5DCX62_J#VuCwmXZy{o3F5gt{mBtFmgR5T*DSBIK_63tU;C%9t-2bAl}g* z)7)V(C1~al2bjbO_F}z+>7p_*K^>P^M|UTZ@ATpx)uwtC*Vy!PQAsj93f~7N@GQLT znbzA+vVaH72wPu`^$O0hoYz>+sqe;=M|edoCYwSZK8q%7FoF%--~|_$>s0nndwc=T WJS>nmC_}^m0000d&TOvr0s4-hti3#tV>m z3t|#xlSzh+bE5OPrzL~%n_7>)rqV>9@9r@NQ+m&3v4vG=1RV7IuU$GlFznwCC!a@g7Q#G7O zHsTEPIEaB&jAcM#jpGx~Sd$#18vj>s4L6dj*JuNXH5n2qYIF7C$6+dfvyM_l@;H2D c_;ri^0K1PihY^F*_y7O^07*qoM6N<$f(+rKU;qFB literal 0 HcmV?d00001 diff --git a/src/calls/CometChatCallHistory/style.ts b/src/calls/CometChatCallLogHistory/style.ts similarity index 88% rename from src/calls/CometChatCallHistory/style.ts rename to src/calls/CometChatCallLogHistory/style.ts index 1d27770..d888763 100644 --- a/src/calls/CometChatCallHistory/style.ts +++ b/src/calls/CometChatCallLogHistory/style.ts @@ -13,7 +13,8 @@ export const Style = StyleSheet.create({ paddingStart: 8 }, row: { - flexDirection: "row" + flexDirection: "row", + alignItems: "center", }, imageStyle: { height: 24, diff --git a/src/calls/CometChatCallLogParticipants/CallLogParticipantsConfiguration.ts b/src/calls/CometChatCallLogParticipants/CallLogParticipantsConfiguration.ts new file mode 100644 index 0000000..2c3c967 --- /dev/null +++ b/src/calls/CometChatCallLogParticipants/CallLogParticipantsConfiguration.ts @@ -0,0 +1,61 @@ +import { StyleProp, ViewStyle } from "react-native/types"; +import { CometChat } from "@cometchat/chat-sdk-react-native"; +import { AvatarStyleInterface, CometChatOptions, ImageType, ListItemStyleInterface } from "../../shared"; +import { CallParticipantsStyleInterface } from "./CallLogParticipantsStyle"; + +export interface CallLogParticipantsConfigurationInterface { + SubtitleView?: (param: { participant?: CometChat.BaseMessage }) => JSX.Element, + TailView?: (param: { participant?: CometChat.BaseMessage }) => JSX.Element, + ListItemView?: (param: { participant?: CometChat.BaseMessage }) => JSX.Element, + AppBarOptions?: () => JSX.Element, + /** + * Participant list + */ + data: any[], + call: any, + hideSeperator?: boolean, + BackButton?: JSX.Element, + showBackButton?: boolean, + EmptyStateView?: () => JSX.Element, + onItemPress?: (item: CometChat.BaseMessage) => void, + onError?: (e: CometChat.CometChatException) => void, + onBack?: () => void, + avatarStyle?: AvatarStyleInterface, + listItemStyle?: ListItemStyleInterface, + callLogParticipantsStyle?: CallParticipantsStyleInterface, + headViewContainerStyle?: StyleProp, + bodyViewContainerStyle?: StyleProp, + tailViewContainerStyle?: StyleProp, +} +export class CallLogParticipantsConfiguration implements CallLogParticipantsConfigurationInterface { + SubtitleView?: (param: { participant?: CometChat.BaseMessage }) => JSX.Element + TailView?: (param: { participant?: CometChat.BaseMessage }) => JSX.Element + ListItemView?: (param: { participant?: CometChat.BaseMessage }) => JSX.Element + AppBarOptions?: () => JSX.Element + /** + * Participant list + */ + data: any[] + call: any + hideSeperator?: boolean + BackButton?: JSX.Element + showBackButton?: boolean + EmptyStateView?: () => JSX.Element + onItemPress?: (item: CometChat.BaseMessage) => void + onError?: (e: CometChat.CometChatException) => void + onBack?: () => void + avatarStyle?: AvatarStyleInterface + listItemStyle?: ListItemStyleInterface + callLogParticipantsStyle?: CallParticipantsStyleInterface + headViewContainerStyle?: StyleProp + bodyViewContainerStyle?: StyleProp + tailViewContainerStyle?: StyleProp + + constructor(props: CallLogParticipantsConfigurationInterface) { + if (props) { + for (const [key, value] of Object.entries(props)) { + this[key] = value; + } + } + } +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogParticipants/CallLogParticipantsStyle.ts b/src/calls/CometChatCallLogParticipants/CallLogParticipantsStyle.ts new file mode 100644 index 0000000..650b8b5 --- /dev/null +++ b/src/calls/CometChatCallLogParticipants/CallLogParticipantsStyle.ts @@ -0,0 +1,59 @@ +import { BaseStyle, BaseStyleInterface, FontStyle, FontStyleInterface } from "../../shared"; + +export interface CallParticipantsStyleInterface extends BaseStyleInterface { + titleFont?: FontStyleInterface, + titleColor?: string, + dateTextFont?: FontStyleInterface; + dateTextColor?: string; + emptyTextFont?: FontStyleInterface; + emptyTextColor?: string; + backIconTint?: string; + durationTextFont?: FontStyleInterface; + durationTextColor?: string; +} + +export class CallParticipantsStyle extends BaseStyle { + titleFont?: FontStyleInterface; + titleColor?: string; + emptyTextFont?: FontStyleInterface; + emptyTextColor?: string; + dateTextFont?: FontStyleInterface; + dateTextColor?: string; + backIconTint?: string; + durationTextFont?: FontStyleInterface; + durationTextColor?: string; + + constructor({ + titleFont = { fontSize: 20, fontWeight: "600" }, + backgroundColor = "white", + border, + borderRadius, + height, + titleColor = "#000", + dateTextFont, + dateTextColor, + emptyTextColor, + emptyTextFont, + backIconTint, + durationTextColor, + durationTextFont, + width + }: CallParticipantsStyleInterface) { + super({ + backgroundColor: backgroundColor, + border: border, + borderRadius: borderRadius, + height: height, + width: width + }); + this.titleColor = titleColor; + this.titleFont = titleFont; + this.dateTextFont = dateTextFont; + this.dateTextColor = dateTextColor; + this.emptyTextColor = emptyTextColor; + this.emptyTextFont = emptyTextFont; + this.backIconTint = backIconTint; + this.durationTextColor = durationTextColor; + this.durationTextFont = durationTextFont; + } +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogParticipants/CometChatCallLogParticipants.tsx b/src/calls/CometChatCallLogParticipants/CometChatCallLogParticipants.tsx new file mode 100644 index 0000000..701ffd6 --- /dev/null +++ b/src/calls/CometChatCallLogParticipants/CometChatCallLogParticipants.tsx @@ -0,0 +1,220 @@ +import { CometChat } from '@cometchat/chat-sdk-react-native' +import React, { useContext, useEffect, useRef } from 'react' +import { FlatList, Image, Text, TouchableOpacity, View } from 'react-native' +import { StyleProp, ViewStyle } from "react-native/types"; +import { AvatarStyleInterface, CometChatContext, CometChatDate, CometChatListItem, DatePattern, ListItemStyleInterface, localize } from '../../shared' +import { CallParticipantsStyle, CallParticipantsStyleInterface } from './CallLogParticipantsStyle' +import { BackIcon } from "./resources"; +import { Style } from './style' +import { CallUtils } from '../CallUtils' + +export interface CometChatCallLogParticipantsConfigurationInterface { + title?: string, + SubtitleView?: (param: { participant?: CometChat.BaseMessage }) => JSX.Element, + TailView?: (param: { participant?: CometChat.BaseMessage }) => JSX.Element, + ListItemView?: (param: { participant?: CometChat.BaseMessage }) => JSX.Element, + AppBarOptions?: () => JSX.Element, + /** + * Participant list + */ + data: any[], + datePattern?: DatePattern, + call: any, + hideSeperator?: boolean, + BackButton?: JSX.Element, + showBackButton?: boolean, + EmptyStateView?: () => JSX.Element, + emptyStateText?: string, + onItemPress?: (item: CometChat.BaseMessage) => void, + onError?: (e: CometChat.CometChatException) => void, + onBack?: () => void, + avatarStyle?: AvatarStyleInterface, + listItemStyle?: ListItemStyleInterface, + callLogParticipantsStyle?: CallParticipantsStyleInterface, + headViewContainerStyle?: StyleProp, + bodyViewContainerStyle?: StyleProp, + tailViewContainerStyle?: StyleProp, +} +export const CometChatParticipants = (props: CometChatCallLogParticipantsConfigurationInterface) => { + + const { + title = localize("PARTICIPANTS"), + SubtitleView, + TailView, + ListItemView, + AppBarOptions, + call, + datePattern, + data, + hideSeperator, + BackButton, + showBackButton, + EmptyStateView, + emptyStateText, + onItemPress, + onError, + onBack, + avatarStyle, + listItemStyle, + callLogParticipantsStyle, + headViewContainerStyle, + bodyViewContainerStyle, + tailViewContainerStyle, + } = props; + + const { theme } = useContext(CometChatContext); + + const _style = new CallParticipantsStyle({ + titleFont: theme.typography.heading, + titleColor: theme.palette.getAccent(), + backgroundColor: theme.palette.getBackgroundColor(), + emptyTextColor: theme?.palette?.getAccent400(), + emptyTextFont: theme?.typography?.subtitle1, + dateTextColor: theme.palette.getAccent(), + dateTextFont: theme.typography.subtitle2, + backIconTint: theme.palette.getPrimary(), + durationTextColor: theme.palette.getAccent(), + durationTextFont: theme.typography.subtitle1, + ...callLogParticipantsStyle + }); + + const { + backgroundColor, + height, + width, + border, + borderRadius, + titleColor, + titleFont, + emptyTextColor, + emptyTextFont, + dateTextColor, + dateTextFont, + backIconTint, + durationTextColor, + durationTextFont + } = _style; + + const loggedInUser = useRef(null); + + useEffect(() => { + CometChat.getLoggedinUser() + .then(u => { + loggedInUser.current = u; + }) + .catch(e => { + onError && onError(e); + }); + }, []); + + const DefaultSubtitleView = ({ participant }) => { + if (SubtitleView) + return SubtitleView(participant); + return ( + + {CallUtils.convertMinutesToHoursMinutesSeconds(participant['totalDurationInMinutes'])} + + ); + } + + const DefaultTailView = () => { + return ( + + {call?.getInitiatedAt() && } + + ) + } + + const onPress = (item) => { + onItemPress && onItemPress(item); + return; + } + + const getCallDetails = (item) => { + return { + title: item['name'], + avatarUrl: item['avatar'] + } + } + + const _render = ({ item, index }) => { + + if (ListItemView) + return + + const { title, avatarUrl } = getCallDetails(item); + + return + + SubtitleView ? : + } + TailView={TailView ? () => : () => } + avatarStyle={avatarStyle} + onPress={() => onPress(item)} + hideSeparator={hideSeperator} + /> + + } + + const EmptyView = () => { + if (EmptyStateView) + return + return ( + + {emptyStateText || localize("NO_PARTICIPANTS")} + + ) + } + + return ( + + + + { + showBackButton ? + BackButton ?? + + + : null + } + {title} + + + { + AppBarOptions && + } + + + {data.length == 0 ? + : + item.sessionId} + renderItem={_render} + /> + } + + ) +} diff --git a/src/calls/CometChatCallLogParticipants/index.ts b/src/calls/CometChatCallLogParticipants/index.ts new file mode 100644 index 0000000..39f7af1 --- /dev/null +++ b/src/calls/CometChatCallLogParticipants/index.ts @@ -0,0 +1,12 @@ +import { CallLogParticipantsConfiguration, CallLogParticipantsConfigurationInterface } from './CallLogParticipantsConfiguration'; +import { CallParticipantsStyle, CallParticipantsStyleInterface } from './CallLogParticipantsStyle'; +import { CometChatParticipants, CometChatCallLogParticipantsConfigurationInterface } from './CometChatCallLogParticipants' + +export { + CallLogParticipantsConfiguration, + CallLogParticipantsConfigurationInterface, + CallParticipantsStyle, + CallParticipantsStyleInterface, + CometChatParticipants, + CometChatCallLogParticipantsConfigurationInterface +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogParticipants/resources/Back.png b/src/calls/CometChatCallLogParticipants/resources/Back.png new file mode 100644 index 0000000000000000000000000000000000000000..cbb2d58022f51f085353d80faf19299462f1fcf9 GIT binary patch literal 346 zcmV-g0j2(lP)Px$6iGxuRA@u(m|+gWFbGE3(L9-YGjBFSGLy!v+kg*&NPn8OdykK1#D$8lr8qye zKy-qgKqp|VK(~;wfadL<2|S4Cz7gJt=w+teIlxO`gy+{XJWIfrhrl;HLqCa#e}^x$ zz#cq9muR7%!*gX&3539-1j67E0-^9$fpB<>Kni%RKpJ?BKq`2tKstDdzziNf8Vm>W z{KO;3;ShNBL$-R79-MtT1pbXc`4-}oOJCwoo2HYvdI!dPmP$e+kgA=u0%;^H0x2Y{ z0^t$}flvvQK$rwlAVdN!Fq1eP%Cy6xhrmq207*qoM6N<$f_;CDm;e9( literal 0 HcmV?d00001 diff --git a/src/calls/CometChatCallLogParticipants/resources/index.ts b/src/calls/CometChatCallLogParticipants/resources/index.ts new file mode 100644 index 0000000..7168f25 --- /dev/null +++ b/src/calls/CometChatCallLogParticipants/resources/index.ts @@ -0,0 +1,4 @@ +import BackIcon from "./Back.png"; +export { + BackIcon, +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogParticipants/style.ts b/src/calls/CometChatCallLogParticipants/style.ts new file mode 100644 index 0000000..d888763 --- /dev/null +++ b/src/calls/CometChatCallLogParticipants/style.ts @@ -0,0 +1,24 @@ +import { StyleSheet } from "react-native"; + +export const Style = StyleSheet.create({ + container: { + flex: 1, + justifyContent: "center", + alignItems: "center", + }, + headerStyle : { + alignItems: "center", + justifyContent: "space-between", + paddingEnd: 8, + paddingStart: 8 + }, + row: { + flexDirection: "row", + alignItems: "center", + }, + imageStyle: { + height: 24, + width: 24, + alignSelf: "center", + } +}); \ No newline at end of file diff --git a/src/calls/CometChatCallLogRecordings/CallLogRecordingsConfiguration.ts b/src/calls/CometChatCallLogRecordings/CallLogRecordingsConfiguration.ts new file mode 100644 index 0000000..1161088 --- /dev/null +++ b/src/calls/CometChatCallLogRecordings/CallLogRecordingsConfiguration.ts @@ -0,0 +1,63 @@ +import { StyleProp, ViewStyle } from "react-native/types"; +import { CometChat } from "@cometchat/chat-sdk-react-native"; +import { DatePattern, ImageType, ListItemStyleInterface } from "../../shared"; +import { CallRecordingsStyleInterface } from "./CallLogRecordingsStyle"; + +export interface CallLogRecordingsConfigurationInterface { + SubtitleView?: (param: { recording?: CometChat.BaseMessage }) => JSX.Element, + TailView?: (param: { recording?: CometChat.BaseMessage }) => JSX.Element, + ListItemView?: (param: { recording?: CometChat.BaseMessage }) => JSX.Element, + AppBarOptions?: () => JSX.Element, + /** + * Recording list + */ + data: any[], + datePattern?: DatePattern, //'timeFormat' | 'dayDateFormat' | 'dayDateTimeFormat', + hideSeperator?: boolean, + BackButton?: JSX.Element, + showBackButton?: boolean, + EmptyStateView?: () => JSX.Element, + onItemPress?: (item: CometChat.BaseMessage) => void, + onError?: (e: CometChat.CometChatException) => void, + onBack?: () => void, + hideDownloadButton?: boolean, + onDownloadIconPress?: (prop: { recording: CometChat.BaseMessage }) => void, + downloadIcon?: ImageType, + listItemStyle?: ListItemStyleInterface, + callLogRecordingsStyle?: CallRecordingsStyleInterface, + bodyViewContainerStyle?: StyleProp, + tailViewContainerStyle?: StyleProp, +} +export class CallLogRecordingsConfiguration implements CallLogRecordingsConfigurationInterface { + SubtitleView?: (param: { recording?: CometChat.BaseMessage }) => JSX.Element + TailView?: (param: { recording?: CometChat.BaseMessage }) => JSX.Element + ListItemView?: (param: { recording?: CometChat.BaseMessage }) => JSX.Element + AppBarOptions?: () => JSX.Element + /** + * Recording list + */ + data: any[] + datePattern: DatePattern; //'timeFormat' | 'dayDateFormat' | 'dayDateTimeFormat' + hideSeperator?: boolean + BackButton?: JSX.Element + showBackButton?: boolean + EmptyStateView?: () => JSX.Element + onItemPress?: (item: CometChat.BaseMessage) => void + onError?: (e: CometChat.CometChatException) => void + onBack?: () => void + hideDownloadButton?: boolean + onDownloadIconPress?: (prop: { recording: CometChat.BaseMessage }) => void + downloadIcon?: ImageType + listItemStyle?: ListItemStyleInterface + callLogRecordingsStyle?: CallRecordingsStyleInterface + bodyViewContainerStyle?: StyleProp + tailViewContainerStyle?: StyleProp + + constructor(props: CallLogRecordingsConfigurationInterface) { + if (props) { + for (const [key, value] of Object.entries(props)) { + this[key] = value; + } + } + } +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogRecordings/CallLogRecordingsStyle.ts b/src/calls/CometChatCallLogRecordings/CallLogRecordingsStyle.ts new file mode 100644 index 0000000..abea45e --- /dev/null +++ b/src/calls/CometChatCallLogRecordings/CallLogRecordingsStyle.ts @@ -0,0 +1,63 @@ +import { BaseStyle, BaseStyleInterface, FontStyle, FontStyleInterface } from "../../shared"; + +export interface CallRecordingsStyleInterface extends BaseStyleInterface { + titleFont?: FontStyleInterface; + titleColor?: string; + dateTextFont?: FontStyleInterface; + dateTextColor?: string; + emptyTextFont?: FontStyleInterface; + emptyTextColor?: string; + backIconTint?: string; + durationTextFont?: FontStyleInterface; + durationTextColor?: string; + loadingIconTint?: string; +} + +export class CallRecordingsStyle extends BaseStyle { + titleFont?: FontStyleInterface; + titleColor?: string; + dateTextFont?: FontStyleInterface; + dateTextColor?: string; + emptyTextFont?: FontStyleInterface; + emptyTextColor?: string; + backIconTint?: string; + durationTextFont?: FontStyleInterface; + durationTextColor?: string; + loadingIconTint?: string; + + constructor({ + titleFont = { fontSize: 20, fontWeight: "600"}, + backgroundColor = "white", + border, + borderRadius, + height, + titleColor = "#000", + dateTextFont, + dateTextColor, + emptyTextColor, + emptyTextFont, + backIconTint, + loadingIconTint, + durationTextColor, + durationTextFont, + width + }: CallRecordingsStyleInterface) { + super({ + backgroundColor: backgroundColor, + border: border, + borderRadius: borderRadius, + height: height, + width: width + }); + this.titleColor = titleColor; + this.titleFont = titleFont; + this.dateTextFont = dateTextFont; + this.dateTextColor = dateTextColor; + this.emptyTextColor = emptyTextColor; + this.emptyTextFont = emptyTextFont; + this.backIconTint = backIconTint; + this.durationTextColor = durationTextColor; + this.durationTextFont = durationTextFont; + this.loadingIconTint = loadingIconTint; + } +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogRecordings/CometChatCallLogRecordings.tsx b/src/calls/CometChatCallLogRecordings/CometChatCallLogRecordings.tsx new file mode 100644 index 0000000..e5a8266 --- /dev/null +++ b/src/calls/CometChatCallLogRecordings/CometChatCallLogRecordings.tsx @@ -0,0 +1,253 @@ +import { CometChat } from '@cometchat/chat-sdk-react-native' +import React, { useContext, useEffect, useRef, useState } from 'react' +import { FlatList, Image, Text, TouchableOpacity, View, NativeModules, Platform, ActivityIndicator } from 'react-native' +import { StyleProp, ViewStyle } from "react-native/types"; +import { CometChatContext, CometChatDate, CometChatListItem, DatePattern, ImageType, ListItemStyleInterface, localize } from '../../shared' +import { CallRecordingsStyle, CallRecordingsStyleInterface } from './CallLogRecordingsStyle' +import { BackIcon, Download } from "./resources"; +import { Style } from './style' +import { CallUtils } from '../CallUtils' + +const { FileManager } = NativeModules; +export interface CometChatCallLogRecordingsConfigurationInterface { + title?: string, + SubtitleView?: (param: { recording?: CometChat.BaseMessage }) => JSX.Element, + TailView?: (param: { recording?: CometChat.BaseMessage }) => JSX.Element, + ListItemView?: (param: { recording?: CometChat.BaseMessage }) => JSX.Element, + AppBarOptions?: () => JSX.Element, + /** + * Recording list + */ + data: any[], + datePattern?: DatePattern, + hideSeperator?: boolean, + BackButton?: JSX.Element, + showBackButton?: boolean, + EmptyStateView?: () => JSX.Element, + emptyStateText?: string, + onItemPress?: (item: CometChat.BaseMessage) => void, + onError?: (e: CometChat.CometChatException) => void, + onBack?: () => void, + hideDownloadButton?: boolean, + onDownloadIconPress?: (prop: { recording: CometChat.BaseMessage }) => void, + downloadIcon?: ImageType, + listItemStyle?: ListItemStyleInterface, + callLogRecordingsStyle?: CallRecordingsStyleInterface, + bodyViewContainerStyle?: StyleProp, + tailViewContainerStyle?: StyleProp, +} + +export const CometChatRecordings = (props: CometChatCallLogRecordingsConfigurationInterface) => { + + const { + title = localize("RECORDINGS"), + SubtitleView, + TailView, + ListItemView, + AppBarOptions, + data, + hideSeperator, + BackButton, + showBackButton, + EmptyStateView, + emptyStateText, + onItemPress, + onError, + onBack, + onDownloadIconPress, + downloadIcon, + listItemStyle, + callLogRecordingsStyle, + bodyViewContainerStyle, + tailViewContainerStyle, + datePattern, + hideDownloadButton + } = props; + + const { theme } = useContext(CometChatContext); + const [processing, setProcessing] = useState(false); + + const _style = new CallRecordingsStyle({ + titleFont: theme.typography.heading, + titleColor: theme.palette.getAccent(), + backgroundColor: theme.palette.getBackgroundColor(), + emptyTextColor: theme?.palette?.getAccent400(), + emptyTextFont: theme?.typography?.subtitle1, + backIconTint: theme.palette.getPrimary(), + durationTextColor: theme.palette.getAccent(), + durationTextFont: theme.typography.subtitle2, + dateTextColor: theme.palette.getAccent(), + dateTextFont: theme.typography.subtitle1, + loadingIconTint: theme.palette.getPrimary(), + ...callLogRecordingsStyle + }); + + const { + backgroundColor, + height, + width, + border, + borderRadius, + titleColor, + titleFont, + backIconTint, + dateTextColor, + dateTextFont, + durationTextColor, + durationTextFont, + emptyTextColor, + emptyTextFont, + loadingIconTint, + } = _style; + + const loggedInUser = useRef(null); + + useEffect(() => { + CometChat.getLoggedinUser() + .then(u => { + loggedInUser.current = u; + }) + .catch(e => { + onError && onError(e); + }); + }, []); + + const DefaultSubtitleView = ({ recording }) => { + if (SubtitleView) + return SubtitleView(recording); + return ( + + + { + CallUtils.convertSecondsToHoursMinutesSeconds(recording['duration']) + } + + + ); + } + + const DefaultTailView = ({ recording }) => { + const getFileName = (fileUrl) => { + return (fileUrl.substring(fileUrl.lastIndexOf("/") + 1, fileUrl.length)).replace(" ", "_"); + } + const _onDownloadIconPress = async () => { + if (onDownloadIconPress) { + onDownloadIconPress({ recording }); + } else { + if (processing) return; + + setProcessing(true); + console.log("DOWNLOAD by Default") + try { + if (Platform.OS === "android") { + await FileManager.checkAndDownload(recording?.recording_url, getFileName(recording?.recording_url), async (isOpened: string) => { + console.log("android", isOpened); + }); + setProcessing(false); + } + else { + FileManager.openFile(recording?.recording_url, getFileName(recording?.recording_url), async (isOpened: string) => { + console.log("ios", isOpened); + setProcessing(false); + }); + } + } + catch (e) { + console.log(e); + setProcessing(false); + } + } + } + return ( + + + {!hideDownloadButton && + {!processing ? + + : + } + } + + ) + } + + const onPress = (item) => { + onItemPress && onItemPress(item); + return; + } + + const _render = ({ item, index }) => { + + if (ListItemView) + return + + const title = item['rid']; + + return + + SubtitleView ? : + } + TailView={TailView ? () => : () => } + onPress={() => onPress(item)} + hideSeparator={hideSeperator} + /> + + } + + const EmptyView = () => { + if (EmptyStateView) + return + return ( + + {emptyStateText || localize("NO_RECORDINGS")} + + ) + } + + return ( + + + + { + showBackButton ? + BackButton ?? + + + : null + } + {title} + + + { + AppBarOptions && + } + + + {data.length == 0 ? + : + item.sessionId} + renderItem={_render} + /> + } + + ) +} diff --git a/src/calls/CometChatCallLogRecordings/index.ts b/src/calls/CometChatCallLogRecordings/index.ts new file mode 100644 index 0000000..bfca5af --- /dev/null +++ b/src/calls/CometChatCallLogRecordings/index.ts @@ -0,0 +1,12 @@ +import { CallLogRecordingsConfiguration, CallLogRecordingsConfigurationInterface } from './CallLogRecordingsConfiguration'; +import { CallRecordingsStyle, CallRecordingsStyleInterface } from './CallLogRecordingsStyle'; +import { CometChatRecordings, CometChatCallLogRecordingsConfigurationInterface } from './CometChatCallLogRecordings'; + +export { + CallLogRecordingsConfiguration, + CallLogRecordingsConfigurationInterface, + CallRecordingsStyle, + CallRecordingsStyleInterface, + CometChatRecordings, + CometChatCallLogRecordingsConfigurationInterface +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogRecordings/resources/Back.png b/src/calls/CometChatCallLogRecordings/resources/Back.png new file mode 100644 index 0000000000000000000000000000000000000000..cbb2d58022f51f085353d80faf19299462f1fcf9 GIT binary patch literal 346 zcmV-g0j2(lP)Px$6iGxuRA@u(m|+gWFbGE3(L9-YGjBFSGLy!v+kg*&NPn8OdykK1#D$8lr8qye zKy-qgKqp|VK(~;wfadL<2|S4Cz7gJt=w+teIlxO`gy+{XJWIfrhrl;HLqCa#e}^x$ zz#cq9muR7%!*gX&3539-1j67E0-^9$fpB<>Kni%RKpJ?BKq`2tKstDdzziNf8Vm>W z{KO;3;ShNBL$-R79-MtT1pbXc`4-}oOJCwoo2HYvdI!dPmP$e+kgA=u0%;^H0x2Y{ z0^t$}flvvQK$rwlAVdN!Fq1eP%Cy6xhrmq207*qoM6N<$f_;CDm;e9( literal 0 HcmV?d00001 diff --git a/src/calls/CometChatCallLogRecordings/resources/download.png b/src/calls/CometChatCallLogRecordings/resources/download.png new file mode 100644 index 0000000000000000000000000000000000000000..19a53d80a19cbd7befd7d0f3d639aa7a0ff4963e GIT binary patch literal 331 zcmV-R0kr;!P)y99|=L9MgDq2dpmKRADKpCB}9QC#OJY5c*OLBw%xZ?6!Md&y=t zvorH%XJ;13p+UjKxYd{Aa?Rvri;C|j4rl#I^`k8)^(GgAFUPd6Eu1dq!!u_O2vPv(?I|L002ovPDHLkV1lunlDPl? literal 0 HcmV?d00001 diff --git a/src/calls/CometChatCallLogRecordings/resources/index.ts b/src/calls/CometChatCallLogRecordings/resources/index.ts new file mode 100644 index 0000000..51ea25a --- /dev/null +++ b/src/calls/CometChatCallLogRecordings/resources/index.ts @@ -0,0 +1,6 @@ +import BackIcon from "./Back.png"; +import Download from './download.png'; +export { + BackIcon, + Download +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogRecordings/style.ts b/src/calls/CometChatCallLogRecordings/style.ts new file mode 100644 index 0000000..d888763 --- /dev/null +++ b/src/calls/CometChatCallLogRecordings/style.ts @@ -0,0 +1,24 @@ +import { StyleSheet } from "react-native"; + +export const Style = StyleSheet.create({ + container: { + flex: 1, + justifyContent: "center", + alignItems: "center", + }, + headerStyle : { + alignItems: "center", + justifyContent: "space-between", + paddingEnd: 8, + paddingStart: 8 + }, + row: { + flexDirection: "row", + alignItems: "center", + }, + imageStyle: { + height: 24, + width: 24, + alignSelf: "center", + } +}); \ No newline at end of file diff --git a/src/calls/CometChatCallLogs/CallLogsConfiguration.ts b/src/calls/CometChatCallLogs/CallLogsConfiguration.ts new file mode 100644 index 0000000..63de3b2 --- /dev/null +++ b/src/calls/CometChatCallLogs/CallLogsConfiguration.ts @@ -0,0 +1,87 @@ +import { StyleProp, ViewStyle } from "react-native/types"; +import { CometChat } from "@cometchat/chat-sdk-react-native"; +import { AvatarStyleInterface, CometChatOptions, ImageType, ListItemStyleInterface } from "../../shared"; +import { CallLogsStyleInterface } from "./CallLogsStyle"; +import { DatePattern } from "../../shared/base/Types"; +import { CometChatOutgoingCallInterface } from "../CometChatOutgoingCall"; + +export interface CallLogsConfigurationInterface { + SubtitleView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element, + ListItemView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element, + TailView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element, + AppBarOptions?: () => JSX.Element, + options?: (param: { message: CometChat.BaseMessage }) => CometChatOptions[], + callRequestBuilder?: any, + datePattern: DatePattern, + dateSeparatorPattern: DatePattern, + hideSeperator?: boolean, + BackButton?: JSX.Element, + showBackButton?: boolean, + EmptyStateView?: () => JSX.Element, + ErrorStateView?: () => JSX.Element, + loadingIcon?: ImageType, + LoadingStateView?: () => JSX.Element, + hideError?: boolean, + onItemPress?: (item: CometChat.BaseMessage) => void, + onError?: (e: CometChat.CometChatException) => void, + onBack?: () => void, + onInfoIconPress?: (prop: { call: CometChat.BaseMessage }) => void, + infoIcon?: ImageType, + avatarStyle?: AvatarStyleInterface, + listItemStyle?: ListItemStyleInterface, + callLogsStyle?: CallLogsStyleInterface, + headViewContainerStyle?: StyleProp, + bodyViewContainerStyle?: StyleProp, + tailViewContainerStyle?: StyleProp, + missedAudioCallIconUrl?: string, + missedVideoCallIconUrl?: string, + incomingAudioCallIconUrl?: string, + incomingVideoCallIconUrl?: string, + outgoingAudioCallIconUrl?: string, + outgoingVideoCallIconUrl?: string, + outgoingCallConfiguration?: CometChatOutgoingCallInterface, +} +export class CallLogsConfiguration implements CallLogsConfigurationInterface { + SubtitleView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element + ListItemView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element + TailView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element + AppBarOptions?: () => JSX.Element + options?: (param: { message: CometChat.BaseMessage }) => CometChatOptions[] + callRequestBuilder?: any + datePattern: DatePattern + dateSeparatorPattern: DatePattern + hideSeperator?: boolean + BackButton?: JSX.Element + showBackButton?: boolean + EmptyStateView?: () => JSX.Element + ErrorStateView?: () => JSX.Element + loadingIcon?: ImageType + LoadingStateView?: () => JSX.Element + hideError?: boolean + onItemPress?: (item: CometChat.BaseMessage) => void + onError?: (e: CometChat.CometChatException) => void + onBack?: () => void + onInfoIconPress?: (prop: { call: CometChat.BaseMessage }) => void + infoIcon?: ImageType + avatarStyle?: AvatarStyleInterface + listItemStyle?: ListItemStyleInterface + callLogsStyle?: CallLogsStyleInterface + headViewContainerStyle?: StyleProp + bodyViewContainerStyle?: StyleProp + tailViewContainerStyle?: StyleProp + missedAudioCallIconUrl?: string + missedVideoCallIconUrl?: string + incomingAudioCallIconUrl?: string + incomingVideoCallIconUrl?: string + outgoingAudioCallIconUrl?: string + outgoingVideoCallIconUrl?: string + outgoingCallConfiguration?: CometChatOutgoingCallInterface + + constructor(props: CallLogsConfigurationInterface) { + if (props) { + for (const [key, value] of Object.entries(props)) { + this[key] = value; + } + } + } +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogs/CallLogsStyle.ts b/src/calls/CometChatCallLogs/CallLogsStyle.ts new file mode 100644 index 0000000..5d5d385 --- /dev/null +++ b/src/calls/CometChatCallLogs/CallLogsStyle.ts @@ -0,0 +1,95 @@ +import { BaseStyle, BaseStyleInterface, FontStyle, FontStyleInterface } from "../../shared"; + +export interface CallLogsStyleInterface extends BaseStyleInterface { + titleFont?: FontStyleInterface, + titleColor?: string, + loadingTint?: string, + emptyTextFont?: FontStyleInterface, + emptyTextColor?: string, + errorTextColor?: string, + errorTextFont?: FontStyleInterface, + separatorColor?: string, + infoIconTint?: string, + missedCallIconTint?: string, + outgoingCallIconTint?: string, + incomingCallIconTint?: string, + subtitleTextFont?: FontStyleInterface, + subtitleTextColor?: string, + dateTextFont?: FontStyleInterface, + dateTextColor?: string, + dateSeparatorTextFont?: FontStyleInterface, + dateSeparatorTextColor?: string, +} + +export class CallLogsStyle extends BaseStyle { + titleFont?: FontStyleInterface; + titleColor?: string; + loadingTint?: string; + emptyTextFont?: FontStyleInterface; + emptyTextColor?: string + errorTextColor?: string; + errorTextFont?: FontStyleInterface; + separatorColor?: string; + infoIconTint?: string; + missedCallIconTint?: string; + outgoingCallIconTint?: string; + incomingCallIconTint?: string; + subtitleTextFont?: FontStyleInterface; + subtitleTextColor?: string; + dateTextFont?: FontStyleInterface; + dateTextColor?: string; + dateSeparatorTextFont?: FontStyleInterface; + dateSeparatorTextColor?: string; + + constructor({ + titleFont = { fontSize: 20, fontWeight: "600" }, + backgroundColor = "white", + border, + borderRadius, + height, + titleColor = "#000", + width, + loadingTint, + emptyTextFont, + emptyTextColor, + errorTextColor, + errorTextFont, + separatorColor, + infoIconTint, + missedCallIconTint, + outgoingCallIconTint, + incomingCallIconTint, + subtitleTextFont, + subtitleTextColor, + dateTextFont, + dateTextColor, + dateSeparatorTextFont, + dateSeparatorTextColor + }: CallLogsStyleInterface) { + super({ + backgroundColor: backgroundColor, + border: border, + borderRadius: borderRadius, + height: height, + width: width + }); + this.titleColor = titleColor; + this.titleFont = titleFont; + this.loadingTint = loadingTint; + this.emptyTextFont = emptyTextFont; + this.emptyTextColor = emptyTextColor; + this.errorTextColor = errorTextColor; + this.errorTextFont = errorTextFont; + this.separatorColor = separatorColor; + this.infoIconTint = infoIconTint; + this.missedCallIconTint = missedCallIconTint; + this.outgoingCallIconTint = outgoingCallIconTint; + this.incomingCallIconTint = incomingCallIconTint; + this.subtitleTextFont = subtitleTextFont; + this.subtitleTextColor = subtitleTextColor; + this.dateTextFont = dateTextFont; + this.dateTextColor = dateTextColor; + this.dateSeparatorTextFont = dateSeparatorTextFont; + this.dateSeparatorTextColor = dateSeparatorTextColor; + } +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogs/CometChatCallLogs.tsx b/src/calls/CometChatCallLogs/CometChatCallLogs.tsx new file mode 100644 index 0000000..8127324 --- /dev/null +++ b/src/calls/CometChatCallLogs/CometChatCallLogs.tsx @@ -0,0 +1,482 @@ +import { CometChat } from '@cometchat/chat-sdk-react-native' +import React, { useContext, useEffect, useRef, useState } from 'react' +import { FlatList, Image, Text, TouchableOpacity, View } from 'react-native' +import { StyleProp, ViewStyle } from "react-native/types"; +import { AvatarStyleInterface, CometChatContext, CometChatDate, CometChatListItem, CometChatOptions, DatePattern, ImageType, ListItemStyleInterface, localize } from '../../shared' +import { CallLogsStyle, CallLogsStyleInterface } from './CallLogsStyle' +import { CometChatUIEventHandler } from '../../shared/events/CometChatUIEventHandler/CometChatUIEventHandler' +import { LoadingIcon, DetailIcon, BackIcon, IncomingCallIcon, IncomingVideoIcon, MissedCallIcon, MissedVideoIcon, OutgoingCallIcon, OutgoingVideoIcon } from "./resources"; +import { CallTypeConstants } from '../../shared/constants/UIKitConstants' +import { Style } from './style' +import { CallingPackage } from '../CallingPackage' +import { CallUtils } from '../CallUtils' +import { CallUIEvents } from '../CallEvents' +import { CometChatOutgoingCall, CometChatOutgoingCallInterface } from '../CometChatOutgoingCall' + +const listenerId = "callEventListener_" + new Date().getTime(); +const CometChatCalls = CallingPackage.CometChatCalls; + +export interface CometChatCallLogsConfigurationInterface { + title?: string, + SubtitleView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element, + ListItemView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element, + TailView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element, + AppBarOptions?: () => JSX.Element, + options?: (param: { message: CometChat.BaseMessage }) => CometChatOptions[], + callRequestBuilder?: any, + datePattern: DatePattern, + dateSeparatorPattern: DatePattern, + hideSeperator?: boolean, + BackButton?: JSX.Element, + showBackButton?: boolean, + EmptyStateView?: () => JSX.Element, + emptyStateText?: string, + ErrorStateView?: () => JSX.Element, + errorStateText?: string, + loadingIcon?: ImageType, + LoadingStateView?: () => JSX.Element, + hideError?: boolean, + onItemPress?: (item: CometChat.BaseMessage) => void, + onError?: (e: CometChat.CometChatException) => void, + onBack?: () => void, + onInfoIconPress?: (prop: { call: CometChat.BaseMessage }) => void, + infoIcon?: ImageType, + avatarStyle?: AvatarStyleInterface, + listItemStyle?: ListItemStyleInterface, + callLogsStyle?: CallLogsStyleInterface, + headViewContainerStyle?: StyleProp, + bodyViewContainerStyle?: StyleProp, + tailViewContainerStyle?: StyleProp, + missedAudioCallIconUrl?: string, + missedVideoCallIconUrl?: string, + incomingAudioCallIconUrl?: string, + incomingVideoCallIconUrl?: string, + outgoingAudioCallIconUrl?: string, + outgoingVideoCallIconUrl?: string, + outgoingCallConfiguration?: CometChatOutgoingCallInterface, +} + +export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface) => { + + const { + title = localize("CALL_LOGS"), + SubtitleView, + ListItemView, + TailView, + AppBarOptions, + options, + callRequestBuilder, + datePattern, + dateSeparatorPattern, + hideSeperator, + BackButton, + showBackButton, + EmptyStateView, + emptyStateText, + ErrorStateView, + errorStateText, + loadingIcon, + LoadingStateView, + hideError, + onItemPress, + onInfoIconPress, + infoIcon, + onError, + onBack, + avatarStyle, + listItemStyle, + callLogsStyle, + headViewContainerStyle, + bodyViewContainerStyle, + tailViewContainerStyle, + missedAudioCallIconUrl, + missedVideoCallIconUrl, + incomingAudioCallIconUrl, + incomingVideoCallIconUrl, + outgoingAudioCallIconUrl, + outgoingVideoCallIconUrl, + outgoingCallConfiguration, + } = props; + + const { theme } = useContext(CometChatContext); + + const _style = new CallLogsStyle({ + titleFont: theme.typography.heading, + titleColor: theme.palette.getAccent(), + backgroundColor: theme.palette.getBackgroundColor(), + emptyTextColor: theme?.palette?.getAccent400(), + emptyTextFont: theme?.typography?.subtitle1, + errorTextColor: theme?.palette?.getError(), + errorTextFont: theme?.typography?.subtitle1, + loadingTint: theme?.palette.getAccent700(), + infoIconTint: theme.palette.getPrimary(), + subtitleTextColor: theme.palette.getAccent(), + subtitleTextFont: theme.typography.text2, + dateSeparatorTextColor: theme.palette.getAccent600(), + dateSeparatorTextFont: theme.typography.text2, + dateTextColor: theme.palette.getAccent(), + dateTextFont: theme.typography.text2, + ...callLogsStyle + }); + + const { + backgroundColor, + height, + width, + border, + borderRadius, + titleColor, + titleFont, + loadingTint, + dateSeparatorTextColor, + dateSeparatorTextFont, + dateTextColor, + dateTextFont, + emptyTextColor, + emptyTextFont, + errorTextColor, + errorTextFont, + incomingCallIconTint, + infoIconTint, + missedCallIconTint, + outgoingCallIconTint, + separatorColor, + subtitleTextColor, + subtitleTextFont + } = _style; + + const [list, setList] = useState([]); + const [listState, setListState] = useState<"loading" | "error" | "done">("loading"); + const [showOutgoingCallScreen, setShowOutgoingCallScreen] = useState(false); + + const loggedInUser = useRef(null); + const callRequestBuilderRef = useRef(null); + const outGoingCall = useRef(null); + + function setRequestBuilder() { + callRequestBuilderRef.current = (callRequestBuilder && callRequestBuilder.build()) ?? + new CometChatCalls.CallLogRequestBuilder() + .setLimit(30) + .setAuthToken(loggedInUser.current.getAuthToken() || "") + .setCallCategory("call") + .build() + } + + const fetchCallLogs = () => { + setListState("loading"); + callRequestBuilderRef.current.fetchNext() + .then(callLogs => { + console.log(callLogs.length); + if (callLogs.length > 0) { + setList([...list, ...callLogs]); + } + setListState("done"); + }) + .catch(err => { + onError && onError(err); + setListState("error"); + }); + } + + useEffect(() => { + CometChat.getLoggedinUser() + .then(u => { + loggedInUser.current = u; + setRequestBuilder(); + fetchCallLogs(); + }) + .catch(e => { + onError && onError(e); + }); + CometChat.addCallListener( + listenerId, + new CometChat.CallListener({ + onOutgoingCallRejected: (call) => { + setShowOutgoingCallScreen(false); + outGoingCall.current = null; + }, + }) + ) + + CometChatUIEventHandler.addCallListener( + listenerId, + { + ccCallRejected: (call) => { + outGoingCall.current = null; + setShowOutgoingCallScreen(false); + }, + ccCallEnded: () => { + outGoingCall.current = null; + setShowOutgoingCallScreen(false); + }, + } + ); + + }, []); + + const DefaultSubtitleView = ({ call }) => { + function getCallDirectionIcon(call) { + const missedCall = CallUtils.isMissedCall(call, loggedInUser.current); + const callType = call.getType(); + let icon, tintColor; + if (missedCall) { + tintColor = missedCallIconTint || theme.palette.getAccent700(); + if (callType === CometChat.CALL_TYPE.AUDIO) { + icon = missedAudioCallIconUrl || MissedCallIcon; + } else { + icon = missedVideoCallIconUrl || MissedVideoIcon; + } + } else if (call.getInitiator().getUid() === loggedInUser.current?.getUid()) { + tintColor = outgoingCallIconTint || theme.palette.getAccent700(); + if (callType === CometChat.CALL_TYPE.AUDIO) { + icon = outgoingAudioCallIconUrl || OutgoingCallIcon; + } else { + icon = outgoingVideoCallIconUrl || OutgoingVideoIcon; + } + } else { + tintColor = incomingCallIconTint || theme.palette.getAccent700(); + if (callType === CometChat.CALL_TYPE.AUDIO) { + icon = incomingAudioCallIconUrl || IncomingCallIcon; + } else { + icon = incomingVideoCallIconUrl || IncomingVideoIcon; + } + } + return { icon, tintColor }; + } + + if (SubtitleView) + return SubtitleView(call); + return ( + + + + { + CallUtils.getCallStatus(call as CometChat.Call, loggedInUser.current) + } + + + ); + } + + const DeafultTailView = ({ call }) => { + return ( + + + {onInfoIconPress && onInfoIconPress && onInfoIconPress({ call })} style={{ marginStart: 8 }}> + + } + + ) + } + + const makeCall = (call, type) => { + if (type == CallTypeConstants.audio || type == CallTypeConstants.video) { + let user = call?.getReceiverType() == "user" ? loggedInUser.current?.getUid() === call?.getInitiator()?.getUid() ? call.getReceiver() : call?.getInitiator() : undefined + let group = call?.getReceiverType() == "group" ? loggedInUser.current?.getUid() === call?.getInitiator()?.getUid() ? call.getReceiver() : call?.getInitiator() : undefined + + var receiverID = user ? user.getUid() : group ? group.getGuid() : undefined; + var callType = type; + console.log({ receiverID, callType }) + var receiverType = user ? CometChat.RECEIVER_TYPE.USER : group ? CometChat.RECEIVER_TYPE.GROUP : undefined + console.log({ receiverType }) + if (!receiverID || !receiverType) + return; + + var call = new CometChat.Call(receiverID, callType, receiverType, CometChat.CATEGORY_CALL); + + CometChat.initiateCall(call).then( + initiatedCall => { + outGoingCall.current = initiatedCall; + setShowOutgoingCallScreen(true); + CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccOutgoingCall, { call: outGoingCall.current }); + }, + error => { + console.log("Call initialization failed with exception:", error); + CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccCallFailled, { call }); + onError && onError(error); + } + ); + } else { + console.log("Invalid call type.", type, CallTypeConstants.audio, type != CallTypeConstants.audio || type != CallTypeConstants.video); + return; + } + } + + const onPress = (item) => { + if (onItemPress) { + onItemPress(item); + } else { + if (item?.getReceiverType() == "user") { + console.log("MAKE A CALL"); + makeCall(item, item.getType()); + } + } + } + + const getCallDetails = (call) => { + const { mode, initiator, receiver, receiverType } = call; + + if (mode == "meet") { + return { + title: receiver['name'], + avatarUrl: receiver['icon'] + } + } else if (mode == "call") { + + return { + title: receiverType === 'group' ? receiver['name'] : loggedInUser.current['uid'] == initiator?.getUid() ? receiver['name'] : initiator['name'], + avatarUrl: receiverType === 'group' ? receiver['avatar'] : loggedInUser.current['uid'] == initiator?.getUid() ? receiver['avatar'] : initiator['avatar'], + } + } + return { title: "", avatarUrl: undefined } + } + + const getInitiatedAtTimestamp = (item) => { + return item['initiatedAt'] * 1000; + } + + const _render = ({ item, index }) => { + + if (ListItemView) + return + + const { title, avatarUrl } = getCallDetails(item); + + let seperatorView = null; + const previousMessageDate = list[index - 1] ? new Date(getInitiatedAtTimestamp(list[index - 1])) : null; + const currentMessageDate = new Date(getInitiatedAtTimestamp(item)); + + const currentDate = isNaN(currentMessageDate.getDate()) ? undefined : `${currentMessageDate.getDate()}-${currentMessageDate.getMonth()}-${currentMessageDate.getFullYear()}`; + + const previousDate = `${previousMessageDate?.getDate()}-${previousMessageDate?.getMonth()}-${previousMessageDate?.getFullYear()}`; + + if (currentDate != undefined && previousDate !== currentDate) { + seperatorView = ( + + + + ) + } + + return + {seperatorView} + + SubtitleView ? : + } + TailView={TailView ? () => : () => } + avatarStyle={avatarStyle} + options={() => options && options(item)} + onPress={() => onPress(item)} + hideSeparator={hideSeperator} + separatorColor={separatorColor} + /> + + } + + const EmptyView = () => { + if (EmptyStateView) + return + return ( + + {emptyStateText || localize("NO_CALL_HISTORY")} + + ) + } + + const ErrorView = () => { + if (hideError) return null; + if (ErrorStateView) + return + return + {errorStateText || localize("SOMETHING_WRONG")} + + } + + const LoadingView = () => { + if (LoadingStateView) + return + return + + + } + + return ( + + <> + + + { + showBackButton ? + BackButton ?? + + + : null + } + {title} + + + { + AppBarOptions && + } + + + { + listState == "loading" && list.length == 0 ? + : + listState == "error" && list.length == 0 ? + : + list.length == 0 ? + : + item.sessionId} + renderItem={_render} + onEndReached={fetchCallLogs} + /> + } + + { + showOutgoingCallScreen && { + CometChat.rejectCall(call['sessionId'], CometChat.CALL_STATUS.CANCELLED).then( + rejectedCall => { + CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccCallRejected, { call: rejectedCall }); + }, + err => { + onError && onError(err); + } + ); + }} + {...outgoingCallConfiguration} + /> + } + + ) +} diff --git a/src/calls/CometChatCallLogs/index.ts b/src/calls/CometChatCallLogs/index.ts new file mode 100644 index 0000000..9679730 --- /dev/null +++ b/src/calls/CometChatCallLogs/index.ts @@ -0,0 +1,12 @@ +import { CallLogsConfiguration, CallLogsConfigurationInterface } from "./CallLogsConfiguration"; +import { CallLogsStyle, CallLogsStyleInterface } from "./CallLogsStyle"; +import { CometChatCallLogs, CometChatCallLogsConfigurationInterface } from "./CometChatCallLogs"; + +export { + CallLogsConfiguration, + CallLogsConfigurationInterface, + CallLogsStyle, + CallLogsStyleInterface, + CometChatCallLogs, + CometChatCallLogsConfigurationInterface +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogs/resources/Back.png b/src/calls/CometChatCallLogs/resources/Back.png new file mode 100644 index 0000000000000000000000000000000000000000..cbb2d58022f51f085353d80faf19299462f1fcf9 GIT binary patch literal 346 zcmV-g0j2(lP)Px$6iGxuRA@u(m|+gWFbGE3(L9-YGjBFSGLy!v+kg*&NPn8OdykK1#D$8lr8qye zKy-qgKqp|VK(~;wfadL<2|S4Cz7gJt=w+teIlxO`gy+{XJWIfrhrl;HLqCa#e}^x$ zz#cq9muR7%!*gX&3539-1j67E0-^9$fpB<>Kni%RKpJ?BKq`2tKstDdzziNf8Vm>W z{KO;3;ShNBL$-R79-MtT1pbXc`4-}oOJCwoo2HYvdI!dPmP$e+kgA=u0%;^H0x2Y{ z0^t$}flvvQK$rwlAVdN!Fq1eP%Cy6xhrmq207*qoM6N<$f_;CDm;e9( literal 0 HcmV?d00001 diff --git a/src/calls/CometChatCallLogs/resources/Info.png b/src/calls/CometChatCallLogs/resources/Info.png new file mode 100644 index 0000000000000000000000000000000000000000..f902e1d3ce0130d01cd825992bea0f5920d860f2 GIT binary patch literal 564 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|Tv8)E(|mmy zw18|52FCVG1{RPKAeI7R1_tH@j10^`nh_+nfC(-uv49!D1}S`GTDlgfY@Vl!V~7Xu z)~UO_m;*&z9}Da1uy#&Rs+Fog80B57>EM z;&io%H#ZoYKYz3NefGP#VXG5$u6%gE;AXq+jdNel+q{2hT5~4J*uHFq#KHAF`Zn*4 zZp}M#b;VlV^sDX3KiK>e#s9S#7H3_F3f`&2rMGag^a0)oR@1DtI~$hHwcu(^F9?fB zUMr^<VER5kSnEpm#{xBbk=wKL^&SC8x(HBrZ;O)g@2>_01=t6t7Lf1o>?ds^Ac;S2_{81Z#q7{{&k6P`lFD&JML_G@zyBKuQw{&Yd`Cgu3e|>k3Sowk-%!_YG_T(K9l@K*gF!0*R+7tJ@>lMbOyo9^ihX;rkAH#ijm6utp3U03uhI7Vwrg+F zTK3<*X19B`!=JMo_h)4bZ>-ySuA5aSS60#9`DdnJboAv8@ePf~@1MVQjj1TKo-Hz? zdGA`@CC6t+d@`(=a%1-PE}PW{giMrlzqIdU%G5Dt_@(x_6XbPIS3j3^P6Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91FrWhf1ONa40RR91FaQ7m0NXcg3;+NGVM#e5n7xaYM-;|48jS%J zHCiZf0}8@Igy46PU?JuYkaQxu7KxQ;m87w-Fk)q4B_ayih`peJ6n4UHR8WM36vC=m zB?iCEnl*WTd+)Q%zW06KnYq_{w{RbL?tGmybI#0}kN5WV&7yJ!Hmc>cct+e*Db-=a z2Oa9ysh?8g3UQA3w>T)ibI^IW@JY~dm=CHu&vw&+&aF%6p;r!cEmV8uK*C(MC-PxL zZK>M75f_V>#am)8@TCU%R(vcT6aN%T5p!Udv_2OJfqmjxaYRhPe@&s>@cCMLN5#1! zxqN>b*m$DC zGtamuo8y)yF$eBQ>%3TWVn}r{C%kGBjiSo-(7i5V%pTDWlMabsxRI3p z+KIXq!1yC#IP-Ld@t4TdA;kgoZ!|l>2_xo&jkkPRT4nqX5{?>Ahn~^0&Wm+8aZV(h z*bfjR_lldvA~*t#znlruoyvRWvBS0`8&6;C_8f2?KNQ!C4hzx^;;1+#8uygp2p$(t zi1$U~D`hy}=ZP5ZQzy%K=}j3yJ_lb&c(+Ih+JHyO9~M(^Q9^4)4EH2{uY6M2NNx(L zdtgeTnem>$2^;XbC{$Dar>Tc7E7+Ft^zXsR=Ynt|Oje4#_b-S~#T0Nn6NazELn8Oh zEM{k5CT74#;TjFjrNZOQa9dfKwr3(w>_05fX1YUq$Hi4m{czkc@9wGNNIoe3Y=Q4o z2#r^<1(ppPo~uy%*b0R!^0!rw@n!v&saOst27HYAW-U{2UD?y%UpID;a+yI;Hb$dm z`Y&>mj`$em+GiH%h(^=T1cFS z=kvH|;50@9JB}@$kjaLWpIis})hRP?<2~T7stdoy7<)i;m|$%9S;?Eq8N*<5{;TF<44rYo1_e^QVc$| z78L{?UT+HZEyWZER!hqpHVmCQ<2{g_aGbk7Ozi}ZN#qo2iS;3Zq8sDJA!Q;eT1!*-^)QH_re7002ovPDHLkV1lTzH`V|E literal 0 HcmV?d00001 diff --git a/src/calls/CometChatCallLogs/resources/check.png b/src/calls/CometChatCallLogs/resources/check.png new file mode 100644 index 0000000000000000000000000000000000000000..984303d34b380b948f320ba9c51fec1a35b2a417 GIT binary patch literal 1440 zcmV;R1z-A!P)lAB>0(0*bmA z1z#9n2nsOTJYyZcBF3}_xC@$fIBOY4Y7S2ij9|6t6|LWg%f-{k;bbVd zi<-mV#MnuUt4z0w7#CZIH?6}zr30StzL`m1onoftQR%5#v!=94LSUkFXy%nk4-iF(wtj zfmfT2sXSmbXk&(3D?0FD1#y#GqC%Frr%a0!z(8Qn9*sKB&KD!GA#gb+i<)T5YSk+~ z_U_d)b;dxckOy|)B64U(Z#!bx*nEE5i1But<-O(|v?RAE0EG?%`VTMEw%dkq zO`BzY>J_r2Sdqg-H$oQGhH-tHh-h3~)xZNk<7+3#TJX?i!k{s1mn@C#NBTLonA z)4SrVU+0x-ERlQMI&3wN{V!NNEy1nB&&0U81K7GC&+Z@Y(iv28I4(OIi+&lfiWna& zo5C&iD}7FHnAGKc{z^PsohQ#Rt2^-TTJ&tCo*X3bFOsv>0V>*D&a*dW=u_&+{`Lq0dgB;J0{#q-w_5Sokb@@B zh~(Obpp|#a!&U-0Y)V*hw)1q>$?nx?-t!1Dob)8y*QZOt)4v5-@wgAgDAs28Ws}dAMzAsxZh|J zWq739E=D27pwTF~9!Jr_0_|GiFfSU-Dz5ygayK%m?uwsfuKuas0O>FxrI7_o0Q>B(@h$f4Mc5|Fk^JUjB$y= zNu5l$YQui4DR$I-r!3n^;I!)t~VI0000sZ;0aOAC`6}B0}CT{SGQ!I3A)+3D{ Xs(ms){Sa^H00000NkvXXu0mjfEbx&o literal 0 HcmV?d00001 diff --git a/src/calls/CometChatCallLogs/resources/incomingvideo.png b/src/calls/CometChatCallLogs/resources/incomingvideo.png new file mode 100644 index 0000000000000000000000000000000000000000..a3a499a448a22ad6c452d6e8c3fb8dd8c5660030 GIT binary patch literal 373 zcmV-*0gC>KP)o{EHxWUW_m?`99VyO(;WnmL*C&2Q$M8CuRVfj^8%w58lB;|!H% zz$u*I0-q_sL3CmU?~RfUu$=-5?H1!f++A~O<@Mqz1u_u$kLbfZuHtwDvVT;xhiNRv zaToTH!w!0|jH9Fn$RZ!ayI8?ya5jPx#&9g^dxqo}T@v-Q23y4f9)g?>T%-E?awCQ9 zO<+x}Q4b3kZ33%eB3AlCWs<_~7*@bNE)#M}qCVbXE#`cM35VEfpf<_QF{l1*Ua?NS zG6>%yWy^j=FJ{B@7Vf4b~FcgE+mcxr^IlQIhwTgWMD+e>E TYkNU!00000NkvXXu0mjf8&aXo literal 0 HcmV?d00001 diff --git a/src/calls/CometChatCallLogs/resources/index.ts b/src/calls/CometChatCallLogs/resources/index.ts new file mode 100644 index 0000000..0933568 --- /dev/null +++ b/src/calls/CometChatCallLogs/resources/index.ts @@ -0,0 +1,25 @@ +import LoadingIcon from "./Spinner.png"; +import DetailIcon from "./Info.png"; +import BackIcon from "./Back.png"; +import CheckIcon from "./check.png"; +import SelectionIcon from "./Selection.png"; +import IncomingCallIcon from './incomingcall.png'; +import OutgoingCallIcon from './outgoingcall.png'; +import MissedCallIcon from './missedcall.png'; +import MissedVideoIcon from './missedvideo.png'; +import IncomingVideoIcon from './incomingvideo.png'; +import OutgoingVideoIcon from './outgoingvideo.png'; + +export { + SelectionIcon, + CheckIcon, + DetailIcon, + LoadingIcon, + BackIcon, + IncomingCallIcon, + OutgoingCallIcon, + MissedCallIcon, + MissedVideoIcon, + IncomingVideoIcon, + OutgoingVideoIcon +} \ No newline at end of file diff --git a/src/calls/CometChatCallLogs/resources/missedcall.png b/src/calls/CometChatCallLogs/resources/missedcall.png new file mode 100644 index 0000000000000000000000000000000000000000..4a620e75e8fb8a57b1be1b3323ac76e5d21d89f1 GIT binary patch literal 342 zcmV-c0jd6pP)mm;yq@I0a)$NBwO&$T`GeLvr>`?((KN+^djY-0n3{{r)P z#VJP7@})O|y)=*lN@$3{JIvw`opELW*BGt^>%tWduoN9l$6h5u$8dw8H11}wAiUis z78Csnp3=f#U04@7@Qn7vO#U}OW8(aRGJ3IsRXikS?$f%131OvuA&90dmw!?#&QVO% zi#Wo(?_1T>ATE7=;vON@61If&GegU`K);asRIKN)gUM|*?{u)5Oe9amK`pBgD8l>h($07*qoM6N<$g7^)WSpWb4 literal 0 HcmV?d00001 diff --git a/src/calls/CometChatCallLogs/resources/missedvideo.png b/src/calls/CometChatCallLogs/resources/missedvideo.png new file mode 100644 index 0000000000000000000000000000000000000000..1f2b611dc9b8e72fcead593cebfbf8e43a8894f9 GIT binary patch literal 413 zcmV;O0b>4%P)%t(1U4Q z#e5r9#<366xJlqLQ>#9&c7Is6u^mf7YEGx>r&j6Ra=iQvWdT&^Pv zvX&RIj4fd>jWB{0{LSV59Y_90FpOuyR2$)|V40#j-z>NV(d$E$goUHl00000NkvXX Hu0mjfe`UG^ literal 0 HcmV?d00001 diff --git a/src/calls/CometChatCallLogs/resources/outgoingcall.png b/src/calls/CometChatCallLogs/resources/outgoingcall.png new file mode 100644 index 0000000000000000000000000000000000000000..8f2609d0507854c4ba0fc0c3dff66a1f7ef39d0c GIT binary patch literal 324 zcmV-K0lWT*P)L_rjX@!ztIjR*=fTo7uZczVc+wH~%wd_;ZvBo*%$I%ILu`#(x_i z!#tkw(N5DCX62_J#VuCwmXZy{o3F5gt{mBtFmgR5T*DSBIK_63tU;C%9t-2bAl}g* z)7)V(C1~al2bjbO_F}z+>7p_*K^>P^M|UTZ@ATpx)uwtC*Vy!PQAsj93f~7N@GQLT znbzA+vVaH72wPu`^$O0hoYz>+sqe;=M|edoCYwSZK8q%7FoF%--~|_$>s0nndwc=T WJS>nmC_}^m0000d&TOvr0s4-hti3#tV>m z3t|#xlSzh+bE5OPrzL~%n_7>)rqV>9@9r@NQ+m&3v4vG=1RV7IuU$GlFznwCC!a@g7Q#G7O zHsTEPIEaB&jAcM#jpGx~Sd$#18vj>s4L6dj*JuNXH5n2qYIF7C$6+dfvyM_l@;H2D c_;ri^0K1PihY^F*_y7O^07*qoM6N<$f(+rKU;qFB literal 0 HcmV?d00001 diff --git a/src/calls/CometChatCallLogs/style.ts b/src/calls/CometChatCallLogs/style.ts new file mode 100644 index 0000000..d888763 --- /dev/null +++ b/src/calls/CometChatCallLogs/style.ts @@ -0,0 +1,24 @@ +import { StyleSheet } from "react-native"; + +export const Style = StyleSheet.create({ + container: { + flex: 1, + justifyContent: "center", + alignItems: "center", + }, + headerStyle : { + alignItems: "center", + justifyContent: "space-between", + paddingEnd: 8, + paddingStart: 8 + }, + row: { + flexDirection: "row", + alignItems: "center", + }, + imageStyle: { + height: 24, + width: 24, + alignSelf: "center", + } +}); \ No newline at end of file diff --git a/src/calls/CometChatCallLogsWithDetails/CallLogsWithDetailsConfiguration.ts b/src/calls/CometChatCallLogsWithDetails/CallLogsWithDetailsConfiguration.ts new file mode 100644 index 0000000..82791b0 --- /dev/null +++ b/src/calls/CometChatCallLogsWithDetails/CallLogsWithDetailsConfiguration.ts @@ -0,0 +1,9 @@ +import { CometChat } from '@cometchat/chat-sdk-react-native' +import { CallLogDetailsConfigurationInterface } from "../CometChatCallLogDetails"; +import { CallLogsConfigurationInterface } from "../CometChatCallLogs/CallLogsConfiguration"; + +export interface CallLogsWithDetailsConfigurationInterface { + onError?: (e: CometChat.CometChatException) => void, + CallLogsConfiguration?: CallLogsConfigurationInterface, + callLogDetailsConfiguration?: CallLogDetailsConfigurationInterface, +} \ No newline at end of file diff --git a/src/calls/CometChatCallHistoryWithDetails/CometChatCallHistoryWithDetails.tsx b/src/calls/CometChatCallLogsWithDetails/CometChatCallLogsWithDetails.tsx similarity index 54% rename from src/calls/CometChatCallHistoryWithDetails/CometChatCallHistoryWithDetails.tsx rename to src/calls/CometChatCallLogsWithDetails/CometChatCallLogsWithDetails.tsx index ec94603..c201372 100644 --- a/src/calls/CometChatCallHistoryWithDetails/CometChatCallHistoryWithDetails.tsx +++ b/src/calls/CometChatCallLogsWithDetails/CometChatCallLogsWithDetails.tsx @@ -1,25 +1,26 @@ import React, { useState, useRef, useContext } from 'react' import { View } from 'react-native' import { CometChat } from '@cometchat/chat-sdk-react-native' -import { CallHistoryConfigurationInterface } from '../CometChatCallHistory/CallHistoryConfiguration' -// import { CometChatCallHistory } from '../CometChatCallHistory/CometChatCallHistory' -import { CallDetailsConfigurationInterface } from '../CometChatCallDetails' +import { CometChatCallLogs } from '../CometChatCallLogs/CometChatCallLogs' import { Style } from './style' import { CometChatContext } from '../../shared' +import { CometChatCallLogDetails } from '../CometChatCallLogDetails/CometChatCallLogDetails' +import { CallLogsConfigurationInterface } from '../CometChatCallLogs/CallLogsConfiguration' +import { CallLogDetailsConfigurationInterface } from '../CometChatCallLogDetails' -interface CometChatCallHistoryWithDetailsInterface { - call?: CometChat.Call, +interface CometChatCallLogsWithDetailsConfigurationInterface { + call?: any, onError?: (e: CometChat.CometChatException) => void, - callHistoryConfiguration?: CallHistoryConfigurationInterface, - callDetailsConfiguration?: CallDetailsConfigurationInterface, + CallLogsConfiguration?: CallLogsConfigurationInterface, + callLogDetailsConfiguration?: CallLogDetailsConfigurationInterface, } -const CometChatCallHistoryWithDetails = (props: CometChatCallHistoryWithDetailsInterface) => { +export const CometChatCallLogsWithDetails = (props: CometChatCallLogsWithDetailsConfigurationInterface) => { const { call, - callDetailsConfiguration, - callHistoryConfiguration, + callLogDetailsConfiguration, + CallLogsConfiguration, onError } = props; @@ -30,23 +31,23 @@ const CometChatCallHistoryWithDetails = (props: CometChatCallHistoryWithDetailsI return ( - {/* { selectedCall.current = call as CometChat.Call; setShowDetails(true) }} onError={onError} - {...callHistoryConfiguration} - /> */} + {...CallLogsConfiguration} + /> { showDetails && - {/* setShowDetails(false)} - {...callDetailsConfiguration} - /> */} + {...callLogDetailsConfiguration} + /> } diff --git a/src/calls/CometChatCallLogsWithDetails/index.ts b/src/calls/CometChatCallLogsWithDetails/index.ts new file mode 100644 index 0000000..e72ebd6 --- /dev/null +++ b/src/calls/CometChatCallLogsWithDetails/index.ts @@ -0,0 +1,7 @@ +import { CallLogsWithDetailsConfigurationInterface } from "./CallLogsWithDetailsConfiguration"; +import { CometChatCallLogsWithDetails } from "./CometChatCallLogsWithDetails"; + +export { + CallLogsWithDetailsConfigurationInterface, + CometChatCallLogsWithDetails, +} \ No newline at end of file diff --git a/src/calls/CometChatCallHistoryWithDetails/style.ts b/src/calls/CometChatCallLogsWithDetails/style.ts similarity index 100% rename from src/calls/CometChatCallHistoryWithDetails/style.ts rename to src/calls/CometChatCallLogsWithDetails/style.ts diff --git a/src/calls/index.ts b/src/calls/index.ts index 1ad6e47..69df0d1 100644 --- a/src/calls/index.ts +++ b/src/calls/index.ts @@ -20,6 +20,13 @@ import { import { CallingPackage } from "./CallingPackage"; import { CallUIEvents } from "./CallEvents"; +import { CallLogsWithDetailsConfigurationInterface, CometChatCallLogsWithDetails } from './CometChatCallLogsWithDetails' +import { CallLogsConfiguration, CallLogsConfigurationInterface, CallLogsStyle, CallLogsStyleInterface, CometChatCallLogs, CometChatCallLogsConfigurationInterface } from './CometChatCallLogs' +import { CometChatCallLogDetails, CometChatCallLogDetailsConfigurationInterface, CallLogDetailsConfiguration, CallLogDetailsConfigurationInterface, CallLogDetailsStyle, CallLogDetailsStyleInterface } from './CometChatCallLogDetails' +import { CallLogHistoryConfiguration, CallLogHistoryConfigurationInterface, CallLogHistoryStyle, CallLogHistoryStyleInterface, CometChatCallLogHistory, CometChatCallLogHistoryInterface } from './CometChatCallLogHistory' +import { CallLogParticipantsConfiguration, CallLogParticipantsConfigurationInterface, CallParticipantsStyle, CallParticipantsStyleInterface, CometChatCallLogParticipantsConfigurationInterface, CometChatParticipants } from './CometChatCallLogParticipants' +import { CallLogRecordingsConfiguration, CallLogRecordingsConfigurationInterface, CallRecordingsStyle, CallRecordingsStyleInterface, CometChatCallLogRecordingsConfigurationInterface, CometChatRecordings } from './CometChatCallLogRecordings' + export { CallUIEvents, CallingPackage, @@ -35,5 +42,37 @@ export { CometChatIncomingCall, CometChatOngoingCall, CometChatOutgoingCall, - CometChatCallBubble + CometChatCallBubble, + CometChatCallLogsWithDetails, + CallLogsWithDetailsConfigurationInterface, + CometChatCallLogs, + CallLogsConfiguration, + CallLogsConfigurationInterface, + CallLogsStyle, + CallLogsStyleInterface, + CometChatCallLogsConfigurationInterface, + CometChatCallLogDetails, + CometChatCallLogDetailsConfigurationInterface, + CallLogDetailsConfiguration, + CallLogDetailsConfigurationInterface, + CallLogDetailsStyle, + CallLogDetailsStyleInterface, + CometChatCallLogHistory, + CallLogHistoryConfiguration, + CallLogHistoryConfigurationInterface, + CallLogHistoryStyle, + CallLogHistoryStyleInterface, + CometChatCallLogHistoryInterface, + CometChatParticipants, + CallLogParticipantsConfiguration, + CallLogParticipantsConfigurationInterface, + CallParticipantsStyle, + CallParticipantsStyleInterface, + CometChatCallLogParticipantsConfigurationInterface, + CometChatRecordings, + CallLogRecordingsConfiguration, + CallLogRecordingsConfigurationInterface, + CallRecordingsStyle, + CallRecordingsStyleInterface, + CometChatCallLogRecordingsConfigurationInterface } \ No newline at end of file diff --git a/src/calls/resources/index.ts b/src/calls/resources/index.ts index d36e72b..d6698f3 100644 --- a/src/calls/resources/index.ts +++ b/src/calls/resources/index.ts @@ -1,7 +1,9 @@ import AudioIcon from "./Call.png"; import VideoIcon from "./Video.png"; +import NextArrowIcon from "./nextarrow.png"; export { AudioIcon, - VideoIcon + VideoIcon, + NextArrowIcon } \ No newline at end of file diff --git a/src/calls/resources/nextarrow.png b/src/calls/resources/nextarrow.png new file mode 100644 index 0000000000000000000000000000000000000000..e4093f5681a533e5d7afe59dcafb0340ebb24b02 GIT binary patch literal 227 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0y_Rh}-6Ar*{sFIn?3DGIP9$f<1z zYf$|tu}#ivZ`)e&PfTIk%&v(9`807_s7(6dkobK)+lk{UJacT4*T!-vmIa;SX1L>_ zyhcP*b-@(Ao{hbRX*Zkph}`?V``Ry&7t8U7xvMPrzCK*?j4}Gp^^oJ{THt z*lT5SU3<~F6Gtw@vsbQDY|-t@Jg~0%`JJtt(JQ#BFNnW!%`f0NHFGM{bCcusTpfJ6 bQ$91SsF?F_ad;y?(A5l{u6{1-oD!M {}, - () => {} - ); + CometChatUIKit.sendTextMessage(textMessage) + .then(() => {}) + .catch(() => {}) }; onCloseRepliesPannel = () => { diff --git a/src/extensions/Stickers/StickersExtensionDecorator.tsx b/src/extensions/Stickers/StickersExtensionDecorator.tsx index 3430e3f..057509a 100644 --- a/src/extensions/Stickers/StickersExtensionDecorator.tsx +++ b/src/extensions/Stickers/StickersExtensionDecorator.tsx @@ -86,7 +86,7 @@ export class StickersExtensionDecorator extends DataSourceDecorator { customMessage.setMuid(new Date().getTime().toString()); customMessage.setSender(loggedInUser.current); customMessage.setReceiver(user || group); - CometChatUIKit.sendCustomMessage(customMessage,null, null); + CometChatUIKit.sendCustomMessage(customMessage).then((res) => null).catch(err => null); } let views:JSX.Element[] = super.getAuxiliaryOptions(user,group,id) diff --git a/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx b/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx index 2b08880..2f3ddab 100644 --- a/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +++ b/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx @@ -14,6 +14,7 @@ import { import React from 'react'; import { CometChatTheme } from '../../shared/resources/CometChatTheme'; import { ThumbnailGenerationConfigurationInterface } from './ThumbnailGenerationExtension'; +import { Empty } from './resources'; export class ThumbnailGenerationExtensionDecorator extends DataSourceDecorator { thumbnailGenerationConfiguration?: ThumbnailGenerationConfigurationInterface; @@ -41,16 +42,17 @@ export class ThumbnailGenerationExtensionDecorator extends DataSourceDecorator { ExtensionConstants.thumbnailGeneration ); if (thumbnailData == undefined) { - image = { uri: message?.data?.url }; + image = message.getType() === "image" ? message?.data?.url : Empty; //default image for type video } else { let attachmentData = thumbnailData['attachments']; if (attachmentData.length == 1) { let dataObj = attachmentData[0]; if (!dataObj['error']) { - image = { uri: dataObj['data']['thumbnails']['url_small'] }; + let imageLink = dataObj?.['data']?.['thumbnails']?.['url_small']; + image = imageLink ? { uri: dataObj['data']['thumbnails']['url_small'] } : Empty; //if imageLink is empty or does not exist then load default image } else { - image = { uri: null }; + image = Empty; //default image } } } diff --git a/src/extensions/ThumbnailGeneration/resources/empty.png b/src/extensions/ThumbnailGeneration/resources/empty.png new file mode 100644 index 0000000000000000000000000000000000000000..e3f2fde5f9ccd44cec46ed4538dec89de33b05cb GIT binary patch literal 70 zcmeAS@N?(olHy`uVBq!ia0vp^j3CSbBp9sfW`_bPUQZXtkcwN3Obmbj1G!8LjKSJ- Q3_uDzUHx3vIVCg!0Fg-zPXGV_ literal 0 HcmV?d00001 diff --git a/src/extensions/ThumbnailGeneration/resources/index.ts b/src/extensions/ThumbnailGeneration/resources/index.ts new file mode 100644 index 0000000..52f59e2 --- /dev/null +++ b/src/extensions/ThumbnailGeneration/resources/index.ts @@ -0,0 +1,5 @@ +import Empty from './empty.png'; + +export { + Empty +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 2668378..8bff960 100644 --- a/src/index.ts +++ b/src/index.ts @@ -295,6 +295,38 @@ import { CometChatOutgoingCall, CometChatCallBubble, CallingExtensionDecorator, + CometChatCallLogsWithDetails, + CallLogsWithDetailsConfigurationInterface, + CometChatCallLogs, + CallLogsConfiguration, + CallLogsConfigurationInterface, + CallLogsStyle, + CallLogsStyleInterface, + CometChatCallLogsConfigurationInterface, + CometChatCallLogDetails, + CometChatCallLogDetailsConfigurationInterface, + CallLogDetailsConfiguration, + CallLogDetailsConfigurationInterface, + CallLogDetailsStyle, + CallLogDetailsStyleInterface, + CometChatCallLogHistory, + CallLogHistoryConfiguration, + CallLogHistoryConfigurationInterface, + CallLogHistoryStyle, + CallLogHistoryStyleInterface, + CometChatCallLogHistoryInterface, + CometChatParticipants, + CallLogParticipantsConfiguration, + CallLogParticipantsConfigurationInterface, + CallParticipantsStyle, + CallParticipantsStyleInterface, + CometChatCallLogParticipantsConfigurationInterface, + CometChatRecordings, + CallLogRecordingsConfiguration, + CallLogRecordingsConfigurationInterface, + CallRecordingsStyle, + CallRecordingsStyleInterface, + CometChatCallLogRecordingsConfigurationInterface } from "./calls"; import { @@ -599,7 +631,43 @@ export { RadioButtonElement, SingleSelectElement, TextInputElement, - URLNavigationAction + URLNavigationAction, + + /*Call Logs */ + CometChatCallLogsWithDetails, + CallLogsWithDetailsConfigurationInterface, + CometChatCallLogs, + CallLogsConfiguration, + CallLogsConfigurationInterface, + CallLogsStyle, + CallLogsStyleInterface, + CometChatCallLogsConfigurationInterface, + CometChatCallLogDetails, + CometChatCallLogDetailsConfigurationInterface, + CallLogDetailsConfiguration, + CallLogDetailsConfigurationInterface, + CallLogDetailsStyle, + CallLogDetailsStyleInterface, + CometChatCallLogHistory, + CallLogHistoryConfiguration, + CallLogHistoryConfigurationInterface, + CallLogHistoryStyle, + CallLogHistoryStyleInterface, + CometChatCallLogHistoryInterface, + CometChatParticipants, + CallLogParticipantsConfiguration, + CallLogParticipantsConfigurationInterface, + CallParticipantsStyle, + CallParticipantsStyleInterface, + CometChatCallLogParticipantsConfigurationInterface, + CometChatRecordings, + CallLogRecordingsConfiguration, + CallLogRecordingsConfigurationInterface, + CallRecordingsStyle, + CallRecordingsStyleInterface, + CometChatCallLogRecordingsConfigurationInterface + /*Call Logs */ + }; // AI @@ -607,12 +675,19 @@ export { AIConversationStarterExtension } from './AI/AIConversationStarter/AICon export { AIConversationStarterDecorator } from './AI/AIConversationStarter/AIConversationStarterDecorator' export { AIConversationStarterStyle } from './AI/AIConversationStarter/AIConversationStarterStyle' export { AIConversationStarterConfiguration } from './AI/AIConversationStarter/configuration' -export { AIEnabler } from './AI/AIEnabler' -export { AIEnablerDecorator } from './AI/AIEnablerDecorator' export { AIExtensionDataSource } from './AI/AIExtensionDataSource' export { AISmartRepliesExtension } from './AI/AISmartReplies/AISmartReplies' export { AISmartRepliesExtensionDecorator } from './AI/AISmartReplies/AISmartRepliesDecorator' export { AISmartRepliesStyle } from './AI/AISmartReplies/AISmartRepliesStyle' export { AISmartRepliesConfiguration } from './AI/AISmartReplies/configuration' export { CardStyle, CardViewStyle } from './AI/CardViewStyle' -export { AIEnablerConfiguration } from './AI/configuration' \ No newline at end of file +export { AIBaseConfiguration } from './AI/AIBaseConfiguration' +export { AIAssistBotConfiguration } from './AI/AIAssistBot/configuration' +export { AIAssistBotDecorator } from './AI/AIAssistBot/AIAssistBotDecorator' +export { AIAssistBotExtension } from './AI/AIAssistBot/AIAssistBotExtension' +export { AIAssistBotStyle, AIBotMessageBubbleStyle, AISenderMessageBubbleStyle } from './AI/AIAssistBot/AIAssistBotStyle' +export { AIConversationSummaryDecorator } from './AI/AIConversationSummary/AIConversationSummaryDecorator' +export { AIConversationSummaryExtension } from './AI/AIConversationSummary/AIConversationSummaryExtension' +export { AIConversationSummaryStyle } from './AI/AIConversationSummary/AIConversationSummaryStyle' +export { AIConversationSummaryConfiguration } from './AI/AIConversationSummary/configuration' +export { AIBaseStyle } from './AI/AIBaseStyle' diff --git a/src/shared/CometChatUiKit/CometChatUIKit.ts b/src/shared/CometChatUiKit/CometChatUIKit.ts index b2836dd..34d8940 100644 --- a/src/shared/CometChatUiKit/CometChatUIKit.ts +++ b/src/shared/CometChatUiKit/CometChatUIKit.ts @@ -21,12 +21,15 @@ import { CometChatSoundManager } from "../utils"; import { CometChatLocalize } from "../resources"; import { CardMessage, CustomInteractiveMessage, FormMessage } from "../modals/InteractiveData"; import { ListenerInitializer } from "../events/ListenerInitializer"; -import { AIEnabler } from "../../AI/AIEnabler"; import { AIConversationStarterExtension } from "../../AI/AIConversationStarter/AIConversationStarter"; +import { AIExtensionDataSource } from "../../AI/AIExtensionDataSource"; +import { AISmartRepliesExtension } from "../../AI/AISmartReplies/AISmartReplies"; +import { AIConversationSummaryExtension } from "../../AI/AIConversationSummary/AIConversationSummaryExtension"; +import { AIAssistBotExtension } from "../../AI/AIAssistBot/AIAssistBotExtension"; export class CometChatUIKit { static uiKitSettings: UIKitSettings; - static aiFeatures: AIEnabler + static aiFeatures:AIExtensionDataSource[] static init(uiKitSettings: UIKitSettings): Promise { //perform sdk init taking values from uiKitSettings @@ -40,8 +43,6 @@ export class CometChatUIKit { .overrideAdminHost(uiKitSettings?.overrideAdminHost) .overrideClientHost(uiKitSettings?.overrideClientHost) .setRegion(uiKitSettings.region) - .overrideAdminHost(uiKitSettings.overrideAdminHost) - .overrideClientHost(uiKitSettings.overrideClientHost) appSetting.subscriptionType = uiKitSettings.subscriptionType; @@ -68,6 +69,13 @@ export class CometChatUIKit { new PollsExtension(), new ReactionsExtension(), new ImageModerationExtension() + ] + + static defaultAIFeatures: AIExtensionDataSource[] = [ + new AISmartRepliesExtension(), + new AIConversationStarterExtension(), + new AIConversationSummaryExtension(), + new AIAssistBotExtension() ] private static enableExtensions() { @@ -78,18 +86,18 @@ export class CometChatUIKit { new CallingExtension().enable(); } let extensionList: ExtensionsDataSource[] = this.uiKitSettings?.extensions || this.defaultExtensions; + let aiFeaturesList: AIExtensionDataSource[] = this.uiKitSettings?.aiFeatures || this.defaultAIFeatures; - if (extensionList.length > 0) { - extensionList.forEach((extension: ExtensionsDataSource) => { - extension?.enable(); - }); - } - if (this.uiKitSettings.aiFeatures) { - this.uiKitSettings.aiFeatures?.enable() - } - else { - new AIEnabler().enable() - } + if (extensionList.length > 0) { + extensionList.forEach((extension: ExtensionsDataSource) => { + extension?.enable(); + }); + } + if(aiFeaturesList.length > 0){ + aiFeaturesList.forEach((aiFeatures: AIExtensionDataSource) => { + aiFeatures.enable(); + }) + } } @@ -166,68 +174,75 @@ export class CometChatUIKit { //---------- Helper methods to send messages ---------- ///[sendCustomMessage] used to send a custom message - static sendCustomMessage(message: CometChat.CustomMessage, onSuccess?: (msg: CometChat.CustomMessage | CometChat.BaseMessage) => void, onError?: (msg: CometChat.CometChatException) => void): void { - CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress); - CometChat.sendCustomMessage(message) - .then(customMessage => { - CometChatUIKitHelper.onMessageSent(customMessage, messageStatus.success); - onSuccess && onSuccess(customMessage); - }) - .catch(err => { - CometChatUIKitHelper.onMessageSent(message, messageStatus.error); - onError && onError(err); - }) + static sendCustomMessage(message: CometChat.CustomMessage): Promise { + return new Promise((resolve, reject) => { + CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress); + CometChat.sendCustomMessage(message) + .then(customMessage => { + CometChatUIKitHelper.onMessageSent(customMessage, messageStatus.success); + resolve(customMessage); + }) + .catch(err => { + CometChatUIKitHelper.onMessageSent(message, messageStatus.error); + reject(err); + }); + }); } ///[sendMediaMessage] used to send a media message - static sendMediaMessage(message: CometChat.MediaMessage, onSuccess?: (msg: CometChat.MediaMessage | CometChat.BaseMessage) => void, onError?: (msg: CometChat.CometChatException) => void): void { - let hasAttachment; - try { - hasAttachment = message.getAttachment(); - } catch (error) { - console.log("no attachment found"); - } - if (hasAttachment == undefined) { - let file = message['files'][0]; - if (file == undefined) { - onError && onError(new CometChat.CometChatException({ - code: "Invalid Media message object", - message: "file object not found." - })) + static sendMediaMessage(message: CometChat.MediaMessage): Promise { + return new Promise((resolve, reject) => { + let hasAttachment; + try { + hasAttachment = message.getAttachment(); + } catch (error) { + console.log("no attachment found"); + } + if (hasAttachment == undefined) { + let file = message['files'][0]; + if (file == undefined) { + reject(new CometChat.CometChatException({ + code: "Invalid Media message object", + message: "file object not found." + })); + } + + let attachmentObject: CometChat.Attachment = new CometChat.Attachment(file); + attachmentObject.setName(file['name']); + attachmentObject.setExtension((file['name'].lastIndexOf('.') + 1).toString()); + attachmentObject.setMimeType(file['type']); + attachmentObject.setSize(0); + attachmentObject.setUrl(file['uri']); + message.setAttachment(attachmentObject); } - let attachmentObject: CometChat.Attachment = new CometChat.Attachment(file); - attachmentObject.setName(file['name']); - attachmentObject.setExtension((file['name'].lastIndexOf('.') + 1).toString()); - attachmentObject.setMimeType(file['type']); - attachmentObject.setSize(0); - attachmentObject.setUrl(file['uri']); - message.setAttachment(attachmentObject); - } - CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress); - CometChat.sendMediaMessage(message) - .then(mediaMessage => { - CometChatUIKitHelper.onMessageSent(mediaMessage, messageStatus.success); - onSuccess && onSuccess(mediaMessage); - }) - .catch(err => { - CometChatUIKitHelper.onMessageSent(message, messageStatus.error); - onError && onError(err); - }) + CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress); + CometChat.sendMediaMessage(message) + .then(mediaMessage => { + CometChatUIKitHelper.onMessageSent(mediaMessage, messageStatus.success); + resolve(mediaMessage); + }) + .catch(err => { + CometChatUIKitHelper.onMessageSent(message, messageStatus.error); + reject(err); + }); + }); } ///[sendTextMessage] used to send a text message - static sendTextMessage(message: CometChat.TextMessage, onSuccess?: (msg: CometChat.TextMessage | CometChat.BaseMessage) => void, onError?: (msg: CometChat.CometChatException) => void): void { - CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress); - CometChat.sendMessage(message) - .then(textMessage => { - CometChatUIKitHelper.onMessageSent(textMessage, messageStatus.success); - onSuccess && onSuccess(textMessage); - }) - .catch(err => { - CometChatUIKitHelper.onMessageSent(message, messageStatus.error); - onError && onError(err); - }) + static sendTextMessage(message: CometChat.TextMessage): Promise { + return new Promise((resolve, reject) => { + CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress); + CometChat.sendMessage(message) + .then(textMessage => { + CometChatUIKitHelper.onMessageSent(textMessage, messageStatus.success); + resolve(textMessage); + }) + .catch(err => { + CometChatUIKitHelper.onMessageSent(message, messageStatus.error); + reject(err); + }); + }); } /** @@ -235,26 +250,29 @@ export class CometChatUIKit { * @param message - The FormMessage message to be sent. * @param disableLocalEvents - A boolean indicating whether to disable local events or not. Default value is false. */ - static sendFormMessage(message: FormMessage, disableLocalEvents: boolean = false, onSuccess?: (msg: CometChat.TextMessage | CometChat.BaseMessage) => void, onError?: (msg: CometChat.CometChatException) => void) { - if (!disableLocalEvents) { - CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress); - } - CometChat.sendInteractiveMessage(message) - .then((message: CometChat.BaseMessage) => { - console.log("message sent successfully", message.getSentAt()) - if (!disableLocalEvents) { - CometChatUIKitHelper.onMessageSent(message, messageStatus.success); - } - onSuccess && onSuccess(message); - }) - .catch((error: CometChat.CometChatException) => { - console.log("error while sending message", { error }) - message.setMetadata({ error }); - // if (!disableLocalEvents) { - // CometChatUIKitHelper.onMessageSent(message, messageStatus.error); - // } - onError && onError(error); - }); + static sendFormMessage(message: FormMessage, disableLocalEvents: boolean = false): Promise { + return new Promise((resolve, reject) => { + if (!disableLocalEvents) { + CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress); + } + + CometChat.sendInteractiveMessage(message) + .then((message: CometChat.BaseMessage) => { + console.log("message sent successfully", message.getSentAt()) + if (!disableLocalEvents) { + CometChatUIKitHelper.onMessageSent(message, messageStatus.success); + } + resolve(message); + }) + .catch((error: CometChat.CometChatException) => { + console.log("error while sending message", { error }) + message.setMetadata({ error }); + // if (!disableLocalEvents) { + // CometChatUIKitHelper.onMessageSent(message, messageStatus.error); + // } + reject(error); + }); + }); } /** @@ -262,27 +280,30 @@ export class CometChatUIKit { * @param message - The Card message to be sent. * @param disableLocalEvents - A boolean indicating whether to disable local events or not. Default value is false. */ - static sendCardMessage(message: CardMessage, disableLocalEvents: boolean = false, onSuccess?: (msg: CometChat.TextMessage | CometChat.BaseMessage) => void, onError?: (msg: CometChat.CometChatException) => void) { - if (!disableLocalEvents) { - CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress); - } - console.log("message", JSON.stringify(message)) - CometChat.sendInteractiveMessage(message) - .then((message: CometChat.BaseMessage) => { - console.log("message sent successfully", message.getSentAt()) - if (!disableLocalEvents) { - CometChatUIKitHelper.onMessageSent(message, messageStatus.success); - } - onSuccess && onSuccess(message); - }) - .catch((error: CometChat.CometChatException) => { - console.log("error while sending message", { error }) - message.setMetadata({ error }); - // if (!disableLocalEvents) { - // CometChatUIKitHelper.onMessageSent(message, messageStatus.error); - // } - onError && onError(error); - }); + static sendCardMessage(message: CardMessage, disableLocalEvents: boolean = false): Promise { + return new Promise((resolve, reject) => { + if (!disableLocalEvents) { + CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress); + } + console.log("message", JSON.stringify(message)); + + CometChat.sendInteractiveMessage(message) + .then((message: CometChat.BaseMessage) => { + console.log("message sent successfully", message.getSentAt()) + if (!disableLocalEvents) { + CometChatUIKitHelper.onMessageSent(message, messageStatus.success); + } + resolve(message); + }) + .catch((error: CometChat.CometChatException) => { + console.log("error while sending message", { error }) + message.setMetadata({ error }); + // if (!disableLocalEvents) { + // CometChatUIKitHelper.onMessageSent(message, messageStatus.error); + // } + reject(error); + }); + }); } /** @@ -290,26 +311,29 @@ export class CometChatUIKit { * @param message - The Custom Interactive message to be sent. * @param disableLocalEvents - A boolean indicating whether to disable local events or not. Default value is false. */ - static sendCustomInteractiveMessage(message: CustomInteractiveMessage, disableLocalEvents: boolean = false, onSuccess?: (msg: CometChat.TextMessage | CometChat.BaseMessage) => void, onError?: (msg: CometChat.CometChatException) => void) { - if (!disableLocalEvents) { - CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress); - } - CometChat.sendInteractiveMessage(message) - .then((message: CometChat.BaseMessage) => { - console.log("message sent successfully", message.getSentAt()) - if (!disableLocalEvents) { - CometChatUIKitHelper.onMessageSent(message, messageStatus.success); - } - onSuccess && onSuccess(message); - }) - .catch((error: CometChat.CometChatException) => { - console.log("error while sending message", { error }) - message.setMetadata({ error }); - // if (!disableLocalEvents) { - // CometChatUIKitHelper.onMessageSent(message, messageStatus.error); - // } - onError && onError(error); - }); + static sendCustomInteractiveMessage(message: CustomInteractiveMessage, disableLocalEvents: boolean = false): Promise { + return new Promise((resolve, reject) => { + if (!disableLocalEvents) { + CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress); + } + + CometChat.sendInteractiveMessage(message) + .then((message: CometChat.BaseMessage) => { + console.log("message sent successfully", message.getSentAt()) + if (!disableLocalEvents) { + CometChatUIKitHelper.onMessageSent(message, messageStatus.success); + } + resolve(message); + }) + .catch((error: CometChat.CometChatException) => { + console.log("error while sending message", { error }) + message.setMetadata({ error }); + // if (!disableLocalEvents) { + // CometChatUIKitHelper.onMessageSent(message, messageStatus.error); + // } + reject(error); + }); + }); } static getDataSource() { diff --git a/src/shared/CometChatUiKit/UIKitSettings.ts b/src/shared/CometChatUiKit/UIKitSettings.ts index 77ea453..2ce416e 100644 --- a/src/shared/CometChatUiKit/UIKitSettings.ts +++ b/src/shared/CometChatUiKit/UIKitSettings.ts @@ -1,4 +1,4 @@ -import { AIEnabler } from "../../AI/AIEnabler" +import { AIExtensionDataSource } from "../../AI/AIExtensionDataSource" import { ExtensionsDataSource } from "../framework" export type UIKitSettings = { @@ -12,7 +12,7 @@ export type UIKitSettings = { deviceToken?: string, googleApiKey?: string, disableCalling?: boolean, - aiFeatures?:AIEnabler, + aiFeatures?:AIExtensionDataSource[], extensions?:ExtensionsDataSource[] } diff --git a/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts b/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts index 8e4312f..4c063d6 100644 --- a/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +++ b/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts @@ -10,7 +10,7 @@ import { PanelListener, UserListener, UserUIEventListener, - UIEventListener, + UIEventListener, UIListener } from "./Listener"; diff --git a/src/shared/framework/DataSource.ts b/src/shared/framework/DataSource.ts index ba7e00b..d91ba56 100644 --- a/src/shared/framework/DataSource.ts +++ b/src/shared/framework/DataSource.ts @@ -8,6 +8,8 @@ import { AudioBubbleStyleInterface } from "../views/CometChatAudioBubble"; import { FileBubbleStyleInterface } from "../views/CometChatFileBubble"; import { ImageBubbleStyleInterface } from "../views/CometChatImageBubble"; import { VideoBubbleStyleInterface } from "../views/CometChatVideoBubble"; +import { CometChatMessageComposerActionInterface } from "../helper/types"; +import { AIOptionsStyle } from "../../AI/AIOptionsStyle"; import { CardMessage, FormMessage } from "../modals/InteractiveData"; import { FormBubbleStyle } from "../views/CometChatFormBubble/FormBubbleStyle"; import { CardBubbleStyle } from "../views/CometChatCardBubble/CardBubbleStyle"; @@ -80,4 +82,6 @@ export interface DataSource { getLastConversationMessage(conversation : CometChat.Conversation): string getAuxiliaryHeaderAppbarOptions(user?: CometChat.User, group?: CometChat.Group, theme?: CometChatTheme): JSX.Element + + getAIOptions(user: CometChat.User | null, group: CometChat.Group | null, theme: CometChatTheme, id?: Map, AIOptionsStyle?: AIOptionsStyle): Array<(CometChatMessageComposerActionInterface | CometChatMessageOption)> } \ No newline at end of file diff --git a/src/shared/framework/DataSourceDecorator.tsx b/src/shared/framework/DataSourceDecorator.tsx index 61f244d..cb3a375 100644 --- a/src/shared/framework/DataSourceDecorator.tsx +++ b/src/shared/framework/DataSourceDecorator.tsx @@ -1,3 +1,4 @@ +import { AIOptionsStyle } from "../../AI/AIOptionsStyle"; import { MessageBubbleAlignmentType } from "../constants/UIKitConstants"; import { CometChatMessageComposerActionInterface } from "../helper/types"; import { CometChatMessageOption, CometChatMessageTemplate } from "../modals"; @@ -196,4 +197,8 @@ export class DataSourceDecorator implements DataSource { getAuxiliaryHeaderAppbarOptions(user?: CometChat.User, group?: CometChat.Group, theme?: CometChatTheme) { return this.dataSource.getAuxiliaryHeaderAppbarOptions(user, group, theme); } + + getAIOptions(user: CometChat.User | null, group: CometChat.Group | null, theme: CometChatTheme, id?: Map, AIOptionsStyle?: AIOptionsStyle): (CometChatMessageComposerActionInterface | CometChatMessageOption)[] { + return this.dataSource.getAIOptions(user, group, theme, id, AIOptionsStyle); + } } \ No newline at end of file diff --git a/src/shared/framework/MessageDataSource.tsx b/src/shared/framework/MessageDataSource.tsx index 14458d3..cb42bba 100644 --- a/src/shared/framework/MessageDataSource.tsx +++ b/src/shared/framework/MessageDataSource.tsx @@ -16,6 +16,7 @@ import { ChatConfigurator } from "./ChatConfigurator"; import { CometChatMessageComposerActionInterface } from "../helper/types"; import { ICONS } from "./resources"; import { CometChatConversationUtils } from "../utils/conversationUtils"; +import { AIOptionsStyle } from "../../AI/AIOptionsStyle"; import { CometChatFormBubble, CometChatCardBubble } from "../views"; import { CardMessage, FormMessage } from "../modals/InteractiveData"; import { FormBubbleStyle } from "../views/CometChatFormBubble/FormBubbleStyle"; @@ -692,7 +693,9 @@ export class MessageDataSource implements DataSource { return null; } - + getAIOptions(user: CometChat.User | null, group: CometChat.Group | null, theme: CometChatTheme, id?: Map, AIOptionsStyle?: AIOptionsStyle) { + return []; + } getLastConversationMessage(conversation: CometChat.Conversation): string { return CometChatConversationUtils.getMessagePreview(conversation.getLastMessage()); diff --git a/src/shared/index.ts b/src/shared/index.ts index 3514c8d..b7d99e0 100644 --- a/src/shared/index.ts +++ b/src/shared/index.ts @@ -24,6 +24,8 @@ import { CometChatMessageTemplate, CometChatDetailsTemplate, CometChatDetailsOption, + CometChatCallLogDetailsTemplate, + CometChatCallLogDetailsOption, APIAction, ActionEntity, BaseInputElement, @@ -214,6 +216,8 @@ export { CometChatMessageTemplate, CometChatDetailsTemplate, CometChatDetailsOption, + CometChatCallLogDetailsTemplate, + CometChatCallLogDetailsOption, // CometChatLocalize, localize, diff --git a/src/shared/modals/CometChatCallLogDetailsOptions.ts b/src/shared/modals/CometChatCallLogDetailsOptions.ts new file mode 100644 index 0000000..0cb8a03 --- /dev/null +++ b/src/shared/modals/CometChatCallLogDetailsOptions.ts @@ -0,0 +1,23 @@ +import { TextStyle } from 'react-native'; +import { ImageType } from '../base'; + +export interface CometChatCallLogDetailsOption { + id?: string | number; + ///[title] passes title to option + title?: string; + ///to pass icon url + icon?: ImageType; + ///[titleStyle] styling property for [title] + titleStyle?: TextStyle; + backgroundColor?: string; + iconTint?: string; + ///to pass custom view to options + CustomView?: () => JSX.Element; + /// to pass tail component for detail option + Tail?:() => JSX.Element; + ///to pass height for details + height?: number; + ///[onClick] call function which takes 3 parameter , and one of user or group is populated at a time + onClick?: (callLog: any) => void; +} + diff --git a/src/shared/modals/CometChatCallLogDetailsTemplate.ts b/src/shared/modals/CometChatCallLogDetailsTemplate.ts new file mode 100644 index 0000000..559e2ea --- /dev/null +++ b/src/shared/modals/CometChatCallLogDetailsTemplate.ts @@ -0,0 +1,16 @@ +import { TextStyle } from 'react-native'; +import { FontStyleInterface } from '../base'; +import { CometChatCallLogDetailsOption } from './CometChatCallLogDetailsOptions'; + +export interface CometChatCallLogDetailsTemplate { + id?: string | number; + title?: string; + titleColor?: string; + titleFont?: FontStyleInterface; + titleStyle?: TextStyle; + sectionSeparatorColor?: string; + itemSeparatorColor?: string; + hideSectionSeparator?: boolean; + hideItemSeparator?: boolean; + options?: CometChatCallLogDetailsOption[]; +} \ No newline at end of file diff --git a/src/shared/modals/index.ts b/src/shared/modals/index.ts index 1994200..9802602 100644 --- a/src/shared/modals/index.ts +++ b/src/shared/modals/index.ts @@ -3,6 +3,8 @@ import { CometChatOptions } from './CometChatOptions'; import { CometChatMessageTemplate } from './CometChatMessageTemplate'; import { CometChatDetailsTemplate } from './CometChatDetailsTemplate'; import { CometChatDetailsOption } from './CometChatDetailsOption'; +import { CometChatCallLogDetailsTemplate } from './CometChatCallLogDetailsTemplate'; +import { CometChatCallLogDetailsOption } from './CometChatCallLogDetailsOptions'; import { APIAction, ActionEntity, BaseInputElement, BaseInteractiveElement, ButtonElement, CardMessage, CheckboxElement, CustomAction, CustomInteractiveMessage, DropdownElement, ElementEntity, FormMessage, LabelElement, OptionElement, RadioButtonElement, SingleSelectElement, TextInputElement, URLNavigationAction } from './InteractiveData' export { @@ -28,5 +30,7 @@ export { RadioButtonElement, SingleSelectElement, TextInputElement, - URLNavigationAction + URLNavigationAction, + CometChatCallLogDetailsTemplate, + CometChatCallLogDetailsOption }; diff --git a/src/shared/resources/CometChatLocalize/resources/ar/translation.json b/src/shared/resources/CometChatLocalize/resources/ar/translation.json index 9453e06..512480e 100644 --- a/src/shared/resources/CometChatLocalize/resources/ar/translation.json +++ b/src/shared/resources/CometChatLocalize/resources/ar/translation.json @@ -18,7 +18,7 @@ "ONLINE": "عبر الإنترنت", "ADMINISTRATOR": "مدير", "MODERATOR": "مدير الجلسة", - "SUGGEST_A_REPLIES":"اقترح ردًا", + "SUGGEST_A_REPLY":"اقترح ردًا", "GENERATIONG_ICEBREAKER":"توليد كاسحات الجليد", "GENERATING_REPLIES":"توليد الردود", "PARTICIPANT": "مشارك", @@ -86,7 +86,7 @@ "UNANSWERED_AUDIO_CALL": "مكالمة صوتية لم تتم الإجابة عليها", "UNANSWERED_VIDEO_CALL": "مكالمة فيديو لم تتم الإجابة عليها", "CALL_ENDED": "انتهت المكالمة", - "CALL_CANCELLED": "تم إلغاء المكالمة", + "CANCELLED_CALL": "مكالمة ملغاة", "CALL_BUSY": "استدعاء مشغول", "CALLING": "الدعوة...", "ADD": "إضافة", @@ -149,7 +149,7 @@ "ADDED": "أضاف", "UNBANNED": "غير محظور", "MADE": "صنع", - "CALL_UNANSWERED": "اتصل دون إجابة", + "UNANSWERED_CALL": "مكالمة لم يتم الرد عليها", "MISSED_AUDIO_CALL": "مكالمة صوتية فائتة", "ENTER_YOUR_PASSWORD": "أدخل كلمة المرور", "DOCS": "مستندات", @@ -264,14 +264,28 @@ "TEXT": "النص", "INCOMING_CALL": "مكالمة واردة", "OUTGOING_CALL": "مكالمة صادرة", - "CALL_MISSED": "مكالمة فائتة", + "MISSED_CALL": "مكالمة فائتة", "NEW_CONVERSATION": "دردشة جديدة", "FORWARDING": "إرسال الرسائل..", "READ": "اقرأ", "No_RECIPIENT": "لا يوجد مستلم", "RECEIPT_INFORMATION": "معلومات الاستلام", "MESSAGE": "رسالة", + "GENERATING_SUMMARY":"ملخص التوليد", + "CONVERSATION_SUMMARY":"ملخص المحادثة", + "GENERATE_SUMMARY":"قم بإنشاء ملخص", + "COMETCHAT_BOT_FIRST_MESSAGE":"كيف يمكنني مساعدتك في هذه المحادثة؟ من فضلك اسألني سؤالاً وسأنصحك 🙂", + "COMETCHAT_ASK_BOT":"اسأل", + "COMETCHAT_ASK_AI_BOT":"اسأل روبوتات الذكاء الاصطناعي", + "COMETCHAT_ASK_BOT_SUBTITLE":"بوت الذكاء الاصطناعي", "FORM_COMPLETION_MESSAGE": "شكرًا لك على ملء النموذج.", "FORM":"نموذج", - "CARD":"بطاقة" + "CARD":"بطاقة", + "RECORDINGS":"التسجيلات", + "PARTICIPANTS":"مشاركون", + "NO_PARTICIPANTS":"لا يوجد مشاركون", + "NO_RECORDINGS":"لا توجد تسجيلات", + "CALL_LOGS":"سجلات المكالمات", + "CANCELLED_AUDIO_CALL":"مكالمة صوتية ملغاة", + "CANCELLED_VIDEO_CALL":"مكالمة فيديو ملغاة" } \ No newline at end of file diff --git a/src/shared/resources/CometChatLocalize/resources/de/translation.json b/src/shared/resources/CometChatLocalize/resources/de/translation.json index e393c57..b0c193c 100644 --- a/src/shared/resources/CometChatLocalize/resources/de/translation.json +++ b/src/shared/resources/CometChatLocalize/resources/de/translation.json @@ -22,7 +22,7 @@ "PARTICIPANT": "Teilnehmerin", "PUBLIC": "Öffentlich", "PRIVATE": "Privat", - "SUGGEST_A_REPLIES":"Schlage eine Antwort vor", + "SUGGEST_A_REPLY":"Schlage eine Antwort vor", "GENERATIONG_ICEBREAKER":"Eisbrecher erzeugen", "PASSWORD_PROTECTED": "Passwort-geschützt", "PRIVACY_AND_SECURITY": "Datenschutz und Sicherheit", @@ -86,7 +86,7 @@ "UNANSWERED_AUDIO_CALL": "Unbeantworteter Audioan", "UNANSWERED_VIDEO_CALL": "Unbeantworteter Videoan", "CALL_ENDED": "Anruf endete", - "CALL_CANCELLED": "Anruf wurde abgebrochen", + "CANCELLED_CALL": "Anruf abgesagt", "CALL_BUSY": "Anruf beschäftigt", "CALLING": "Rufen...", "ADD": "Add", @@ -149,7 +149,7 @@ "ADDED": "hinzugefügt", "UNBANNED": "unverbannt", "MADE": "hergestellt", - "CALL_UNANSWERED": "Anruf unbeantwortet", + "UNANSWERED_CALL": "Unbeantworteter Anruf", "MISSED_AUDIO_CALL": "Audioanruf verpasst", "ENTER_YOUR_PASSWORD": "Geben Sie Ihr Passwort ein", "DOCS": "docs", @@ -264,14 +264,28 @@ "TEXT": "Text", "INCOMING_CALL": "Eingehender Anruf", "OUTGOING_CALL": "Ausgehender Anruf", - "CALL_MISSED": "Verpasster Anruf", + "MISSED_CALL": "Verpasster Anruf", "NEW_CONVERSATION": "Neuer Chat", "FORWARDING": "Nachrichten werden gesendet..", "READ": "Lesen", "No_RECIPIENT": "Kein Empfänger", "RECEIPT_INFORMATION": "Informationen zum Zahlungseingang", "MESSAGE": "Nachricht", + "GENERATING_SUMMARY":"Zusammenfassung wird generiert", + "CONVERSATION_SUMMARY":"Zusammenfassung der Konversation", + "GENERATE_SUMMARY":"Generieren Sie eine Zusammenfassung", + "COMETCHAT_BOT_FIRST_MESSAGE":"Wie kann ich dir bei diesem Gespräch helfen? Bitte stell mir eine Frage und ich berate dich 🙂", + "COMETCHAT_ASK_BOT":"Frag", + "COMETCHAT_ASK_AI_BOT":"Fragen Sie KI-Bots", + "COMETCHAT_ASK_BOT_SUBTITLE":"KI-Bot", "FORM_COMPLETION_MESSAGE": "Vielen Dank für das Ausfüllen des Formulars.", "FORM":"Formular", - "CARD":"Karte" + "CARD":"Karte", + "RECORDINGS":"Aufzeichnungen", + "PARTICIPANTS":"Teilnehmer", + "NO_PARTICIPANTS":"Keine Teilnehmer", + "NO_RECORDINGS":"Keine Aufzeichnungen", + "CALL_LOGS":"Anruflisten", + "CANCELLED_AUDIO_CALL":"Abgebrochener Audioanruf", + "CANCELLED_VIDEO_CALL":"Videoanruf abgesagt" } \ No newline at end of file diff --git a/src/shared/resources/CometChatLocalize/resources/en/translation.json b/src/shared/resources/CometChatLocalize/resources/en/translation.json index b905010..b4571db 100644 --- a/src/shared/resources/CometChatLocalize/resources/en/translation.json +++ b/src/shared/resources/CometChatLocalize/resources/en/translation.json @@ -18,8 +18,8 @@ "ADMINISTRATOR": "Administrator", "MODERATOR": "Moderator", "PARTICIPANT": "Participant", - "SUGGEST_A_REPLIES" : "Suggest a reply", -"GENERATIONG_ICEBREAKER" : "Generating icebreakers", + "SUGGEST_A_REPLY" : "Suggest a reply", + "GENERATIONG_ICEBREAKER" : "Generating icebreakers", "PUBLIC": "Public", "NO_REPLIES_FOUND":"No Replies Found", "PRIVATE": "Private", @@ -78,14 +78,14 @@ "OUTGOING_AUDIO_CALL": "Outgoing audio call", "OUTGOING_VIDEO_CALL": "Outgoing video call", "CALL_REJECTED": "Call rejected", - "REJECTED_CALL": "rejected call", + "REJECTED_CALL": "Rejected call", "CALL_ACCEPTED": "Call accepted", "JOINED": "joined", "LEFT_THE_CALL": "left the call", "UNANSWERED_AUDIO_CALL": "Unanswered audio call", "UNANSWERED_VIDEO_CALL": "Unanswered video call", "CALL_ENDED": "Call ended", - "CALL_CANCELLED": "Call cancelled", + "CANCELLED_CALL": "Cancelled call", "CALL_BUSY": "Call busy", "CALLING": "Calling...", "ADD": "Add", @@ -148,7 +148,7 @@ "ADDED": "added", "UNBANNED": "unbanned", "MADE": "made", - "CALL_UNANSWERED": "Call unanswered", + "UNANSWERED_CALL": "Unanswered call", "MISSED_AUDIO_CALL": "Missed audio call", "ENTER_YOUR_PASSWORD": "Enter your password", "DOCS": "Docs", @@ -260,7 +260,7 @@ "TEXT": "Text", "INCOMING_CALL": "Incoming call", "OUTGOING_CALL": "Outgoing call", - "CALL_MISSED": "Missed call", + "MISSED_CALL": "Missed call", "GROUP_NAME_BLANK": "Group name should not be empty", "GROUP_TYPE_BLANK": "Group type Cannot is empty", "POLL_QUESTION_BLANK": "Question canaut is empty", @@ -271,7 +271,21 @@ "No_RECIPIENT": "No Recipient", "RECEIPT_INFORMATION": "Receipt Information", "MESSAGE": "Message", + "GENERATING_SUMMARY": "Generating Summary", + "CONVERSATION_SUMMARY": "Conversation Summary", + "GENERATE_SUMMARY": "Generate a summary", + "COMETCHAT_BOT_FIRST_MESSAGE": "How can I help you with this conversation? Please ask me a question and I’ll advice you 🙂", + "COMETCHAT_ASK_BOT": "Ask", + "COMETCHAT_ASK_AI_BOT": "Ask AI Bots", + "COMETCHAT_ASK_BOT_SUBTITLE": "AI Bot", "FORM_COMPLETION_MESSAGE": "Thank you for filling out the form.", "FORM":"Form", - "CARD":"Card" + "CARD":"Card", + "RECORDINGS":"Recordings", + "PARTICIPANTS":"Participants", + "NO_PARTICIPANTS":"No Participants", + "NO_RECORDINGS":"No Recordings", + "CALL_LOGS":"Call Logs", + "CANCELLED_AUDIO_CALL":"Cancelled audio call", + "CANCELLED_VIDEO_CALL":"Cancelled video call" } \ No newline at end of file diff --git a/src/shared/resources/CometChatLocalize/resources/es/translation.json b/src/shared/resources/CometChatLocalize/resources/es/translation.json index d746b5b..0854dcd 100644 --- a/src/shared/resources/CometChatLocalize/resources/es/translation.json +++ b/src/shared/resources/CometChatLocalize/resources/es/translation.json @@ -20,7 +20,7 @@ "NO_REPLIES_FOUND":"No se encontraron respuestas", "PARTICIPANT": "Participante", "GENERATING_REPLIES":"Generación de respuestas", - "SUGGEST_A_REPLIES":"Sugerir una respuesta", + "SUGGEST_A_REPLY":"Sugerir una respuesta", "GENERATIONG_ICEBREAKER":"Generando rompehielos", "PUBLIC": "Público", "PRIVATE": "Privado", @@ -86,7 +86,7 @@ "UNANSWERED_AUDIO_CALL": "Llamada de audio sin respuesta", "UNANSWERED_VIDEO_CALL": "Videollamada sin respuesta", "CALL_ENDED": "Llamada finalizada", - "CALL_CANCELLED": "Llamada cancelada", + "CANCELLED_CALL": "Llamada cancelada", "CALL_BUSY": "Llamada ocupada", "CALLING": "Llamando...", "ADD": "Añadir", @@ -149,7 +149,7 @@ "ADDED": "añadido", "UNBANNED": "no prohibida", "MADE": "hecho", - "CALL_UNANSWERED": "Llamada sin respuesta", + "UNANSWERED_CALL": "Llamada sin respuesta", "MISSED_AUDIO_CALL": "Llamada de audio perdida", "ENTER_YOUR_PASSWORD": "Introduce tu contraseña", "DOCS": "Documentos", @@ -264,14 +264,28 @@ "TEXT": "Texto", "INCOMING_CALL": "Llamada entrante", "OUTGOING_CALL": "Llamada saliente", - "CALL_MISSED": "Llamada perdida", + "MISSED_CALL": "Llamada perdida", "NEW_CONVERSATION": "Nuevo chat", "FORWARDING": "Envío de mensajes..", "READ": "Leer", "No_RECIPIENT": "Sin destinatario", "RECEIPT_INFORMATION": "Información del recibo", "MESSAGE": "Mensaje", + "GENERATING_SUMMARY":"Generación de resumen", + "CONVERSATION_SUMMARY":"Resumen de la conversación", + "GENERATE_SUMMARY":"Generar un resumen", + "COMETCHAT_BOT_FIRST_MESSAGE":"¿Cómo puedo ayudarte con esta conversación? Por favor, hazme una pregunta y te asesoraré 🙂", + "COMETCHAT_ASK_BOT":"Preguntar", + "COMETCHAT_ASK_AI_BOT":"Pregúntale a los bots de IA", + "COMETCHAT_ASK_BOT_SUBTITLE":"Bot de IA", "FORM_COMPLETION_MESSAGE": "Gracias por rellenar el formulario.", "FORM":"Formulario", - "CARD":"Tarjeta" + "CARD":"Tarjeta", + "RECORDINGS":"Grabaciones", + "PARTICIPANTS":"Participantes", + "NO_PARTICIPANTS":"No hay participantes", + "NO_RECORDINGS":"Sin grabaciones", + "CALL_LOGS":"Registros de llamadas", + "CANCELLED_AUDIO_CALL":"Llamada de audio cancelada", + "CANCELLED_VIDEO_CALL":"Videollamada cancelada" } \ No newline at end of file diff --git a/src/shared/resources/CometChatLocalize/resources/fr/translation.json b/src/shared/resources/CometChatLocalize/resources/fr/translation.json index d79a3c6..1aa7514 100644 --- a/src/shared/resources/CometChatLocalize/resources/fr/translation.json +++ b/src/shared/resources/CometChatLocalize/resources/fr/translation.json @@ -21,7 +21,7 @@ "PARTICIPANT": "Participant", "GENERATING_REPLIES":"Génération de réponses", "PUBLIC": "Public", - "SUGGEST_A_REPLIES":"Suggérer une réponse", + "SUGGEST_A_REPLY":"Suggérer une réponse", "GENERATIONG_ICEBREAKER":"Génération de brise-glaces", "PRIVATE": "Privé", "PASSWORD_PROTECTED": "Mot de passe", @@ -86,7 +86,7 @@ "UNANSWERED_AUDIO_CALL": "Appel audio sans réponse", "UNANSWERED_VIDEO_CALL": "Appel vidéo sans réponse", "CALL_ENDED": "Appel terminé", - "CALL_CANCELLED": "Appel annulé", + "CANCELLED_CALL": "Appel annulé", "CALL_BUSY": "Appeler occupé", "CALLING": "Appeler...", "ADD": "Ajouter", @@ -149,7 +149,7 @@ "ADDED": "ajoutée", "UNBANNED": "non interdite", "MADE": "confectionné", - "CALL_UNANSWERED": "Appel sans réponse", + "UNANSWERED_CALL": "Appel sans réponse", "MISSED_AUDIO_CALL": "Appel audio manqué", "ENTER_YOUR_PASSWORD": "Entrez votre mot de passe", "DOCS": "Docs", @@ -264,14 +264,28 @@ "TEXT": "Texte", "INCOMING_CALL": "Appel entrant", "OUTGOING_CALL": "Appel sortant", - "CALL_MISSED": "Appel manqué", + "MISSED_CALL": "Appel manqué", "NEW_CONVERSATION": "Nouveau chat", "FORWARDING": "Envoi de messages.", "READ": "Lisez", "No_RECIPIENT": "Aucun destinataire", "RECEIPT_INFORMATION": "Informations sur le reçu", "MESSAGE": "Un message", + "GENERATING_SUMMARY":"Génération d'un résumé", + "CONVERSATION_SUMMARY":"Résumé de la conversation", + "GENERATE_SUMMARY":"Générez un résumé", + "COMETCHAT_BOT_FIRST_MESSAGE":"Comment puis-je vous aider dans cette conversation ? Posez-moi une question et je vous conseillerai 🙂", + "COMETCHAT_ASK_BOT":"Demandez", + "COMETCHAT_ASK_AI_BOT":"Demandez à AI Bots", + "COMETCHAT_ASK_BOT_SUBTITLE":"Robot IA", "FORM_COMPLETION_MESSAGE": "Merci d'avoir rempli le formulaire.", "FORM":"Formulaire", - "CARD":"Carte" + "CARD":"Carte", + "RECORDINGS":"Enregistrements", + "PARTICIPANTS":"Participants", + "NO_PARTICIPANTS":"Aucun participant", + "NO_RECORDINGS":"Aucun enregistrement", + "CALL_LOGS":"Journaux d'appels", + "CANCELLED_AUDIO_CALL":"Appel audio annulé", + "CANCELLED_VIDEO_CALL":"Appel vidéo annulé" } \ No newline at end of file diff --git a/src/shared/resources/CometChatLocalize/resources/hi/translation.json b/src/shared/resources/CometChatLocalize/resources/hi/translation.json index ffe947e..2eb292f 100644 --- a/src/shared/resources/CometChatLocalize/resources/hi/translation.json +++ b/src/shared/resources/CometChatLocalize/resources/hi/translation.json @@ -13,7 +13,7 @@ "CUSTOM_MESSAGE_POLL": "📊 पोल", "CUSTOM_MESSAGE_STICKER": "💟 स्टीकर", "CUSTOM_MESSAGE_DOCUMENT": "📃 दस्तावेज़", - "SUGGEST_A_REPLIES":"जवाब सुझाएं", + "SUGGEST_A_REPLY":"जवाब सुझाएं", "GENERATIONG_ICEBREAKER":"आइसब्रेकर उत्पन्न करना", "CUSTOM_MESSAGE_WHITEBOARD": "📝 व्हाइटबोर्ड", "ONLINE": "ऑनलाइन", @@ -86,7 +86,7 @@ "UNANSWERED_AUDIO_CALL": "अनुत्तरित ऑडियो कॉल", "UNANSWERED_VIDEO_CALL": "अनुत्तरित वीडियो कॉल", "CALL_ENDED": "कॉल समाप्त", - "CALL_CANCELLED": "कॉल रद्द", + "CANCELLED_CALL": "कैंसिल किया गया कॉल", "CALL_BUSY": "व्यस्त कॉल करें", "CALLING": "कॉल कर रहा है...", "ADD": "जोड़ें", @@ -149,7 +149,7 @@ "ADDED": "जोड़ा गया", "UNBANNED": "अप्रतिबंधित", "MADE": "बनाया", - "CALL_UNANSWERED": "अनुत्तरित कॉल करें", + "UNANSWERED_CALL": "अनुत्तरित कॉल", "MISSED_AUDIO_CALL": "मिस ऑडियो कॉल", "ENTER_YOUR_PASSWORD": "अपना पासवर्ड दर्ज करें", "DOCS": "डॉक्स", @@ -264,14 +264,28 @@ "TEXT": "टेक्स्ट", "INCOMING_CALL": "इनकमिंग कॉल", "OUTGOING_CALL": "आउटगोइंग कॉल", - "CALL_MISSED": "मिस्ड कॉल", + "MISSED_CALL": "मिस्ड कॉल", "NEW_CONVERSATION": "नई चैट", "FORWARDING": "संदेश भेजा जा रहा है..", "READ": "पढ़ें", "No_RECIPIENT": "कोई प्राप्तकर्ता नहीं", "RECEIPT_INFORMATION": "रसीद की जानकारी", "MESSAGE": "सन्देश", + "GENERATING_SUMMARY":"सारांश तैयार करना", + "CONVERSATION_SUMMARY":"बातचीत का सारांश", + "GENERATE_SUMMARY":"एक सारांश जनरेट करें", + "COMETCHAT_BOT_FIRST_MESSAGE":"मैं इस बातचीत में आपकी कैसे मदद कर सकता हूं? कृपया मुझसे एक प्रश्न पूछें और मैं आपको सलाह दूंगा 🙂", + "COMETCHAT_ASK_BOT":"पूछो", + "COMETCHAT_ASK_AI_BOT":"AI बॉट्स से पूछें", + "COMETCHAT_ASK_BOT_SUBTITLE":"एआई बॉट", "FORM_COMPLETION_MESSAGE": "फॉर्म भरने के लिए धन्यवाद।", "FORM":"प्रपत्र", - "CARD":"कार्ड" + "CARD":"कार्ड", + "RECORDINGS":"रिकॉर्डिंग्स", + "PARTICIPANTS":"प्रतिभागी", + "NO_PARTICIPANTS":"कोई सहभागी नहीं", + "NO_RECORDINGS":"कोई रिकॉर्डिंग नहीं", + "CALL_LOGS":"कॉल लॉग्स", + "CANCELLED_AUDIO_CALL":"रद्द किया गया ऑडियो कॉल", + "CANCELLED_VIDEO_CALL":"रद्द किया गया वीडियो कॉल" } \ No newline at end of file diff --git a/src/shared/resources/CometChatLocalize/resources/lt/translation.json b/src/shared/resources/CometChatLocalize/resources/lt/translation.json index 1dff309..5bdd82d 100644 --- a/src/shared/resources/CometChatLocalize/resources/lt/translation.json +++ b/src/shared/resources/CometChatLocalize/resources/lt/translation.json @@ -18,7 +18,7 @@ "ADMINISTRATOR": "Administratorius", "MODERATOR": "Moderatorius", "NO_REPLIES_FOUND":"Nessuna risposta trovata", - "SUGGEST_A_REPLIES":"Suggerisci una risposta", + "SUGGEST_A_REPLY":"Suggerisci una risposta", "GENERATIONG_ICEBREAKER":"Generazione di rompighiaccio", "PARTICIPANT": "Dalyvis", "PUBLIC": "Vieša", @@ -86,7 +86,7 @@ "UNANSWERED_AUDIO_CALL": "Neatsakė į skambutį", "UNANSWERED_VIDEO_CALL": "Neatsakė į vaizdo skambutį", "CALL_ENDED": "Skambutis baigtas", - "CALL_CANCELLED": "Skambutis atšauktas", + "CANCELLED_CALL": "Chiamata annullata", "CALL_BUSY": "Užimta", "CALLING": "Skambinama...", "ADD": "Pridėti", @@ -149,7 +149,7 @@ "ADDED": "pridėjo", "UNBANNED": "atblokavo", "MADE": "sukūrė", - "CALL_UNANSWERED": "Skambutis neatsakytas", + "UNANSWERED_CALL": "Chiamata senza risposta", "MISSED_AUDIO_CALL": "Praleistas skambutis", "ENTER_YOUR_PASSWORD": "Įrašykite slaptažodį", "DOCS": "Dokumentai", @@ -264,14 +264,28 @@ "TEXT": "Testo", "INCOMING_CALL": "Chiamata in arrivo", "OUTGOING_CALL": "Chiamata in uscita", - "CALL_MISSED": "Chiamata persa", + "MISSED_CALL": "Chiamata persa", "NEW_CONVERSATION": "Nuova chat", "FORWARDING": "Invio di messaggi..", "READ": "Leggi", "No_RECIPIENT": "Nessun destinatario", "RECEIPT_INFORMATION": "Informazioni sulla ricevuta", "MESSAGE": "Messaggio", + "GENERATING_SUMMARY":"Generazione del riassunto", + "CONVERSATION_SUMMARY":"Riepilogo della conversazione", + "GENERATE_SUMMARY":"Genera un riepilogo", + "COMETCHAT_BOT_FIRST_MESSAGE":"Come posso aiutarti con questa conversazione? Per favore fammi una domanda e ti consiglierò 🙂", + "COMETCHAT_ASK_BOT":"Chiedere", + "COMETCHAT_ASK_AI_BOT":"Chiedi ai bot AI", + "COMETCHAT_ASK_BOT_SUBTITLE":"Bot AI", "FORM_COMPLETION_MESSAGE": "Grazie per aver compilato il modulo.", "FORM":"Modulo", - "CARD":"Carta" + "CARD":"Carta", + "RECORDINGS":"Registrazioni", + "PARTICIPANTS":"Partecipanti", + "NO_PARTICIPANTS":"Nessun partecipante", + "NO_RECORDINGS":"Nessuna registrazione", + "CALL_LOGS":"Registri delle chiamate", + "CANCELLED_AUDIO_CALL":"Chiamata audio annullata", + "CANCELLED_VIDEO_CALL":"Videochiamata annullata" } \ No newline at end of file diff --git a/src/shared/resources/CometChatLocalize/resources/ms/translation.json b/src/shared/resources/CometChatLocalize/resources/ms/translation.json index 78017cf..39a61f1 100644 --- a/src/shared/resources/CometChatLocalize/resources/ms/translation.json +++ b/src/shared/resources/CometChatLocalize/resources/ms/translation.json @@ -13,7 +13,7 @@ "CUSTOM_MESSAGE_POLL": "📊 Undian", "CUSTOM_MESSAGE_STICKER": "💟 Pelekat", "CUSTOM_MESSAGE_DOCUMENT": "📃 Dokumen", - "SUGGEST_A_REPLIES":"Cadangkan balasan", + "SUGGEST_A_REPLY":"Cadangkan balasan", "GENERATIONG_ICEBREAKER":"Menjana pemecah ais", "CUSTOM_MESSAGE_WHITEBOARD": "📝 Papan Putih", "ONLINE": "Dalam Talian", @@ -86,7 +86,7 @@ "UNANSWERED_AUDIO_CALL": "Panggilan audio tidak dijawab", "UNANSWERED_VIDEO_CALL": "Panggilan video tidak dijawab", "CALL_ENDED": "Panggilan berakhir", - "CALL_CANCELLED": "Panggilan dibatalkan", + "CANCELLED_CALL": "Panggilan Dibatalkan", "CALL_BUSY": "Panggilan sibuk", "CALLING": "Memanggil...", "ADD": "Tambah", @@ -149,7 +149,7 @@ "ADDED": "campurkan", "UNBANNED": "tidak diharamkan", "MADE": "diperbuat", - "CALL_UNANSWERED": "Panggilan tidak dijawab", + "UNANSWERED_CALL": "Panggilan Tidak Dijawab", "MISSED_AUDIO_CALL": "Panggilan audio tidak dijawab", "ENTER_YOUR_PASSWORD": "Masukkan kata laluan anda", "DOCS": "Dokumen", @@ -264,14 +264,28 @@ "TEXT": "Teks", "INCOMING_CALL": "Panggilan masuk", "OUTGOING_CALL": "Panggilan keluar", - "CALL_MISSED": "Panggilan tidak dijawab", + "MISSED_CALL": "Panggilan tidak dijawab", "NEW_CONVERSATION": "Sembang Baru", "FORWARDING": "Menghantar mesej..", "READ": "Baca", "No_RECIPIENT": "Tiada Penerima", "RECEIPT_INFORMATION": "Maklumat Resit", "MESSAGE": "Pesanan", + "GENERATING_SUMMARY":"Menjana Ringkasan", + "CONVERSATION_SUMMARY":"Ringkasan Perbualan", + "GENERATE_SUMMARY":"Menjana ringkasan", + "COMETCHAT_BOT_FIRST_MESSAGE":"Bagaimana saya boleh membantu anda dalam perbualan ini? Sila tanya saya soalan dan saya akan memberi nasihat kepada anda 🙂", + "COMETCHAT_ASK_BOT":"Tanya", + "COMETCHAT_ASK_AI_BOT":"Tanya AI Bots", + "COMETCHAT_ASK_BOT_SUBTITLE":"AI Bot", "FORM_COMPLETION_MESSAGE": "Terima kasih kerana mengisi borang.", "FORM":"Borang", - "CARD":"Kad" + "CARD":"Kad", + "RECORDINGS":"Rakaman", + "PARTICIPANTS":"Peserta", + "NO_PARTICIPANTS":"Tiada Peserta", + "NO_RECORDINGS":"Tiada Rakaman", + "CALL_LOGS":"Log Panggilan", + "CANCELLED_AUDIO_CALL":"Panggilan audio yang dibatalkan", + "CANCELLED_VIDEO_CALL":"Panggilan video dibatalkan" } \ No newline at end of file diff --git a/src/shared/resources/CometChatLocalize/resources/pt/translation.json b/src/shared/resources/CometChatLocalize/resources/pt/translation.json index 43d966b..6ceb086 100644 --- a/src/shared/resources/CometChatLocalize/resources/pt/translation.json +++ b/src/shared/resources/CometChatLocalize/resources/pt/translation.json @@ -21,7 +21,7 @@ "PARTICIPANT": "Participante", "GENERATING_REPLIES":"Gerando respostas", "PUBLIC": "Público", - "SUGGEST_A_REPLIES":"Sugira uma resposta", + "SUGGEST_A_REPLY":"Sugira uma resposta", "GENERATIONG_ICEBREAKER":"Gerando quebra-gelos", "PRIVATE": "Privado", "PASSWORD_PROTECTED": "Protegido por senha", @@ -86,7 +86,7 @@ "UNANSWERED_AUDIO_CALL": "Chamada de áudio sem resposta", "UNANSWERED_VIDEO_CALL": "Chamada de vídeo sem resposta", "CALL_ENDED": "Chamada encerrada", - "CALL_CANCELLED": "Chamada cancelada", + "CANCELLED_CALL": "Chamada cancelada", "CALL_BUSY": "Ligue ocupado", "CALLING": "Chamando...", "ADD": "Adicionar", @@ -149,7 +149,7 @@ "ADDED": "adicionada", "UNBANNED": "não banido", "MADE": "fez", - "CALL_UNANSWERED": "Chamada sem resposta", + "UNANSWERED_CALL": "Chamada não atendida", "MISSED_AUDIO_CALL": "Chamada de áudio perdida", "ENTER_YOUR_PASSWORD": "Digite sua senha", "DOCS": "Documentos", @@ -264,14 +264,28 @@ "TEXT": "Texto", "INCOMING_CALL": "Chamada recebida", "OUTGOING_CALL": "Chamada de saída", - "CALL_MISSED": "Chamada perdida", + "MISSED_CALL": "Chamada perdida", "NEW_CONVERSATION": "Novo bate-papo", "FORWARDING": "Enviando mensagens..", "READ": "Leia", "No_RECIPIENT": "Nenhum destinatário", "RECEIPT_INFORMATION": "Informações sobre o recibo", "MESSAGE": "Mensagem", + "GENERATING_SUMMARY":"Gerando resumo", + "CONVERSATION_SUMMARY":"Resumo da conversa", + "GENERATE_SUMMARY":"Gere um resumo", + "COMETCHAT_BOT_FIRST_MESSAGE":"Como posso te ajudar nessa conversa? Por favor, me faça uma pergunta e eu vou te aconselhar 🙂", + "COMETCHAT_ASK_BOT":"Pergunte", + "COMETCHAT_ASK_AI_BOT":"Pergunte aos robôs de IA", + "COMETCHAT_ASK_BOT_SUBTITLE":"Robô de IA", "FORM_COMPLETION_MESSAGE": "Obrigado por preencher o formulário.", "FORM":"Formulário", - "CARD":"Cartão" + "CARD":"Cartão", + "RECORDINGS":"Gravações", + "PARTICIPANTS":"Participantes", + "NO_PARTICIPANTS":"Sem participantes", + "NO_RECORDINGS":"Sem gravações", + "CALL_LOGS":"Registros de chamadas", + "CANCELLED_AUDIO_CALL":"Chamada de áudio cancelada", + "CANCELLED_VIDEO_CALL":"Chamada de vídeo cancelada" } \ No newline at end of file diff --git a/src/shared/resources/CometChatLocalize/resources/ru/translation.json b/src/shared/resources/CometChatLocalize/resources/ru/translation.json index e8f165a..2286e2e 100644 --- a/src/shared/resources/CometChatLocalize/resources/ru/translation.json +++ b/src/shared/resources/CometChatLocalize/resources/ru/translation.json @@ -8,7 +8,7 @@ "MESSAGE_VIDEO": "📹 Видео", "MESSAGE_AUDIO": "🎵 Аудио", "CUSTOM_MESSAGE": "У вас есть сообщение", - "SUGGEST_A_REPLIES":"Предложите ответ", + "SUGGEST_A_REPLY":"Предложите ответ", "GENERATIONG_ICEBREAKER":"Генерация ледоколов", "MISSED_VOICE_CALL": "Пропущенный голосовой вызов", "MISSED_VIDEO_CALL": "Пропущенный видеовызов", @@ -86,7 +86,7 @@ "UNANSWERED_AUDIO_CALL": "Аудиовызов без ответа", "UNANSWERED_VIDEO_CALL": "Видеозвонок без ответа", "CALL_ENDED": "Звонок завершен", - "CALL_CANCELLED": "Вызов отменен", + "CANCELLED_CALL": "Отмененный звонок", "CALL_BUSY": "Вызов занят", "CALLING": "Звонок...", "ADD": "Добавить", @@ -149,7 +149,7 @@ "ADDED": "добавлено", "UNBANNED": "разблокирован", "MADE": "сделано", - "CALL_UNANSWERED": "Звонок остался без ответа", + "UNANSWERED_CALL": "Звонок без ответа", "MISSED_AUDIO_CALL": "Пропущенный аудиовызов", "ENTER_YOUR_PASSWORD": "Введите свой пароль", "DOCS": "Документы", @@ -264,14 +264,28 @@ "TEXT": "Текст", "INCOMING_CALL": "Входящий звонок", "OUTGOING_CALL": "Исходящий звонок", - "CALL_MISSED": "Пропущенный звонок", + "MISSED_CALL": "Пропущенный звонок", "NEW_CONVERSATION": "Новый чат", "FORWARDING": "Отправка сообщений..", "READ": "Прочитайте", "No_RECIPIENT": "Нет получателя", "RECEIPT_INFORMATION": "Информация о чеке", "MESSAGE": "Послание", + "GENERATING_SUMMARY":"Создание сводки", + "CONVERSATION_SUMMARY":"Краткое содержание беседы", + "GENERATE_SUMMARY":"Сгенерируйте сводку", + "COMETCHAT_BOT_FIRST_MESSAGE":"Чем я могу помочь вам в этом разговоре? Пожалуйста, задайте мне вопрос, и я дам вам совет 🙂", + "COMETCHAT_ASK_BOT":"Спросите", + "COMETCHAT_ASK_AI_BOT":"Спросите роботов AI", + "COMETCHAT_ASK_BOT_SUBTITLE":"ИИ-бот", "FORM_COMPLETION_MESSAGE": "Спасибо за заполнение формы.", "FORM":"Форма", - "CARD":"Карточка" + "CARD":"Карточка", + "RECORDINGS":"Записи", + "PARTICIPANTS":"Участники", + "NO_PARTICIPANTS":"Нет участников", + "NO_RECORDINGS":"Нет записей", + "CALL_LOGS":"Журналы вызовов", + "CANCELLED_AUDIO_CALL":"Отмененный аудиозвонок", + "CANCELLED_VIDEO_CALL":"Отмененный видеозвонок" } \ No newline at end of file diff --git a/src/shared/resources/CometChatLocalize/resources/sv/translation.json b/src/shared/resources/CometChatLocalize/resources/sv/translation.json index 2e7e3a6..5c1eb1d 100644 --- a/src/shared/resources/CometChatLocalize/resources/sv/translation.json +++ b/src/shared/resources/CometChatLocalize/resources/sv/translation.json @@ -16,7 +16,7 @@ "CUSTOM_MESSAGE_WHITEBOARD": "📝 Whiteboard", "ONLINE": "Online", "ADMINISTRATOR": "Administrator", - "SUGGEST_A_REPLIES":"Föreslå ett svar", + "SUGGEST_A_REPLY":"Föreslå ett svar", "GENERATIONG_ICEBREAKER":"Generera isbrytare", "NO_REPLIES_FOUND":"Inga svar hittades", "MODERATOR": "Moderator", @@ -86,7 +86,7 @@ "UNANSWERED_AUDIO_CALL": "Obesvarat telefonsamtal", "UNANSWERED_VIDEO_CALL": "Obesvarat videosamtal", "CALL_ENDED": "Samtal avslutat", - "CALL_CANCELLED": "Samtal avslutat", + "CANCELLED_CALL": "Avbrutet samtal", "CALL_BUSY": "Upptagen i samtal", "CALLING": "Ringer...", "ADD": "Lägg till", @@ -149,7 +149,7 @@ "ADDED": "Tillagd", "UNBANNED": "Avstängning borttagen", "MADE": "skapad", - "CALL_UNANSWERED": "Telefonsamtal obesvarat", + "UNANSWERED_CALL": "Obesvarat samtal", "MISSED_AUDIO_CALL": "Missat ljudsamtal", "ENTER_YOUR_PASSWORD": "Skriv i ditt lösenord", "DOCS": "Dokumentation", @@ -264,14 +264,28 @@ "TEXT": "Text", "INCOMING_CALL": "Inkommande samtal", "OUTGOING_CALL": "Utgående samtal", - "CALL_MISSED": "Missat samtal", + "MISSED_CALL": "Missat samtal", "NEW_CONVERSATION": "Ny chatt", "FORWARDING": "Skickar meddelanden..", "READ": "Läs", "No_RECIPIENT": "Ingen mottagare", "RECEIPT_INFORMATION": "Information om kvitto", "MESSAGE": "Meddelande", + "GENERATING_SUMMARY":"Generera sammanfattning", + "CONVERSATION_SUMMARY":"Konversationssammanfattning", + "GENERATE_SUMMARY":"Skapa en sammanfattning", + "COMETCHAT_BOT_FIRST_MESSAGE":"Hur kan jag hjälpa dig med det här samtalet? Ställ en fråga så ska jag ge dig råd 🙂", + "COMETCHAT_ASK_BOT":"Fråga", + "COMETCHAT_ASK_AI_BOT":"Fråga AI-bots", + "COMETCHAT_ASK_BOT_SUBTITLE":"AI Bot", "FORM_COMPLETION_MESSAGE": "Tack för att du fyller i formuläret.", "FORM":"Formulär", - "CARD":"Kort" + "CARD":"Kort", + "RECORDINGS":"Inspelningar", + "PARTICIPANTS":"Deltagare", + "NO_PARTICIPANTS":"Inga deltagare", + "NO_RECORDINGS":"Inga inspelningar", + "CALL_LOGS":"Samtalsloggar", + "CANCELLED_AUDIO_CALL":"Avbrutet ljudsamtal", + "CANCELLED_VIDEO_CALL":"Avbrutet videosamtal" } \ No newline at end of file diff --git a/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json b/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json index fb3d4df..3c7c81a 100644 --- a/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +++ b/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json @@ -30,7 +30,7 @@ "YESTERDAY": "昨天", "TYPING": "輸入...", "IS_TYPING": "正在輸入...", - "SUGGEST_A_REPLIES":"建議回覆", + "SUGGEST_A_REPLY":"建議回覆", "GENERATIONG_ICEBREAKER":"生成破冰船", "CLOSE": "關閉", "ENTER_GROUP_NAME": "輸入群組名稱", @@ -79,7 +79,7 @@ "UNANSWERED_AUDIO_CALL": "未接聽的音訊通話", "UNANSWERED_VIDEO_CALL": "未接聽的視訊通話", "CALL_ENDED": "通話結束", - "CALL_CANCELLED": "通話已取消", + "CANCELLED_CALL": "已取消通話", "CALL_BUSY": "對方正在忙碌", "CALLING": "正在撥打...", "ADD": "新增", @@ -149,7 +149,7 @@ "ADDED": "添加", "UNBANNED": "取消封鎖", "MADE": "製作", - "CALL_UNANSWERED": "未接聽來電", + "UNANSWERED_CALL": "未接聽的電話", "MISSED_AUDIO_CALL": "未接聽的音訊通話", "ENTER_YOUR_PASSWORD": "輸入您的密碼", "DOCS": "文件", @@ -264,14 +264,28 @@ "TEXT": "文字", "INCOMING_CALL": "來電", "OUTGOING_CALL": "撥出電話", - "CALL_MISSED": "未接來電", + "MISSED_CALL": "未接來電", "NEW_CONVERSATION": "新聊天", "FORWARDING": "正在傳送訊息..", "READ": "閱讀", "No_RECIPIENT": "沒有收件人", "RECEIPT_INFORMATION": "收據資料", "MESSAGE": "留言", + "GENERATING_SUMMARY":"產生摘要", + "CONVERSATION_SUMMARY":"對話摘要", + "GENERATE_SUMMARY":"產生摘要", + "COMETCHAT_BOT_FIRST_MESSAGE":"我該如何幫助您進行這個對話?請問我一個問題,我會給你建議 🙂", + "COMETCHAT_ASK_BOT":"詢問", + "COMETCHAT_ASK_AI_BOT":"詢問 AI 機器人", + "COMETCHAT_ASK_BOT_SUBTITLE":"人工智能機器人", "FORM_COMPLETION_MESSAGE": "感謝您填寫表格。", "FORM":"表格", - "CARD":"卡" + "CARD":"卡", + "RECORDINGS":"錄音", + "PARTICIPANTS":"參加者", + "NO_PARTICIPANTS":"沒有參加者", + "NO_RECORDINGS":"沒有錄音", + "CALL_LOGS":"通話記錄", + "CANCELLED_AUDIO_CALL":"已取消音訊通話", + "CANCELLED_VIDEO_CALL":"已取消視頻通話" } \ No newline at end of file diff --git a/src/shared/resources/CometChatLocalize/resources/zh/translation.json b/src/shared/resources/CometChatLocalize/resources/zh/translation.json index c0497ea..e5cfbba 100644 --- a/src/shared/resources/CometChatLocalize/resources/zh/translation.json +++ b/src/shared/resources/CometChatLocalize/resources/zh/translation.json @@ -30,7 +30,7 @@ "YESTERDAY": "昨天", "SUNDAY": "周日", "MONDAY": "周一", - "SUGGEST_A_REPLIES":"建议回复", + "SUGGEST_A_REPLY":"建议回复", "GENERATIONG_ICEBREAKER":"生成破冰船", "TUESDAY": "周二", "WEDNESDAY": "周三", @@ -86,7 +86,8 @@ "UNANSWERED_AUDIO_CALL": "未接听的音讯通话", "UNANSWERED_VIDEO_CALL": "未接听的视讯通话", "CALL_ENDED": "通话结束", - "CALL_CANCELLED": "通话已取消", + "CANCELLED_CALL": "已取消通话", + "UNANSWERED_CALL": "未接听的电话", "CALL_BUSY": "对方正在忙碌", "CALLING": "正在拨打...", "ADD": "添加", @@ -264,14 +265,28 @@ "TEXT": "文本", "INCOMING_CALL": "来电", "OUTGOING_CALL": "拨出电话", - "CALL_MISSED": "未接来电", + "MISSED_CALL": "未接来电", "NEW_CONVERSATION": "新聊天", "FORWARDING": "正在发送消息...", "READ": "阅读", "No_RECIPIENT": "没有收件人", "RECEIPT_INFORMATION": "收据信息", "MESSAGE": "消息", + "GENERATING_SUMMARY":"正在生成摘要", + "CONVERSATION_SUMMARY":"对话摘要", + "GENERATE_SUMMARY":"生成摘要", + "COMETCHAT_BOT_FIRST_MESSAGE":"我怎样才能帮助你完成这次对话?请问我一个问题我会给你建议 🙂", + "COMETCHAT_ASK_BOT":"问", + "COMETCHAT_ASK_AI_BOT":"向 AI 机器人提问", + "COMETCHAT_ASK_BOT_SUBTITLE":"AI Bot", "FORM_COMPLETION_MESSAGE": "感谢您填写表格。", "FORM":"表格", - "CARD":"卡片" + "CARD":"卡片", + "RECORDINGS":"录音", + "PARTICIPANTS":"参与者", + "NO_PARTICIPANTS":"没有参与者", + "NO_RECORDINGS":"没有录音", + "CALL_LOGS":"通话记录", + "CANCELLED_AUDIO_CALL":"语音通话已取消", + "CANCELLED_VIDEO_CALL":"视频通话取消" } \ No newline at end of file diff --git a/src/shared/resources/CometChatTheme/Palette.ts b/src/shared/resources/CometChatTheme/Palette.ts index 95af0f2..b23cf05 100644 --- a/src/shared/resources/CometChatTheme/Palette.ts +++ b/src/shared/resources/CometChatTheme/Palette.ts @@ -98,6 +98,7 @@ class PaletteItem { * @param {String} mode * @param {Object} backgroundColor * @param {Object} primary + * @param {Object} primary40 * @param {Object} secondary * @param {Object} error * @param {Object} success @@ -118,6 +119,7 @@ class Palette { mode: string backgroundColor: PaletteItem primary: PaletteItem + primary40: PaletteItem secondary: PaletteItem error: PaletteItem success: PaletteItem @@ -142,6 +144,10 @@ class Palette { [modes.light]: 'rgb(51, 153, 255)', [modes.dark]: 'rgb(51, 153, 255)', }), + primary40 = new PaletteItem({ + [modes.light]: 'rgba(51, 153, 255, .04)', + [modes.dark]: 'rgba(51, 153, 255, .04)', + }), secondary = new PaletteItem({ [modes.light]: 'rgba(248, 248, 248, 0.92)', [modes.dark]: 'rgba(248, 248, 248, 0.92)', @@ -202,6 +208,7 @@ class Palette { this.mode = mode; this.backgroundColor = backgroundColor; this.primary = primary; + this.primary40 = primary40; this.secondary = secondary; this.error = error; this.success = success; @@ -263,6 +270,9 @@ class Palette { getPrimary = () => { return this.primary[this.mode]; }; + getPrimary40 = () => { + return this.primary40[this.mode]; + } getSecondary = () => { return this.secondary[this.mode]; }; @@ -287,6 +297,12 @@ class Palette { } } + setPrimary40(colorset) { + if (colorset && colorset[modes.light] && colorset[modes.dark]) { + this.primary40 = colorset; + } + } + setError(colorset) { if (colorset && colorset[modes.light] && colorset[modes.dark]) { this.error = colorset; diff --git a/src/shared/utils/DetailsUtils/DetailsUtils.tsx b/src/shared/utils/DetailsUtils/DetailsUtils.tsx index f5720c5..ba2803c 100644 --- a/src/shared/utils/DetailsUtils/DetailsUtils.tsx +++ b/src/shared/utils/DetailsUtils/DetailsUtils.tsx @@ -24,7 +24,7 @@ const validateDetailOptions = ({ loggedInUser, group, optionId }) => { let isValid = validateGroupMemberOptions( loggedInUser.uid === group.owner ? GroupMemberScope.owner - : GroupMemberScope.participant, + : group.scope, group.scope, optionId ); diff --git a/src/shared/views/CometChatAICard/CometChatAICard.tsx b/src/shared/views/CometChatAICard/CometChatAICard.tsx new file mode 100644 index 0000000..684f514 --- /dev/null +++ b/src/shared/views/CometChatAICard/CometChatAICard.tsx @@ -0,0 +1,71 @@ +import { View, Text, ActivityIndicator, Image } from 'react-native' +import React, { useContext } from 'react' +import { AIBaseStyle, AIBaseStyleInterface } from '../../../AI/AIBaseStyle'; +import { CometChatContext } from '../../CometChatContext'; +import { ErrorMessageIcon, NoMessageIcon } from './resources'; + +const enum States { + loading = "loading", + error = "error", + empty = "empty", +} + +export interface CometChatAICardInterface { + state: "loading" | "error" | "empty", + style: AIBaseStyleInterface, + loadingIconTint?: string, + errorIconTint?: string, + emptyIconTint?: string, + loadingIconURL?: string, + errorIconURL?: string, + emptyIconURL?: string, + loadingStateText?: string, + errorStateText?: string, + emptyStateText?: string, +} + +const CometChatAICard = (props: CometChatAICardInterface) => { + const { state, style, + loadingStateText, loadingIconURL, + emptyIconURL, emptyStateText, + errorIconURL, errorStateText } = props; + + const { theme } = useContext(CometChatContext); + + const { emptyStateTextColor, emptyStateTextFont, emptyIconTint, + errorStateTextColor, errorStateTextFont, errorIconTint, + loadingStateTextColor, loadingStateTextFont, loadingIconTint + } = new AIBaseStyle({ + emptyIconTint: theme.palette.getAccent(), + emptyStateTextColor: theme.palette.getAccent(), + emptyStateTextFont: theme.typography.subtitle1, + errorIconTint: theme.palette.getAccent(), + errorStateTextColor: theme.palette.getAccent(), + errorStateTextFont: theme.typography.subtitle1, + loadingIconTint: theme.palette.getAccent(), + loadingStateTextColor: theme.palette.getAccent(), + loadingStateTextFont: theme.typography.subtitle1, + ...style, + }) + return ( + + {props.children ? props.children : + state === States.loading ? + {!loadingIconURL ? : + } + {loadingStateText} + + : state === States.error ? + + {errorStateText} + + : state === States.empty ? + + {emptyStateText} + + : null} + + ) +} + +export default CometChatAICard \ No newline at end of file diff --git a/src/shared/views/CometChatAICard/resources/errormessage.png b/src/shared/views/CometChatAICard/resources/errormessage.png new file mode 100644 index 0000000000000000000000000000000000000000..0f09f87af2d2de9f483b841ac2e58bd3481aef5b GIT binary patch literal 1293 zcmV+o1@iidP)s$#Ico@2%smS*_n>ZZuE{VQ8KggO8mPN4xL*E> zalO5&<&Ro+Tp7|RJBIbvLoIJ`KHdu1l<^0JCkw)DUt_aKWSi%+ajup8ugR5{zB$H$8FLjc- zh1B1WIfk%{kwH55SifZDN-W4~DR7GGvDI_DgQ+z&dBZQfIN~RVhUxk4r9U z?UY;|=(FH~{)(1d4<(t0#D?uCqot((nk@@*synf(N!3}Xv>5g9O|-sgHoI7ubikn`oBvSG@wG|N1Tj=0##6qkyOUY8R^ ztU`W7nUt|($WJKe_&RUJgjl*KJ6lL*h^1?mBiGEBhG<#+L!fAxHJ%_QA&7_%Sp+Ef07GCPLt&POUTbXnF@UZJ_ZqZq1?-#z6A zl-V(Cd-r}tuX6Uz^dcI|NB`ci8 zh~*rZ7OCHFxVlNQ_#5IZQ@;DEqx@%Pw(tUf?+$q^>`-an^-}yt<+gD-VkYS?Smf6uAT`CKa zWun}cc^_G>B*yZ!b(AQJVsK-LtV$FpilQirqMY*?kETP@z9wZ?ZNY%!|`?3*%wyC z(gl&uo;v%bvq!=r_^^T;j`p#$ElwyU0$bTufK6wgJNs71Y}#*~)i{xrGb+l95Hc&y z6L*gFhPtzsc|^Em`(vJlhQ-xWGoLra3iHeiOx>whxX>hw$9B?RdGDw%A-Golfwb0s z=k0%8kqLz%$|P%4&J$7>7; zoA$dkE9Zq_o?zql)E#QgFwgm&6=Ey3C0>Y%`KgE(<`XLlVS>wW%t&U5V}F|`o41(! z3kyexD~#==mp;~SSh*;|busMc73)EWE0eG=Y-_(3rnane25j?eJ$hB5*pbJz5Vdw1 zu6Oi{;DvBT8*Yb&g%62^`w^q3AzbE)8QF8&Vai8?zub04KTBU33RR1VrvjT_-f!l9&WyLzb^o>W}&>j!=C>b?mW% z_$D`hqnzWblc)(|tRUife^qxUO@yybgb0R=vMy1ivsyVxjWpFmzM^C$RuBzM6Ok&& zPbgVQ?L&S>IVWkkJywu|=lu^T=ZNS19TB7oA}FzB?}w9?1n!82iB`mYi;FeNIj097 zY(p-xAL2V*u|c_n;Dji)r(WS-T3+LA2CFBuv|ORgLd#6&kCe;!_SMx(W@6S;ddg)Q z)JqnHdPzZkU^xGD_9K_QL2!E{f1ylD$V>JpqZzyWZWqe_2z+)62>BPwZ1?dCw>>d5q>FM*4EvdoiJIFV?i$965+g>|4XbuUCfA5zxG0m0A>4Mj zI>!(%%H(2LYSP1%9MiF#T8rDO|CQw)mM~lwWfn0kEyKc9|8EB`xQDe|drod&xTRqT z=R0J@#1O*as(*s?Gp=Iyj4y=!?JLU)gN6l(VW|Tbj(IF>N(*ao`!G)f3n(~Ig*+G* zB8H^}zAeaXfj=Gdb!vMqduOg^SeeMY6%|8Zbj2;nYSMX(xXv4ev7zEKdH(amrm@5I z5jANY=1|*^#lfE}* z5=9t3^elzo@==}HBl)&Uhs?kYGl_C9j9Csbs3=89S(`GbC|Sv|P-sw5vau&kj2=T+ zlxLKy2zkWlF{qa$;XCAzvNmNrX{Jn4?}~ - + />} { const { theme } = useContext(CometChatContext); @@ -155,6 +157,8 @@ export const CometChatActionSheet = (props: CometChatActionSheetInterface) => { listItemTitleColor: theme.palette.getAccent(), titleColor: theme.palette.getAccent(), titleFont: theme.typography.name, + backgroundColor: props.style?.backgroundColor, + paddingHorizontal: props.style?.paddingHorizontal }), ...props.style, }; @@ -166,7 +170,7 @@ export const CometChatActionSheet = (props: CometChatActionSheetInterface) => { const _render = ({ item }) => { return ( - + ); }; const _renderGrid = ({ item }) => ( @@ -188,7 +192,7 @@ export const CometChatActionSheet = (props: CometChatActionSheetInterface) => { style={{ height: 1, backgroundColor: - props.style?.actionSheetSeparatorTint || + props.style?.actionSheetSeparatorTint || props.style?.optionsSeparatorTint || theme.palette.getAccent200(), }} /> @@ -238,12 +242,12 @@ export const CometChatActionSheet = (props: CometChatActionSheetInterface) => { width: style?.width, backgroundColor: style?.backgroundColor || 'transparent', borderRadius: style?.borderRadius, - paddingHorizontal: 10, + paddingHorizontal: style?.paddingHorizontal ?? 10, }, style?.border, ]} > - + {!props.hideHeader && { {props.title} {getLayoutModeIcon()} - + } {getList()} ); diff --git a/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx b/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx index 0f1ed23..33d8e58 100644 --- a/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +++ b/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx @@ -7,7 +7,7 @@ import { PanResponder, TouchableOpacity, View, - Modal, + Modal, ScrollView, KeyboardAvoidingView, Platform } from 'react-native'; import { Styles } from './style'; import { CometChatContext } from '../../CometChatContext'; @@ -26,9 +26,12 @@ export interface CometChatBottomSheetInterface { shadowColor?: string; backgroundColor?: string; lineColor?: string; + lineHeight?: number, + paddingHorizontal?: number, + borderRadius?: number, }; } -const CometChatBottomSheet = forwardRef((props: CometChatBottomSheetInterface,ref) => { +const CometChatBottomSheet = forwardRef((props: CometChatBottomSheetInterface, ref) => { const { theme } = useContext(CometChatContext); const { sliderMaxHeight, @@ -98,62 +101,68 @@ const CometChatBottomSheet = forwardRef((props: CometChatBottomSheetInterface,re BackHandler.removeEventListener('hardwareBackPress', _onBackPress); }; }, []); - + return ( togglePanel()} > - - togglePanel()} - /> - + + togglePanel()} + /> + - - - + + + + + + + {typeof children === 'function' + ? children(_handleScrollEndDrag) + : children} - - - {typeof children === 'function' - ? children(_handleScrollEndDrag) - : children} - - - + + + ); }); diff --git a/src/shared/views/CometChatBottomSheet/style.ts b/src/shared/views/CometChatBottomSheet/style.ts index 97f6b31..e66eee3 100644 --- a/src/shared/views/CometChatBottomSheet/style.ts +++ b/src/shared/views/CometChatBottomSheet/style.ts @@ -22,8 +22,6 @@ export const Styles = StyleSheet.create({ shadowRadius: 7.49, elevation: 12, paddingHorizontal: 5, - borderTopLeftRadius: 30, - borderTopRightRadius: 30, position: 'absolute', bottom: 0, right: 0, diff --git a/src/shared/views/CometChatDate/CometChatDate.tsx b/src/shared/views/CometChatDate/CometChatDate.tsx index 0f7e5c3..82248b0 100644 --- a/src/shared/views/CometChatDate/CometChatDate.tsx +++ b/src/shared/views/CometChatDate/CometChatDate.tsx @@ -65,17 +65,21 @@ export interface CometChatDateInterface { * object of DateStyle class. */ style?: DateStyleInterface; + /** + * + */ + dateAlignment?: "auto" | "left" | "right" | "center" | "justify" | undefined; } export const CometChatDate = (props: CometChatDateInterface) => { const { theme } = useContext(CometChatContext); - const { timeStamp, pattern, customDateString } = props; + const { timeStamp, pattern, customDateString, dateAlignment } = props; const defaultStyleProps = new DateStyle({ textFont: theme.typography.caption1, textColor: theme.palette.getAccent500(), }); - + const style = { ...defaultStyleProps, ...props.style, @@ -171,7 +175,7 @@ export const CometChatDate = (props: CometChatDateInterface) => { ]} > {customDateString ? customDateString : getFormattedDate()} diff --git a/src/shared/views/CometChatDate/DateConfiguration.ts b/src/shared/views/CometChatDate/DateConfiguration.ts index e5b1784..88d7a85 100644 --- a/src/shared/views/CometChatDate/DateConfiguration.ts +++ b/src/shared/views/CometChatDate/DateConfiguration.ts @@ -7,6 +7,7 @@ import { DateStyle, DateStyleInterface } from './DateStyle'; export class DateConfiguration { pattern?: string; style?: DateConfigurationStyle; + dateAlignment?: "auto" | "left" | "right" | "center" | "justify" | undefined; /** * @param {Object} param0 * @field pattern - pattern in which time should be displayed. One of ["timeFormat","dayDateFormat","dayDateTimeFormat"] @@ -15,9 +16,11 @@ export class DateConfiguration { constructor({ style = new DateStyle({}), pattern = 'timeFormat', + dateAlignment, }: DateConfigurationInterface) { this.pattern = pattern; this.style = style; + this.dateAlignment = dateAlignment; } } @@ -25,4 +28,5 @@ type DateConfigurationStyle = DateStyleInterface; export interface DateConfigurationInterface { pattern?: string; style?: DateConfigurationStyle; + dateAlignment?: "auto" | "left" | "right" | "center" | "justify" | undefined; } diff --git a/src/shared/views/CometChatDate/style.ts b/src/shared/views/CometChatDate/style.ts index 2a05b12..3cb0a7f 100644 --- a/src/shared/views/CometChatDate/style.ts +++ b/src/shared/views/CometChatDate/style.ts @@ -3,6 +3,6 @@ import { StyleSheet } from 'react-native'; export const Style = StyleSheet.create({ textStyle: { - textAlign: 'center', + textAlign: 'auto', }, }); diff --git a/src/shared/views/CometChatListItem/CometChatListItem.tsx b/src/shared/views/CometChatListItem/CometChatListItem.tsx index 2f54b86..8f469ab 100644 --- a/src/shared/views/CometChatListItem/CometChatListItem.tsx +++ b/src/shared/views/CometChatListItem/CometChatListItem.tsx @@ -39,6 +39,7 @@ export interface CometChatListItemInterface { options?: () => CometChatOptions[]; TailView?: React.FC; hideSeparator?: boolean; + separatorColor?: string; listItemStyle?: ListItemStyle; onPress?: Function; onLongPress?: Function; @@ -64,6 +65,7 @@ export const CometChatListItem = (props: CometChatListItemInterface) => { options, TailView, hideSeparator, + separatorColor, headViewContainerStyle, tailViewContainerStyle, bodyViewContainerStyle, @@ -221,7 +223,7 @@ export const CometChatListItem = (props: CometChatListItemInterface) => { typeof item.icon === 'string' ? { uri: item.icon } : item.icon } /> - {item.title && item.title.length && ( + {Boolean(item.title) && item.title.length > 0 && ( { ); }; + let ListComponent = ((onPress && typeof onPress == 'function') || (onLongPress && typeof onLongPress == 'function')) ? TouchableOpacity : View; + let listComponentProps = ((onPress && typeof onPress == 'function') || (onLongPress && typeof onLongPress == 'function')) ? { + activeOpacity: 1, + onPress: clickHandler, + onLongPress: longPressHandler + } : {}; + + let WrapperComponent = swipeRowOptions.length ? SwipeRow : React.Fragment; + let wrapperComponentProps = swipeRowOptions.length ? { + key: id, + onRowDidOpen: rowOpened, + onRowDidClose: rowClosed, + disableRightSwipe: true, + disableLeftSwipe: !swipeRowOptions.length, + rightOpenValue: 0 - translate + } : {}; + return ( - { )} - { }, ]} > - {(avatarURL || avatarName) && } + {Boolean(avatarURL || avatarName) && } - {title && } - {SubtitleView && } + {Boolean(title) && } + {Boolean(SubtitleView) && } - {TailView && } + {Boolean(TailView) && } - - + + ); }; diff --git a/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx b/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx index 23379c2..8c2743d 100644 --- a/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +++ b/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx @@ -122,13 +122,12 @@ export const CometChatMessageInput = ( } = props; return ( - + void +} + +export const CometChatPanel = (props: CometChatPanelInterface) => { + const { hideCloseButton, style, textContent, title, onClose } = props; + + const { theme } = useContext(CometChatContext); + + const { + backgroundColor, border, borderRadius, closeIconTint, + textColor, textFont, titleColor, titleFont + } = new PanelStyle({ + closeIconTint: theme.palette.getAccent(), + border: { borderWidth: 1, borderColor: theme.palette.getPrimary() }, + titleFont: theme.typography.title1, + titleColor: theme.palette.getAccent(), + textColor: theme.palette.getAccent600(), + textFont: theme.typography.text1, + backgroundColor: theme.palette.getPrimary40(), + ...style, + }) + + const _onClose = () => { + onClose && onClose(); + } + + return ( + + + {title} + {!hideCloseButton && + + } + + + {textContent} + + + ) +} \ No newline at end of file diff --git a/src/shared/views/CometChatPanel/PanelStyle.tsx b/src/shared/views/CometChatPanel/PanelStyle.tsx new file mode 100644 index 0000000..90d2f98 --- /dev/null +++ b/src/shared/views/CometChatPanel/PanelStyle.tsx @@ -0,0 +1,43 @@ +import { BaseStyle, FontStyle } from "../../base"; + +export interface PanelStyleInterface extends BaseStyle { + titleFont?: FontStyle, + titleColor?: string, + closeIconTint?: string, + textFont?: FontStyle, + textColor?: string +} + +export class PanelStyle extends BaseStyle { + titleFont?: FontStyle; + titleColor?: string; + closeIconTint?: string; + textFont?: FontStyle; + textColor?: string; + + constructor({ + height, + width, + backgroundColor, + border, + borderRadius, + closeIconTint, + titleFont, + titleColor, + textColor, + textFont + }: PanelStyleInterface) { + super({ + backgroundColor, + border, + borderRadius, + height, + width + }) + this.closeIconTint = closeIconTint; + this.titleColor = titleColor; + this.titleFont = titleFont; + this.textColor = textColor; + this.textFont = textFont; + } +} \ No newline at end of file diff --git a/src/shared/views/CometChatPanel/resources/CloseIcon.png b/src/shared/views/CometChatPanel/resources/CloseIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..6c7315d396f3f817cc016daa9a5353c291d2a568 GIT binary patch literal 650 zcmeAS@N?(olHy`uVBq!ia0vp^DIm?0yMnwlmrj8YCz zZdxMulDD}2WKm}2nxDMIF|tums`aYGrNs|Km6f>e87eIlU{z+~x@cgtSU~i!GS@{zn}rit z4>NP!G|*W*LG-W^*G)s6g$g{@8XSlDxDIV-ZZdeY02kMweEI{M$9JbpQ&;`o>eQ|= z7pS%bsOJ*rVLmVQ9zkb?GN<^+GAH&@>xGx&tQX3+X$Q;SQo2JnSXEx zd)m`>p;NzQH{Ip}3S5`?ADwjN(qf(?JEVn`ZM$51woFcvRF*v@ZontC&eV)+!(&!u zn=bdB4I1+d4=r>#z|kzkdD!-p@UgE9J%1mm>{-ZgJJ9gX!juCA%|-%`uNk*hPHANS zaCGUny_3H8uh^_9wv{m^b!Jb#&neXnam!Y)pJIBP&ndM!aM|G(jY3k3*-w3u@D2z{ z&~eOc|H$a2)x#ffEBQ*p*`qhZJ*5no>$b+VBgJ^?Avwmx2__;Oo~2uXiHpJ0)z4*} HQ$iB}