2019-08-27 12:25:38 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Text } from 'react-native';
|
2019-09-16 20:50:51 +00:00
|
|
|
import { shortnameToUnicode } from 'emoji-toolkit';
|
2019-08-27 12:25:38 +00:00
|
|
|
|
|
|
|
import CustomEmoji from '../EmojiPicker/CustomEmoji';
|
|
|
|
|
|
|
|
import styles from './styles';
|
|
|
|
|
|
|
|
const Emoji = React.memo(({
|
|
|
|
emojiName, literal, isMessageContainsOnlyEmoji, getCustomEmoji, baseUrl
|
|
|
|
}) => {
|
2019-09-16 20:50:51 +00:00
|
|
|
const emojiUnicode = shortnameToUnicode(literal);
|
2019-08-27 12:25:38 +00:00
|
|
|
const emoji = getCustomEmoji && getCustomEmoji(emojiName);
|
|
|
|
if (emoji) {
|
|
|
|
return (
|
|
|
|
<CustomEmoji
|
|
|
|
baseUrl={baseUrl}
|
|
|
|
style={isMessageContainsOnlyEmoji ? styles.customEmojiBig : styles.customEmoji}
|
|
|
|
emoji={emoji}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return <Text style={isMessageContainsOnlyEmoji ? styles.textBig : styles.text}>{emojiUnicode}</Text>;
|
|
|
|
});
|
|
|
|
|
|
|
|
Emoji.propTypes = {
|
|
|
|
emojiName: PropTypes.string,
|
|
|
|
literal: PropTypes.string,
|
|
|
|
isMessageContainsOnlyEmoji: PropTypes.bool,
|
|
|
|
getCustomEmoji: PropTypes.func,
|
|
|
|
baseUrl: PropTypes.string
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Emoji;
|