verdnatura-chat/app/containers/markdown/Emoji.js

47 lines
1.1 KiB
JavaScript
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
import { Text } from 'react-native';
import { shortnameToUnicode } from 'emoji-toolkit';
import CustomEmoji from '../EmojiPicker/CustomEmoji';
import styles from './styles';
const Emoji = React.memo(({
2019-10-02 12:41:51 +00:00
emojiName, literal, isMessageContainsOnlyEmoji, getCustomEmoji, baseUrl, customEmojis, style = []
}) => {
const emojiUnicode = shortnameToUnicode(literal);
const emoji = getCustomEmoji && getCustomEmoji(emojiName);
2019-10-02 12:41:51 +00:00
if (emoji && customEmojis) {
return (
<CustomEmoji
baseUrl={baseUrl}
style={isMessageContainsOnlyEmoji ? styles.customEmojiBig : styles.customEmoji}
emoji={emoji}
/>
);
}
2019-10-02 12:41:51 +00:00
return (
<Text
style={[
isMessageContainsOnlyEmoji ? styles.textBig : styles.text,
...style
]}
>
{emojiUnicode}
</Text>
);
});
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,
style: PropTypes.array
};
export default Emoji;