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-11-23 00:07:32 +01:00
|
|
|
import constants from 'src/utils/styles/constants'
|
|
|
|
import { useTheme } from 'src/utils/styles/ThemeManager'
|
|
|
|
|
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-11-23 00:07:32 +01:00
|
|
|
const { theme } = useTheme()
|
2020-10-29 14:52:28 +01:00
|
|
|
const [spoilerCollapsed, setSpoilerCollapsed] = useState(true)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{content &&
|
|
|
|
(spoiler_text ? (
|
|
|
|
<>
|
|
|
|
<Text>
|
|
|
|
{spoiler_text}{' '}
|
2020-11-23 00:07:32 +01:00
|
|
|
<Text
|
|
|
|
onPress={() => setSpoilerCollapsed(!spoilerCollapsed)}
|
|
|
|
style={{ color: theme.link }}
|
|
|
|
>
|
|
|
|
{spoilerCollapsed ? '点击展开' : '点击收起'}
|
2020-10-29 14:52:28 +01:00
|
|
|
</Text>
|
|
|
|
</Text>
|
|
|
|
<Collapsible collapsed={spoilerCollapsed}>
|
|
|
|
<ParseContent
|
|
|
|
content={content}
|
2020-11-23 00:07:32 +01:00
|
|
|
size={constants.FONT_SIZE_M}
|
2020-10-29 14:52:28 +01:00
|
|
|
emojis={emojis}
|
|
|
|
mentions={mentions}
|
|
|
|
/>
|
|
|
|
</Collapsible>
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<ParseContent
|
|
|
|
content={content}
|
2020-11-23 00:07:32 +01:00
|
|
|
size={constants.FONT_SIZE_M}
|
2020-10-29 14:52:28 +01:00
|
|
|
emojis={emojis}
|
|
|
|
mentions={mentions}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-10-31 21:04:46 +01:00
|
|
|
export default Content
|