mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React, {useCallback} from 'react'
2import {Image} from 'expo-image'
3import {msg} from '@lingui/macro'
4import {useLingui} from '@lingui/react'
5
6import {logEvent} from '#/lib/statsig/statsig'
7import {Gif} from '#/state/queries/tenor'
8import {atoms as a, useBreakpoints, useTheme} from '#/alf'
9import {Button} from '../Button'
10
11export function GifPreview({
12 gif,
13 onSelectGif,
14}: {
15 gif: Gif
16 onSelectGif: (gif: Gif) => void
17}) {
18 const {gtTablet} = useBreakpoints()
19 const {_} = useLingui()
20 const t = useTheme()
21
22 const onPress = useCallback(() => {
23 logEvent('composer:gif:select', {})
24 onSelectGif(gif)
25 }, [onSelectGif, gif])
26
27 return (
28 <Button
29 label={_(msg`Select GIF "${gif.title}"`)}
30 style={[a.flex_1, gtTablet ? {maxWidth: '33%'} : {maxWidth: '50%'}]}
31 onPress={onPress}>
32 {({pressed}) => (
33 <Image
34 style={[
35 a.flex_1,
36 a.mb_sm,
37 a.rounded_sm,
38 {aspectRatio: 1, opacity: pressed ? 0.8 : 1},
39 t.atoms.bg_contrast_25,
40 ]}
41 source={{
42 uri: gif.media_formats.tinygif.url,
43 }}
44 contentFit="cover"
45 accessibilityLabel={gif.title}
46 accessibilityHint=""
47 cachePolicy="none"
48 accessibilityIgnoresInvertColors
49 />
50 )}
51 </Button>
52 )
53}