diff --git a/ImageSlider.js b/ImageSlider.js index 965741d..6f66b5c 100644 --- a/ImageSlider.js +++ b/ImageSlider.js @@ -25,6 +25,8 @@ type Slide = { type PropsType = { images: Array, + startString: string, + imageKey: string, style?: any, loop?: boolean, loopBothSides?: boolean, @@ -185,25 +187,25 @@ class ImageSlider extends Component { _renderImage = (image: any, index: number) => { const { width } = Dimensions.get('window'); - const { onPress, customSlide } = this.props; + const { onPress, customSlide, startString = '', imageKey = '', imageStyle={}, resizeMode='cover' } = this.props; const offset = { marginLeft: index === -1 ? -width : 0 }; - const imageStyle = [styles.image, { width }, offset]; + const imgStyle = [styles.image, { width }, offset, imageStyle]; if (customSlide) { - return customSlide({ item: image, style: imageStyle, index, width }); + return customSlide({ item: image, style: imgStyle, index, width }); } - const imageObject = typeof image === 'string' ? { uri: image } : image; + const imageObject = typeof image === 'string' ? image.includes('file:/') ? { uri: image } : { uri: startString + image } : typeof image === 'object' ? { uri: startString + image[imageKey] } : image; const imageComponent = ( - + ); if (onPress) { return ( onPress && onPress({ image, index })} delayPressIn={200} > @@ -294,7 +296,6 @@ const styles = StyleSheet.create({ backgroundColor: '#222', }, image: { - width: 200, height: '100%', }, buttons: {