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.
This commit is contained in:
@@ -1,35 +1,43 @@
|
||||
import {useState} from 'react'
|
||||
import {Dimensions, View} from 'react-native'
|
||||
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({
|
||||
slide,
|
||||
value,
|
||||
index,
|
||||
onLongPress,
|
||||
}: {
|
||||
slide: number
|
||||
value: DocumentPickerResponse
|
||||
index: number
|
||||
onLongPress: () => void
|
||||
}) {
|
||||
const [paused, setPaused] = useState(false)
|
||||
const [width, setWidth] = useState(0)
|
||||
|
||||
const height = Dimensions.get('screen').height
|
||||
|
||||
return (
|
||||
<View style={{alignItems: 'center'}}>
|
||||
<Video
|
||||
paused={slide !== index}
|
||||
<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={{
|
||||
height: Dimensions.get('screen').height - 125,
|
||||
width,
|
||||
alignItems: 'center',
|
||||
}}
|
||||
source={{uri: value.uri}}
|
||||
resizeMode="contain"
|
||||
onLoad={response => {
|
||||
setWidth(response.naturalSize.width)
|
||||
}}
|
||||
/>
|
||||
color: 'white',
|
||||
}}>
|
||||
{value.name}
|
||||
</Text>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user