mirror of https://github.com/tooot-app/app
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import GracefullyImage from '@components/GracefullyImage'
|
|
import { useTheme } from '@utils/styles/ThemeManager'
|
|
import React from 'react'
|
|
import { View } from 'react-native'
|
|
import AttachmentAltText from './AltText'
|
|
import { aspectRatio } from './dimensions'
|
|
|
|
export interface Props {
|
|
total: number
|
|
index: number
|
|
sensitiveShown: boolean
|
|
image: Mastodon.AttachmentImage
|
|
navigateToImagesViewer: (imageIndex: string) => void
|
|
}
|
|
|
|
const AttachmentImage = ({
|
|
total,
|
|
index,
|
|
sensitiveShown,
|
|
image,
|
|
navigateToImagesViewer
|
|
}: Props) => {
|
|
const { colors } = useTheme()
|
|
|
|
return (
|
|
<View style={{ flex: 1, backgroundColor: colors.shimmerDefault, alignContent: 'center', justifyContent: 'center' }}>
|
|
<GracefullyImage
|
|
accessibilityLabel={image.description}
|
|
hidden={sensitiveShown}
|
|
sources={{
|
|
default: { uri: image.preview_url },
|
|
remote: { uri: image.remote_url },
|
|
blurhash: image.blurhash
|
|
}}
|
|
onPress={() => navigateToImagesViewer(image.id)}
|
|
style={{ aspectRatio: aspectRatio({ total, index, ...image.meta?.original }) }}
|
|
dim
|
|
/>
|
|
<AttachmentAltText sensitiveShown={sensitiveShown} text={image.description} />
|
|
</View>
|
|
)
|
|
}
|
|
|
|
export default AttachmentImage
|