Skip to content

Commit 6765699

Browse files
elicwhitefacebook-github-bot
authored andcommitted
Move Image PropTypes to a new file
Reviewed By: yungsters Differential Revision: D7270058 fbshipit-source-id: 91ad7700b7e89c393c6977bfd82494d2febda4a4
1 parent 7ce943e commit 6765699

File tree

2 files changed

+136
-116
lines changed

2 files changed

+136
-116
lines changed

Libraries/Image/Image.ios.js

+2-116
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
'use strict';
1212

1313
const EdgeInsetsPropType = require('EdgeInsetsPropType');
14+
const ImageProps = require('ImageProps');
1415
const ImageResizeMode = require('ImageResizeMode');
1516
const ImageSourcePropType = require('ImageSourcePropType');
1617
const ImageStylePropTypes = require('ImageStylePropTypes');
@@ -38,122 +39,7 @@ const ImageViewManager = NativeModules.ImageViewManager;
3839
*/
3940
const Image = createReactClass({
4041
displayName: 'Image',
41-
propTypes: {
42-
/**
43-
* See https://facebook.github.io/react-native/docs/image.html#style
44-
*/
45-
style: StyleSheetPropType(ImageStylePropTypes),
46-
/**
47-
* The image source (either a remote URL or a local file resource).
48-
*
49-
* See https://facebook.github.io/react-native/docs/image.html#source
50-
*/
51-
source: ImageSourcePropType,
52-
/**
53-
* A static image to display while loading the image source.
54-
*
55-
* See https://facebook.github.io/react-native/docs/image.html#defaultsource
56-
*/
57-
defaultSource: PropTypes.oneOfType([
58-
PropTypes.shape({
59-
uri: PropTypes.string,
60-
width: PropTypes.number,
61-
height: PropTypes.number,
62-
scale: PropTypes.number,
63-
}),
64-
PropTypes.number,
65-
]),
66-
/**
67-
* When true, indicates the image is an accessibility element.
68-
*
69-
* See https://facebook.github.io/react-native/docs/image.html#accessible
70-
*/
71-
accessible: PropTypes.bool,
72-
/**
73-
* The text that's read by the screen reader when the user interacts with
74-
* the image.
75-
*
76-
* See https://facebook.github.io/react-native/docs/image.html#accessibilitylabel
77-
*/
78-
accessibilityLabel: PropTypes.node,
79-
/**
80-
* blurRadius: the blur radius of the blur filter added to the image
81-
*
82-
* See https://facebook.github.io/react-native/docs/image.html#blurradius
83-
*/
84-
blurRadius: PropTypes.number,
85-
/**
86-
* See https://facebook.github.io/react-native/docs/image.html#capinsets
87-
*/
88-
capInsets: EdgeInsetsPropType,
89-
/**
90-
* See https://facebook.github.io/react-native/docs/image.html#resizemethod
91-
*/
92-
resizeMethod: PropTypes.oneOf(['auto', 'resize', 'scale']),
93-
/**
94-
* Determines how to resize the image when the frame doesn't match the raw
95-
* image dimensions.
96-
*
97-
* See https://facebook.github.io/react-native/docs/image.html#resizemode
98-
*/
99-
resizeMode: PropTypes.oneOf([
100-
'cover',
101-
'contain',
102-
'stretch',
103-
'repeat',
104-
'center',
105-
]),
106-
/**
107-
* A unique identifier for this element to be used in UI Automation
108-
* testing scripts.
109-
*
110-
* See https://facebook.github.io/react-native/docs/image.html#testid
111-
*/
112-
testID: PropTypes.string,
113-
/**
114-
* Invoked on mount and layout changes with
115-
* `{nativeEvent: {layout: {x, y, width, height}}}`.
116-
*
117-
* See https://facebook.github.io/react-native/docs/image.html#onlayout
118-
*/
119-
onLayout: PropTypes.func,
120-
/**
121-
* Invoked on load start.
122-
*
123-
* See https://facebook.github.io/react-native/docs/image.html#onloadstart
124-
*/
125-
onLoadStart: PropTypes.func,
126-
/**
127-
* Invoked on download progress with `{nativeEvent: {loaded, total}}`.
128-
*
129-
* See https://facebook.github.io/react-native/docs/image.html#onprogress
130-
*/
131-
onProgress: PropTypes.func,
132-
/**
133-
* Invoked on load error with `{nativeEvent: {error}}`.
134-
*
135-
* See https://facebook.github.io/react-native/docs/image.html#onerror
136-
*/
137-
onError: PropTypes.func,
138-
/**
139-
* Invoked when a partial load of the image is complete.
140-
*
141-
* See https://facebook.github.io/react-native/docs/image.html#onpartialload
142-
*/
143-
onPartialLoad: PropTypes.func,
144-
/**
145-
* Invoked when load completes successfully.
146-
*
147-
* See https://facebook.github.io/react-native/docs/image.html#onload
148-
*/
149-
onLoad: PropTypes.func,
150-
/**
151-
* Invoked when load either succeeds or fails.
152-
*
153-
* See https://facebook.github.io/react-native/docs/image.html#onloadend
154-
*/
155-
onLoadEnd: PropTypes.func,
156-
},
42+
propTypes: ImageProps,
15743

15844
statics: {
15945
resizeMode: ImageResizeMode,

Libraries/Image/ImageProps.js

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @providesModule ImageProps
8+
* @flow
9+
*/
10+
11+
'use strict';
12+
13+
const EdgeInsetsPropType = require('EdgeInsetsPropType');
14+
const ImageSourcePropType = require('ImageSourcePropType');
15+
const ImageStylePropTypes = require('ImageStylePropTypes');
16+
const PropTypes = require('prop-types');
17+
const StyleSheetPropType = require('StyleSheetPropType');
18+
19+
module.exports = {
20+
/**
21+
* See https://facebook.github.io/react-native/docs/image.html#style
22+
*/
23+
style: StyleSheetPropType(ImageStylePropTypes),
24+
/**
25+
* The image source (either a remote URL or a local file resource).
26+
*
27+
* See https://facebook.github.io/react-native/docs/image.html#source
28+
*/
29+
source: ImageSourcePropType,
30+
/**
31+
* A static image to display while loading the image source.
32+
*
33+
* See https://facebook.github.io/react-native/docs/image.html#defaultsource
34+
*/
35+
defaultSource: PropTypes.oneOfType([
36+
PropTypes.shape({
37+
uri: PropTypes.string,
38+
width: PropTypes.number,
39+
height: PropTypes.number,
40+
scale: PropTypes.number,
41+
}),
42+
PropTypes.number,
43+
]),
44+
/**
45+
* When true, indicates the image is an accessibility element.
46+
*
47+
* See https://facebook.github.io/react-native/docs/image.html#accessible
48+
*/
49+
accessible: PropTypes.bool,
50+
/**
51+
* The text that's read by the screen reader when the user interacts with
52+
* the image.
53+
*
54+
* See https://facebook.github.io/react-native/docs/image.html#accessibilitylabel
55+
*/
56+
accessibilityLabel: PropTypes.node,
57+
/**
58+
* blurRadius: the blur radius of the blur filter added to the image
59+
*
60+
* See https://facebook.github.io/react-native/docs/image.html#blurradius
61+
*/
62+
blurRadius: PropTypes.number,
63+
/**
64+
* See https://facebook.github.io/react-native/docs/image.html#capinsets
65+
*/
66+
capInsets: EdgeInsetsPropType,
67+
/**
68+
* See https://facebook.github.io/react-native/docs/image.html#resizemethod
69+
*/
70+
resizeMethod: PropTypes.oneOf(['auto', 'resize', 'scale']),
71+
/**
72+
* Determines how to resize the image when the frame doesn't match the raw
73+
* image dimensions.
74+
*
75+
* See https://facebook.github.io/react-native/docs/image.html#resizemode
76+
*/
77+
resizeMode: PropTypes.oneOf([
78+
'cover',
79+
'contain',
80+
'stretch',
81+
'repeat',
82+
'center',
83+
]),
84+
/**
85+
* A unique identifier for this element to be used in UI Automation
86+
* testing scripts.
87+
*
88+
* See https://facebook.github.io/react-native/docs/image.html#testid
89+
*/
90+
testID: PropTypes.string,
91+
/**
92+
* Invoked on mount and layout changes with
93+
* `{nativeEvent: {layout: {x, y, width, height}}}`.
94+
*
95+
* See https://facebook.github.io/react-native/docs/image.html#onlayout
96+
*/
97+
onLayout: PropTypes.func,
98+
/**
99+
* Invoked on load start.
100+
*
101+
* See https://facebook.github.io/react-native/docs/image.html#onloadstart
102+
*/
103+
onLoadStart: PropTypes.func,
104+
/**
105+
* Invoked on download progress with `{nativeEvent: {loaded, total}}`.
106+
*
107+
* See https://facebook.github.io/react-native/docs/image.html#onprogress
108+
*/
109+
onProgress: PropTypes.func,
110+
/**
111+
* Invoked on load error with `{nativeEvent: {error}}`.
112+
*
113+
* See https://facebook.github.io/react-native/docs/image.html#onerror
114+
*/
115+
onError: PropTypes.func,
116+
/**
117+
* Invoked when a partial load of the image is complete.
118+
*
119+
* See https://facebook.github.io/react-native/docs/image.html#onpartialload
120+
*/
121+
onPartialLoad: PropTypes.func,
122+
/**
123+
* Invoked when load completes successfully.
124+
*
125+
* See https://facebook.github.io/react-native/docs/image.html#onload
126+
*/
127+
onLoad: PropTypes.func,
128+
/**
129+
* Invoked when load either succeeds or fails.
130+
*
131+
* See https://facebook.github.io/react-native/docs/image.html#onloadend
132+
*/
133+
onLoadEnd: PropTypes.func,
134+
};

0 commit comments

Comments
 (0)