import React from 'react'; import { SendbirdUserMessage, urlRegexStrict } from '@sendbird/uikit-utils'; import Box from '../../components/Box'; import RegexText, { RegexTextPattern } from '../../components/RegexText'; import Text from '../../components/Text'; import createStyleSheet from '../../styles/createStyleSheet'; import useUIKitTheme from '../../theme/useUIKitTheme'; import type { GroupChannelMessageProps } from './index'; type Props = GroupChannelMessageProps< SendbirdUserMessage, { backgroundColor?: string; regexTextPatterns?: RegexTextPattern[]; renderRegexTextChildren?: (message: SendbirdUserMessage) => string; } >; const MessageBubbleWithText = ({ backgroundColor, message, onPressURL, onLongPress, strings, variant = 'incoming', regexTextPatterns = [], renderRegexTextChildren = (msg) => msg.message, }: Props) => { const { colors } = useUIKitTheme(); const color = colors.ui.groupChannelMessage[variant]; return ( onPressURL?.(match)} onLongPress={onLongPress} style={[parentProps?.style, styles.urlText]} > {match} ); }, }, ]} > {renderRegexTextChildren(message)} {Boolean(message.updatedAt) && ( {strings?.edited ?? ' (edited)'} )} ); }; const styles = createStyleSheet({ bubble: { paddingHorizontal: 12, paddingVertical: 6, }, urlText: { textDecorationLine: 'underline', }, }); export default MessageBubbleWithText;