-
Notifications
You must be signed in to change notification settings - Fork 51
/
index.android.js
49 lines (43 loc) · 1.22 KB
/
index.android.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
import React,{Component,PropTypes} from 'react';
import {
requireNativeComponent,
View,
} from 'react-native';
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
export default class ImageViewZoom extends Component {
static propTypes = {
...View.propTypes,
source: PropTypes.oneOfType([
PropTypes.shape({
uri: PropTypes.string,
thumbnail: PropTypes.string,
headers: PropTypes.object,
}),
// Opaque type returned by require('./image.jpg')
PropTypes.number,
]),
scale: PropTypes.number,
scaleType: PropTypes.oneOf(["center","centerCrop","centerInside","fitCenter","fitStart","fitEnd","fitXY","matrix"]),
onTap : PropTypes.func,
onLoad : PropTypes.func,
onScaleChange : PropTypes.func,
onMatrixChange : PropTypes.func,
};
constructor(props) {
super(props);
}
render() {
const source = resolveAssetSource(this.props.source);
if (source && source.uri){
const props = {...this.props, src: source };
return <ZoomImage {...props} />;
}
return null
}
}
const cfg = {
nativeOnly: {
src: true,
},
};
const ZoomImage = requireNativeComponent('ImageViewZoom', ImageViewZoom, cfg);