2021-09-13 20:41:05 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { Text } from 'react-native';
|
|
|
|
|
2022-06-06 14:17:51 +00:00
|
|
|
import shortnameToUnicode from '../../lib/methods/helpers/shortnameToUnicode';
|
2021-09-13 20:41:05 +00:00
|
|
|
import CustomEmoji from '../EmojiPicker/CustomEmoji';
|
|
|
|
import styles from './styles';
|
2022-06-06 15:33:36 +00:00
|
|
|
import { useTheme } from '../../theme';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
|
|
|
interface IEmoji {
|
|
|
|
literal: string;
|
|
|
|
isMessageContainsOnlyEmoji: boolean;
|
|
|
|
getCustomEmoji?: Function;
|
|
|
|
customEmojis?: any;
|
2022-02-17 15:27:01 +00:00
|
|
|
style?: object;
|
2021-09-13 20:41:05 +00:00
|
|
|
onEmojiSelected?: Function;
|
|
|
|
tabEmojiStyle?: object;
|
|
|
|
}
|
|
|
|
|
2022-10-21 18:27:55 +00:00
|
|
|
const Emoji = React.memo(({ literal, isMessageContainsOnlyEmoji, getCustomEmoji, customEmojis = true, style = {} }: IEmoji) => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
const emojiUnicode = shortnameToUnicode(literal);
|
|
|
|
const emoji: any = getCustomEmoji && getCustomEmoji(literal.replace(/:/g, ''));
|
|
|
|
if (emoji && customEmojis) {
|
|
|
|
return <CustomEmoji style={[isMessageContainsOnlyEmoji ? styles.customEmojiBig : styles.customEmoji, style]} emoji={emoji} />;
|
2021-09-13 20:41:05 +00:00
|
|
|
}
|
2022-10-21 18:27:55 +00:00
|
|
|
return (
|
|
|
|
<Text style={[{ color: colors.bodyText }, isMessageContainsOnlyEmoji ? styles.textBig : styles.text, style]}>
|
|
|
|
{emojiUnicode}
|
|
|
|
</Text>
|
|
|
|
);
|
|
|
|
});
|
2021-09-13 20:41:05 +00:00
|
|
|
|
|
|
|
export default Emoji;
|