2021-10-20 16:32:58 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { Text } from 'react-native';
|
|
|
|
import { InlineCode as InlineCodeProps } from '@rocket.chat/message-parser';
|
|
|
|
|
|
|
|
import styles from '../styles';
|
2022-07-04 18:10:14 +00:00
|
|
|
import { themes } from '../../../lib/constants';
|
2021-10-20 16:32:58 +00:00
|
|
|
import { useTheme } from '../../../theme';
|
|
|
|
|
|
|
|
interface IInlineCodeProps {
|
|
|
|
value: InlineCodeProps['value'];
|
|
|
|
}
|
|
|
|
|
2022-03-25 17:20:09 +00:00
|
|
|
const InlineCode = ({ value }: IInlineCodeProps) => {
|
2022-07-04 18:10:14 +00:00
|
|
|
const { theme } = useTheme();
|
2021-10-20 16:32:58 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Text
|
|
|
|
style={[
|
|
|
|
styles.codeInline,
|
|
|
|
{
|
2022-07-04 18:10:14 +00:00
|
|
|
color: themes[theme].bodyText,
|
|
|
|
backgroundColor: themes[theme].bannerBackground,
|
|
|
|
borderColor: themes[theme].borderColor
|
2021-10-20 16:32:58 +00:00
|
|
|
}
|
|
|
|
]}>
|
|
|
|
{(block => {
|
|
|
|
switch (block.type) {
|
|
|
|
case 'PLAIN_TEXT':
|
|
|
|
return <Text>{block.value}</Text>;
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
})(value)}
|
|
|
|
</Text>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default InlineCode;
|