react-native/Libraries/Image/Image.ios.js

175 lines
5.4 KiB
JavaScript
Raw Normal View History

2015-01-30 01:10:49 +00:00
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
2015-01-30 01:10:49 +00:00
*
* @providesModule Image
Update from Friday March 27 - [React Native] Sync from github | Amjad Masad - [react-packager] Watch asset roots for changes to update dependency graph | Amjad Masad - Fix sourceTree of RCTActionSheet.xcodeproj | Alex Kotliarskyi - Cancel contents animation before setting new contents in RCTNetworkImageView | Alex Akers - [react-packager] move dependencies to root package.json | Amjad Masad - Fix font crash on iOS < 8.2 | Nick Lockwood - [react-packager] Fix node v0.11.14 query parse bug | Amjad Masad - [ReactNative][Docs] Remove references to ReactNavigator from docs | Tadeu Zagallo - [CLI] react-native start won't run from dir with spaces | Amjad Masad - Revert .buckversion bumps. | Jakub Zika - [react_native] Update default bundle name to org.reactjs.native.* | Krzysztof Magiera - [react-packager] better error when main file not found | Amjad Masad - [React Kit] Remove embarrassing TODOs | Alex Akers - [ReactNative][MAdMan] Clean up after D1942269 | Philipp von Weitershausen - flowify a few more Libraries | Basil Hosmer - [ReactNative] PushNotificationIOS documentation | Eric Vicenti - [ReactNative][CustomComponents] Update old headers | Tadeu Zagallo - [ReactNative] UIViewControllerBasedStatusBarAppearance = NO in SampleApp | Alex Kotliarskyi - [React Native] Fix CocoaPods spec | Alex Akers - [ReactNative] Navigator Example Overhaul | Eric Vicenti - [React Native] Fix incorrect if-statement in RCTGeolocation | Alex Akers - [ReactNative] s/ReactKit/React/g | Tadeu Zagallo - [React Native] [FRC - Don't accept] View border support | Nick Lockwood - [Assets] Allow scripts to override assetRoots | Amjad Masad - [ReactNative] Navigator docs | Eric Vicenti - [ReactNative] License headers and renaming | Eric Vicenti - [React Native] Add CocoaPods spec | Tadeu Zagallo - Added explicit types for all view properties | Nick Lockwood - [ReactNative] s/ReactNavigator/Navigator/ | Tadeu Zagallo - [ReactNative] Add copyright header for code copied from the jQuery UI project | Martin Konicek - [ReactNative] PanResponder documentation | Eric Vicenti - [ReactNative] Add deep linking api | Tadeu Zagallo - [ReactNative] Add gitignore example for SampleApp | Alex Kotliarskyi - [ReactNative] Add react-native-start bin to react-native packge | Alex Kotliarskyi - [ReactNative] Update package.json to be npm-ready | Christopher Chedeau - [RFC][ReactNative] Integrate dev menu directly into RootView | Alex Kotliarskyi - flowify Libraries/ReactIOS | Marshall Roch - [WIP] Added support for italics and additional font weights | Nick Lockwood - [ReactNative] Improve View documentation | Christopher Chedeau - [react-packager] Readme | Amjad Masad - Fix for incorrect contentSize reported by RCTScrollView | Nick Lockwood - [ReactNative] Flow and doc formatting for NetInfo | Eric Vicenti - [ReactNative] Document AppStateIOS | Eric Vicenti - [MAdMan][Android] Make things look more Androidy | Philipp von Weitershausen - flowified Libraries from Avik | Basil Hosmer - flowify some Libraries | Basil Hosmer - [ReactKit] Add shake development menu | Alex Kotliarskyi - [ReactNative] Add debugger and change SampleApp files structure | Alex Kotliarskyi - Flowify ReactIOSEventEmitter | Marshall Roch - [react_native] JS files from D1941151: Allow fontWeight to be 100,200,...,900 | Krzysztof Magiera - [ReactNative] Add snapshot tests for examples | Spencer Ahrens - [ReactNative] bring back some native modules | Spencer Ahrens - [ReactNative] Rename JSNavigationStack to ReactNavigator, rename scene config | Eric Vicenti - [ReactNative] cleanup view example | Spencer Ahrens - Flowify a bunch of Libraries | Marshall Roch - [ReactNative] JSNavigationStack - Use key to blow away old scenes | Eric Vicenti - [ReactNative] Add more logging to RCTJSONParse | Sumeet Vaidya - Unfork UIManager | Nick Lockwood - [react-packager] kill non-standard RAW_SOURCE_MAP | Amjad Masad - Flowify Libraries/StyleSheet and Libraries/Text | Marshall Roch - [ReactNative] Fix OSS Dependency Issues | Eric Vicenti - [react-packager] Fix more issues with node modules | Amjad Masad - [ReactNative] rename navigationOperations to navigator | Eric Vicenti - JS files from D1936817: Add to XMLHttpRequest android and share code with ios | Olivia Bishop - flowify some Libraries | Basil Hosmer - last batch of UIExplorer flowification | Basil Hosmer - [ReactNative] JSNavigationStack rename routeMapper to renderSceneForRoute | Eric Vicenti - Flowify renderApplication | Marshall Roch - [ReactNative] OSS Responder example | Eric Vicenti - [ReactNative] Use oss TimerMixin | Tadeu Zagallo - [ReactNative] Remove auto permission request from setAppIconBadgeNumber | Tadeu Zagallo - [ReactNative] OSS snapshot tests | Spencer Ahrens - [ReactNative] OSS JSNavigationStack w/ Examples | Eric Vicenti - Fix build - remove relative import path | Jakub Zika - Bump .buckversion to a5b8b8ef45d714018ba3542cf98d48ef6aab7088. | Jakub Zika - [ReactNative] Open Source PushNotifications and move Badge Number methods and permission into it | Tadeu Zagallo - [react-packager] Fix regression with transform errors | Amjad Masad - Flowify TextStylePropTypes and fix a bug with unsupported props | Marshall Roch - [ReactNative] Remove `arc build` instructions from require | Alex Kotliarskyi - Flowify Library/Utilities/ | Marshall Roch - [react-packager] Default to index.js from main if it's a dir | Amjad Masad - [ReactNative] Use deprecated ix in TabBarExample | Amjad Masad - [ReactNative] Expanded license on obj-c files | Christopher Chedeau - [ReactNative] Expanded license on js files | Christopher Chedeau - [ReactNative] Fix React Devtools integration | Alex Kotliarskyi - [Text] Account for font leading so descenders are not clipped | Alex Kotliarskyi - [ReactNative] Expanded license on js packager files | Christopher Chedeau - more UIExplorer flow | Basil Hosmer - [react-packager] Pick up package changes while running | Amjad Masad - Added a graph view and a ReactNative metric that displays current queue and execution time for the JS thread. | Bryce Redd - [ReactNative] Add NativeModules and DeviceEventEmitter to react-native exports | Alex Kotliarskyi - [React Native] Fix iOS 7 crashes b/c missing Photos.fmwk | Alex Akers - UIExplorer flowification | Basil Hosmer - Add clearImmediate module | Marshall Roch - [ReactNative] Print directories packager is serving files from | Alex Kotliarskyi - Work around flow bug with exports | Marshall Roch - [ReactNative] Move packager/init.sh to GitHub | Alex Kotliarskyi - [ReactNative] Remove react-native/package.json | Christopher Chedeau - [ReactNative] Returning actual contentSize for RCTScrollViewManager | Henry Lung - declare timeoutID | Basil Hosmer - [ReactNative] Add root package.json name back | Tadeu Zagallo - [react-packager] Allow entry point extensions like .ios.js | Amjad Masad - [react-native] Use SpreadProperty to make react-docgen happy | Felix Kling - clean Examples/2048 | Basil Hosmer - [ReactNative] Adjust packager default root when running from within node_modules | Alex Kotliarskyi - [ReactNative] Add missing websocket dependency | Alex Kotliarskyi - [react-packager] change all but one `ix` to `require` | Amjad Masad - [react-packager] Make sure projectRoots is converted to an array | Amjad Masad - [ReactNative] Init script that bootstraps new Xcode project | Alex Kotliarskyi - [ReactNative] New SampleApp | Alex Kotliarskyi - [ReactNative] Touchable invoke press on longPress when longPress handler missing | Eric Vicenti - [ReactNative] Commit missing RCTWebSocketDebugger.xcodeproj | Alex Kotliarskyi
2015-03-27 18:46:17 +00:00
* @flow
2015-01-30 01:10:49 +00:00
*/
'use strict';
var EdgeInsetsPropType = require('EdgeInsetsPropType');
var NativeMethodsMixin = require('NativeMethodsMixin');
var NativeModules = require('NativeModules');
2015-01-30 01:10:49 +00:00
var PropTypes = require('ReactPropTypes');
var ImageResizeMode = require('ImageResizeMode');
var ImageStylePropTypes = require('ImageStylePropTypes');
var React = require('React');
var ReactIOSViewAttributes = require('ReactIOSViewAttributes');
var StyleSheet = require('StyleSheet');
var StyleSheetPropType = require('StyleSheetPropType');
var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentClass');
var flattenStyle = require('flattenStyle');
var insetsDiffer = require('insetsDiffer');
var invariant = require('invariant');
var merge = require('merge');
var warning = require('warning');
/**
* A react component for displaying different types of images,
2015-01-30 01:10:49 +00:00
* including network images, static resources, temporary local images, and
* images from local disk, such as the camera roll.
2015-01-30 01:10:49 +00:00
*
* Example usage:
2015-01-30 01:10:49 +00:00
*
* ```
* renderImages: function() {
* return (
* <View>
* <Image
* style={styles.icon}
* source={require('image!myIcon')}
* />
* <Image
* style={styles.logo}
* source={{uri: 'http://facebook.github.io/react/img/logo_og.png'}}
* />
* </View>
* );
* },
* ```
2015-01-30 01:10:49 +00:00
*/
var Image = React.createClass({
propTypes: {
/**
* `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 `required('image!name')` function).
*/
source: PropTypes.shape({
uri: PropTypes.string,
}),
2015-01-30 01:10:49 +00:00
/**
* Whether this element should be revealed as an accessible element.
2015-01-30 01:10:49 +00:00
*/
accessible: PropTypes.bool,
/**
* Custom string to display for accessibility.
2015-01-30 01:10:49 +00:00
*/
accessibilityLabel: PropTypes.string,
/**
* When the image is resized, the corners of the size specified
2015-01-30 01:10:49 +00:00
* by capInsets will stay a fixed size, but the center content and borders
* of the image will be stretched. This is useful for creating resizable
* rounded buttons, shadows, and other resizable assets. More info on
* [Apple documentation](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImage_Class/index.html#//apple_ref/occ/instm/UIImage/resizableImageWithCapInsets)
2015-01-30 01:10:49 +00:00
*/
capInsets: EdgeInsetsPropType,
style: StyleSheetPropType(ImageStylePropTypes),
/**
* A unique identifier for this element to be used in UI Automation
2015-01-30 01:10:49 +00:00
* testing scripts.
*/
testID: PropTypes.string,
},
statics: {
resizeMode: ImageResizeMode,
},
mixins: [NativeMethodsMixin],
/**
* `NativeMethodsMixin` will look for this when invoking `setNativeProps`. We
* make `this` look like an actual native component class.
*/
viewConfig: {
uiViewClassName: 'UIView',
validAttributes: ReactIOSViewAttributes.UIView
},
render: function() {
var style = flattenStyle([styles.base, this.props.style]);
Update from Friday March 27 - [React Native] Sync from github | Amjad Masad - [react-packager] Watch asset roots for changes to update dependency graph | Amjad Masad - Fix sourceTree of RCTActionSheet.xcodeproj | Alex Kotliarskyi - Cancel contents animation before setting new contents in RCTNetworkImageView | Alex Akers - [react-packager] move dependencies to root package.json | Amjad Masad - Fix font crash on iOS < 8.2 | Nick Lockwood - [react-packager] Fix node v0.11.14 query parse bug | Amjad Masad - [ReactNative][Docs] Remove references to ReactNavigator from docs | Tadeu Zagallo - [CLI] react-native start won't run from dir with spaces | Amjad Masad - Revert .buckversion bumps. | Jakub Zika - [react_native] Update default bundle name to org.reactjs.native.* | Krzysztof Magiera - [react-packager] better error when main file not found | Amjad Masad - [React Kit] Remove embarrassing TODOs | Alex Akers - [ReactNative][MAdMan] Clean up after D1942269 | Philipp von Weitershausen - flowify a few more Libraries | Basil Hosmer - [ReactNative] PushNotificationIOS documentation | Eric Vicenti - [ReactNative][CustomComponents] Update old headers | Tadeu Zagallo - [ReactNative] UIViewControllerBasedStatusBarAppearance = NO in SampleApp | Alex Kotliarskyi - [React Native] Fix CocoaPods spec | Alex Akers - [ReactNative] Navigator Example Overhaul | Eric Vicenti - [React Native] Fix incorrect if-statement in RCTGeolocation | Alex Akers - [ReactNative] s/ReactKit/React/g | Tadeu Zagallo - [React Native] [FRC - Don't accept] View border support | Nick Lockwood - [Assets] Allow scripts to override assetRoots | Amjad Masad - [ReactNative] Navigator docs | Eric Vicenti - [ReactNative] License headers and renaming | Eric Vicenti - [React Native] Add CocoaPods spec | Tadeu Zagallo - Added explicit types for all view properties | Nick Lockwood - [ReactNative] s/ReactNavigator/Navigator/ | Tadeu Zagallo - [ReactNative] Add copyright header for code copied from the jQuery UI project | Martin Konicek - [ReactNative] PanResponder documentation | Eric Vicenti - [ReactNative] Add deep linking api | Tadeu Zagallo - [ReactNative] Add gitignore example for SampleApp | Alex Kotliarskyi - [ReactNative] Add react-native-start bin to react-native packge | Alex Kotliarskyi - [ReactNative] Update package.json to be npm-ready | Christopher Chedeau - [RFC][ReactNative] Integrate dev menu directly into RootView | Alex Kotliarskyi - flowify Libraries/ReactIOS | Marshall Roch - [WIP] Added support for italics and additional font weights | Nick Lockwood - [ReactNative] Improve View documentation | Christopher Chedeau - [react-packager] Readme | Amjad Masad - Fix for incorrect contentSize reported by RCTScrollView | Nick Lockwood - [ReactNative] Flow and doc formatting for NetInfo | Eric Vicenti - [ReactNative] Document AppStateIOS | Eric Vicenti - [MAdMan][Android] Make things look more Androidy | Philipp von Weitershausen - flowified Libraries from Avik | Basil Hosmer - flowify some Libraries | Basil Hosmer - [ReactKit] Add shake development menu | Alex Kotliarskyi - [ReactNative] Add debugger and change SampleApp files structure | Alex Kotliarskyi - Flowify ReactIOSEventEmitter | Marshall Roch - [react_native] JS files from D1941151: Allow fontWeight to be 100,200,...,900 | Krzysztof Magiera - [ReactNative] Add snapshot tests for examples | Spencer Ahrens - [ReactNative] bring back some native modules | Spencer Ahrens - [ReactNative] Rename JSNavigationStack to ReactNavigator, rename scene config | Eric Vicenti - [ReactNative] cleanup view example | Spencer Ahrens - Flowify a bunch of Libraries | Marshall Roch - [ReactNative] JSNavigationStack - Use key to blow away old scenes | Eric Vicenti - [ReactNative] Add more logging to RCTJSONParse | Sumeet Vaidya - Unfork UIManager | Nick Lockwood - [react-packager] kill non-standard RAW_SOURCE_MAP | Amjad Masad - Flowify Libraries/StyleSheet and Libraries/Text | Marshall Roch - [ReactNative] Fix OSS Dependency Issues | Eric Vicenti - [react-packager] Fix more issues with node modules | Amjad Masad - [ReactNative] rename navigationOperations to navigator | Eric Vicenti - JS files from D1936817: Add to XMLHttpRequest android and share code with ios | Olivia Bishop - flowify some Libraries | Basil Hosmer - last batch of UIExplorer flowification | Basil Hosmer - [ReactNative] JSNavigationStack rename routeMapper to renderSceneForRoute | Eric Vicenti - Flowify renderApplication | Marshall Roch - [ReactNative] OSS Responder example | Eric Vicenti - [ReactNative] Use oss TimerMixin | Tadeu Zagallo - [ReactNative] Remove auto permission request from setAppIconBadgeNumber | Tadeu Zagallo - [ReactNative] OSS snapshot tests | Spencer Ahrens - [ReactNative] OSS JSNavigationStack w/ Examples | Eric Vicenti - Fix build - remove relative import path | Jakub Zika - Bump .buckversion to a5b8b8ef45d714018ba3542cf98d48ef6aab7088. | Jakub Zika - [ReactNative] Open Source PushNotifications and move Badge Number methods and permission into it | Tadeu Zagallo - [react-packager] Fix regression with transform errors | Amjad Masad - Flowify TextStylePropTypes and fix a bug with unsupported props | Marshall Roch - [ReactNative] Remove `arc build` instructions from require | Alex Kotliarskyi - Flowify Library/Utilities/ | Marshall Roch - [react-packager] Default to index.js from main if it's a dir | Amjad Masad - [ReactNative] Use deprecated ix in TabBarExample | Amjad Masad - [ReactNative] Expanded license on obj-c files | Christopher Chedeau - [ReactNative] Expanded license on js files | Christopher Chedeau - [ReactNative] Fix React Devtools integration | Alex Kotliarskyi - [Text] Account for font leading so descenders are not clipped | Alex Kotliarskyi - [ReactNative] Expanded license on js packager files | Christopher Chedeau - more UIExplorer flow | Basil Hosmer - [react-packager] Pick up package changes while running | Amjad Masad - Added a graph view and a ReactNative metric that displays current queue and execution time for the JS thread. | Bryce Redd - [ReactNative] Add NativeModules and DeviceEventEmitter to react-native exports | Alex Kotliarskyi - [React Native] Fix iOS 7 crashes b/c missing Photos.fmwk | Alex Akers - UIExplorer flowification | Basil Hosmer - Add clearImmediate module | Marshall Roch - [ReactNative] Print directories packager is serving files from | Alex Kotliarskyi - Work around flow bug with exports | Marshall Roch - [ReactNative] Move packager/init.sh to GitHub | Alex Kotliarskyi - [ReactNative] Remove react-native/package.json | Christopher Chedeau - [ReactNative] Returning actual contentSize for RCTScrollViewManager | Henry Lung - declare timeoutID | Basil Hosmer - [ReactNative] Add root package.json name back | Tadeu Zagallo - [react-packager] Allow entry point extensions like .ios.js | Amjad Masad - [react-native] Use SpreadProperty to make react-docgen happy | Felix Kling - clean Examples/2048 | Basil Hosmer - [ReactNative] Adjust packager default root when running from within node_modules | Alex Kotliarskyi - [ReactNative] Add missing websocket dependency | Alex Kotliarskyi - [react-packager] change all but one `ix` to `require` | Amjad Masad - [react-packager] Make sure projectRoots is converted to an array | Amjad Masad - [ReactNative] Init script that bootstraps new Xcode project | Alex Kotliarskyi - [ReactNative] New SampleApp | Alex Kotliarskyi - [ReactNative] Touchable invoke press on longPress when longPress handler missing | Eric Vicenti - [ReactNative] Commit missing RCTWebSocketDebugger.xcodeproj | Alex Kotliarskyi
2015-03-27 18:46:17 +00:00
invariant(style, "style must be initialized");
2015-01-30 01:10:49 +00:00
var source = this.props.source;
Update from Friday March 27 - [React Native] Sync from github | Amjad Masad - [react-packager] Watch asset roots for changes to update dependency graph | Amjad Masad - Fix sourceTree of RCTActionSheet.xcodeproj | Alex Kotliarskyi - Cancel contents animation before setting new contents in RCTNetworkImageView | Alex Akers - [react-packager] move dependencies to root package.json | Amjad Masad - Fix font crash on iOS < 8.2 | Nick Lockwood - [react-packager] Fix node v0.11.14 query parse bug | Amjad Masad - [ReactNative][Docs] Remove references to ReactNavigator from docs | Tadeu Zagallo - [CLI] react-native start won't run from dir with spaces | Amjad Masad - Revert .buckversion bumps. | Jakub Zika - [react_native] Update default bundle name to org.reactjs.native.* | Krzysztof Magiera - [react-packager] better error when main file not found | Amjad Masad - [React Kit] Remove embarrassing TODOs | Alex Akers - [ReactNative][MAdMan] Clean up after D1942269 | Philipp von Weitershausen - flowify a few more Libraries | Basil Hosmer - [ReactNative] PushNotificationIOS documentation | Eric Vicenti - [ReactNative][CustomComponents] Update old headers | Tadeu Zagallo - [ReactNative] UIViewControllerBasedStatusBarAppearance = NO in SampleApp | Alex Kotliarskyi - [React Native] Fix CocoaPods spec | Alex Akers - [ReactNative] Navigator Example Overhaul | Eric Vicenti - [React Native] Fix incorrect if-statement in RCTGeolocation | Alex Akers - [ReactNative] s/ReactKit/React/g | Tadeu Zagallo - [React Native] [FRC - Don't accept] View border support | Nick Lockwood - [Assets] Allow scripts to override assetRoots | Amjad Masad - [ReactNative] Navigator docs | Eric Vicenti - [ReactNative] License headers and renaming | Eric Vicenti - [React Native] Add CocoaPods spec | Tadeu Zagallo - Added explicit types for all view properties | Nick Lockwood - [ReactNative] s/ReactNavigator/Navigator/ | Tadeu Zagallo - [ReactNative] Add copyright header for code copied from the jQuery UI project | Martin Konicek - [ReactNative] PanResponder documentation | Eric Vicenti - [ReactNative] Add deep linking api | Tadeu Zagallo - [ReactNative] Add gitignore example for SampleApp | Alex Kotliarskyi - [ReactNative] Add react-native-start bin to react-native packge | Alex Kotliarskyi - [ReactNative] Update package.json to be npm-ready | Christopher Chedeau - [RFC][ReactNative] Integrate dev menu directly into RootView | Alex Kotliarskyi - flowify Libraries/ReactIOS | Marshall Roch - [WIP] Added support for italics and additional font weights | Nick Lockwood - [ReactNative] Improve View documentation | Christopher Chedeau - [react-packager] Readme | Amjad Masad - Fix for incorrect contentSize reported by RCTScrollView | Nick Lockwood - [ReactNative] Flow and doc formatting for NetInfo | Eric Vicenti - [ReactNative] Document AppStateIOS | Eric Vicenti - [MAdMan][Android] Make things look more Androidy | Philipp von Weitershausen - flowified Libraries from Avik | Basil Hosmer - flowify some Libraries | Basil Hosmer - [ReactKit] Add shake development menu | Alex Kotliarskyi - [ReactNative] Add debugger and change SampleApp files structure | Alex Kotliarskyi - Flowify ReactIOSEventEmitter | Marshall Roch - [react_native] JS files from D1941151: Allow fontWeight to be 100,200,...,900 | Krzysztof Magiera - [ReactNative] Add snapshot tests for examples | Spencer Ahrens - [ReactNative] bring back some native modules | Spencer Ahrens - [ReactNative] Rename JSNavigationStack to ReactNavigator, rename scene config | Eric Vicenti - [ReactNative] cleanup view example | Spencer Ahrens - Flowify a bunch of Libraries | Marshall Roch - [ReactNative] JSNavigationStack - Use key to blow away old scenes | Eric Vicenti - [ReactNative] Add more logging to RCTJSONParse | Sumeet Vaidya - Unfork UIManager | Nick Lockwood - [react-packager] kill non-standard RAW_SOURCE_MAP | Amjad Masad - Flowify Libraries/StyleSheet and Libraries/Text | Marshall Roch - [ReactNative] Fix OSS Dependency Issues | Eric Vicenti - [react-packager] Fix more issues with node modules | Amjad Masad - [ReactNative] rename navigationOperations to navigator | Eric Vicenti - JS files from D1936817: Add to XMLHttpRequest android and share code with ios | Olivia Bishop - flowify some Libraries | Basil Hosmer - last batch of UIExplorer flowification | Basil Hosmer - [ReactNative] JSNavigationStack rename routeMapper to renderSceneForRoute | Eric Vicenti - Flowify renderApplication | Marshall Roch - [ReactNative] OSS Responder example | Eric Vicenti - [ReactNative] Use oss TimerMixin | Tadeu Zagallo - [ReactNative] Remove auto permission request from setAppIconBadgeNumber | Tadeu Zagallo - [ReactNative] OSS snapshot tests | Spencer Ahrens - [ReactNative] OSS JSNavigationStack w/ Examples | Eric Vicenti - Fix build - remove relative import path | Jakub Zika - Bump .buckversion to a5b8b8ef45d714018ba3542cf98d48ef6aab7088. | Jakub Zika - [ReactNative] Open Source PushNotifications and move Badge Number methods and permission into it | Tadeu Zagallo - [react-packager] Fix regression with transform errors | Amjad Masad - Flowify TextStylePropTypes and fix a bug with unsupported props | Marshall Roch - [ReactNative] Remove `arc build` instructions from require | Alex Kotliarskyi - Flowify Library/Utilities/ | Marshall Roch - [react-packager] Default to index.js from main if it's a dir | Amjad Masad - [ReactNative] Use deprecated ix in TabBarExample | Amjad Masad - [ReactNative] Expanded license on obj-c files | Christopher Chedeau - [ReactNative] Expanded license on js files | Christopher Chedeau - [ReactNative] Fix React Devtools integration | Alex Kotliarskyi - [Text] Account for font leading so descenders are not clipped | Alex Kotliarskyi - [ReactNative] Expanded license on js packager files | Christopher Chedeau - more UIExplorer flow | Basil Hosmer - [react-packager] Pick up package changes while running | Amjad Masad - Added a graph view and a ReactNative metric that displays current queue and execution time for the JS thread. | Bryce Redd - [ReactNative] Add NativeModules and DeviceEventEmitter to react-native exports | Alex Kotliarskyi - [React Native] Fix iOS 7 crashes b/c missing Photos.fmwk | Alex Akers - UIExplorer flowification | Basil Hosmer - Add clearImmediate module | Marshall Roch - [ReactNative] Print directories packager is serving files from | Alex Kotliarskyi - Work around flow bug with exports | Marshall Roch - [ReactNative] Move packager/init.sh to GitHub | Alex Kotliarskyi - [ReactNative] Remove react-native/package.json | Christopher Chedeau - [ReactNative] Returning actual contentSize for RCTScrollViewManager | Henry Lung - declare timeoutID | Basil Hosmer - [ReactNative] Add root package.json name back | Tadeu Zagallo - [react-packager] Allow entry point extensions like .ios.js | Amjad Masad - [react-native] Use SpreadProperty to make react-docgen happy | Felix Kling - clean Examples/2048 | Basil Hosmer - [ReactNative] Adjust packager default root when running from within node_modules | Alex Kotliarskyi - [ReactNative] Add missing websocket dependency | Alex Kotliarskyi - [react-packager] change all but one `ix` to `require` | Amjad Masad - [react-packager] Make sure projectRoots is converted to an array | Amjad Masad - [ReactNative] Init script that bootstraps new Xcode project | Alex Kotliarskyi - [ReactNative] New SampleApp | Alex Kotliarskyi - [ReactNative] Touchable invoke press on longPress when longPress handler missing | Eric Vicenti - [ReactNative] Commit missing RCTWebSocketDebugger.xcodeproj | Alex Kotliarskyi
2015-03-27 18:46:17 +00:00
invariant(source, "source must be initialized");
2015-01-30 01:10:49 +00:00
var isNetwork = source.uri && source.uri.match(/^https?:/);
invariant(
!(isNetwork && source.isStatic),
'static image uris cannot start with "http": "' + source.uri + '"'
);
var isStored = !source.isStatic && !isNetwork;
var RawImage = isNetwork ? RCTNetworkImage : RCTStaticImage;
2015-01-30 01:10:49 +00:00
if (this.props.style && this.props.style.tintColor) {
warning(RawImage === RCTStaticImage, 'tintColor style only supported on static images.');
2015-01-30 01:10:49 +00:00
}
var contentModes = NativeModules.UIManager.UIView.ContentMode;
2015-01-30 01:10:49 +00:00
var resizeMode;
if (style.resizeMode === ImageResizeMode.stretch) {
resizeMode = contentModes.ScaleToFill;
} else if (style.resizeMode === ImageResizeMode.contain) {
resizeMode = contentModes.ScaleAspectFit;
} else { // ImageResizeMode.cover or undefined
resizeMode = contentModes.ScaleAspectFill;
}
var nativeProps = merge(this.props, {
style,
resizeMode,
tintColor: style.tintColor,
});
if (isStored) {
nativeProps.imageTag = source.uri;
} else {
nativeProps.src = source.uri;
}
return <RawImage {...nativeProps} />;
}
});
var styles = StyleSheet.create({
base: {
overflow: 'hidden',
},
});
var CommonImageViewAttributes = merge(ReactIOSViewAttributes.UIView, {
accessible: true,
accessibilityLabel: true,
capInsets: {diff: insetsDiffer}, // UIEdgeInsets=UIEdgeInsetsZero
imageTag: true,
resizeMode: true,
src: true,
testID: PropTypes.string,
});
var RCTStaticImage = createReactIOSNativeComponentClass({
2015-01-30 01:10:49 +00:00
validAttributes: merge(CommonImageViewAttributes, { tintColor: true }),
uiViewClassName: 'RCTStaticImage',
});
var RCTNetworkImage = createReactIOSNativeComponentClass({
2015-01-30 01:10:49 +00:00
validAttributes: merge(CommonImageViewAttributes, { defaultImageSrc: true }),
uiViewClassName: 'RCTNetworkImageView',
});
module.exports = Image;