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;
|
|
|
|
baseUrl: string;
|
|
|
|
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-06-27 21:27:22 +00:00
|
|
|
testID: string;
|
2021-09-13 20:41:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const Emoji = React.memo(
|
2022-06-27 21:27:22 +00:00
|
|
|
({ literal, isMessageContainsOnlyEmoji, getCustomEmoji, baseUrl, testID, customEmojis = true, style = {} }: IEmoji) => {
|
2022-06-06 15:33:36 +00:00
|
|
|
const { colors } = useTheme();
|
2021-09-13 20:41:05 +00:00
|
|
|
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}
|
2022-06-27 21:27:22 +00:00
|
|
|
testID={`${testID}-custom-emoji`}
|
2021-09-13 20:41:05 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return (
|
2022-06-27 21:27:22 +00:00
|
|
|
<Text
|
|
|
|
style={[{ color: colors.bodyText }, isMessageContainsOnlyEmoji ? styles.textBig : styles.text, style]}
|
|
|
|
testID={`${testID}-unicode-emoji`}>
|
2021-09-13 20:41:05 +00:00
|
|
|
{emojiUnicode}
|
|
|
|
</Text>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
export default Emoji;
|