2021-10-28 17:48:53 +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-29 18:53:10 +00:00
|
|
|
const Heading = ({ value, level }: IHeadingProps) => {
|
2021-10-28 17:48:53 +00:00
|
|
|
const { theme } = useTheme();
|
|
|
|
const textStyle = styles[`heading${level}`];
|
|
|
|
|
|
|
|
return (
|
2022-03-29 18:53:10 +00:00
|
|
|
<Text style={[textStyle, { color: themes[theme].bodyText }]}>
|
2021-10-28 17:48:53 +00:00
|
|
|
{value.map(block => {
|
|
|
|
switch (block.type) {
|
|
|
|
case 'PLAIN_TEXT':
|
|
|
|
return block.value;
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
})}
|
|
|
|
</Text>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Heading;
|