2021-10-20 16:32:58 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { Text } from 'react-native';
|
|
|
|
import { Heading as HeadingProps } from '@rocket.chat/message-parser';
|
|
|
|
|
|
|
|
import { themes } from '../../../constants/colors';
|
|
|
|
import styles from '../styles';
|
|
|
|
import { useTheme } from '../../../theme';
|
|
|
|
|
|
|
|
interface IHeadingProps {
|
|
|
|
value: HeadingProps['value'];
|
|
|
|
level: HeadingProps['level'];
|
|
|
|
}
|
|
|
|
|
2022-03-25 17:20:09 +00:00
|
|
|
const Heading = ({ value, level }: IHeadingProps) => {
|
2021-10-20 16:32:58 +00:00
|
|
|
const { theme } = useTheme();
|
|
|
|
const textStyle = styles[`heading${level}`];
|
|
|
|
|
|
|
|
return (
|
2022-03-25 17:20:09 +00:00
|
|
|
<Text style={[textStyle, { color: themes[theme].bodyText }]}>
|
2021-10-20 16:32:58 +00:00
|
|
|
{value.map(block => {
|
|
|
|
switch (block.type) {
|
|
|
|
case 'PLAIN_TEXT':
|
|
|
|
return block.value;
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
})}
|
|
|
|
</Text>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Heading;
|