mirror of
https://github.com/tooot-app/app
synced 2025-04-17 19:57:33 +02:00
https://github.com/facebook/react-native/issues/19193 describes the issue. But https://github.com/facebook/react-native/issues/19193#issuecomment-467852112 suggestion does not look well with PingFang and English
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
import Button from '@components/Button'
|
|
import openLink from '@root/utils/openLink'
|
|
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'
|
|
|
|
export interface Props {
|
|
attachment: Mastodon.AttachmentUnknown
|
|
}
|
|
|
|
const AttachmentUnsupported: React.FC<Props> = ({ attachment }) => {
|
|
const { theme } = useTheme()
|
|
return (
|
|
<View style={styles.base}>
|
|
{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>
|
|
{attachment.remote_url ? (
|
|
<Button
|
|
type='text'
|
|
content='尝试远程链接'
|
|
size='S'
|
|
overlay
|
|
onPress={async () => await openLink(attachment.remote_url!)}
|
|
/>
|
|
) : null}
|
|
</View>
|
|
)
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
base: {
|
|
flex: 1,
|
|
flexBasis: '50%',
|
|
aspectRatio: 16 / 9,
|
|
padding: StyleConstants.Spacing.XS / 2,
|
|
justifyContent: 'center',
|
|
alignItems: 'center'
|
|
},
|
|
text: {
|
|
...StyleConstants.FontStyle.S,
|
|
textAlign: 'center',
|
|
marginBottom: StyleConstants.Spacing.S
|
|
}
|
|
})
|
|
|
|
export default AttachmentUnsupported
|