about summary refs log tree commit diff
path: root/src/view/com/lightbox/Images.tsx
blob: 7179f0887a7c143ac703d6f554c985f834d3aa2b (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
import React from 'react'
import {Image, StyleSheet, useWindowDimensions, View} from 'react-native'

export function Component({
  uris,
  index,
  isZooming,
}: {
  uris: string[]
  index: number
  isZooming: boolean
}) {
  const winDim = useWindowDimensions()
  const left = index * winDim.width * -1
  return (
    <View style={[styles.container, {left}]}>
      {uris.map((uri, i) => (
        <Image
          key={i}
          style={[
            styles.image,
            {left: i * winDim.width},
            isZooming && i !== index ? {opacity: 0} : undefined,
          ]}
          source={{uri}}
        />
      ))}
    </View>
  )
}

const styles = StyleSheet.create({
  container: {
    position: 'absolute',
    top: 0,
    left: 0,
    width: '100%',
  },
  image: {
    position: 'absolute',
    top: 200,
    left: 0,
    resizeMode: 'contain',
    width: '100%',
    aspectRatio: 1,
  },
})