import React from 'react'; import { Avatar, Box, Icon, PressBox, Text, createStyleSheet, useUIKitTheme, } from '@sendbird/uikit-react-native-foundation'; import type { SendbirdBaseMessage } from '@sendbird/uikit-utils'; import { getFileIconFromMessage, isVoiceMessage, useIIFE } from '@sendbird/uikit-utils'; import type { MessageSearchProps } from '../domain/messageSearch/types'; import { useLocalization } from '../hooks/useContext'; const MessageSearchResultItem: MessageSearchProps['List']['renderSearchResultItem'] = ({ onPress, message }) => { const { colors, select, palette } = useUIKitTheme(); const { STRINGS } = useLocalization(); const fileIcon = useIIFE(() => { if (!message?.isFileMessage()) return undefined; if (isVoiceMessage(message)) return undefined; return getFileIconFromMessage(message); }); return ( {STRINGS.MESSAGE_SEARCH.SEARCH_RESULT_ITEM_TITLE(message)} {STRINGS.MESSAGE_SEARCH.SEARCH_RESULT_ITEM_TITLE_CAPTION(message)} {fileIcon && ( )} {STRINGS.MESSAGE_SEARCH.SEARCH_RESULT_ITEM_BODY(message)} ); }; function getSenderProfile(message: SendbirdBaseMessage) { if (message.isUserMessage() || message.isFileMessage()) { return message.sender.profileUrl; } else { return undefined; } } const styles = createStyleSheet({ container: { height: 76, width: '100%', flexDirection: 'row', alignItems: 'center', justifyContent: 'center', }, avatar: { marginHorizontal: 16, }, avatarSize: { width: 56, }, titleLine: { flexDirection: 'row', marginTop: 10, marginBottom: 4, }, bodyIcon: { borderRadius: 8, width: 26, height: 26, marginEnd: 4, }, bodyText: { lineHeight: 16, }, separator: { position: 'absolute', start: 0, end: -16, bottom: 0, height: 1, }, }); export default MessageSearchResultItem;