import React, { useEffect, FunctionComponent, useContext } from 'react'; import { View, ViewStyle, Linking } from 'react-native'; import styles from './PixelTopicAnswerStyles'; import usePixelTopicAnswerTranslation from './PixelTopicAnswerTranslation' import { PixelStyles } from 'react-native-pixel-styles'; import { ForumUserInfos } from '../ForumUserInfos/ForumUserInfos'; import { PixelwolfText, PixelButton } from 'react-native-pixel-components'; import { dateStore } from 'react-native-pixel-utils'; import HTML from 'react-native-render-html'; import { PixelAnswer } from '../../Model/PixelAnswer'; import { AnswerButton } from '../AnswerButton/AnswerButton'; interface IProps { // Props type definition style?: ViewStyle | ViewStyle[] answer: PixelAnswer isTopic?: boolean isQuote?: boolean } interface IState { // State type definition } export const PixelTopicAnswer: FunctionComponent = (props) => { const { I18n } = usePixelTopicAnswerTranslation() const themeStore = useContext(PixelStyles.pixelThemeStoreContext) const initialState: IState = { }; // ComponentDidMount useEffect(() => { return () => { //ComponentDidUnmount } }, []) const content = props.answer.content const paragraphs = content.split('\n') let formattedParagraphs = '' paragraphs.forEach((paragraph: string) => { formattedParagraphs += '

' + paragraph + '

' }) return ( {dateStore.getDateDescriptionFromString(props.answer.created_at)} {props.answer.quote && } { Linking.openURL(url) }} tagsStyles={{ p: { ...styles.defaultText, ...themeStore.mainTextStyle, ...styles.bigText, marginTop: -7, }, a: { ...styles.defaultText, ...themeStore.getContrastTextStyle, ...styles.bigText, } }} html={formattedParagraphs} containerStyle={[styles.marginTop, styles.leftAlignedColumn, styles.fullWidthContainer]} /> {props.isQuote !== true && } ); };