Swiper/Item.tsx
Brandon Presley 73c1dc3c2b Use buttons instead of swiping
I had so much trouble with both react-native-swiper
and the app slider intro libraries. I would like to be able
to swipe between videos but will settle with this for now.
2022-12-18 19:55:56 +13:00

44 lines
1.0 KiB
TypeScript

import {useState} from 'react'
import {Dimensions, Pressable, Text, View} from 'react-native'
import {DocumentPickerResponse} from 'react-native-document-picker'
import Video from 'react-native-video'
export default function Item({
value,
onLongPress,
}: {
value: DocumentPickerResponse
onLongPress: () => void
}) {
const [paused, setPaused] = useState(false)
const [width, setWidth] = useState(0)
const height = Dimensions.get('screen').height
return (
<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
style={{
color: 'white',
}}>
{value.name}
</Text>
</View>
)
}