ImageShowScreen.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import React, {Component} from 'react';
  2. import {Dimensions, Image, StyleSheet, View, ViewPagerAndroid} from 'react-native';
  3. const {width, height} = Dimensions.get('window');
  4. export default class ImageShowScreen extends Component {
  5. render() {
  6. let data = this.props.navigation.state.params.images;
  7. let index = this.props.navigation.state.params.index;
  8. let pages = [];
  9. if (data != null && data.length > 0) {
  10. for (let i = 0; i < data.length; i++) {
  11. pages.push(
  12. <View key={data[i]} style={{width: width, height: height}}>
  13. <Image resizeMode="contain" style={styles.image} source={{uri: data[i]}}/>
  14. </View>
  15. );
  16. }
  17. }
  18. return (
  19. <View style={styles.container}>
  20. <ViewPagerAndroid initialPage={this.props.navigation.state.params.index} style={styles.viewPager}>
  21. {pages}
  22. </ViewPagerAndroid>
  23. </View>
  24. );
  25. }
  26. }
  27. const styles = StyleSheet.create({
  28. container: {
  29. flex: 1,
  30. flexDirection: 'column',
  31. justifyContent: 'center',
  32. alignItems: 'center',
  33. backgroundColor: '#000000',
  34. },
  35. image: {
  36. flex: 1,
  37. width: width
  38. },
  39. viewPager: {
  40. width: width,
  41. height: height
  42. }
  43. })