Swiper/Item.tsx

44 lines
1.0 KiB
TypeScript
Raw Normal View History

2022-12-18 18:32:44 +13:00
import {useState} from 'react'
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'
export default function Item({
value,
onLongPress,
}: {
2022-12-18 18:32:44 +13:00
value: DocumentPickerResponse
onLongPress: () => void
}) {
2022-12-18 18:32:44 +13:00
const [paused, setPaused] = useState(false)
const [width, setWidth] = useState(0)
const height = Dimensions.get('screen').height
return (
2022-12-18 18:32:44 +13:00
<View style={{alignItems: 'center'}}>
<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={{
color: 'white',
}}>
{value.name}
</Text>
</View>
2022-12-18 18:32:44 +13:00
)
}