about summary refs log tree commit diff
path: root/src/view/com/util/images/ImageHorzList.tsx
blob: bade2a44460baa2ed215c799e6f6ecfc9fbcd3a8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React from 'react'
import {StyleProp, StyleSheet, View, ViewStyle} from 'react-native'
import {Image} from 'expo-image'
import {AppBskyEmbedImages} from '@atproto/api'
import {Trans} from '@lingui/macro'

import {atoms as a} from '#/alf'
import {Text} from '#/components/Typography'

interface Props {
  images: AppBskyEmbedImages.ViewImage[]
  style?: StyleProp<ViewStyle>
  gif?: boolean
}

export function ImageHorzList({images, style, gif}: Props) {
  return (
    <View style={[a.flex_row, a.gap_xs, style]}>
      {images.map(({thumb, alt}) => (
        <View
          key={thumb}
          style={[a.relative, a.flex_1, {aspectRatio: 1, maxWidth: 100}]}>
          <Image
            key={thumb}
            source={{uri: thumb}}
            style={[a.flex_1, a.rounded_xs]}
            accessible={true}
            accessibilityIgnoresInvertColors
            accessibilityHint={alt}
            accessibilityLabel=""
          />
          {gif && (
            <View style={styles.altContainer}>
              <Text style={styles.alt}>
                <Trans>GIF</Trans>
              </Text>
            </View>
          )}
        </View>
      ))}
    </View>
  )
}

const styles = StyleSheet.create({
  altContainer: {
    backgroundColor: 'rgba(0, 0, 0, 0.75)',
    borderRadius: 6,
    paddingHorizontal: 6,
    paddingVertical: 3,
    position: 'absolute',
    right: 5,
    bottom: 5,
    zIndex: 2,
  },
  alt: {
    color: 'white',
    fontSize: 7,
    fontWeight: 'bold',
  },
})