import React from "react";
import {
StyleSheet,
Dimensions,
ScrollView,
Image,
Animated,
Platform
} from "react-native";
import { Block, theme } from "galio-framework";
import { HeaderHeight } from "../constants/utils";
const { width } = Dimensions.get("window");
export default class Gallery extends React.Component {
scrollX = new Animated.Value(0);
renderGallery = () => {
const { navigation, route } = this.props;
const { images, index } = route.params;
return (
{images.map((image, key) => (
))}
);
};
renderProgress = () => {
const { navigation, route } = this.props;
const { images, index } = route.params;
const position = Animated.divide(this.scrollX, width);
return (
{images.map((_, i) => {
const opacity = position.interpolate({
inputRange: [i - 1, i, i + 1],
outputRange: [0.5, 1, 0.5],
extrapolate: "clamp"
});
const width = position.interpolate({
inputRange: [i - 1, i, i + 1],
outputRange: [8, 18, 8],
extrapolate: "clamp"
});
return (
);
})}
);
};
render() {
return (
{this.renderGallery()}
{this.renderProgress()}
);
}
}
const styles = StyleSheet.create({
gallery: {
backgroundColor: theme.COLORS.BLACK,
marginTop: Platform.OS === "android" ? -HeaderHeight : 0
},
galleryImage: {
width: width,
height: "auto"
},
dots: {
height: 8,
margin: 8,
borderRadius: 4,
backgroundColor: "white"
},
dotsContainer: {
position: "absolute",
bottom: theme.SIZES.BASE * 3,
left: 0,
right: 0
}
});