|
| 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