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

51 lines
1.1 KiB
TypeScript
Raw Normal View History

import React from 'react';
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';
2021-07-15 23:15:59 +00:00
interface IEmoji {
literal: string;
isMessageContainsOnlyEmoji: boolean;
getCustomEmoji?({}: any): string;
baseUrl: string;
customEmojis?: boolean;
style: object;
theme?: string;
}
const Emoji = React.memo(({
literal, isMessageContainsOnlyEmoji, getCustomEmoji, baseUrl, customEmojis = true, style = {}, theme
2021-07-15 23:15:59 +00:00
}: IEmoji) => {
const emojiUnicode = shortnameToUnicode(literal);
2021-07-15 23:15:59 +00:00
const emoji: any = 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,
style
]}
emoji={emoji}
/>
);
}
2019-10-02 12:41:51 +00:00
return (
<Text
style={[
2021-07-15 23:15:59 +00:00
{ color: themes[theme!].bodyText },
2019-10-02 12:41:51 +00:00
isMessageContainsOnlyEmoji ? styles.textBig : styles.text,
style
2019-10-02 12:41:51 +00:00
]}
>
{emojiUnicode}
</Text>
);
});
export default Emoji;