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

49 lines
1.2 KiB
JavaScript
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
import { Text } from 'react-native';
import shortnameToUnicode from '../../utils/shortnameToUnicode';
import CustomEmoji from '../EmojiPicker/CustomEmoji';
2019-12-04 16:39:53 +00:00
import { themes } from '../../constants/colors';
import styles from './styles';
const Emoji = React.memo(({
literal, isMessageContainsOnlyEmoji, getCustomEmoji, baseUrl, customEmojis = true, style = [], theme
}) => {
const emojiUnicode = shortnameToUnicode(literal);
const emoji = getCustomEmoji && getCustomEmoji(literal.replace(/:/g, ''));
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={[
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>
);
});
Emoji.propTypes = {
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
};
export default Emoji;