2020-12-26 23:05:17 +01:00
|
|
|
import Button from '@components/Button'
|
2020-12-25 18:20:09 +01:00
|
|
|
import openLink from '@root/utils/openLink'
|
2020-12-28 17:30:20 +01:00
|
|
|
import { StyleConstants } from '@root/utils/styles/constants'
|
|
|
|
import { useTheme } from '@root/utils/styles/ThemeManager'
|
|
|
|
import { Surface } from 'gl-react-expo'
|
|
|
|
import { Blurhash } from 'gl-react-blurhash'
|
|
|
|
import React from 'react'
|
|
|
|
import { StyleSheet, Text, View } from 'react-native'
|
2020-12-25 18:20:09 +01:00
|
|
|
|
|
|
|
export interface Props {
|
2020-12-25 21:09:43 +01:00
|
|
|
attachment: Mastodon.AttachmentUnknown
|
2020-12-25 18:20:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const AttachmentUnsupported: React.FC<Props> = ({ attachment }) => {
|
|
|
|
const { theme } = useTheme()
|
|
|
|
return (
|
|
|
|
<View style={styles.base}>
|
2020-12-28 17:30:20 +01:00
|
|
|
{attachment.blurhash ? (
|
|
|
|
<Surface
|
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
width: '100%',
|
|
|
|
height: '100%'
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Blurhash hash={attachment.blurhash} />
|
|
|
|
</Surface>
|
|
|
|
) : null}
|
|
|
|
<Text
|
|
|
|
style={[
|
|
|
|
styles.text,
|
|
|
|
{ color: attachment.blurhash ? theme.background : theme.primary }
|
|
|
|
]}
|
|
|
|
>
|
|
|
|
文件不支持
|
|
|
|
</Text>
|
2020-12-25 18:20:09 +01:00
|
|
|
{attachment.remote_url ? (
|
2020-12-26 23:05:17 +01:00
|
|
|
<Button
|
|
|
|
type='text'
|
|
|
|
content='尝试远程链接'
|
2020-12-25 18:20:09 +01:00
|
|
|
size='S'
|
2020-12-28 17:30:20 +01:00
|
|
|
overlay
|
2020-12-25 18:20:09 +01:00
|
|
|
onPress={async () => await openLink(attachment.remote_url!)}
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
</View>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
base: {
|
|
|
|
flex: 1,
|
2020-12-28 17:30:20 +01:00
|
|
|
flexBasis: '50%',
|
|
|
|
aspectRatio: 16 / 9,
|
|
|
|
padding: StyleConstants.Spacing.XS / 2,
|
2020-12-25 18:20:09 +01:00
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center'
|
|
|
|
},
|
|
|
|
text: {
|
|
|
|
fontSize: StyleConstants.Font.Size.S,
|
|
|
|
textAlign: 'center',
|
|
|
|
marginBottom: StyleConstants.Spacing.S
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
export default AttachmentUnsupported
|