2019-08-27 12:25:38 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Text } from 'react-native';
|
|
|
|
|
2019-12-11 19:00:38 +00:00
|
|
|
import shortnameToUnicode from '../../utils/shortnameToUnicode';
|
2019-08-27 12:25:38 +00:00
|
|
|
import CustomEmoji from '../EmojiPicker/CustomEmoji';
|
2019-12-04 16:39:53 +00:00
|
|
|
import { themes } from '../../constants/colors';
|
2019-08-27 12:25:38 +00:00
|
|
|
|
|
|
|
import styles from './styles';
|
|
|
|
|
|
|
|
const Emoji = React.memo(({
|
2019-12-04 16:39:53 +00:00
|
|
|
emojiName, literal, isMessageContainsOnlyEmoji, getCustomEmoji, baseUrl, customEmojis, style = [], theme
|
2019-08-27 12:25:38 +00:00
|
|
|
}) => {
|
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);
|
2019-10-02 12:41:51 +00:00
|
|
|
if (emoji && customEmojis) {
|
2019-08-27 12:25:38 +00:00
|
|
|
return (
|
|
|
|
<CustomEmoji
|
|
|
|
baseUrl={baseUrl}
|
|
|
|
style={isMessageContainsOnlyEmoji ? styles.customEmojiBig : styles.customEmoji}
|
|
|
|
emoji={emoji}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2019-10-02 12:41:51 +00:00
|
|
|
return (
|
|
|
|
<Text
|
|
|
|
style={[
|
2019-12-17 14:08:06 +00:00
|
|
|
{ color: themes[theme].bodyText },
|
2019-10-02 12:41:51 +00:00
|
|
|
isMessageContainsOnlyEmoji ? styles.textBig : styles.text,
|
|
|
|
...style
|
|
|
|
]}
|
|
|
|
>
|
|
|
|
{emojiUnicode}
|
|
|
|
</Text>
|
|
|
|
);
|
2019-08-27 12:25:38 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
Emoji.propTypes = {
|
|
|
|
emojiName: PropTypes.string,
|
|
|
|
literal: PropTypes.string,
|
|
|
|
isMessageContainsOnlyEmoji: PropTypes.bool,
|
|
|
|
getCustomEmoji: PropTypes.func,
|
2019-10-02 12:41:51 +00:00
|
|
|
baseUrl: PropTypes.string,
|
|
|
|
customEmojis: PropTypes.bool,
|
2019-12-04 16:39:53 +00:00
|
|
|
style: PropTypes.array,
|
|
|
|
theme: PropTypes.string
|
2019-08-27 12:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Emoji;
|