import React from 'react'; import { Box, ImageWithPlaceholder, PressBox, RegexText, type RegexTextPattern, Text, createStyleSheet, useUIKitTheme, } from '@sendbird/uikit-react-native-foundation'; import { SendbirdUserMessage, urlRegexStrict, useFreshCallback } from '@sendbird/uikit-utils'; import { useSendbirdChat } from './../../hooks/useContext'; import { ThreadParentMessageRendererProps } from './index'; type Props = ThreadParentMessageRendererProps<{ regexTextPatterns?: RegexTextPattern[]; renderRegexTextChildren?: (message: SendbirdUserMessage) => string; }>; const ThreadParentMessageUserOg = (props: Props) => { const userMessage: SendbirdUserMessage = props.parentMessage as SendbirdUserMessage; if (!userMessage) return null; const { sbOptions } = useSendbirdChat(); const { select, colors, palette } = useUIKitTheme(); const enableOgtag = sbOptions.uikitWithAppInfo.groupChannel.channel.enableOgtag; const onPressMessage = (userMessage: SendbirdUserMessage) => useFreshCallback(() => { typeof userMessage.ogMetaData?.url === 'string' && props.onPressURL?.(userMessage.ogMetaData.url); }); return ( props.onPressURL?.(match)} style={[parentProps?.style, styles.urlText]} > {match} ); }, }, ]} > {props.renderRegexTextChildren?.(userMessage)} {Boolean(userMessage.updatedAt) && ( {' (edited)'} )} {userMessage.ogMetaData && enableOgtag && ( {!!userMessage.ogMetaData.defaultImage && ( )} {userMessage.ogMetaData.title} {!!userMessage.ogMetaData.description && ( {userMessage.ogMetaData.description} )} {userMessage.ogMetaData.url} )} ); }; const styles = createStyleSheet({ container: { borderRadius: 16, overflow: 'hidden', }, ogContainer: { paddingHorizontal: 12, paddingTop: 8, paddingBottom: 12, maxWidth: 240, borderBottomStartRadius: 16, borderBottomEndRadius: 16, }, ogImage: { width: 240, height: 136, borderTopStartRadius: 16, borderTopEndRadius: 16, }, ogUrl: { marginBottom: 4, }, ogTitle: { marginBottom: 4, }, ogDesc: { lineHeight: 14, marginBottom: 8, }, urlText: { textDecorationLine: 'underline', }, }); export default ThreadParentMessageUserOg;