import React, {ComponentProps, FC} from 'react' import {Pressable, View} from 'react-native' import {Image} from 'expo-image' import {AppBskyEmbedImages} from '@atproto/api' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useLargeAltBadgeEnabled} from '#/state/preferences/large-alt-badge' import {PostEmbedViewContext} from '#/view/com/util/post-embeds/types' import {atoms as a, useTheme} from '#/alf' import {MediaInsetBorder} from '#/components/MediaInsetBorder' import {Text} from '#/components/Typography' type EventFunction = (index: number) => void interface GalleryItemProps { images: AppBskyEmbedImages.ViewImage[] index: number onPress?: EventFunction onLongPress?: EventFunction onPressIn?: EventFunction imageStyle?: ComponentProps['style'] viewContext?: PostEmbedViewContext } export const GalleryItem: FC = ({ images, index, imageStyle, onPress, onPressIn, onLongPress, viewContext, }) => { const t = useTheme() const {_} = useLingui() const largeAltBadge = useLargeAltBadgeEnabled() const image = images[index] const hasAlt = !!image.alt const hideBadges = viewContext === PostEmbedViewContext.FeedEmbedRecordWithMedia return ( onPress(index) : undefined} onPressIn={onPressIn ? () => onPressIn(index) : undefined} onLongPress={onLongPress ? () => onLongPress(index) : undefined} style={[ a.flex_1, a.rounded_sm, a.overflow_hidden, t.atoms.bg_contrast_25, imageStyle, ]} accessibilityRole="button" accessibilityLabel={image.alt || _(msg`Image`)} accessibilityHint=""> {hasAlt && !hideBadges ? ( ALT ) : null} ) }