Add slideshow

This commit is contained in:
Adolfo Reyna
2023-05-06 22:58:16 -04:00
parent 022fd75fa5
commit 0b57db225d
5 changed files with 1023 additions and 10766 deletions

View File

@@ -2,7 +2,7 @@ import React from 'react';
import SinglePostComponent from '../components/SinglePostComponent';
let SinglePost = ({ route }) => {
console.log(route.params.postid)
//console.log(route.params.postid)
return <SinglePostComponent postId={route.params.postid} />;
};

41
Views/Slideshow.js Normal file
View File

@@ -0,0 +1,41 @@
import React from 'react';
import { StyleSheet, TouchableHighlight, Image, TouchableWithoutFeedback, View } from 'react-native';
let Slideshow = (props) => {
//console.log(route.params.postid)
//return <SinglePostComponent postId={route.params.postid} />;
console.log(props)
const images = props.route.params.images;
[imageIndex, setImageIndex] = React.useState(props.route.params.startIndex);
//images.length
console.log(imageIndex);
console.log(images[imageIndex][1], images.length);
return (
<View
style={{ padding: 10, paddingTop: 20, flex: 1, justifyContent: "center" }}
onTouchStart={e => {
this.touchY = e.nativeEvent.pageY
this.touchX = e.nativeEvent.pageX
}}
onTouchEnd={e => {
if ((this.touchX - e.nativeEvent.pageX > 20) && (images.length - 1 > imageIndex))
setImageIndex(imageIndex + 1)
if ((this.touchX - e.nativeEvent.pageX < -20) && (imageIndex > 0))
setImageIndex(imageIndex - 1)
}}
>
<Image source={{ uri: images[imageIndex][1] }} key={images[imageIndex][1]} style={styles.image} />
</View>
)
};
const styles = StyleSheet.create({
image: {
width: "100%",
height: "100%",
resizeMode: "contain",
},
});
export default Slideshow;