mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-11 02:30:41 +08:00
Implement multi-source Images on iOS
Summary: Mirrors Android's support for multiple sources for Image, allowing us to fetch new images as the size of the view changes. Reviewed By: mmmulani Differential Revision: D3615134 fbshipit-source-id: 3d0bf2b75f63a4379e0e49f2dab9aea351b31d5f
This commit is contained in:
committed by
Facebook Github Bot 2
parent
7e2e0deeb0
commit
fd48bc3cff
@@ -13,44 +13,48 @@
|
||||
|
||||
const PropTypes = require('react/lib/ReactPropTypes');
|
||||
|
||||
const ImageURISourcePropType = PropTypes.shape({
|
||||
/**
|
||||
* `uri` is a string representing the resource identifier for the image, which
|
||||
* could be an http address, a local file path, or the name of a static image
|
||||
* resource (which should be wrapped in the `require('./path/to/image.png')`
|
||||
* function).
|
||||
*/
|
||||
uri: PropTypes.string,
|
||||
/**
|
||||
* `method` is the HTTP Method to use. Defaults to GET if not specified.
|
||||
*/
|
||||
method: PropTypes.string,
|
||||
/**
|
||||
* `headers` is an object representing the HTTP headers to send along with the
|
||||
* request for a remote image.
|
||||
*/
|
||||
headers: PropTypes.objectOf(PropTypes.string),
|
||||
/**
|
||||
* `body` is the HTTP body to send with the request. This must be a valid
|
||||
* UTF-8 string, and will be sent exactly as specified, with no
|
||||
* additional encoding (e.g. URL-escaping or base64) applied.
|
||||
*/
|
||||
body: PropTypes.string,
|
||||
/**
|
||||
* `width` and `height` can be specified if known at build time, in which case
|
||||
* these will be used to set the default `<Image/>` component dimensions.
|
||||
*/
|
||||
width: PropTypes.number,
|
||||
height: PropTypes.number,
|
||||
/**
|
||||
* `scale` is used to indicate the scale factor of the image. Defaults to 1.0 if
|
||||
* unspecified, meaning that one image pixel equates to one display point / DIP.
|
||||
*/
|
||||
scale: PropTypes.number,
|
||||
});
|
||||
|
||||
const ImageSourcePropType = PropTypes.oneOfType([
|
||||
PropTypes.shape({
|
||||
/**
|
||||
* `uri` is a string representing the resource identifier for the image, which
|
||||
* could be an http address, a local file path, or the name of a static image
|
||||
* resource (which should be wrapped in the `require('./path/to/image.png')`
|
||||
* function).
|
||||
*/
|
||||
uri: PropTypes.string,
|
||||
/**
|
||||
* `method` is the HTTP Method to use. Defaults to GET if not specified.
|
||||
*/
|
||||
method: PropTypes.string,
|
||||
/**
|
||||
* `headers` is an object representing the HTTP headers to send along with the
|
||||
* request for a remote image.
|
||||
*/
|
||||
headers: PropTypes.objectOf(PropTypes.string),
|
||||
/**
|
||||
* `body` is the HTTP body to send with the request. This must be a valid
|
||||
* UTF-8 string, and will be sent exactly as specified, with no
|
||||
* additional encoding (e.g. URL-escaping or base64) applied.
|
||||
*/
|
||||
body: PropTypes.string,
|
||||
/**
|
||||
* `width` and `height` can be specified if known at build time, in which case
|
||||
* these will be used to set the default `<Image/>` component dimensions.
|
||||
*/
|
||||
width: PropTypes.number,
|
||||
height: PropTypes.number,
|
||||
/**
|
||||
* `scale` is used to indicate the scale factor of the image. Defaults to 1.0 if
|
||||
* unspecified, meaning that one image pixel equates to one display point / DIP.
|
||||
*/
|
||||
scale: PropTypes.number,
|
||||
}),
|
||||
ImageURISourcePropType,
|
||||
// Opaque type returned by require('./image.jpg')
|
||||
PropTypes.number,
|
||||
// Multiple sources
|
||||
PropTypes.arrayOf(ImageURISourcePropType),
|
||||
]);
|
||||
|
||||
module.exports = ImageSourcePropType;
|
||||
|
||||
Reference in New Issue
Block a user