Preserve shape in lightbox

This commit is contained in:
Dan Abramov
2024-11-02 12:33:59 +00:00
parent e04f8341fd
commit d600cc3343
6 changed files with 22 additions and 5 deletions
+1
View File
@@ -72,6 +72,7 @@ let ProfileHeaderShell = ({
height: 1000, height: 1000,
width: 1000, width: 1000,
}, },
shape: 'circle',
}, },
], ],
index: 0, index: 0,
@@ -24,4 +24,5 @@ export type ImageSource = {
thumbRect: MeasuredDimensions | null thumbRect: MeasuredDimensions | null
alt?: string alt?: string
dimensions: Dimensions | null dimensions: Dimensions | null
shape: 'circle' | 'rect' | 'rounded-rect'
} }
@@ -297,7 +297,7 @@ const ImageItem = ({
ref={containerRef} ref={containerRef}
// Necessary to make opacity work for both children together. // Necessary to make opacity work for both children together.
renderToHardwareTextureAndroid renderToHardwareTextureAndroid
style={[styles.container, animatedStyle]}> style={[styles.container, animatedStyle, {}]}>
<ActivityIndicator size="small" color="#FFF" style={styles.loading} /> <ActivityIndicator size="small" color="#FFF" style={styles.loading} />
<GestureDetector gesture={composedGesture}> <GestureDetector gesture={composedGesture}>
<Image <Image
@@ -305,7 +305,16 @@ const ImageItem = ({
source={{uri: imageSrc.uri}} source={{uri: imageSrc.uri}}
placeholderContentFit="contain" placeholderContentFit="contain"
placeholder={{uri: imageSrc.thumbUri}} placeholder={{uri: imageSrc.thumbUri}}
style={styles.image} style={{
width: SCREEN.width,
height: imageAspect ? SCREEN.width / imageAspect : undefined,
borderRadius:
imageSrc.shape === 'circle'
? SCREEN.width / 2
: imageSrc.shape === 'rounded-rect'
? 20
: 0,
}}
accessibilityLabel={imageSrc.alt} accessibilityLabel={imageSrc.alt}
accessibilityHint="" accessibilityHint=""
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
@@ -321,9 +330,7 @@ const styles = StyleSheet.create({
width: SCREEN.width, width: SCREEN.width,
height: SCREEN.height, height: SCREEN.height,
overflow: 'hidden', overflow: 'hidden',
}, justifyContent: 'center',
image: {
flex: 1,
}, },
loading: { loading: {
position: 'absolute', position: 'absolute',
@@ -137,6 +137,12 @@ const ImageItem = ({
style={{ style={{
width: SCREEN.width, width: SCREEN.width,
height: imageAspect ? SCREEN.width / imageAspect : undefined, height: imageAspect ? SCREEN.width / imageAspect : undefined,
borderRadius:
imageSrc.shape === 'circle'
? SCREEN.width / 2
: imageSrc.shape === 'rounded-rect'
? 20
: 0,
}} }}
accessibilityLabel={imageSrc.alt} accessibilityLabel={imageSrc.alt}
accessibilityHint="" accessibilityHint=""
@@ -87,6 +87,7 @@ export function ProfileSubpageHeader({
height: 1000, height: 1000,
width: 1000, width: 1000,
}, },
shape: 'rounded-rect',
}, },
], ],
index: 0, index: 0,
+1
View File
@@ -155,6 +155,7 @@ export function PostEmbeds({
images: items.map((item, i) => ({ images: items.map((item, i) => ({
...item, ...item,
thumbRect: thumbRects[i] ?? null, thumbRect: thumbRects[i] ?? null,
shape: 'rect',
})), })),
index, index,
}) })