UNPKG

@cometchat/chat-uikit-react-native

Version:

Ready-to-use Chat UI Components for React Native

78 lines (77 loc) 3.69 kB
import { DataSource, DataSourceDecorator } from "../../shared/framework"; import { CometChat } from "@cometchat/chat-sdk-react-native"; import { CometChatMessageOption } from "../../shared/modals"; import { JSX } from "react"; import { AdditionalParams, MessageBubbleAlignmentType } from "../../shared/base/Types"; import { CometChatTheme } from "../../theme/type"; /** * Decorator class for handling message translation in the chat application. */ export declare class MessageTranslationExtensionDecorator extends DataSourceDecorator { translatedMessage: any; /** * Creates an instance of MessageTranslationExtensionDecorator. * * @param {DataSource} dataSource - The data source to be decorated. */ constructor(dataSource: DataSource); /** * Returns the unique ID for this extension. * * @returns {string} The ID string "MessageTranslation". */ getId(): string; /** * Gets the text message options for a given message. * * @param {CometChat.User} loggedInUser - The currently logged in user. * @param {CometChat.BaseMessage} messageObject - The message object. * @param {CometChatTheme} theme - The current theme settings. * @param {CometChat.Group} group - The group to which the message belongs. * * @returns {CometChatMessageOption[]} An array of message options including the translate option. */ getTextMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, theme: CometChatTheme, group?: CometChat.Group, additionalParams?: AdditionalParams): CometChatMessageOption[]; /** * Constructs the translation option for a message. * * @param {CometChat.BaseMessage} messageObject - The message object to be translated. * @param {CometChatTheme} theme - The current theme settings. * * @returns {CometChatMessageOption} A message option object for translation. */ getTranslateOption(messageObject: CometChat.BaseMessage, theme: CometChatTheme): CometChatMessageOption; /** * Updates the metadata of a message with translation information. * * @param {CometChat.TextMessage} messageObj - The text message object. * @param {any} messageTranslation - The translated text for the message. * * @returns {object} An object containing the updated message and translation metadata. */ getSetMetaData: (messageObj: CometChat.TextMessage, messageTranslation: any) => { msg: CometChat.TextMessage; metaData: any; }; /** * Translates a given text message by calling the translation extension. * * @param {CometChat.TextMessage} message - The text message to be translated. */ translateMessage: (message: CometChat.TextMessage) => void; /** * Returns the text message bubble component. * * This method renders a MessageTranslationBubble if the message has been translated; * otherwise, it falls back to the default text message bubble. * * @param {string} messageText - The original text of the message. * @param {CometChat.TextMessage} message - The message object. * @param {MessageBubbleAlignmentType} alignment - The alignment of the message bubble. * @param {CometChatTheme} theme - The current theme settings. * @param {AdditionalParams} [additionalParams] - Additional parameters for rendering. * * @returns {JSX.Element} The text message bubble component. */ getTextMessageBubble(messageText: string, message: CometChat.TextMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme, additionalParams?: AdditionalParams): JSX.Element; }