-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathPhotoZoom.android.js
More file actions
88 lines (79 loc) · 3.02 KB
/
PhotoZoom.android.js
File metadata and controls
88 lines (79 loc) · 3.02 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {requireNativeComponent} from 'react-native';
import ViewPropTypes from 'react-native/Libraries/Components/View/ViewPropTypes';
export default class PhotoZoom extends Component {
static propTypes = {
source: PropTypes.oneOfType([
PropTypes.shape({
uri: PropTypes.string
}),
// Opaque type returned by require('./image.jpg')
PropTypes.number
]),
loadingIndicatorSource: PropTypes.oneOfType([
PropTypes.shape({
uri: PropTypes.string
}),
// Opaque type returned by require('./image.jpg')
PropTypes.number
]),
fadeDuration: PropTypes.number,
minimumZoomScale: PropTypes.number,
maximumZoomScale: PropTypes.number,
scale: PropTypes.number,
androidZoomTransitionDuration: PropTypes.number,
androidScaleType: PropTypes.oneOf(["center", "centerCrop", "centerInside", "fitCenter", "fitStart", "fitEnd", "fitXY", "matrix"]),
onLoadStart: PropTypes.func,
onError: PropTypes.func,
onLoad: PropTypes.func,
onLoadEnd: PropTypes.func,
onTap: PropTypes.func,
onViewTap: PropTypes.func,
onScale: PropTypes.func,
...ViewPropTypes
};
render() {
const source = this.props.source;
var loadingIndicatorSource = this.props.loadingIndicatorSource;
if (source && source.uri === '') {
console.warn('source.uri should not be an empty string');
}
if (this.props.src) {
console.warn('The <PhotoZoom> component requires a `source` property rather than `src`.');
}
if (source && source.uri) {
var {onLoadStart, onLoad, onLoadEnd, onTap, onViewTap, onScale, onError, ...props} = this.props;
var nativeProps = {
onPhotoZoomerError: onError,
onPhotoZoomerLoadStart: onLoadStart,
onPhotoZoomerLoad: onLoad,
onPhotoZoomerLoadEnd: onLoadEnd,
onPhotoZoomerTap: onTap,
onPhotoZoomerViewTap: onViewTap,
onPhotoZoomerScale: onScale,
...props,
shouldNotifyLoadEvents: !!(onLoadStart || onLoad || onLoadEnd || onError),
src: source,
loadingIndicatorSrc: loadingIndicatorSource ? loadingIndicatorSource.uri : null,
};
return <PhotoZoomAndroid {...nativeProps} />
}
return null
}
}
var cfg = {
nativeOnly: {
onPhotoZoomerError: true,
onPhotoZoomerLoadStart: true,
onPhotoZoomerLoad: true,
onPhotoZoomerLoadEnd: true,
onPhotoZoomerTap: true,
onPhotoZoomerViewTap: true,
onPhotoZoomerScale: true,
shouldNotifyLoadEvents: true,
src: true,
loadingIndicatorSrc: true
}
};
const PhotoZoomAndroid = requireNativeComponent('PhotoZoomAndroid', PhotoZoom, cfg);