Trim docs that are already present in the open source docs site

Summary:
A lot of these docs are already present in https://github.com/facebook/react-native-website.
Closes https://github.com/facebook/react-native/pull/17776

Differential Revision: D6839783

Pulled By: hramos

fbshipit-source-id: 945fde22afb8f181d0463617d224d3f3429faa24
This commit is contained in:
Héctor Ramos 2018-01-29 16:10:49 -08:00 committed by Facebook Github Bot
parent 31288161e1
commit 28d60b68ad
11 changed files with 261 additions and 1285 deletions

View File

@ -147,15 +147,9 @@ const getPhotosReturnChecker = createStrictShapeTypeChecker({
});
/**
* `CameraRoll` provides access to the local camera roll / gallery.
* Before using this you must link the `RCTCameraRoll` library.
* You can refer to [Linking](docs/linking-libraries-ios.html) for help.
*
* ### Permissions
* The user's permission is required in order to access the Camera Roll on devices running iOS 10 or later.
* Add the `NSPhotoLibraryUsageDescription` key in your `Info.plist` with a string that describes how your
* app will use this data. This key will appear as `Privacy - Photo Library Usage Description` in Xcode.
* `CameraRoll` provides access to the local camera roll or photo library.
*
* See https://facebook.github.io/react-native/docs/cameraroll.html
*/
class CameraRoll {
static GroupTypesOptions: Object = GROUP_TYPES_OPTIONS;
@ -176,18 +170,9 @@ class CameraRoll {
}
/**
* Saves the photo or video to the camera roll / gallery.
* Saves the photo or video to the camera roll or photo library.
*
* On Android, the tag must be a local image or video URI, such as `"file:///sdcard/img.png"`.
*
* On iOS, the tag can be any image URI (including local, remote asset-library and base64 data URIs)
* or a local video file URI (remote or data URIs are not supported for saving video at this time).
*
* If the tag has a file extension of .mov or .mp4, it will be inferred as a video. Otherwise
* it will be treated as a photo. To override the automatic choice, you can pass an optional
* `type` parameter that must be one of 'photo' or 'video'.
*
* Returns a Promise which will resolve with the new URI.
* See https://facebook.github.io/react-native/docs/cameraroll.html#savetocameraroll
*/
static saveToCameraRoll(
tag: string,
@ -218,84 +203,7 @@ class CameraRoll {
* Returns a Promise with photo identifier objects from the local camera
* roll of the device matching shape defined by `getPhotosReturnChecker`.
*
* Expects a params object of the following shape:
*
* - `first` : {number} : The number of photos wanted in reverse order of the photo application (i.e. most recent first for SavedPhotos).
* - `after` : {string} : A cursor that matches `page_info { end_cursor }` returned from a previous call to `getPhotos`.
* - `groupTypes` : {string} : Specifies which group types to filter the results to. Valid values are:
* - `Album`
* - `All`
* - `Event`
* - `Faces`
* - `Library`
* - `PhotoStream`
* - `SavedPhotos` // default
* - `groupName` : {string} : Specifies filter on group names, like 'Recent Photos' or custom album titles.
* - `assetType` : {string} : Specifies filter on asset type. Valid values are:
* - `All`
* - `Videos`
* - `Photos` // default
* - `mimeTypes` : {string} : Filter by mimetype (e.g. image/jpeg).
*
* Returns a Promise which when resolved will be of the following shape:
*
* - `edges` : {Array<node>} An array of node objects
* - `node`: {object} An object with the following shape:
* - `type`: {string}
* - `group_name`: {string}
* - `image`: {object} : An object with the following shape:
* - `uri`: {string}
* - `height`: {number}
* - `width`: {number}
* - `isStored`: {boolean}
* - `timestamp`: {number}
* - `location`: {object} : An object with the following shape:
* - `latitude`: {number}
* - `longitude`: {number}
* - `altitude`: {number}
* - `heading`: {number}
* - `speed`: {number}
* - `page_info` : {object} : An object with the following shape:
* - `has_next_page`: {boolean}
* - `start_cursor`: {string}
* - `end_cursor`: {string}
*
* Loading images:
* ```
* _handleButtonPress = () => {
* CameraRoll.getPhotos({
* first: 20,
* assetType: 'All',
* })
* .then(r => {
* this.setState({ photos: r.edges });
* })
* .catch((err) => {
* //Error Loading Images
* });
* };
* render() {
* return (
* <View>
* <Button title="Load Images" onPress={this._handleButtonPress} />
* <ScrollView>
* {this.state.photos.map((p, i) => {
* return (
* <Image
* key={i}
* style={{
* width: 300,
* height: 100,
* }}
* source={{ uri: p.node.image.uri }}
* />
* );
* })}
* </ScrollView>
* </View>
* );
* }
* ```
* See https://facebook.github.io/react-native/docs/cameraroll.html#getphotos
*/
static getPhotos(params: GetPhotosParams): GetPhotosReturn {
if (__DEV__) {

View File

@ -45,58 +45,14 @@ type GeoOptions = {
* The Geolocation API extends the web spec:
* https://developer.mozilla.org/en-US/docs/Web/API/Geolocation
*
* As a browser polyfill, this API is available through the `navigator.geolocation`
* global - you do not need to `import` it.
*
* ### Configuration and Permissions
*
* <div class="banner-crna-ejected">
* <h3>Projects with Native Code Only</h3>
* <p>
* This section only applies to projects made with <code>react-native init</code>
* or to those made with Create React Native App which have since ejected. For
* more information about ejecting, please see
* the <a href="https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md" target="_blank">guide</a> on
* the Create React Native App repository.
* </p>
* </div>
*
* #### iOS
* You need to include the `NSLocationWhenInUseUsageDescription` key
* in Info.plist to enable geolocation when using the app. Geolocation is
* enabled by default when you create a project with `react-native init`.
*
* In order to enable geolocation in the background, you need to include the
* 'NSLocationAlwaysUsageDescription' key in Info.plist and add location as
* a background mode in the 'Capabilities' tab in Xcode.
*
* #### Android
* To request access to location, you need to add the following line to your
* app's `AndroidManifest.xml`:
*
* `<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />`
*
* Android API >= 18 Positions will also contain a `mocked` boolean to indicate if position
* was created from a mock provider.
*
* <p>
* Android API >= 23 Requires an additional step to check for, and request
* the ACCESS_FINE_LOCATION permission using
* the <a href="https://facebook.github.io/react-native/docs/permissionsandroid.html" target="_blank">PermissionsAndroid API</a>.
* Failure to do so may result in a hard crash.
* </p>
* See https://facebook.github.io/react-native/docs/geolocation.html
*/
var Geolocation = {
/*
* Sets configuration options that will be used in all location requests.
*
* ### Options
*
* #### iOS
*
* - `skipPermissionRequests` - defaults to `false`, if `true` you must request permissions
* before using Geolocation APIs.
* See https://facebook.github.io/react-native/docs/geolocation.html#setrnconfiguration
*
*/
setRNConfiguration: function(
@ -109,19 +65,17 @@ var Geolocation = {
/*
* Request suitable Location permission based on the key configured on pList.
* If NSLocationAlwaysUsageDescription is set, it will request Always authorization,
* although if NSLocationWhenInUseUsageDescription is set, it will request InUse
* authorization.
*
* See https://facebook.github.io/react-native/docs/geolocation.html#requestauthorization
*/
requestAuthorization: function() {
RCTLocationObserver.requestAuthorization();
},
/*
* Invokes the success callback once with the latest location info. Supported
* options: timeout (ms), maximumAge (ms), enableHighAccuracy (bool)
* On Android, if the location is cached this can return almost immediately,
* or it will request an update which might take a while.
* Invokes the success callback once with the latest location info.
*
* See https://facebook.github.io/react-native/docs/geolocation.html#getcurrentposition
*/
getCurrentPosition: async function(
geo_success: Function,
@ -156,8 +110,9 @@ var Geolocation = {
},
/*
* Invokes the success callback whenever the location changes. Supported
* options: timeout (ms), maximumAge (ms), enableHighAccuracy (bool), distanceFilter(m), useSignificantChanges (bool)
* Invokes the success callback whenever the location changes.
*
* See https://facebook.github.io/react-native/docs/geolocation.html#watchposition
*/
watchPosition: function(success: Function, error?: Function, options?: GeoOptions): number {
if (!updatesEnabled) {

View File

@ -39,44 +39,19 @@ function generateRequestId() {
}
/**
* <Image> - A react component for displaying different types of images,
* A React component for displaying different types of images,
* including network images, static resources, temporary local images, and
* images from local disk, such as the camera roll. Example usage:
* images from local disk, such as the camera roll.
*
* renderImages: function() {
* return (
* <View>
* <Image
* style={styles.icon}
* source={require('./myIcon.png')}
* />
* <Image
* style={styles.logo}
* source={{uri: 'https://facebook.github.io/react-native/img/opengraph.png'}}
* />
* </View>
* );
* },
*
* More example code in ImageExample.js
* See https://facebook.github.io/react-native/docs/image.html
*/
var Image = createReactClass({
displayName: 'Image',
propTypes: {
...ViewPropTypes,
style: StyleSheetPropType(ImageStylePropTypes),
/**
* `uri` is a string representing the resource identifier for the image, which
* could be an http address, a local file path, or a static image
* resource (which should be wrapped in the `require('./path/to/image.png')` function).
*
* `headers` is an object representing the HTTP headers to send along with the request
* for a remote image.
*
* This prop can also contain several remote `uri`, specified together with
* their width and height. The native side will then choose the best `uri` to display
* based on the measured size of the image container.
* See https://facebook.github.io/react-native/docs/image.html#source
*/
source: PropTypes.oneOfType([
PropTypes.shape({
@ -97,12 +72,12 @@ var Image = createReactClass({
]),
/**
* blurRadius: the blur radius of the blur filter added to the image
*
* See https://facebook.github.io/react-native/docs/image.html#blurradius
*/
blurRadius: PropTypes.number,
/**
* similarly to `source`, this property represents the resource used to render
* the loading indicator for the image, displayed until image is ready to be
* displayed, typically after when it got downloaded from network.
* See https://facebook.github.io/react-native/docs/image.html#loadingindicatorsource
*/
loadingIndicatorSource: PropTypes.oneOfType([
PropTypes.shape({
@ -137,40 +112,14 @@ var Image = createReactClass({
* The mechanism that should be used to resize the image when the image's dimensions
* differ from the image view's dimensions. Defaults to `auto`.
*
* - `auto`: Use heuristics to pick between `resize` and `scale`.
*
* - `resize`: A software operation which changes the encoded image in memory before it
* gets decoded. This should be used instead of `scale` when the image is much larger
* than the view.
*
* - `scale`: The image gets drawn downscaled or upscaled. Compared to `resize`, `scale` is
* faster (usually hardware accelerated) and produces higher quality images. This
* should be used if the image is smaller than the view. It should also be used if the
* image is slightly bigger than the view.
*
* More details about `resize` and `scale` can be found at http://frescolib.org/docs/resizing-rotating.html.
*
* @platform android
* See https://facebook.github.io/react-native/docs/image.html#resizemethod
*/
resizeMethod: PropTypes.oneOf(['auto', 'resize', 'scale']),
/**
* Determines how to resize the image when the frame doesn't match the raw
* image dimensions.
*
* 'cover': Scale the image uniformly (maintain the image's aspect ratio)
* so that both dimensions (width and height) of the image will be equal
* to or larger than the corresponding dimension of the view (minus padding).
*
* 'contain': Scale the image uniformly (maintain the image's aspect ratio)
* so that both dimensions (width and height) of the image will be equal to
* or less than the corresponding dimension of the view (minus padding).
*
* 'stretch': Scale width and height independently, This may change the
* aspect ratio of the src.
*
* 'center': Scale the image down so that it is completely visible,
* if bigger than the area of the view.
* The image will not be scaled up.
* See https://facebook.github.io/react-native/docs/image.html#resizemode
*/
resizeMode: PropTypes.oneOf(['cover', 'contain', 'stretch', 'center']),
},
@ -198,6 +147,8 @@ var Image = createReactClass({
/**
* Prefetches a remote image for later use by downloading it to the disk
* cache
*
* See https://facebook.github.io/react-native/docs/image.html#prefetch
*/
prefetch(url: string, callback: ?Function) {
const requestId = generateRequestId();
@ -206,7 +157,9 @@ var Image = createReactClass({
},
/**
* Abort prefetch request
* Abort prefetch request.
*
* See https://facebook.github.io/react-native/docs/image.html#abortprefetch
*/
abortPrefetch(requestId: number) {
ImageLoader.abortRequest(requestId);
@ -215,9 +168,7 @@ var Image = createReactClass({
/**
* Perform cache interrogation.
*
* @param urls the list of image URLs to check the cache for.
* @return a mapping from url to cache status, such as "disk" or "memory". If a requested URL is
* not in the mapping, it means it's not in the cache.
* See https://facebook.github.io/react-native/docs/image.html#querycache
*/
async queryCache(
urls: Array<string>,
@ -226,9 +177,9 @@ var Image = createReactClass({
},
/**
* Resolves an asset reference into an object which has the properties `uri`, `width`,
* and `height`. The input may either be a number (opaque type returned by
* require('./foo.png')) or an `ImageSource` like { uri: '<http location || file path>' }
* Resolves an asset reference into an object.
*
* See https://facebook.github.io/react-native/docs/image.html#resolveassetsource
*/
resolveAssetSource: resolveAssetSource,
},

View File

@ -36,141 +36,27 @@ const ImageViewManager = NativeModules.ImageViewManager;
* including network images, static resources, temporary local images, and
* images from local disk, such as the camera roll.
*
* This example shows fetching and displaying an image from local storage
* as well as one from network and even from data provided in the `'data:'` uri scheme.
*
* > Note that for network and data images, you will need to manually specify the dimensions of your image!
*
* ```ReactNativeWebPlayer
* import React, { Component } from 'react';
* import { AppRegistry, View, Image } from 'react-native';
*
* export default class DisplayAnImage extends Component {
* render() {
* return (
* <View>
* <Image
* source={require('./img/favicon.png')}
* />
* <Image
* style={{width: 50, height: 50}}
* source={{uri: 'https://facebook.github.io/react-native/img/favicon.png'}}
* />
* <Image
* style={{width: 66, height: 58}}
* source={{uri: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAYAAAA6oTAqAAAAEXRFWHRTb2Z0d2FyZQBwbmdjcnVzaEB1SfMAAABQSURBVGje7dSxCQBACARB+2/ab8BEeQNhFi6WSYzYLYudDQYGBgYGBgYGBgYGBgYGBgZmcvDqYGBgmhivGQYGBgYGBgYGBgYGBgYGBgbmQw+P/eMrC5UTVAAAAABJRU5ErkJggg=='}}
* />
* </View>
* );
* }
* }
*
* // skip this line if using Create React Native App
* AppRegistry.registerComponent('DisplayAnImage', () => DisplayAnImage);
* ```
*
* You can also add `style` to an image:
*
* ```ReactNativeWebPlayer
* import React, { Component } from 'react';
* import { AppRegistry, View, Image, StyleSheet } from 'react-native';
*
* const styles = StyleSheet.create({
* stretch: {
* width: 50,
* height: 200
* }
* });
*
* export default class DisplayAnImageWithStyle extends Component {
* render() {
* return (
* <View>
* <Image
* style={styles.stretch}
* source={require('./img/favicon.png')}
* />
* </View>
* );
* }
* }
*
* // skip these lines if using Create React Native App
* AppRegistry.registerComponent(
* 'DisplayAnImageWithStyle',
* () => DisplayAnImageWithStyle
* );
* ```
*
* ### GIF and WebP support on Android
*
* When building your own native code, GIF and WebP are not supported by default on Android.
*
* You will need to add some optional modules in `android/app/build.gradle`, depending on the needs of your app.
*
* ```
* dependencies {
* // If your app supports Android versions before Ice Cream Sandwich (API level 14)
* compile 'com.facebook.fresco:animated-base-support:1.3.0'
*
* // For animated GIF support
* compile 'com.facebook.fresco:animated-gif:1.3.0'
*
* // For WebP support, including animated WebP
* compile 'com.facebook.fresco:animated-webp:1.3.0'
* compile 'com.facebook.fresco:webpsupport:1.3.0'
*
* // For WebP support, without animations
* compile 'com.facebook.fresco:webpsupport:1.3.0'
* }
* ```
*
* Also, if you use GIF with ProGuard, you will need to add this rule in `proguard-rules.pro` :
* ```
* -keep class com.facebook.imagepipeline.animated.factory.AnimatedFactoryImpl {
* public AnimatedFactoryImpl(com.facebook.imagepipeline.bitmaps.PlatformBitmapFactory, com.facebook.imagepipeline.core.ExecutorSupplier);
* }
* ```
*
* See https://facebook.github.io/react-native/docs/image.html
*/
const Image = createReactClass({
displayName: 'Image',
propTypes: {
/**
* > `ImageResizeMode` is an `Enum` for different image resizing modes, set via the
* > `resizeMode` style property on `Image` components. The values are `contain`, `cover`,
* > `stretch`, `center`, `repeat`.
* See https://facebook.github.io/react-native/docs/image.html#style
*/
style: StyleSheetPropType(ImageStylePropTypes),
/**
* The image source (either a remote URL or a local file resource).
*
* This prop can also contain several remote URLs, specified together with
* their width and height and potentially with scale/other URI arguments.
* The native side will then choose the best `uri` to display based on the
* measured size of the image container. A `cache` property can be added to
* control how networked request interacts with the local cache.
*
* The currently supported formats are `png`, `jpg`, `jpeg`, `bmp`, `gif`,
* `webp` (Android only), `psd` (iOS only).
* See https://facebook.github.io/react-native/docs/image.html#source
*/
source: ImageSourcePropType,
/**
* A static image to display while loading the image source.
*
* - `uri` - a string representing the resource identifier for the image, which
* should be either a local file path or the name of a static image resource
* (which should be wrapped in the `require('./path/to/image.png')` function).
* - `width`, `height` - can be specified if known at build time, in which case
* these will be used to set the default `<Image/>` component dimensions.
* - `scale` - 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.
* - `number` - Opaque type returned by something like `require('./image.jpg')`.
*
* @platform ios
* See https://facebook.github.io/react-native/docs/image.html#defaultsource
*/
defaultSource: PropTypes.oneOfType([
// TODO: Tooling to support documenting these directly and having them display in the docs.
PropTypes.shape({
uri: PropTypes.string,
width: PropTypes.number,
@ -181,70 +67,36 @@ const Image = createReactClass({
]),
/**
* When true, indicates the image is an accessibility element.
* @platform ios
*
* See https://facebook.github.io/react-native/docs/image.html#accessible
*/
accessible: PropTypes.bool,
/**
* The text that's read by the screen reader when the user interacts with
* the image.
* @platform ios
*
* See https://facebook.github.io/react-native/docs/image.html#accessibilitylabel
*/
accessibilityLabel: PropTypes.node,
/**
* blurRadius: the blur radius of the blur filter added to the image
*
* See https://facebook.github.io/react-native/docs/image.html#blurradius
*/
blurRadius: PropTypes.number,
/**
* When the image is resized, the corners of the size specified
* 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 in the
* [official Apple documentation](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImage_Class/index.html#//apple_ref/occ/instm/UIImage/resizableImageWithCapInsets).
*
* @platform ios
* See https://facebook.github.io/react-native/docs/image.html#capinsets
*/
capInsets: EdgeInsetsPropType,
/**
* The mechanism that should be used to resize the image when the image's dimensions
* differ from the image view's dimensions. Defaults to `auto`.
*
* - `auto`: Use heuristics to pick between `resize` and `scale`.
*
* - `resize`: A software operation which changes the encoded image in memory before it
* gets decoded. This should be used instead of `scale` when the image is much larger
* than the view.
*
* - `scale`: The image gets drawn downscaled or upscaled. Compared to `resize`, `scale` is
* faster (usually hardware accelerated) and produces higher quality images. This
* should be used if the image is smaller than the view. It should also be used if the
* image is slightly bigger than the view.
*
* More details about `resize` and `scale` can be found at http://frescolib.org/docs/resizing-rotating.html.
*
* @platform android
* See https://facebook.github.io/react-native/docs/image.html#resizemethod
*/
resizeMethod: PropTypes.oneOf(['auto', 'resize', 'scale']),
/**
* Determines how to resize the image when the frame doesn't match the raw
* image dimensions.
*
* - `cover`: Scale the image uniformly (maintain the image's aspect ratio)
* so that both dimensions (width and height) of the image will be equal
* to or larger than the corresponding dimension of the view (minus padding).
*
* - `contain`: Scale the image uniformly (maintain the image's aspect ratio)
* so that both dimensions (width and height) of the image will be equal to
* or less than the corresponding dimension of the view (minus padding).
*
* - `stretch`: Scale width and height independently, This may change the
* aspect ratio of the src.
*
* - `repeat`: Repeat the image to cover the frame of the view. The
* image will keep it's size and aspect ratio. (iOS only)
*
* - 'center': Scale the image down so that it is completely visible,
* if bigger than the area of the view.
* The image will not be scaled up.
* See https://facebook.github.io/react-native/docs/image.html#resizemode
*/
resizeMode: PropTypes.oneOf([
'cover',
@ -256,41 +108,51 @@ const Image = createReactClass({
/**
* A unique identifier for this element to be used in UI Automation
* testing scripts.
*
* See https://facebook.github.io/react-native/docs/image.html#testid
*/
testID: PropTypes.string,
/**
* Invoked on mount and layout changes with
* `{nativeEvent: {layout: {x, y, width, height}}}`.
*
* See https://facebook.github.io/react-native/docs/image.html#onlayout
*/
onLayout: PropTypes.func,
/**
* Invoked on load start.
*
* e.g., `onLoadStart={(e) => this.setState({loading: true})}`
* See https://facebook.github.io/react-native/docs/image.html#onloadstart
*/
onLoadStart: PropTypes.func,
/**
* Invoked on download progress with `{nativeEvent: {loaded, total}}`.
* @platform ios
*
* See https://facebook.github.io/react-native/docs/image.html#onprogress
*/
onProgress: PropTypes.func,
/**
* Invoked on load error with `{nativeEvent: {error}}`.
*
* See https://facebook.github.io/react-native/docs/image.html#onerror
*/
onError: PropTypes.func,
/**
* Invoked when a partial load of the image is complete. The definition of
* what constitutes a "partial load" is loader specific though this is meant
* for progressive JPEG loads.
* @platform ios
* Invoked when a partial load of the image is complete.
*
* See https://facebook.github.io/react-native/docs/image.html#onpartialload
*/
onPartialLoad: PropTypes.func,
/**
* Invoked when load completes successfully.
*
* See https://facebook.github.io/react-native/docs/image.html#onload
*/
onLoad: PropTypes.func,
/**
* Invoked when load either succeeds or fails.
*
* See https://facebook.github.io/react-native/docs/image.html#onloadend
*/
onLoadEnd: PropTypes.func,
},
@ -299,26 +161,8 @@ const Image = createReactClass({
resizeMode: ImageResizeMode,
/**
* Retrieve the width and height (in pixels) of an image prior to displaying it.
* This method can fail if the image cannot be found, or fails to download.
*
* In order to retrieve the image dimensions, the image may first need to be
* loaded or downloaded, after which it will be cached. This means that in
* principle you could use this method to preload images, however it is not
* optimized for that purpose, and may in future be implemented in a way that
* does not fully load/download the image data. A proper, supported way to
* preload images will be provided as a separate API.
*
* Does not work for static image resources.
*
* @param uri The location of the image.
* @param success The function that will be called if the image was successfully found and width
* and height retrieved.
* @param failure The function that will be called if there was an error, such as failing to
* to retrieve the image.
*
* @returns void
*
* @platform ios
* See https://facebook.github.io/react-native/docs/image.html#getsize
*/
getSize: function(
uri: string,
@ -336,19 +180,17 @@ const Image = createReactClass({
},
/**
* Prefetches a remote image for later use by downloading it to the disk
* cache
* cache.
*
* @param url The remote location of the image.
*
* @return The prefetched image.
* See https://facebook.github.io/react-native/docs/image.html#prefetch
*/
prefetch(url: string) {
return ImageViewManager.prefetchImage(url);
},
/**
* Resolves an asset reference into an object which has the properties `uri`, `width`,
* and `height`. The input may either be a number (opaque type returned by
* require('./foo.png')) or an `ImageSource` like { uri: '<http location || file path>' }
* Resolves an asset reference into an object.
*
* See https://facebook.github.io/react-native/docs/image.html#resolveassetsource
*/
resolveAssetSource: resolveAssetSource,
},

View File

@ -21,128 +21,10 @@ const LinkingManager = Platform.OS === 'android' ?
NativeModules.IntentAndroid : NativeModules.LinkingManager;
/**
* <div class="banner-crna-ejected">
* <h3>Projects with Native Code Only</h3>
* <p>
* This section only applies to projects made with <code>react-native init</code>
* or to those made with Create React Native App which have since ejected. For
* more information about ejecting, please see
* the <a href="https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md" target="_blank">guide</a> on
* the Create React Native App repository.
* </p>
* </div>
*
* `Linking` gives you a general interface to interact with both incoming
* and outgoing app links.
*
* ### Basic Usage
*
* #### Handling deep links
*
* If your app was launched from an external url registered to your app you can
* access and handle it from any component you want with
*
* ```
* componentDidMount() {
* Linking.getInitialURL().then((url) => {
* if (url) {
* console.log('Initial url is: ' + url);
* }
* }).catch(err => console.error('An error occurred', err));
* }
* ```
*
* NOTE: For instructions on how to add support for deep linking on Android,
* refer to [Enabling Deep Links for App Content - Add Intent Filters for Your Deep Links](http://developer.android.com/training/app-indexing/deep-linking.html#adding-filters).
*
* If you wish to receive the intent in an existing instance of MainActivity,
* you may set the `launchMode` of MainActivity to `singleTask` in
* `AndroidManifest.xml`. See [`<activity>`](http://developer.android.com/guide/topics/manifest/activity-element.html)
* documentation for more information.
*
* ```
* <activity
* android:name=".MainActivity"
* android:launchMode="singleTask">
* ```
*
* NOTE: On iOS, you'll need to link `RCTLinking` to your project by following
* the steps described [here](docs/linking-libraries-ios.html#manual-linking).
* If you also want to listen to incoming app links during your app's
* execution, you'll need to add the following lines to your `*AppDelegate.m`:
*
* ```
* // iOS 9.x or newer
* #import <React/RCTLinkingManager.h>
*
* - (BOOL)application:(UIApplication *)application
* openURL:(NSURL *)url
* options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
* {
* return [RCTLinkingManager application:application openURL:url options:options];
* }
* ```
*
* If you're targeting iOS 8.x or older, you can use the following code instead:
*
* ```
* // iOS 8.x or older
* #import <React/RCTLinkingManager.h>
*
* - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
* sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
* {
* return [RCTLinkingManager application:application openURL:url
* sourceApplication:sourceApplication annotation:annotation];
* }
* ```
*
*
* // If your app is using [Universal Links](https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html),
* you'll need to add the following code as well:
*
* ```
* - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity
* restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
* {
* return [RCTLinkingManager application:application
* continueUserActivity:userActivity
* restorationHandler:restorationHandler];
* }
* ```
*
* And then on your React component you'll be able to listen to the events on
* `Linking` as follows
*
* ```
* componentDidMount() {
* Linking.addEventListener('url', this._handleOpenURL);
* },
* componentWillUnmount() {
* Linking.removeEventListener('url', this._handleOpenURL);
* },
* _handleOpenURL(event) {
* console.log(event.url);
* }
* ```
* #### Opening external links
*
* To start the corresponding activity for a link (web URL, email, contact etc.), call
*
* ```
* Linking.openURL(url).catch(err => console.error('An error occurred', err));
* ```
*
* If you want to check if any installed app can handle a given URL beforehand you can call
* ```
* Linking.canOpenURL(url).then(supported => {
* if (!supported) {
* console.log('Can\'t handle url: ' + url);
* } else {
* return Linking.openURL(url);
* }
* }).catch(err => console.error('An error occurred', err));
* ```
*
* See https://facebook.github.io/react-native/docs/linking.html
*/
class Linking extends NativeEventEmitter {
@ -153,13 +35,17 @@ class Linking extends NativeEventEmitter {
/**
* Add a handler to Linking changes by listening to the `url` event type
* and providing the handler
*
* See https://facebook.github.io/react-native/docs/linking.html#addeventlistener
*/
addEventListener(type: string, handler: Function) {
this.addListener(type, handler);
}
/**
* Remove a handler by passing the `url` event type and the handler
* Remove a handler by passing the `url` event type and the handler.
*
* See https://facebook.github.io/react-native/docs/linking.html#removeeventlistener
*/
removeEventListener(type: string, handler: Function ) {
this.removeListener(type, handler);
@ -168,18 +54,7 @@ class Linking extends NativeEventEmitter {
/**
* Try to open the given `url` with any of the installed apps.
*
* You can use other URLs, like a location (e.g. "geo:37.484847,-122.148386" on Android
* or "http://maps.apple.com/?ll=37.484847,-122.148386" on iOS), a contact,
* or any other URL that can be opened with the installed apps.
*
* The method returns a `Promise` object. If the user confirms the open dialog or the
* url automatically opens, the promise is resolved. If the user cancels the open dialog
* or there are no registered applications for the url, the promise is rejected.
*
* NOTE: This method will fail if the system doesn't know how to open the specified URL.
* If you're passing in a non-http(s) URL, it's best to check {@code canOpenURL} first.
*
* NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!
* See https://facebook.github.io/react-native/docs/linking.html#openurl
*/
openURL(url: string): Promise<any> {
this._validateURL(url);
@ -189,12 +64,7 @@ class Linking extends NativeEventEmitter {
/**
* Determine whether or not an installed app can handle a given URL.
*
* NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!
*
* NOTE: As of iOS 9, your app needs to provide the `LSApplicationQueriesSchemes` key
* inside `Info.plist` or canOpenURL will always return false.
*
* @param URL the URL to open
* See https://facebook.github.io/react-native/docs/linking.html#canopenurl
*/
canOpenURL(url: string): Promise<boolean> {
this._validateURL(url);
@ -205,7 +75,7 @@ class Linking extends NativeEventEmitter {
* If the app launch was triggered by an app link,
* it will give the link url, otherwise it will give `null`
*
* NOTE: To support deep linking on Android, refer http://developer.android.com/training/app-indexing/deep-linking.html#handling-intents
* See https://facebook.github.io/react-native/docs/linking.html#getinitialurl
*/
getInitialURL(): Promise<?string> {
return LinkingManager.getInitialURL();

View File

@ -31,58 +31,8 @@ import type EmitterSubscription from 'EmitterSubscription';
/**
* The Modal component is a simple way to present content above an enclosing view.
*
* _Note: If you need more control over how to present modals over the rest of your app,
* then consider using a top-level Navigator._
*
* ```javascript
* import React, { Component } from 'react';
* import { Modal, Text, TouchableHighlight, View } from 'react-native';
*
* class ModalExample extends Component {
*
* state = {
* modalVisible: false,
* }
*
* setModalVisible(visible) {
* this.setState({modalVisible: visible});
* }
*
* render() {
* return (
* <View style={{marginTop: 22}}>
* <Modal
* animationType="slide"
* transparent={false}
* visible={this.state.modalVisible}
* onRequestClose={() => {alert("Modal has been closed.")}}
* >
* <View style={{marginTop: 22}}>
* <View>
* <Text>Hello World!</Text>
*
* <TouchableHighlight onPress={() => {
* this.setModalVisible(!this.state.modalVisible)
* }}>
* <Text>Hide Modal</Text>
* </TouchableHighlight>
*
* </View>
* </View>
* </Modal>
*
* <TouchableHighlight onPress={() => {
* this.setModalVisible(true)
* }}>
* <Text>Show Modal</Text>
* </TouchableHighlight>
*
* </View>
* );
* }
* }
* ```
*
* See https://facebook.github.io/react-native/docs/modal.html
*/
// In order to route onDismiss callbacks, we need to uniquely identifier each
@ -96,50 +46,54 @@ class Modal extends React.Component<Object> {
/**
* The `animationType` prop controls how the modal animates.
*
* - `slide` slides in from the bottom
* - `fade` fades into view
* - `none` appears without an animation
*
* Default is set to `none`.
* See https://facebook.github.io/react-native/docs/modal.html#animationtype
*/
animationType: PropTypes.oneOf(['none', 'slide', 'fade']),
/**
* The `presentationStyle` prop controls how the modal appears (generally on larger devices such as iPad or plus-sized iPhones).
* See https://developer.apple.com/reference/uikit/uimodalpresentationstyle for details.
* @platform ios
*
* - `fullScreen` covers the screen completely
* - `pageSheet` covers portrait-width view centered (only on larger devices)
* - `formSheet` covers narrow-width view centered (only on larger devices)
* - `overFullScreen` covers the screen completely, but allows transparency
*
* Default is set to `overFullScreen` or `fullScreen` depending on `transparent` property.
* The `presentationStyle` prop controls how the modal appears.
*
* See https://facebook.github.io/react-native/docs/modal.html#presentationstyle
*/
presentationStyle: PropTypes.oneOf(['fullScreen', 'pageSheet', 'formSheet', 'overFullScreen']),
/**
* The `transparent` prop determines whether your modal will fill the entire view. Setting this to `true` will render the modal over a transparent background.
* The `transparent` prop determines whether your modal will fill the
* entire view.
*
* See https://facebook.github.io/react-native/docs/modal.html#transparent
*/
transparent: PropTypes.bool,
/**
* The `hardwareAccelerated` prop controls whether to force hardware acceleration for the underlying window.
* @platform android
* The `hardwareAccelerated` prop controls whether to force hardware
* acceleration for the underlying window.
*
* See https://facebook.github.io/react-native/docs/modal.html#hardwareaccelerated
*/
hardwareAccelerated: PropTypes.bool,
/**
* The `visible` prop determines whether your modal is visible.
*
* See https://facebook.github.io/react-native/docs/modal.html#visible
*/
visible: PropTypes.bool,
/**
* The `onRequestClose` callback is called when the user taps the hardware back button on Android or the menu button on Apple TV.
* The `onRequestClose` callback is called when the user taps the hardware
* back button on Android or the menu button on Apple TV.
*
* See https://facebook.github.io/react-native/docs/modal.html#onrequestclose
*/
onRequestClose: (Platform.isTVOS || Platform.OS === 'android') ? PropTypes.func.isRequired : PropTypes.func,
/**
* The `onShow` prop allows passing a function that will be called once the modal has been shown.
* The `onShow` prop allows passing a function that will be called once the
* modal has been shown.
*
* See https://facebook.github.io/react-native/docs/modal.html#onshow
*/
onShow: PropTypes.func,
/**
* The `onDismiss` prop allows passing a function that will be called once the modal has been dismissed.
* @platform ios
* The `onDismiss` prop allows passing a function that will be called once
* the modal has been dismissed.
*
* See https://facebook.github.io/react-native/docs/modal.html#ondismiss
*/
onDismiss: PropTypes.func,
animated: deprecatedPropType(
@ -148,15 +102,14 @@ class Modal extends React.Component<Object> {
),
/**
* The `supportedOrientations` prop allows the modal to be rotated to any of the specified orientations.
* On iOS, the modal is still restricted by what's specified in your app's Info.plist's UISupportedInterfaceOrientations field.
* When using `presentationStyle` of `pageSheet` or `formSheet`, this property will be ignored by iOS.
* @platform ios
*
* See https://facebook.github.io/react-native/docs/modal.html#supportedorientations
*/
supportedOrientations: PropTypes.arrayOf(PropTypes.oneOf(['portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right'])),
/**
* The `onOrientationChange` callback is called when the orientation changes while the modal is being displayed.
* The orientation provided is only 'portrait' or 'landscape'. This callback is also called on initial render, regardless of the current orientation.
* @platform ios
*
* See https://facebook.github.io/react-native/docs/modal.html#onorientationchange
*/
onOrientationChange: PropTypes.func,
};

View File

@ -81,131 +81,15 @@ function _isConnected(connection) {
const _isConnectedSubscriptions = new Map();
/**
* NetInfo exposes info about online/offline status
*
* ```
* NetInfo.getConnectionInfo().then((connectionInfo) => {
* console.log('Initial, type: ' + connectionInfo.type + ', effectiveType: ' + connectionInfo.effectiveType);
* });
* function handleFirstConnectivityChange(connectionInfo) {
* console.log('First change, type: ' + connectionInfo.type + ', effectiveType: ' + connectionInfo.effectiveType);
* NetInfo.removeEventListener(
* 'connectionChange',
* handleFirstConnectivityChange
* );
* }
* NetInfo.addEventListener(
* 'connectionChange',
* handleFirstConnectivityChange
* );
* ```
*
* ### ConnectionType enum
*
* `ConnectionType` describes the type of connection the device is using to communicate with the network.
*
* Cross platform values for `ConnectionType`:
* - `none` - device is offline
* - `wifi` - device is online and connected via wifi, or is the iOS simulator
* - `cellular` - device is connected via Edge, 3G, WiMax, or LTE
* - `unknown` - error case and the network status is unknown
*
* Android-only values for `ConnectionType`:
* - `bluetooth` - device is connected via Bluetooth
* - `ethernet` - device is connected via Ethernet
* - `wimax` - device is connected via WiMAX
*
* ### EffectiveConnectionType enum
*
* Cross platform values for `EffectiveConnectionType`:
* - `2g`
* - `3g`
* - `4g`
* - `unknown`
*
* ### Android
*
* To request network info, you need to add the following line to your
* app's `AndroidManifest.xml`:
*
* `<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />`
*
* ### isConnectionExpensive
*
* Available on Android. Detect if the current active connection is metered or not. A network is
* classified as metered when the user is sensitive to heavy data usage on that connection due to
* monetary costs, data limitations or battery/performance issues.
*
* ```
* NetInfo.isConnectionExpensive()
* .then(isConnectionExpensive => {
* console.log('Connection is ' + (isConnectionExpensive ? 'Expensive' : 'Not Expensive'));
* })
* .catch(error => {
* console.error(error);
* });
* ```
*
* ### isConnected
*
* Available on all platforms. Asynchronously fetch a boolean to determine
* internet connectivity.
*
* ```
* NetInfo.isConnected.fetch().then(isConnected => {
* console.log('First, is ' + (isConnected ? 'online' : 'offline'));
* });
* function handleFirstConnectivityChange(isConnected) {
* console.log('Then, is ' + (isConnected ? 'online' : 'offline'));
* NetInfo.isConnected.removeEventListener(
* 'connectionChange',
* handleFirstConnectivityChange
* );
* }
* NetInfo.isConnected.addEventListener(
* 'connectionChange',
* handleFirstConnectivityChange
* );
* ```
*
* ### Connectivity Types (deprecated)
*
* The following connectivity types are deprecated. They're used by the deprecated APIs `fetch` and the `change` event.
*
* iOS connectivity types (deprecated):
* - `none` - device is offline
* - `wifi` - device is online and connected via wifi, or is the iOS simulator
* - `cell` - device is connected via Edge, 3G, WiMax, or LTE
* - `unknown` - error case and the network status is unknown
*
* Android connectivity types (deprecated).
* - `NONE` - device is offline
* - `BLUETOOTH` - The Bluetooth data connection.
* - `DUMMY` - Dummy data connection.
* - `ETHERNET` - The Ethernet data connection.
* - `MOBILE` - The Mobile data connection.
* - `MOBILE_DUN` - A DUN-specific Mobile data connection.
* - `MOBILE_HIPRI` - A High Priority Mobile data connection.
* - `MOBILE_MMS` - An MMS-specific Mobile data connection.
* - `MOBILE_SUPL` - A SUPL-specific Mobile data connection.
* - `VPN` - A virtual network using one or more native bearers. Requires API Level 21
* - `WIFI` - The WIFI data connection.
* - `WIMAX` - The WiMAX data connection.
* - `UNKNOWN` - Unknown data connection.
*
* The rest of the connectivity types are hidden by the Android API, but can be used if necessary.
* NetInfo exposes info about online/offline status.
*
* See https://facebook.github.io/react-native/docs/netinfo.html
*/
const NetInfo = {
/**
* Adds an event handler. Supported events:
*
* - `connectionChange`: Fires when the network status changes. The argument to the event
* handler is an object with keys:
* - `type`: A `ConnectionType` (listed above)
* - `effectiveType`: An `EffectiveConnectionType` (listed above)
* - `change`: This event is deprecated. Listen to `connectionChange` instead. Fires when
* the network status changes. The argument to the event handler is one of the deprecated
* connectivity types listed above.
* Adds an event handler.
*
* See https://facebook.github.io/react-native/docs/netinfo.html#addeventlistener
*/
addEventListener(
eventName: ChangeEventName,
@ -246,6 +130,8 @@ const NetInfo = {
/**
* Removes the listener for network status changes.
*
* See https://facebook.github.io/react-native/docs/netinfo.html#removeeventlistener
*/
removeEventListener(
eventName: ChangeEventName,
@ -260,8 +146,37 @@ const NetInfo = {
},
/**
* This function is deprecated. Use `getConnectionInfo` instead. Returns a promise that
* resolves with one of the deprecated connectivity types listed above.
* This function is deprecated. Use `getConnectionInfo` instead.
* Returns a promise that resolves with one of the deprecated connectivity
* types:
*
* The following connectivity types are deprecated. They're used by the
* deprecated APIs `fetch` and the `change` event.
*
* iOS connectivity types (deprecated):
* - `none` - device is offline
* - `wifi` - device is online and connected via wifi, or is the iOS simulator
* - `cell` - device is connected via Edge, 3G, WiMax, or LTE
* - `unknown` - error case and the network status is unknown
*
* Android connectivity types (deprecated).
* - `NONE` - device is offline
* - `BLUETOOTH` - The Bluetooth data connection.
* - `DUMMY` - Dummy data connection.
* - `ETHERNET` - The Ethernet data connection.
* - `MOBILE` - The Mobile data connection.
* - `MOBILE_DUN` - A DUN-specific Mobile data connection.
* - `MOBILE_HIPRI` - A High Priority Mobile data connection.
* - `MOBILE_MMS` - An MMS-specific Mobile data connection.
* - `MOBILE_SUPL` - A SUPL-specific Mobile data connection.
* - `VPN` - A virtual network using one or more native bearers. Requires
* API Level 21
* - `WIFI` - The WIFI data connection.
* - `WIMAX` - The WiMAX data connection.
* - `UNKNOWN` - Unknown data connection.
*
* The rest of the connectivity types are hidden by the Android API, but can
* be used if necessary.
*/
fetch(): Promise<any> {
console.warn('NetInfo.fetch() is deprecated. Use NetInfo.getConnectionInfo() instead.');
@ -269,9 +184,7 @@ const NetInfo = {
},
/**
* Returns a promise that resolves to an object with `type` and `effectiveType` keys
* whose values are a `ConnectionType` and an `EffectiveConnectionType`, (described above),
* respectively.
* See https://facebook.github.io/react-native/docs/netinfo.html#getconnectioninfo
*/
getConnectionInfo(): Promise<any> {
return RCTNetInfo.getCurrentConnectivity().then(resp => {
@ -285,8 +198,8 @@ const NetInfo = {
/**
* An object with the same methods as above but the listener receives a
* boolean which represents the internet connectivity.
* Use this if you are only interested with whether the device has internet
* connectivity.
*
* See https://facebook.github.io/react-native/docs/netinfo.html#isconnected
*/
isConnected: {
addEventListener(

View File

@ -20,56 +20,9 @@ type Rationale = {
type PermissionStatus = 'granted' | 'denied' | 'never_ask_again';
/**
* <div class="banner-crna-ejected">
* <h3>Project with Native Code Required</h3>
* <p>
* This API only works in projects made with <code>react-native init</code>
* or in those made with Create React Native App which have since ejected. For
* more information about ejecting, please see
* the <a href="https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md" target="_blank">guide</a> on
* the Create React Native App repository.
* </p>
* </div>
*
* `PermissionsAndroid` provides access to Android M's new permissions model.
* Some permissions are granted by default when the application is installed
* so long as they appear in `AndroidManifest.xml`. However, "dangerous"
* permissions require a dialog prompt. You should use this module for those
* permissions.
*
* On devices before SDK version 23, the permissions are automatically granted
* if they appear in the manifest, so `check` and `request`
* should always be true.
*
* If a user has previously turned off a permission that you prompt for, the OS
* will advise your app to show a rationale for needing the permission. The
* optional `rationale` argument will show a dialog prompt only if
* necessary - otherwise the normal permission prompt will appear.
*
* ### Example
* ```
* import { PermissionsAndroid } from 'react-native';
*
* async function requestCameraPermission() {
* try {
* const granted = await PermissionsAndroid.request(
* PermissionsAndroid.PERMISSIONS.CAMERA,
* {
* 'title': 'Cool Photo App Camera Permission',
* 'message': 'Cool Photo App needs access to your camera ' +
* 'so you can take awesome pictures.'
* }
* )
* if (granted === PermissionsAndroid.RESULTS.GRANTED) {
* console.log("You can use the camera")
* } else {
* console.log("Camera permission denied")
* }
* } catch (err) {
* console.warn(err)
* }
* }
* ```
*
* See https://facebook.github.io/react-native/docs/permissionsandroid.html
*/
class PermissionsAndroid {
@ -130,6 +83,8 @@ class PermissionsAndroid {
/**
* Returns a promise resolving to a boolean value as to whether the specified
* permissions has been granted
*
* See https://facebook.github.io/react-native/docs/permissionsandroid.html#check
*/
check(permission: string) : Promise<boolean> {
return NativeModules.PermissionsAndroid.checkPermission(permission);
@ -159,11 +114,7 @@ class PermissionsAndroid {
* Prompts the user to enable a permission and returns a promise resolving to a
* string value indicating whether the user allowed or denied the request
*
* If the optional rationale argument is included (which is an object with a
* `title` and `message`), this function checks with the OS whether it is
* necessary to show a dialog explaining why the permission is needed
* (https://developer.android.com/training/permissions/requesting.html#explain)
* and then shows the system permission dialog
* See https://facebook.github.io/react-native/docs/permissionsandroid.html#request
*/
async request(permission: string, rationale?: Rationale) : Promise<PermissionStatus> {
if (rationale) {
@ -186,6 +137,8 @@ class PermissionsAndroid {
* Prompts the user to enable multiple permissions in the same dialog and
* returns an object with the permissions as keys and strings as values
* indicating whether the user allowed or denied the request
*
* See https://facebook.github.io/react-native/docs/permissionsandroid.html#requestmultiple
*/
requestMultiple(permissions: Array<string>) : Promise<{[permission: string]: PermissionStatus}> {
return NativeModules.PermissionsAndroid.requestMultiplePermissions(permissions);

View File

@ -60,64 +60,11 @@ export type PushNotificationEventName = $Enum<{
}>;
/**
* <div class="banner-crna-ejected">
* <h3>Projects with Native Code Only</h3>
* <p>
* This section only applies to projects made with <code>react-native init</code>
* or to those made with Create React Native App which have since ejected. For
* more information about ejecting, please see
* the <a href="https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md" target="_blank">guide</a> on
* the Create React Native App repository.
* </p>
* </div>
*
* Handle push notifications for your app, including permission handling and
* icon badge number.
*
* To get up and running, [configure your notifications with Apple](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AddingCapabilities/AddingCapabilities.html#//apple_ref/doc/uid/TP40012582-CH26-SW6)
* and your server-side system.
*
* [Manually link](docs/linking-libraries-ios.html#manual-linking) the PushNotificationIOS library
*
* - Add the following to your Project: `node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj`
* - Add the following to `Link Binary With Libraries`: `libRCTPushNotification.a`
*
* Finally, to enable support for `notification` and `register` events you need to augment your AppDelegate.
*
* At the top of your `AppDelegate.m`:
*
* `#import <React/RCTPushNotificationManager.h>`
*
* And then in your AppDelegate implementation add the following:
*
* ```
* // Required to register for notifications
* - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
* {
* [RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings];
* }
* // Required for the register event.
* - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
* {
* [RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
* }
* // Required for the notification event. You must call the completion handler after handling the remote notification.
* - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
* fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
* {
* [RCTPushNotificationManager didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
* }
* // Required for the registrationError event.
* - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
* {
* [RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error];
* }
* // Required for the localNotification event.
* - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
* {
* [RCTPushNotificationManager didReceiveLocalNotification:notification];
* }
* ```
* See https://facebook.github.io/react-native/docs/pushnotificationios.html
*/
class PushNotificationIOS {
_data: Object;
@ -140,15 +87,7 @@ class PushNotificationIOS {
/**
* Schedules the localNotification for immediate presentation.
*
* details is an object containing:
*
* - `alertBody` : The message displayed in the notification alert.
* - `alertAction` : The "action" displayed beneath an actionable notification. Defaults to "view";
* - `soundName` : The sound played when the notification is fired (optional).
* - `isSilent` : If true, the notification will appear without sound (optional).
* - `category` : The category of this notification, required for actionable notifications (optional).
* - `userInfo` : An optional object containing additional notification data.
* - `applicationIconBadgeNumber` (optional) : The number to display as the app's icon badge. The default value of this property is 0, which means that no badge is displayed.
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#presentlocalnotification
*/
static presentLocalNotification(details: Object) {
RCTPushNotificationManager.presentLocalNotification(details);
@ -157,50 +96,34 @@ class PushNotificationIOS {
/**
* Schedules the localNotification for future presentation.
*
* details is an object containing:
*
* - `fireDate` : The date and time when the system should deliver the notification.
* - `alertTitle` : The text displayed as the title of the notification alert.
* - `alertBody` : The message displayed in the notification alert.
* - `alertAction` : The "action" displayed beneath an actionable notification. Defaults to "view";
* - `soundName` : The sound played when the notification is fired (optional).
* - `isSilent` : If true, the notification will appear without sound (optional).
* - `category` : The category of this notification, required for actionable notifications (optional).
* - `userInfo` : An optional object containing additional notification data.
* - `applicationIconBadgeNumber` (optional) : The number to display as the app's icon badge. Setting the number to 0 removes the icon badge.
* - `repeatInterval` : The interval to repeat as a string. Possible values: `minute`, `hour`, `day`, `week`, `month`, `year`.
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#schedulelocalnotification
*/
static scheduleLocalNotification(details: Object) {
RCTPushNotificationManager.scheduleLocalNotification(details);
}
/**
* Cancels all scheduled localNotifications
* Cancels all scheduled localNotifications.
*
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#cancelalllocalnotifications
*/
static cancelAllLocalNotifications() {
RCTPushNotificationManager.cancelAllLocalNotifications();
}
/**
* Remove all delivered notifications from Notification Center
* Remove all delivered notifications from Notification Center.
*
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#removealldeliverednotifications
*/
static removeAllDeliveredNotifications(): void {
RCTPushNotificationManager.removeAllDeliveredNotifications();
}
/**
* Provides you with a list of the apps notifications that are still displayed in Notification Center
* Provides you with a list of the apps notifications that are still displayed in Notification Center.
*
* @param callback Function which receive an array of delivered notifications
*
* A delivered notification is an object containing:
*
* - `identifier` : The identifier of this notification.
* - `title` : The title of this notification.
* - `body` : The body of this notification.
* - `category` : The category of this notification, if has one.
* - `userInfo` : An optional object containing additional notification data.
* - `thread-id` : The thread identifier of this notification, if has one.
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#getdeliverednotifications
*/
static getDeliveredNotifications(callback: (notifications: Array<Object>) => void): void {
RCTPushNotificationManager.getDeliveredNotifications(callback);
@ -209,21 +132,25 @@ class PushNotificationIOS {
/**
* Removes the specified notifications from Notification Center
*
* @param identifiers Array of notification identifiers
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#removedeliverednotifications
*/
static removeDeliveredNotifications(identifiers: Array<string>): void {
RCTPushNotificationManager.removeDeliveredNotifications(identifiers);
}
/**
* Sets the badge number for the app icon on the home screen
* Sets the badge number for the app icon on the home screen.
*
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#setapplicationiconbadgenumber
*/
static setApplicationIconBadgeNumber(number: number) {
RCTPushNotificationManager.setApplicationIconBadgeNumber(number);
}
/**
* Gets the current badge number for the app icon on the home screen
* Gets the current badge number for the app icon on the home screen.
*
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#getapplicationiconbadgenumber
*/
static getApplicationIconBadgeNumber(callback: Function) {
RCTPushNotificationManager.getApplicationIconBadgeNumber(callback);
@ -232,9 +159,7 @@ class PushNotificationIOS {
/**
* Cancel local notifications.
*
* Optionally restricts the set of canceled notifications to those
* notifications whose `userInfo` fields match the corresponding fields
* in the `userInfo` argument.
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#cancellocalnotification
*/
static cancelLocalNotifications(userInfo: Object) {
RCTPushNotificationManager.cancelLocalNotifications(userInfo);
@ -242,27 +167,18 @@ class PushNotificationIOS {
/**
* Gets the local notifications that are currently scheduled.
*
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#getscheduledlocalnotifications
*/
static getScheduledLocalNotifications(callback: Function) {
RCTPushNotificationManager.getScheduledLocalNotifications(callback);
}
/**
* Attaches a listener to remote or local notification events while the app is running
* in the foreground or the background.
* Attaches a listener to remote or local notification events while the app
* is running in the foreground or the background.
*
* Valid events are:
*
* - `notification` : Fired when a remote notification is received. The
* handler will be invoked with an instance of `PushNotificationIOS`.
* - `localNotification` : Fired when a local notification is received. The
* handler will be invoked with an instance of `PushNotificationIOS`.
* - `register`: Fired when the user registers for remote notifications. The
* handler will be invoked with a hex string representing the deviceToken.
* - `registrationError`: Fired when the user fails to register for remote
* notifications. Typically occurs when APNS is having issues, or the device
* is a simulator. The handler will be invoked with
* {message: string, code: number, details: any}.
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#addeventlistener
*/
static addEventListener(type: PushNotificationEventName, handler: Function) {
invariant(
@ -304,7 +220,9 @@ class PushNotificationIOS {
/**
* Removes the event listener. Do this in `componentWillUnmount` to prevent
* memory leaks
* memory leaks.
*
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#removeeventlistener
*/
static removeEventListener(type: PushNotificationEventName, handler: Function) {
invariant(
@ -324,18 +242,8 @@ class PushNotificationIOS {
* dialog box. By default, it will request all notification permissions, but
* a subset of these can be requested by passing a map of requested
* permissions.
* The following permissions are supported:
*
* - `alert`
* - `badge`
* - `sound`
*
* If a map is provided to the method, only the permissions with truthy values
* will be requested.
* This method returns a promise that will resolve when the user accepts,
* rejects, or if the permissions were previously rejected. The promise
* resolves to the current state of the permission.
*
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#requestpermissions
*/
static requestPermissions(permissions?: {
alert?: boolean,
@ -366,10 +274,7 @@ class PushNotificationIOS {
/**
* Unregister for all remote notifications received via Apple Push Notification service.
*
* You should call this method in rare circumstances only, such as when a new version of
* the app removes support for all types of remote notifications. Users can temporarily
* prevent apps from receiving remote notifications through the Notifications section of
* the Settings app. Apps unregistered through this method can always re-register.
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#abandonpermissions
*/
static abandonPermissions() {
RCTPushNotificationManager.abandonPermissions();
@ -377,11 +282,9 @@ class PushNotificationIOS {
/**
* See what push permissions are currently enabled. `callback` will be
* invoked with a `permissions` object:
*
* - `alert` :boolean
* - `badge` :boolean
* - `sound` :boolean
* invoked with a `permissions` object.
*
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#checkpermissions
*/
static checkPermissions(callback: Function) {
invariant(
@ -394,6 +297,8 @@ class PushNotificationIOS {
/**
* This method returns a promise that resolves to either the notification
* object if the app was launched by a push notification, or `null` otherwise.
*
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#getinitialnotification
*/
static getInitialNotification(): Promise<?PushNotificationIOS> {
return RCTPushNotificationManager.getInitialNotification().then(notification => {
@ -405,6 +310,7 @@ class PushNotificationIOS {
* You will never need to instantiate `PushNotificationIOS` yourself.
* Listening to the `notification` event and invoking
* `getInitialNotification` is sufficient
*
*/
constructor(nativeNotif: Object) {
this._data = {};
@ -443,15 +349,8 @@ class PushNotificationIOS {
/**
* This method is available for remote notifications that have been received via:
* `application:didReceiveRemoteNotification:fetchCompletionHandler:`
* https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/#//apple_ref/occ/intfm/UIApplicationDelegate/application:didReceiveRemoteNotification:fetchCompletionHandler:
*
* Call this to execute when the remote notification handling is complete. When
* calling this block, pass in the fetch result value that best describes
* the results of your operation. You *must* call this handler and should do so
* as soon as possible. For a list of possible values, see `PushNotificationIOS.FetchResult`.
*
* If you do not call this method your background remote notifications could
* be throttled, to read more about it see the above documentation link.
*
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#finish
*/
finish(fetchResult: string) {
if (!this._isRemote || !this._notificationId || this._remoteNotificationCompleteCallbackCalled) {
@ -472,6 +371,8 @@ class PushNotificationIOS {
/**
* Gets the sound string from the `aps` object
*
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#getsound
*/
getSound(): ?string {
return this._sound;
@ -479,6 +380,8 @@ class PushNotificationIOS {
/**
* Gets the category string from the `aps` object
*
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#getcategory
*/
getCategory(): ?string {
return this._category;
@ -486,6 +389,8 @@ class PushNotificationIOS {
/**
* Gets the notification's main message from the `aps` object
*
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#getalert
*/
getAlert(): ?string | ?Object {
return this._alert;
@ -493,6 +398,8 @@ class PushNotificationIOS {
/**
* Gets the content-available number from the `aps` object
*
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#getcontentavailable
*/
getContentAvailable(): ContentAvailable {
return this._contentAvailable;
@ -500,6 +407,8 @@ class PushNotificationIOS {
/**
* Gets the badge count number from the `aps` object
*
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#getbadgecount
*/
getBadgeCount(): ?number {
return this._badgeCount;
@ -507,6 +416,8 @@ class PushNotificationIOS {
/**
* Gets the data object on the notif
*
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#getdata
*/
getData(): ?Object {
return this._data;
@ -514,6 +425,8 @@ class PushNotificationIOS {
/**
* Gets the thread ID on the notif
*
* See https://facebook.github.io/react-native/docs/pushnotificationios.html#getthreadid
*/
getThreadID(): ?string {
return this._threadID;

View File

@ -52,359 +52,115 @@ import type {ViewChildContext} from 'ViewContext';
/**
* A React component for displaying text.
*
* `Text` supports nesting, styling, and touch handling.
*
* In the following example, the nested title and body text will inherit the
* `fontFamily` from `styles.baseText`, but the title provides its own
* additional styles. The title and body will stack on top of each other on
* account of the literal newlines:
*
* ```ReactNativeWebPlayer
* import React, { Component } from 'react';
* import { AppRegistry, Text, StyleSheet } from 'react-native';
*
* export default class TextInANest extends Component {
* constructor(props) {
* super(props);
* this.state = {
* titleText: "Bird's Nest",
* bodyText: 'This is not really a bird nest.'
* };
* }
*
* render() {
* return (
* <Text style={styles.baseText}>
* <Text style={styles.titleText} onPress={this.onPressTitle}>
* {this.state.titleText}{'\n'}{'\n'}
* </Text>
* <Text numberOfLines={5}>
* {this.state.bodyText}
* </Text>
* </Text>
* );
* }
* }
*
* const styles = StyleSheet.create({
* baseText: {
* fontFamily: 'Cochin',
* },
* titleText: {
* fontSize: 20,
* fontWeight: 'bold',
* },
* });
*
* // skip this line if using Create React Native App
* AppRegistry.registerComponent('TextInANest', () => TextInANest);
* ```
*
* ## Nested text
*
* Both iOS and Android allow you to display formatted text by annotating
* ranges of a string with specific formatting like bold or colored text
* (`NSAttributedString` on iOS, `SpannableString` on Android). In practice,
* this is very tedious. For React Native, we decided to use web paradigm for
* this where you can nest text to achieve the same effect.
*
*
* ```ReactNativeWebPlayer
* import React, { Component } from 'react';
* import { AppRegistry, Text } from 'react-native';
*
* export default class BoldAndBeautiful extends Component {
* render() {
* return (
* <Text style={{fontWeight: 'bold'}}>
* I am bold
* <Text style={{color: 'red'}}>
* and red
* </Text>
* </Text>
* );
* }
* }
*
* // skip this line if using Create React Native App
* AppRegistry.registerComponent('AwesomeProject', () => BoldAndBeautiful);
* ```
*
* Behind the scenes, React Native converts this to a flat `NSAttributedString`
* or `SpannableString` that contains the following information:
*
* ```javascript
* "I am bold and red"
* 0-9: bold
* 9-17: bold, red
* ```
*
* ## Nested views (iOS only)
*
* On iOS, you can nest views within your Text component. Here's an example:
*
* ```ReactNativeWebPlayer
* import React, { Component } from 'react';
* import { AppRegistry, Text, View } from 'react-native';
*
* export default class BlueIsCool extends Component {
* render() {
* return (
* <Text>
* There is a blue square
* <View style={{width: 50, height: 50, backgroundColor: 'steelblue'}} />
* in between my text.
* </Text>
* );
* }
* }
*
* // skip this line if using Create React Native App
* AppRegistry.registerComponent('AwesomeProject', () => BlueIsCool);
* ```
*
* > In order to use this feature, you must give the view a `width` and a `height`.
*
* ## Containers
*
* The `<Text>` element is special relative to layout: everything inside is no
* longer using the flexbox layout but using text layout. This means that
* elements inside of a `<Text>` are no longer rectangles, but wrap when they
* see the end of the line.
*
* ```javascript
* <Text>
* <Text>First part and </Text>
* <Text>second part</Text>
* </Text>
* // Text container: all the text flows as if it was one
* // |First part |
* // |and second |
* // |part |
*
* <View>
* <Text>First part and </Text>
* <Text>second part</Text>
* </View>
* // View container: each text is its own block
* // |First part |
* // |and |
* // |second part|
* ```
*
* ## Limited Style Inheritance
*
* On the web, the usual way to set a font family and size for the entire
* document is to take advantage of inherited CSS properties like so:
*
* ```css
* html {
* font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;
* font-size: 11px;
* color: #141823;
* }
* ```
*
* All elements in the document will inherit this font unless they or one of
* their parents specifies a new rule.
*
* In React Native, we are more strict about it: **you must wrap all the text
* nodes inside of a `<Text>` component**. You cannot have a text node directly
* under a `<View>`.
*
*
* ```javascript
* // BAD: will raise exception, can't have a text node as child of a <View>
* <View>
* Some text
* </View>
*
* // GOOD
* <View>
* <Text>
* Some text
* </Text>
* </View>
* ```
*
* You also lose the ability to set up a default font for an entire subtree.
* The recommended way to use consistent fonts and sizes across your
* application is to create a component `MyAppText` that includes them and use
* this component across your app. You can also use this component to make more
* specific components like `MyAppHeaderText` for other kinds of text.
*
* ```javascript
* <View>
* <MyAppText>Text styled with the default font for the entire application</MyAppText>
* <MyAppHeaderText>Text styled as a header</MyAppHeaderText>
* </View>
* ```
*
* Assuming that `MyAppText` is a component that simply renders out its
* children into a `Text` component with styling, then `MyAppHeaderText` can be
* defined as follows:
*
* ```javascript
* class MyAppHeaderText extends Component {
* render() {
* return (
* <MyAppText>
* <Text style={{fontSize: 20}}>
* {this.props.children}
* </Text>
* </MyAppText>
* );
* }
* }
* ```
*
* Composing `MyAppText` in this way ensures that we get the styles from a
* top-level component, but leaves us the ability to add / override them in
* specific use cases.
*
* React Native still has the concept of style inheritance, but limited to text
* subtrees. In this case, the second part will be both bold and red.
*
* ```javascript
* <Text style={{fontWeight: 'bold'}}>
* I am bold
* <Text style={{color: 'red'}}>
* and red
* </Text>
* </Text>
* ```
*
* We believe that this more constrained way to style text will yield better
* apps:
*
* - (Developer) React components are designed with strong isolation in mind:
* You should be able to drop a component anywhere in your application,
* trusting that as long as the props are the same, it will look and behave the
* same way. Text properties that could inherit from outside of the props would
* break this isolation.
*
* - (Implementor) The implementation of React Native is also simplified. We do
* not need to have a `fontFamily` field on every single element, and we do not
* need to potentially traverse the tree up to the root every time we display a
* text node. The style inheritance is only encoded inside of the native Text
* component and doesn't leak to other components or the system itself.
*
* See https://facebook.github.io/react-native/docs/text.html
*/
const Text = createReactClass({
displayName: 'Text',
propTypes: {
/**
* When `numberOfLines` is set, this prop defines how text will be truncated.
* `numberOfLines` must be set in conjunction with this prop.
* When `numberOfLines` is set, this prop defines how text will be
* truncated.
*
* This can be one of the following values:
*
* - `head` - The line is displayed so that the end fits in the container and the missing text
* at the beginning of the line is indicated by an ellipsis glyph. e.g., "...wxyz"
* - `middle` - The line is displayed so that the beginning and end fit in the container and the
* missing text in the middle is indicated by an ellipsis glyph. "ab...yz"
* - `tail` - The line is displayed so that the beginning fits in the container and the
* missing text at the end of the line is indicated by an ellipsis glyph. e.g., "abcd..."
* - `clip` - Lines are not drawn past the edge of the text container.
*
* The default is `tail`.
*
* > `clip` is working only for iOS
* See https://facebook.github.io/react-native/docs/text.html#ellipsizemode
*/
ellipsizeMode: PropTypes.oneOf(['head', 'middle', 'tail', 'clip']),
/**
* Used to truncate the text with an ellipsis after computing the text
* layout, including line wrapping, such that the total number of lines
* does not exceed this number.
* Used to truncate the text with an ellipsis.
*
* This prop is commonly used with `ellipsizeMode`.
* See https://facebook.github.io/react-native/docs/text.html#numberoflines
*/
numberOfLines: PropTypes.number,
/**
* Set text break strategy on Android API Level 23+, possible values are `simple`, `highQuality`, `balanced`
* The default value is `highQuality`.
* @platform android
* Set text break strategy on Android.
*
* See https://facebook.github.io/react-native/docs/text.html#textbreakstrategy
*/
textBreakStrategy: PropTypes.oneOf(['simple', 'highQuality', 'balanced']),
/**
* Invoked on mount and layout changes with
* Invoked on mount and layout changes.
*
* `{nativeEvent: {layout: {x, y, width, height}}}`
* See https://facebook.github.io/react-native/docs/text.html#onlayout
*/
onLayout: PropTypes.func,
/**
* This function is called on press.
*
* e.g., `onPress={() => console.log('1st')}`
* See https://facebook.github.io/react-native/docs/text.html#onpress
*/
onPress: PropTypes.func,
/**
* This function is called on long press.
*
* e.g., `onLongPress={this.increaseSize}>`
* See https://facebook.github.io/react-native/docs/text.html#onlongpress
*/
onLongPress: PropTypes.func,
/**
* When the scroll view is disabled, this defines how far your touch may
* move off of the button, before deactivating the button. Once deactivated,
* try moving it back and you'll see that the button is once again
* reactivated! Move it back and forth several times while the scroll view
* is disabled. Ensure you pass in a constant to reduce memory allocations.
* Defines how far your touch may move off of the button, before
* deactivating the button.
*
* See https://facebook.github.io/react-native/docs/text.html#pressretentionoffset
*/
pressRetentionOffset: EdgeInsetsPropType,
/**
* Lets the user select text, to use the native copy and paste functionality.
* Lets the user select text.
*
* See https://facebook.github.io/react-native/docs/text.html#selectable
*/
selectable: PropTypes.bool,
/**
* The highlight color of the text.
* @platform android
*
* See https://facebook.github.io/react-native/docs/text.html#selectioncolor
*/
selectionColor: ColorPropType,
/**
* When `true`, no visual change is made when text is pressed down. By
* default, a gray oval highlights the text on press down.
* @platform ios
* When `true`, no visual change is made when text is pressed down.
*
* See https://facebook.github.io/react-native/docs/text.html#supperhighlighting
*/
suppressHighlighting: PropTypes.bool,
style: stylePropType,
/**
* Used to locate this view in end-to-end tests.
*
* See https://facebook.github.io/react-native/docs/text.html#testid
*/
testID: PropTypes.string,
/**
* Used to locate this view from native code.
*
* See https://facebook.github.io/react-native/docs/text.html#nativeid
*/
nativeID: PropTypes.string,
/**
* Specifies whether fonts should scale to respect Text Size accessibility settings. The
* default is `true`.
* Whether fonts should scale to respect Text Size accessibility settings.
*
* See https://facebook.github.io/react-native/docs/text.html#allowfontscaling
*/
allowFontScaling: PropTypes.bool,
/**
* When set to `true`, indicates that the view is an accessibility element. The default value
* for a `Text` element is `true`.
* Indicates whether the view is an accessibility element.
*
* See the
* [Accessibility guide](docs/accessibility.html#accessible-ios-android)
* for more information.
* See https://facebook.github.io/react-native/docs/text.html#accessible
*/
accessible: PropTypes.bool,
/**
* Specifies whether font should be scaled down automatically to fit given style constraints.
* @platform ios
* Whether font should be scaled down automatically.
*
* See https://facebook.github.io/react-native/docs/text.html#adjustsfontsizetofit
*/
adjustsFontSizeToFit: PropTypes.bool,
/**
* Specifies smallest possible scale a font can reach when adjustsFontSizeToFit is enabled. (values 0.01-1.0).
* @platform ios
* Smallest possible scale a font can reach.
*
* See https://facebook.github.io/react-native/docs/text.html#minimumfontscale
*/
minimumFontScale: PropTypes.number,
/**
* Specifies the disabled state of the text view for testing purposes
* @platform android
* Specifies the disabled state of the text view for testing purposes.
*
* See https://facebook.github.io/react-native/docs/text.html#disabled
*/
disabled: PropTypes.bool,
},

View File

@ -16,46 +16,9 @@ var RCTVibration = require('NativeModules').Vibration;
var Platform = require('Platform');
/**
* @class
* @description
* The Vibration API is exposed at `Vibration.vibrate()`.
* The vibration is asynchronous so this method will return immediately.
*
* There will be no effect on devices that do not support Vibration, eg. the simulator.
*
* **Note for Android:**
* add `<uses-permission android:name="android.permission.VIBRATE"/>` to `AndroidManifest.xml`
*
* Since the **vibration duration in iOS is not configurable**, so there are some differences with Android.
* In Android, if `pattern` is a number, it specified the vibration duration in ms. If `pattern`
* is an array, those odd indices is the vibration duration, while the even one are the separation time.
*
* In iOS, invoking `vibrate(duration)` will just ignore the duration and vibrate for a fixed time. While the
* `pattern` array is used to define the duration between each vibration. See below example for more.
*
* Repeatable vibration is also supported, the vibration will repeat with defined pattern until `cancel()` is called.
*
* Example:
* ```
* const DURATION = 10000
* const PATTERN = [1000, 2000, 3000]
*
* Vibration.vibrate(DURATION)
* // Android: vibrate for 10s
* // iOS: duration is not configurable, vibrate for fixed time (about 500ms)
*
* Vibration.vibrate(PATTERN)
* // Android: wait 1s -> vibrate 2s -> wait 3s
* // iOS: wait 1s -> vibrate -> wait 2s -> vibrate -> wait 3s -> vibrate
*
* Vibration.vibrate(PATTERN, true)
* // Android: wait 1s -> vibrate 2s -> wait 3s -> wait 1s -> vibrate 2s -> wait 3s -> ...
* // iOS: wait 1s -> vibrate -> wait 2s -> vibrate -> wait 3s -> vibrate -> wait 1s -> vibrate -> wait 2s -> vibrate -> wait 3s -> vibrate -> ...
*
* Vibration.cancel()
* // Android: vibration stopped
* // iOS: vibration stopped
* ```
* Vibration API
*
* See https://facebook.github.io/react-native/docs/vibration.html
*/
var _vibrating: boolean = false;
@ -96,8 +59,8 @@ function vibrateScheduler(id, pattern: Array<number>, repeat: boolean, nextIndex
var Vibration = {
/**
* Trigger a vibration with specified `pattern`.
* @param pattern Vibration pattern, accept a number or an array of number. Default to 400ms.
* @param repeat Optional. Repeat vibration pattern until cancel(), default to false.
*
* See https://facebook.github.io/react-native/docs/vibration.html#vibrate
*/
vibrate: function(pattern: number | Array<number> = 400, repeat: boolean = false) {
if (Platform.OS === 'android') {
@ -123,9 +86,8 @@ var Vibration = {
},
/**
* Stop vibration
* ```
* Vibration.cancel()
* ```
*
* See https://facebook.github.io/react-native/docs/vibration.html#cancel
*/
cancel: function() {
if (Platform.OS === 'ios') {