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