-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImagePreView.js
57 lines (51 loc) · 1.42 KB
/
ImagePreView.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import React, { Component } from 'react';
import {StyleSheet, Text} from "react-native";
import ImageViewer from 'react-native-image-zoom-viewer';
export default class ImagePreView extends Component {
static navigationOptions = () => ({
title: '图片预览',
headerStyle: {
backgroundColor: '#549cf8',
},
headerTintColor: '#fff',
});
render() {
const { navigation } = this.props;
const urls = navigation.getParam('urls');
const index = navigation.getParam('index');
if (urls === null || urls.length === 0) {
return (
<Text>图片地址错误</Text>
);
}
const images = [];
urls.map(function (item) {
images.push(item.value)
});
return (
<ImageViewer
imageUrls={images} // 照片路径
enableImageZoom={true} // 是否开启手势缩放
onClick={this._clickImage}
style={styles.image}
index={index}
/>
);
}
_clickImage = () => {
this.props.navigation.goBack();
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'black'
},
image: {
width: null,
height: null,
},
});