/* eslint-disable react-hooks/rules-of-hooks */ import React, { useContext } from 'react'; import { StyleSheet, Text } from 'react-native'; import { UiKitParserMessage, UiKitParserModal, uiKitMessage, uiKitModal, BlockContext, Markdown as IMarkdown, PlainText } from '@rocket.chat/ui-kit'; import Markdown, { MarkdownPreview } from '../markdown'; import Button from '../Button'; import { FormTextInput } from '../TextInput'; import { textParser, useBlockContext } from './utils'; import { themes } from '../../lib/constants'; import sharedStyles from '../../views/Styles'; import { Divider } from './Divider'; import { Section } from './Section'; import { Actions } from './Actions'; import { Image } from './Image'; import { Select } from './Select'; import { Context } from './Context'; import { MultiSelect } from './MultiSelect'; import { Input } from './Input'; import { DatePicker } from './DatePicker'; import { Overflow } from './Overflow'; import { ThemeContext } from '../../theme'; import { IActions, IButton, IElement, IInputIndex, IParser, ISection } from './interfaces'; const styles = StyleSheet.create({ input: { marginBottom: 0 }, multiline: { height: 130 }, button: { marginBottom: 16 }, text: { fontSize: 16, lineHeight: 22, textAlignVertical: 'center', ...sharedStyles.textRegular } }); const plainText = ({ text } = { text: '' }) => text; class MessageParser extends UiKitParserMessage { get current() { return this as unknown as IParser; } plain_text(element: PlainText, context: BlockContext): React.ReactElement { const { theme } = useContext(ThemeContext); const isContext = context === BlockContext.CONTEXT; if (isContext) { return ( ); } return {element.text}; } mrkdwn(element: IMarkdown, context: BlockContext) { const { theme } = useContext(ThemeContext); const isContext = context === BlockContext.CONTEXT; if (isContext) { return ( ); } return ; } button(element: IButton, context: BlockContext) { const { text, value, actionId, style } = element; const [{ loading }, action] = useBlockContext(element, context); return (