expo-image tweaks (#10710)

This commit is contained in:
Samuel Newman
2026-06-04 01:03:11 +03:00
committed by GitHub
parent 57ae26fcaa
commit 153772b760
28 changed files with 43 additions and 10 deletions
+1
View File
@@ -499,6 +499,7 @@ function TriggerClone({
accessibilityLabel={label} accessibilityLabel={label}
accessibilityHint={_(msg`The subject of the context menu`)} accessibilityHint={_(msg`The subject of the context menu`)}
accessibilityIgnoresInvertColors={false} accessibilityIgnoresInvertColors={false}
cachePolicy="none"
/> />
</Animated.View> </Animated.View>
) )
@@ -246,6 +246,7 @@ const ImageItem = ({
} }
} }
cachePolicy="memory" cachePolicy="memory"
useAppleWebpCodec
/> />
</Animated.View> </Animated.View>
</Animated.View> </Animated.View>
@@ -32,6 +32,7 @@ import Animated, {
withSpring, withSpring,
type WithSpringConfig, type WithSpringConfig,
} from 'react-native-reanimated' } from 'react-native-reanimated'
import {Image} from 'expo-image'
import * as ScreenOrientation from 'expo-screen-orientation' import * as ScreenOrientation from 'expo-screen-orientation'
import {type Dimensions} from '#/lib/media/types' import {type Dimensions} from '#/lib/media/types'
@@ -136,6 +137,9 @@ export default function ImageViewRoot({
'worklet' 'worklet'
thumbRects.set({}) thumbRects.set({})
})() })()
requestIdleCallback(() => {
void Image.clearMemoryCache()
})
}, [thumbRects]) }, [thumbRects])
useAnimatedReaction( useAnimatedReaction(
+1
View File
@@ -129,6 +129,7 @@ export function ImageItem({
contentFit="cover" contentFit="cover"
accessible={true} accessible={true}
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
useAppleWebpCodec
/> />
<MediaInsetBorder style={[a.rounded_xs]} /> <MediaInsetBorder style={[a.rounded_xs]} />
{children} {children}
@@ -108,6 +108,7 @@ export const ExternalEmbed = ({
source={{uri: imageUri}} source={{uri: imageUri}}
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
loading="lazy" loading="lazy"
useAppleWebpCodec
/> />
) : undefined} ) : undefined}
@@ -166,6 +166,7 @@ export const StandardSiteEmbed = ({
source={{uri: imageUri}} source={{uri: imageUri}}
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
loading="lazy" loading="lazy"
useAppleWebpCodec
/> />
) : undefined} ) : undefined}
@@ -60,6 +60,7 @@ export function FindContactsBannerNUX() {
a.self_end, a.self_end,
a.mt_sm, a.mt_sm,
]} ]}
useAppleWebpCodec
/> />
<View style={[a.flex_1, a.justify_center, a.py_xl, a.pr_5xl]}> <View style={[a.flex_1, a.justify_center, a.py_xl, a.pr_5xl]}>
<Text <Text
@@ -27,6 +27,7 @@ export function ContactsHeroImage() {
alt={_( alt={_(
msg`An illustration depicting user avatars flowing from a contact book into the Bluesky app`, msg`An illustration depicting user avatars flowing from a contact book into the Bluesky app`,
)} )}
useAppleWebpCodec
/> />
</View> </View>
) )
@@ -113,6 +113,7 @@ export function ActivitySubscriptionsNUX() {
alt={_( alt={_(
msg`A screenshot of a profile page with a bell icon next to the follow button, indicating the new activity notifications feature.`, msg`A screenshot of a profile page with a bell icon next to the follow button, indicating the new activity notifications feature.`,
)} )}
useAppleWebpCodec
/> />
</View> </View>
</View> </View>
@@ -124,6 +124,7 @@ export function BookmarksAnnouncement() {
'Contains a post that originally appeared in English. Consider translating the post text if it makes sense in your language, and noting that the post was translated from English.', 'Contains a post that originally appeared in English. Consider translating the post text if it makes sense in your language, and noting that the post was translated from English.',
}), }),
)} )}
useAppleWebpCodec
/> />
</View> </View>
</View> </View>
@@ -101,6 +101,7 @@ export function DraftsAnnouncement() {
'Contains a post that originally appeared in English. Consider translating the post text if it makes sense in your language, and noting that the post was translated from English.', 'Contains a post that originally appeared in English. Consider translating the post text if it makes sense in your language, and noting that the post was translated from English.',
}), }),
)} )}
useAppleWebpCodec
/> />
</View> </View>
<View style={[a.align_center, a.px_xl, a.pt_xl, a.gap_2xl, a.pb_sm]}> <View style={[a.align_center, a.px_xl, a.pt_xl, a.gap_2xl, a.pb_sm]}>
@@ -78,6 +78,7 @@ export function FindContactsAnnouncement() {
alt={_( alt={_(
msg`An illustration depicting user avatars flowing from a contact book into the Bluesky app`, msg`An illustration depicting user avatars flowing from a contact book into the Bluesky app`,
)} )}
useAppleWebpCodec
/> />
</View> </View>
</View> </View>
@@ -85,6 +85,7 @@ export function InitialVerificationAnnouncement() {
alt={_( alt={_(
msg`An illustration showing that Bluesky selects trusted verifiers, and trusted verifiers in turn verify individual user accounts.`, msg`An illustration showing that Bluesky selects trusted verifiers, and trusted verifiers in turn verify individual user accounts.`,
)} )}
useAppleWebpCodec
/> />
</View> </View>
@@ -119,6 +120,7 @@ export function InitialVerificationAnnouncement() {
alt={_( alt={_(
msg`An mockup of a iPhone showing the Bluesky app open to the profile of a verified user with a blue checkmark next to their display name.`, msg`An mockup of a iPhone showing the Bluesky app open to the profile of a verified user with a blue checkmark next to their display name.`,
)} )}
useAppleWebpCodec
/> />
</View> </View>
@@ -150,6 +150,7 @@ export function LiveNowBetaDialog() {
'Contains a post that originally appeared in English. Consider translating the post text if it makes sense in your language, and noting that the post was translated from English.', 'Contains a post that originally appeared in English. Consider translating the post text if it makes sense in your language, and noting that the post was translated from English.',
}), }),
)} )}
useAppleWebpCodec
/> />
</View> </View>
</View> </View>
+1
View File
@@ -142,6 +142,7 @@ export function AutoSizedImage({
} }
}} }}
loading="lazy" loading="lazy"
useAppleWebpCodec
/> />
<MediaInsetBorder /> <MediaInsetBorder />
+1
View File
@@ -480,6 +480,7 @@ function GalleryImage({
height: e.source.height, height: e.source.height,
}) })
}} }}
useAppleWebpCodec
/> />
{(hasAlt || isCropped) && !hideBadges ? ( {(hasAlt || isCropped) && !hideBadges ? (
@@ -106,6 +106,7 @@ export function GalleryItem({
} }
}} }}
loading="lazy" loading="lazy"
useAppleWebpCodec
/> />
<MediaInsetBorder style={insetBorderStyle} /> <MediaInsetBorder style={insetBorderStyle} />
</Pressable> </Pressable>
@@ -87,6 +87,7 @@ function Inner({
alt={_( alt={_(
msg`An illustration showing that Bluesky selects trusted verifiers, and trusted verifiers in turn verify individual user accounts.`, msg`An illustration showing that Bluesky selects trusted verifiers, and trusted verifiers in turn verify individual user accounts.`,
)} )}
useAppleWebpCodec
/> />
</View> </View>
@@ -69,6 +69,7 @@ export function LiveEventFeedCardCompact({
style={[a.absolute, a.inset_0, a.w_full, a.h_full]} style={[a.absolute, a.inset_0, a.w_full, a.h_full]}
contentFit="cover" contentFit="cover"
placeholderContentFit="cover" placeholderContentFit="cover"
useAppleWebpCodec
/> />
<LinearGradient <LinearGradient
@@ -77,6 +77,7 @@ export function LiveEventFeedCardWide({
style={[a.absolute, a.inset_0, a.w_full, a.h_full]} style={[a.absolute, a.inset_0, a.w_full, a.h_full]}
contentFit="cover" contentFit="cover"
placeholderContentFit="cover" placeholderContentFit="cover"
useAppleWebpCodec
/> />
<LinearGradient <LinearGradient
@@ -54,6 +54,7 @@ export function LinkPreview({
contentFit="cover" contentFit="cover"
onLoad={() => setImageLoadError(false)} onLoad={() => setImageLoadError(false)}
onError={() => setImageLoadError(true)} onError={() => setImageLoadError(true)}
useAppleWebpCodec
/> />
)} )}
{linkMeta && (!linkMeta.image || imageLoadError) && ( {linkMeta && (!linkMeta.image || imageLoadError) && (
@@ -147,6 +147,7 @@ export function LiveStatus({
contentFit="cover" contentFit="cover"
style={[a.absolute, a.inset_0]} style={[a.absolute, a.inset_0]}
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
useAppleWebpCodec
/> />
<LiveIndicator <LiveIndicator
size="large" size="large"
@@ -83,6 +83,7 @@ function Page({
style={[a.w_full, a.aspect_square]} style={[a.w_full, a.aspect_square]}
alt={alt} alt={alt}
accessibilityIgnoresInvertColors={false} // I guess we do need it to blend into the background accessibilityIgnoresInvertColors={false} // I guess we do need it to blend into the background
useAppleWebpCodec
/> />
{page === 1 && ( {page === 1 && (
<Image <Image
@@ -97,6 +98,7 @@ function Page({
}, },
]} ]}
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
useAppleWebpCodec
alt={_(msg`Your profile picture`)} alt={_(msg`Your profile picture`)}
/> />
)} )}
@@ -105,6 +105,7 @@ function GermLogo({size}: {size: 'small' | 'large'}) {
source={require('../../../../assets/images/germ_logo.webp')} source={require('../../../../assets/images/germ_logo.webp')}
accessibilityIgnoresInvertColors={false} accessibilityIgnoresInvertColors={false}
contentFit="cover" contentFit="cover"
useAppleWebpCodec
style={[ style={[
a.rounded_full, a.rounded_full,
size === 'large' ? {width: 32, height: 32} : {width: 16, height: 16}, size === 'large' ? {width: 32, height: 32} : {width: 16, height: 16},
+10 -10
View File
@@ -151,8 +151,8 @@ function ComposerReplyToImages({
<Image <Image
source={{uri: images[0].thumb}} source={{uri: images[0].thumb}}
style={[a.flex_1]} style={[a.flex_1]}
cachePolicy="memory-disk"
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
useAppleWebpCodec
/> />
)) || )) ||
(images.length === 2 && ( (images.length === 2 && (
@@ -160,14 +160,14 @@ function ComposerReplyToImages({
<Image <Image
source={{uri: images[0].thumb}} source={{uri: images[0].thumb}}
style={[a.flex_1]} style={[a.flex_1]}
cachePolicy="memory-disk"
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
useAppleWebpCodec
/> />
<Image <Image
source={{uri: images[1].thumb}} source={{uri: images[1].thumb}}
style={[a.flex_1]} style={[a.flex_1]}
cachePolicy="memory-disk"
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
useAppleWebpCodec
/> />
</View> </View>
)) || )) ||
@@ -176,21 +176,21 @@ function ComposerReplyToImages({
<Image <Image
source={{uri: images[0].thumb}} source={{uri: images[0].thumb}}
style={[a.flex_1]} style={[a.flex_1]}
cachePolicy="memory-disk"
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
useAppleWebpCodec
/> />
<View style={[a.flex_1, a.gap_2xs]}> <View style={[a.flex_1, a.gap_2xs]}>
<Image <Image
source={{uri: images[1].thumb}} source={{uri: images[1].thumb}}
style={[a.flex_1]} style={[a.flex_1]}
cachePolicy="memory-disk"
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
useAppleWebpCodec
/> />
<Image <Image
source={{uri: images[2].thumb}} source={{uri: images[2].thumb}}
style={[a.flex_1]} style={[a.flex_1]}
cachePolicy="memory-disk"
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
useAppleWebpCodec
/> />
</View> </View>
</View> </View>
@@ -201,28 +201,28 @@ function ComposerReplyToImages({
<Image <Image
source={{uri: images[0].thumb}} source={{uri: images[0].thumb}}
style={[a.flex_1]} style={[a.flex_1]}
cachePolicy="memory-disk"
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
useAppleWebpCodec
/> />
<Image <Image
source={{uri: images[1].thumb}} source={{uri: images[1].thumb}}
style={[a.flex_1]} style={[a.flex_1]}
cachePolicy="memory-disk"
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
useAppleWebpCodec
/> />
</View> </View>
<View style={[a.flex_1, a.flex_row, a.gap_2xs]}> <View style={[a.flex_1, a.flex_row, a.gap_2xs]}>
<Image <Image
source={{uri: images[2].thumb}} source={{uri: images[2].thumb}}
style={[a.flex_1]} style={[a.flex_1]}
cachePolicy="memory-disk"
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
useAppleWebpCodec
/> />
<Image <Image
source={{uri: images[3].thumb}} source={{uri: images[3].thumb}}
style={[a.flex_1]} style={[a.flex_1]}
cachePolicy="memory-disk"
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
useAppleWebpCodec
/> />
</View> </View>
</View> </View>
+1
View File
@@ -245,6 +245,7 @@ const GalleryItem = ({
}} }}
accessible={true} accessible={true}
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
enforceEarlyResizing
cachePolicy="none" cachePolicy="none"
autoplay={false} autoplay={false}
contentFit="cover" contentFit="cover"
+1
View File
@@ -330,6 +330,7 @@ let UserAvatar = ({
}} }}
blurRadius={moderation?.blur ? BLUR_AMOUNT : 0} blurRadius={moderation?.blur ? BLUR_AMOUNT : 0}
onLoad={onLoad} onLoad={onLoad}
useAppleWebpCodec
/> />
)} )}
{!noBorder && <MediaInsetBorder style={borderStyle} />} {!noBorder && <MediaInsetBorder style={borderStyle} />}
+2
View File
@@ -129,6 +129,7 @@ export function UserBanner({
source={{uri: banner}} source={{uri: banner}}
accessible={true} accessible={true}
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
useAppleWebpCodec
/> />
) : ( ) : (
<View <View
@@ -216,6 +217,7 @@ export function UserBanner({
blurRadius={moderation?.blur ? 100 : 0} blurRadius={moderation?.blur ? 100 : 0}
accessible={true} accessible={true}
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
useAppleWebpCodec
/> />
) : ( ) : (
<View <View