2022-12-18 18:32:44 +13:00
|
|
|
import {useState} from 'react'
|
2022-12-18 19:55:56 +13:00
|
|
|
import {Dimensions, Pressable, Text, View} from 'react-native'
|
2022-12-18 18:32:44 +13:00
|
|
|
import {DocumentPickerResponse} from 'react-native-document-picker'
|
|
|
|
import Video from 'react-native-video'
|
2022-12-15 16:31:35 +13:00
|
|
|
|
|
|
|
export default function Item({
|
|
|
|
value,
|
2022-12-18 19:55:56 +13:00
|
|
|
onLongPress,
|
2022-12-15 16:31:35 +13:00
|
|
|
}: {
|
2022-12-18 18:32:44 +13:00
|
|
|
value: DocumentPickerResponse
|
2022-12-18 19:55:56 +13:00
|
|
|
onLongPress: () => void
|
2022-12-15 16:31:35 +13:00
|
|
|
}) {
|
2022-12-18 18:32:44 +13:00
|
|
|
const [paused, setPaused] = useState(false)
|
|
|
|
const [width, setWidth] = useState(0)
|
2022-12-15 16:31:35 +13:00
|
|
|
|
2022-12-18 19:55:56 +13:00
|
|
|
const height = Dimensions.get('screen').height
|
|
|
|
|
2022-12-15 16:31:35 +13:00
|
|
|
return (
|
2022-12-18 18:32:44 +13:00
|
|
|
<View style={{alignItems: 'center'}}>
|
2022-12-18 19:55:56 +13:00
|
|
|
<Pressable onLongPress={onLongPress} onPress={() => setPaused(!paused)}>
|
|
|
|
<Video
|
|
|
|
paused={paused}
|
|
|
|
style={{
|
|
|
|
height: height - height * 0.25,
|
|
|
|
width,
|
|
|
|
alignItems: 'center',
|
|
|
|
}}
|
|
|
|
source={{uri: value.uri}}
|
|
|
|
resizeMode="contain"
|
|
|
|
onLoad={response => {
|
|
|
|
setWidth(response.naturalSize.width)
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Pressable>
|
|
|
|
<Text
|
2022-12-18 18:32:44 +13:00
|
|
|
style={{
|
2022-12-18 19:55:56 +13:00
|
|
|
color: 'white',
|
|
|
|
}}>
|
|
|
|
{value.name}
|
|
|
|
</Text>
|
2022-12-15 16:31:35 +13:00
|
|
|
</View>
|
2022-12-18 18:32:44 +13:00
|
|
|
)
|
2022-12-15 16:31:35 +13:00
|
|
|
}
|