2020-10-29 14:52:28 +01:00
|
|
|
import React, { useState } from 'react'
|
|
|
|
import { Text } from 'react-native'
|
|
|
|
import Collapsible from 'react-native-collapsible'
|
|
|
|
|
|
|
|
import ParseContent from 'src/components/ParseContent'
|
|
|
|
|
2020-10-31 21:04:46 +01:00
|
|
|
export interface Props {
|
|
|
|
content: string
|
2020-11-21 00:40:55 +01:00
|
|
|
emojis: Mastodon.Emoji[]
|
|
|
|
mentions: Mastodon.Mention[]
|
2020-10-31 21:04:46 +01:00
|
|
|
spoiler_text?: string
|
|
|
|
}
|
|
|
|
|
|
|
|
const Content: React.FC<Props> = ({
|
|
|
|
content,
|
|
|
|
emojis,
|
|
|
|
mentions,
|
|
|
|
spoiler_text
|
|
|
|
}) => {
|
2020-10-29 14:52:28 +01:00
|
|
|
const [spoilerCollapsed, setSpoilerCollapsed] = useState(true)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{content &&
|
|
|
|
(spoiler_text ? (
|
|
|
|
<>
|
|
|
|
<Text>
|
|
|
|
{spoiler_text}{' '}
|
|
|
|
<Text onPress={() => setSpoilerCollapsed(!spoilerCollapsed)}>
|
|
|
|
点击展开
|
|
|
|
</Text>
|
|
|
|
</Text>
|
|
|
|
<Collapsible collapsed={spoilerCollapsed}>
|
|
|
|
<ParseContent
|
|
|
|
content={content}
|
|
|
|
emojis={emojis}
|
|
|
|
emojiSize={14}
|
|
|
|
mentions={mentions}
|
|
|
|
/>
|
|
|
|
</Collapsible>
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<ParseContent
|
|
|
|
content={content}
|
|
|
|
emojis={emojis}
|
|
|
|
emojiSize={14}
|
|
|
|
mentions={mentions}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-10-31 21:04:46 +01:00
|
|
|
export default Content
|