import {useMemo, useState} from 'react'
import {Dimensions, Image, Pressable, Text, View} from 'react-native'
import {DocumentPickerResponse} from 'react-native-document-picker'
import Video from 'react-native-video'
export default function Item({
files,
onLongPress,
selected,
paused,
setPaused,
}: {
files: DocumentPickerResponse[]
onLongPress: () => void
selected: number
paused: boolean
setPaused: (value: boolean) => void
}) {
const [width, setWidth] = useState(0)
const screenHeight = Dimensions.get('screen').height
const file = useMemo(() => files[selected], [files, selected])
const video = (
setPaused(!paused)}>
)
const image = (
setWidth(nativeEvent.source.width)}
/>
)
return (
{file.type?.includes('video') ? video : image}
{file.name} ({selected + 1}/ {files.length})
)
}