diff --git a/src/view/com/util/images/AutoSizedImage.tsx b/src/view/com/util/images/AutoSizedImage.tsx index 9f19b7b32a..7c4a8485d2 100644 --- a/src/view/com/util/images/AutoSizedImage.tsx +++ b/src/view/com/util/images/AutoSizedImage.tsx @@ -1,5 +1,5 @@ import React from 'react' -import {Pressable, View} from 'react-native' +import {DimensionValue, Pressable, View} from 'react-native' import {Image} from 'expo-image' import {AppBskyEmbedImages} from '@atproto/api' import {msg} from '@lingui/macro' @@ -46,17 +46,25 @@ export function SquareFramedImage({ children: React.ReactNode }) { const t = useTheme() - const outerAspectRatio = React.useMemo(() => { - return Math.min(1 / aspectRatio, 1) + /** + * Computed as a % value to apply as `paddingTop` + */ + const outerAspectRatio = React.useMemo(() => { + // capped to square or shorter + const ratio = Math.min(1 / aspectRatio, 1) + return `${ratio * 100}%` }, [aspectRatio]) + /** + * Computed as a CSS `aspectRatio` value + */ const innerAspectRatio = React.useMemo(() => { + // max of 3:4 ratio return Math.max(aspectRatio, 0.75) }, [aspectRatio]) return ( - + {contents} {children} diff --git a/src/view/com/util/images/Gallery.tsx b/src/view/com/util/images/Gallery.tsx index 9bbb2ac100..7787f7db73 100644 --- a/src/view/com/util/images/Gallery.tsx +++ b/src/view/com/util/images/Gallery.tsx @@ -7,7 +7,7 @@ import {useLingui} from '@lingui/react' import {isWeb} from '#/platform/detection' import {useLargeAltBadgeEnabled} from '#/state/preferences/large-alt-badge' -import {atoms as a} from '#/alf' +import {atoms as a, useTheme} from '#/alf' type EventFunction = (index: number) => void @@ -28,6 +28,7 @@ export const GalleryItem: FC = ({ onPressIn, onLongPress, }) => { + const t = useTheme() const {_} = useLingui() const largeAltBadge = useLargeAltBadgeEnabled() const image = images[index] @@ -37,13 +38,19 @@ export const GalleryItem: FC = ({ onPress={onPress ? () => onPress(index) : undefined} onPressIn={onPressIn ? () => onPressIn(index) : undefined} onLongPress={onLongPress ? () => onLongPress(index) : undefined} - style={a.flex_1} + style={[ + a.flex_1, + a.rounded_xs, + a.overflow_hidden, + t.atoms.bg_contrast_25, + imageStyle, + ]} accessibilityRole="button" accessibilityLabel={image.alt || _(msg`Image`)} accessibilityHint="">