2021-10-20 16:32:58 +00:00
|
|
|
import React, { useContext } from 'react';
|
|
|
|
import { Text } from 'react-native';
|
|
|
|
import { Emoji as EmojiProps } from '@rocket.chat/message-parser';
|
|
|
|
|
|
|
|
import shortnameToUnicode from '../../../utils/shortnameToUnicode';
|
|
|
|
import { themes } from '../../../constants/colors';
|
|
|
|
import { useTheme } from '../../../theme';
|
|
|
|
import styles from '../styles';
|
|
|
|
import CustomEmoji from '../../EmojiPicker/CustomEmoji';
|
|
|
|
import MarkdownContext from './MarkdownContext';
|
|
|
|
|
|
|
|
interface IEmojiProps {
|
|
|
|
value: EmojiProps['value'];
|
|
|
|
isBigEmoji?: boolean;
|
|
|
|
}
|
|
|
|
|
2022-03-25 17:20:09 +00:00
|
|
|
const Emoji = ({ value, isBigEmoji }: IEmojiProps) => {
|
2021-10-20 16:32:58 +00:00
|
|
|
const { theme } = useTheme();
|
|
|
|
const { baseUrl, getCustomEmoji } = useContext(MarkdownContext);
|
|
|
|
const emojiUnicode = shortnameToUnicode(`:${value.value}:`);
|
|
|
|
const emoji = getCustomEmoji?.(value.value);
|
|
|
|
|
|
|
|
if (emoji) {
|
|
|
|
return <CustomEmoji baseUrl={baseUrl} style={[isBigEmoji ? styles.customEmojiBig : styles.customEmoji]} emoji={emoji} />;
|
|
|
|
}
|
2022-03-25 17:20:09 +00:00
|
|
|
return <Text style={[{ color: themes[theme].bodyText }, isBigEmoji ? styles.textBig : styles.text]}>{emojiUnicode}</Text>;
|
2021-10-20 16:32:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Emoji;
|