Image viewer use blurhash as loading placeholder

This commit is contained in:
Zhiyuan Zheng 2021-03-27 00:17:34 +01:00
parent b0b7a7567b
commit 516bb1e67d
No known key found for this signature in database
GPG Key ID: 078A93AB607D85E0
5 changed files with 7 additions and 9 deletions

View File

@ -58,9 +58,10 @@ declare namespace Nav {
imageUrls: {
id: Mastodon.Attachment['id']
url: Mastodon.AttachmentImage['url']
remote_url?: Mastodon.AttachmentImage['remote_url']
blurhash: Mastodon.AttachmentImage['blurhash']
width?: number
height?: number
remote_url?: Mastodon.AttachmentImage['remote_url']
}[]
id: Mastodon.Attachment['id']
}

View File

@ -102,11 +102,7 @@ const GracefullyImage = React.memo(
return (
<Pressable
style={[
style,
dimension,
{ backgroundColor: theme.backgroundOverlayDefault }
]}
style={[style, dimension, { backgroundColor: theme.shimmerDefault }]}
{...(onPress
? hidden
? { disabled: true }
@ -130,9 +126,7 @@ const styles = StyleSheet.create({
blurhash: {
width: '100%',
height: '100%',
position: 'absolute',
top: StyleConstants.Spacing.XS / 2,
left: StyleConstants.Spacing.XS / 2
position: 'absolute'
}
})

View File

@ -49,6 +49,7 @@ const TimelineAttachment = React.memo(
id: attachment.id,
url: attachment.url,
remote_url: attachment.remote_url,
blurhash: attachment.blurhash,
width: attachment.meta?.original?.width,
height: attachment.meta?.original?.height
})

View File

@ -93,6 +93,7 @@ const ImageItem = ({
original: imageSrc.url,
remote: imageSrc.remote_url
}}
blurhash={imageSrc.blurhash}
{...((!imageSrc.width || !imageSrc.height) && {
setImageDimensions
})}

View File

@ -148,6 +148,7 @@ const ImageItem = ({
original: imageSrc.url,
remote: imageSrc.remote_url
}}
blurhash={imageSrc.blurhash}
{...((!imageSrc.width || !imageSrc.height) && {
setImageDimensions
})}