diff --git a/docs/accessibility.html b/docs/accessibility.html index 5730565021b..2a52e21c26d 100644 --- a/docs/accessibility.html +++ b/docs/accessibility.html @@ -1,45 +1,45 @@ -
Both iOS and Android provide APIs for making apps accessible to people with disabilities. In addition, both platforms provide bundled assistive technologies, like the screen readers VoiceOver (iOS) and TalkBack (Android) for the visually impaired. Similarly, in React Native we have included APIs designed to provide developers with support for making apps more accessible. Take note, iOS and Android differ slightly in their approaches, and thus the React Native implementations may vary by platform.
In addition to this documentation, you might find this blog post about React Native accessibility to be useful.
When true, indicates that the view is an accessibility element. When a view is an accessibility element, it groups its children into a single selectable component. By default, all touchable elements are accessible.
On Android, ‘accessible={true}’ property for a react-native View will be translated into native ‘focusable={true}’.
In the above example, we can't get accessibility focus separately on 'text one' and 'text two'. Instead we get focus on a parent view with 'accessible' property.
When a view is marked as accessible, it is a good practice to set an accessibilityLabel on the view, so that people who use VoiceOver know what element they have selected. VoiceOver will read this string when a user selects the associated element.
To use, set the accessibilityLabel property to a custom string on your View:
In the above example, the accessibilityLabel on the TouchableOpacity element would default to "Press me!". The label is constructed by concatenating all Text node children separated by spaces.
Accessibility traits tell a person using VoiceOver what kind of element they have selected. Is this element a label? A button? A header? These questions are answered by accessibilityTraits.
To use, set the accessibilityTraits property to one of (or an array of) accessibility trait strings:
A Boolean value indicating whether VoiceOver should ignore the elements within views that are siblings of the receiver.
For example, in a window that contains sibling views A and B, setting accessibilityViewIsModal to true on view B causes VoiceOver to ignore the elements in the view A.
-On the other hand, if view B contains a child view C and you set accessibilityViewIsModal to true on view C, VoiceOver does not ignore the elements in view A.
Use this property to assign a custom function to be called when someone activates an accessible element by double tapping on it while it's selected.
Assign this property to a custom function which will be called when someone performs the "magic tap" gesture, which is a double-tap with two fingers. A magic tap function should perform the most relevant action a user could take on a component. In the Phone app on iPhone, a magic tap answers a phone call, or ends the current one. If the selected element does not have an onMagicTap function, the system will traverse up the view hierarchy until it finds a view that does.
In some cases, we also want to alert the end user of the type of selected component (i.e., that it is a “button”). If we were using native buttons, this would work automatically. Since we are using javascript, we need to provide a bit more context for TalkBack. To do so, you must specify the ‘accessibilityComponentType’ property for any UI component. For instances, we support ‘button’, ‘radiobutton_checked’ and ‘radiobutton_unchecked’ and so on.
Both iOS and Android provide APIs for making apps accessible to people with disabilities. In addition, both platforms provide bundled assistive technologies, like the screen readers VoiceOver (iOS) and TalkBack (Android) for the visually impaired. Similarly, in React Native we have included APIs designed to provide developers with support for making apps more accessible. Take note, iOS and Android differ slightly in their approaches, and thus the React Native implementations may vary by platform.
In addition to this documentation, you might find this blog post about React Native accessibility to be useful.
When true, indicates that the view is an accessibility element. When a view is an accessibility element, it groups its children into a single selectable component. By default, all touchable elements are accessible.
On Android, ‘accessible={true}’ property for a react-native View will be translated into native ‘focusable={true}’.
In the above example, we can't get accessibility focus separately on 'text one' and 'text two'. Instead we get focus on a parent view with 'accessible' property.
When a view is marked as accessible, it is a good practice to set an accessibilityLabel on the view, so that people who use VoiceOver know what element they have selected. VoiceOver will read this string when a user selects the associated element.
To use, set the accessibilityLabel property to a custom string on your View:
In the above example, the accessibilityLabel on the TouchableOpacity element would default to "Press me!". The label is constructed by concatenating all Text node children separated by spaces.
Accessibility traits tell a person using VoiceOver what kind of element they have selected. Is this element a label? A button? A header? These questions are answered by accessibilityTraits.
To use, set the accessibilityTraits property to one of (or an array of) accessibility trait strings:
A Boolean value indicating whether VoiceOver should ignore the elements within views that are siblings of the receiver.
For example, in a window that contains sibling views A and B, setting accessibilityViewIsModal to true on view B causes VoiceOver to ignore the elements in the view A.
+On the other hand, if view B contains a child view C and you set accessibilityViewIsModal to true on view C, VoiceOver does not ignore the elements in view A.
Use this property to assign a custom function to be called when someone activates an accessible element by double tapping on it while it's selected.
Assign this property to a custom function which will be called when someone performs the "magic tap" gesture, which is a double-tap with two fingers. A magic tap function should perform the most relevant action a user could take on a component. In the Phone app on iPhone, a magic tap answers a phone call, or ends the current one. If the selected element does not have an onMagicTap function, the system will traverse up the view hierarchy until it finds a view that does.
In some cases, we also want to alert the end user of the type of selected component (i.e., that it is a “button”). If we were using native buttons, this would work automatically. Since we are using javascript, we need to provide a bit more context for TalkBack. To do so, you must specify the ‘accessibilityComponentType’ property for any UI component. For instances, we support ‘button’, ‘radiobutton_checked’ and ‘radiobutton_unchecked’ and so on.
In the above example, the TouchableWithoutFeedback is being announced by TalkBack as a native Button.
When components dynamically change, we want TalkBack to alert the end user. This is made possible by the ‘accessibilityLiveRegion’ property. It can be set to ‘none’, ‘polite’ and ‘assertive’:
In the above example, the TouchableWithoutFeedback is being announced by TalkBack as a native Button.
When components dynamically change, we want TalkBack to alert the end user. This is made possible by the ‘accessibilityLiveRegion’ property. It can be set to ‘none’, ‘polite’ and ‘assertive’:
In the above example method _addOne changes the state.count variable. As soon as an end user clicks the TouchableWithoutFeedback, TalkBack reads text in the Text view because of its 'accessibilityLiveRegion=”polite”' property.
In the case of two overlapping UI components with the same parent, default accessibility focus can have unpredictable behavior. The ‘importantForAccessibility’ property will resolve this by controlling if a view fires accessibility events and if it is reported to accessibility services. It can be set to ‘auto’, ‘yes’, ‘no’ and ‘no-hide-descendants’ (the last value will force accessibility services to ignore the component and all of its children).
In the above example method _addOne changes the state.count variable. As soon as an end user clicks the TouchableWithoutFeedback, TalkBack reads text in the Text view because of its 'accessibilityLiveRegion=”polite”' property.
In the case of two overlapping UI components with the same parent, default accessibility focus can have unpredictable behavior. The ‘importantForAccessibility’ property will resolve this by controlling if a view fires accessibility events and if it is reported to accessibility services. It can be set to ‘auto’, ‘yes’, ‘no’ and ‘no-hide-descendants’ (the last value will force accessibility services to ignore the component and all of its children).
In the above example, the yellow layout and its descendants are completely invisible to TalkBack and all other accessibility services. So we can easily use overlapping views with the same parent without confusing TalkBack.
The AccessibilityInfo API allows you to determine whether or not a screen reader is currently active. See the AccessibilityInfo documentation for details.
Sometimes it is useful to trigger an accessibility event on a UI component (i.e. when a custom view appears on a screen or a custom radio button has been selected). Native UIManager module exposes a method ‘sendAccessibilityEvent’ for this purpose. It takes two arguments: view tag and a type of an event.
In the above example, the yellow layout and its descendants are completely invisible to TalkBack and all other accessibility services. So we can easily use overlapping views with the same parent without confusing TalkBack.
The AccessibilityInfo API allows you to determine whether or not a screen reader is currently active. See the AccessibilityInfo documentation for details.
Sometimes it is useful to trigger an accessibility event on a UI component (i.e. when a custom view appears on a screen or a custom radio button has been selected). Native UIManager module exposes a method ‘sendAccessibilityEvent’ for this purpose. It takes two arguments: view tag and a type of an event.
In the above example we've created a custom radio button that now behaves like a native one. More specifically, TalkBack now correctly announces changes to the radio button selection.
To enable VoiceOver, go to the Settings app on your iOS device. Tap General, then Accessibility. There you will find many tools that people use to use to make their devices more usable, such as bolder text, increased contrast, and VoiceOver.
To enable VoiceOver, tap on VoiceOver under "Vision" and toggle the switch that appears at the top.
At the very bottom of the Accessibility settings, there is an "Accessibility Shortcut". You can use this to toggle VoiceOver by triple clicking the Home button.
You can edit the content above on GitHub and send us a pull request!
Sometimes it's useful to know whether or not the device has a screen reader that is currently active. The +
Sometimes it's useful to know whether or not the device has a screen reader that is currently active. The
AccessibilityInfo API is designed for this purpose. You can use it to query the current state of the
-screen reader as well as to register to be notified when the state of the screen reader changes.
Here's a small example illustrating how to use AccessibilityInfo:
Here's a small example illustrating how to use AccessibilityInfo:
Query whether a screen reader is currently enabled. Returns a promise which
resolves to a boolean. The result is true when a screen reader is enabled
and false otherwise.
Add an event handler. Supported events:
change: Fires when the state of the screen reader changes. The argument
to the event handler is a boolean. The boolean is true when a screen
-reader is enabled and false otherwise.Remove an event handler.
You can edit the content above on GitHub and send us a pull request!
Display an iOS action sheet. The options object must contain one or more
+
Display an iOS action sheet. The options object must contain one or more
of:
options (array of strings) - a list of button titles (required)cancelButtonIndex (int) - index of cancel button in optionsdestructiveButtonIndex (int) - index of destructive button in optionstitle (string) - a title to show above the action sheetmessage (string) - a message to show below the titleDisplay the iOS share sheet. The options object should contain
one or both of message and url and can additionally have
a subject or excludedActivityTypes:
url (string) - a URL to sharemessage (string) - a message to sharesubject (string) - a subject for the messageexcludedActivityTypes (array) - the activities to exclude from the ActionSheetNOTE: if url points to a local file, or is a base64-encoded
@@ -19,6 +19,6 @@ In this way, you can share images, videos, PDF files, etc.
Displays a circular loading indicator.
Whether to show the indicator (true, the default) or hide it (false).
Size of the indicator (default is 'small'). -Passing a number to the size prop is only supported on Android.
Whether the indicator should hide when not animating (true by default).
You can edit the content above on GitHub and send us a pull request!
Displays a circular loading indicator.
Whether to show the indicator (true, the default) or hide it (false).
Size of the indicator (default is 'small'). +Passing a number to the size prop is only supported on Android.
Whether the indicator should hide when not animating (true by default).
You can edit the content above on GitHub and send us a pull request!
AdSupport provides access to the "advertising identifier". If you link this library
+
AdSupport provides access to the "advertising identifier". If you link this library
in your project, you may need to justify your use for this identifier when submitting
your application to the App Store.
In order to use AdSupport in your project, you must link the RCTAdSupport library.
In Xcode, you can manually add the RCTAdSupport.m and RCTAdSupport.h files from
@@ -19,6 +19,6 @@ of your current project.
You can refer to
\ No newline at end of file
diff --git a/docs/alert.html b/docs/alert.html
index 9e0d4ba6982..5cf205d20f5 100644
--- a/docs/alert.html
+++ b/docs/alert.html
@@ -1,4 +1,4 @@
- Launches an alert dialog with the specified title and message. Optionally provide a list of buttons. Tapping any button will fire the
+ Launches an alert dialog with the specified title and message. Optionally provide a list of buttons. Tapping any button will fire the
respective onPress callback and dismiss the alert. By default, the only
button will be an 'OK' button. This is an API that works both on iOS and Android and can show static
alerts. To show an alert that prompts the user to enter some information,
@@ -9,13 +9,13 @@ box. This event can be handled by providing an optional Alternatively, the dismissing behavior can be disabled altogether by providing
an optional Example usage: You can edit the content above on GitHub and send us a pull request! Creating an iOS alert: Creating an iOS alert: Creating an iOS prompt: Creating an iOS prompt: We recommend using the Create and display a popup alert. The dialog's title. An optional message that appears below
the dialog's title. This optional argument should
be either a single-argument function or an array of buttons. If passed
a function, it will be called when the user taps 'OK'. If passed an array of button configurations, each button should include
a Deprecated, do not use. Deprecated, do not use. Create and display a prompt to enter some text. The dialog's title. An optional message that appears above the text
input. This optional argument should
@@ -29,18 +29,18 @@ cross-platform support if you don't need to create iOS-only prompts. The default text in text input. The keyboard type of first text field(if exists).
One of 'default', 'email-address', 'numeric', 'phone-pad',
'ascii-capable', 'numbers-and-punctuation', 'url', 'number-pad',
- 'name-phone-pad', 'decimal-pad', 'twitter' or 'web-search'. An Alert button type Default alert with no inputs Plain text input alert Secure text input alert Login and password alert An Alert button style Default button style Cancel button style Destructive button style Array or buttons Button label Callback function when button pressed Button style Button label Callback function when button pressed Button style You can edit the content above on GitHub and send us a pull request! You will need to build React Native from source if you want to work on a new feature/bug fix, try out the latest features which are not released yet, or maintain your own fork with patches that cannot be merged to the core. Assuming you have the Android SDK installed, run Make sure you have the following installed: Step 1: Set environment variables through your local shell. Note: Files may vary based on shell flavor. See below for examples from common shells. Example: Step 2: Create a Example: You can find further instructions on the official page. First, you need to install Alternatively, you can clone the repo to your Add You will need to build React Native from source if you want to work on a new feature/bug fix, try out the latest features which are not released yet, or maintain your own fork with patches that cannot be merged to the core. Assuming you have the Android SDK installed, run Make sure you have the following installed: Step 1: Set environment variables through your local shell. Note: Files may vary based on shell flavor. See below for examples from common shells. Example: Step 2: Create a Example: You can find further instructions on the official page. First, you need to install Alternatively, you can clone the repo to your Add Add the Add the Modify your Modify your If you use 3rd-party React Native modules, you need to override their dependencies so that they don't bundle the pre-compiled library. Otherwise you'll get an error while compiling - Modify your If you use 3rd-party React Native modules, you need to override their dependencies so that they don't bundle the pre-compiled library. Otherwise you'll get an error while compiling - Modify your From the Welcome screen of Android Studio choose "Import project" and select the You should be able to use the Run button to run your app on a device. Android Studio won't start the packager automatically, you'll need to start it by running Building from source can take a long time, especially for the first build, as it needs to download ~200 MB of artifacts and compile the native code. Every time you update the From the Welcome screen of Android Studio choose "Import project" and select the You should be able to use the Run button to run your app on a device. Android Studio won't start the packager automatically, you'll need to start it by running Building from source can take a long time, especially for the first build, as it needs to download ~200 MB of artifacts and compile the native code. Every time you update the The The The simplest workflow for creating an animation is to to create an
Refer to the Animations guide to see
+).start(); // Start the animation Refer to the Animations guide to see
additional examples of There are two value types you can use with For example, when working with horizontal scrolling gestures, you would do
the following in order to map Config is an object that may have the following options: Config is an object that may have the following options: Spring animation based on Rebound and
Origami. Tracks velocity state to
-create fluid motions as the Config is an object that may have the following options: Creates a new Animated value composed from two Animated values added
+create fluid motions as the Config is an object that may have the following options. Note that you can
+only define bounciness/speed or tension/friction but not both: Creates a new Animated value composed from two Animated values added
together. Creates a new Animated value composed by dividing the first Animated value
by the second Animated value. Creates a new Animated value composed from two Animated values multiplied
together. Creates a new Animated value that is the (non-negative) modulo of the
@@ -86,12 +87,12 @@ sequence with successive delays. Nice for doing trailing effects. Takes an array of mappings and extracts values from each arg accordingly,
-then calls Config is an object that may have the following options: Make any React component Animatable. Used to create Imperative API to attach an animated value to an event on a view. Prefer using
@@ -113,37 +114,37 @@ state to match the animation position with layout. Typically only used internally, but could be used by a custom Animation
class. Typically only used internally. Typically only used internally. 2D Value for driving 2D animations, such as pan gestures. Almost identical
API to normal Converts Converts Converts Converts You can edit the content above on GitHub and send us a pull request! Animations are very important to create a great user experience.
+ Animations are very important to create a great user experience.
Stationary objects must overcome inertia as they start moving.
Objects in motion have momentum and rarely come to a stop immediately.
Animations allow you to convey physically believable motion in your interface. React Native provides two complementary animation systems:
The For example, a container view that fades in when it is mounted may look like this:Alert #
Alert #
options par
with an onDismiss callback property { onDismiss: () => {} }.options parameter with the cancelable property set to false
i.e. { cancelable: false }Methods #
static alert(title, message?, buttons?, options?, type?) #
AlertIOS #
AlertIOS provides functionality to create an iOS alert dialog with a
-message or create a prompt for user input.AlertIOS #
AlertIOS provides functionality to create an iOS alert dialog with a
+message or create a prompt for user input.Alert.alert method for
cross-platform support if you don't need to create iOS-only prompts.Methods #
static alert(title: string, message?: string, callbackOrButtons?: ?(() => void), ButtonsArray, type?: AlertType) #
Name and Type Description title [message] [callbackOrButtons] text key, as well as optional onPress and style keys. style
- should be one of 'default', 'cancel' or 'destructive'.[type]
Example with custom buttons:[type]
Example with custom buttons:static prompt(title: string, message?: string, callbackOrButtons?: ?((text: string) => void), ButtonsArray, type?: AlertType, defaultValue?: string, keyboardType?: string) #
Name and Type Description title [message] [callbackOrButtons] [defaultValue] [keyboardType]
Example with custom buttons:
Example with custom buttons:
Example with the default button and a custom callback:
Example with the default button and a custom callback:Type Definitions #
AlertType #
$Enum
Constants:Value Description default plain-text secure-text login-password AlertButtonStyle #
$Enum
Constants:Value Description default cancel destructive ButtonsArray #
Array
Properties:Name and Type Description [text] [onPress] [style]
Constants:Value Description text onPress style Building React Native from source #
Prerequisites #
android to open the Android SDK Manager.build.gradle)build.gradle)Point Gradle to your Android SDK: #
.bash_profile or .bashrc.zprofile or .zshrc.profile or $ENVlocal.properties file in the android directory of your react-native app with the following contents:Download links for Android NDK #
Building the source #
1. Installing the fork #
react-native from your fork. For example, to install the master branch from the official repo, run the following:node_modules directory and run npm install inside the cloned repo.2. Adding gradle dependencies #
gradle-download-task as dependency in android/build.gradle:Building React Native from source #
Prerequisites #
android to open the Android SDK Manager.build.gradle)build.gradle)Point Gradle to your Android SDK: #
.bash_profile or .bashrc.zprofile or .zshrc.profile or $ENVlocal.properties file in the android directory of your react-native app with the following contents:Download links for Android NDK #
Building the source #
1. Installing the fork #
react-native from your fork. For example, to install the master branch from the official repo, run the following:node_modules directory and run npm install inside the cloned repo.2. Adding gradle dependencies #
gradle-download-task as dependency in android/build.gradle:3. Adding the
:ReactAndroid project #:ReactAndroid project in android/settings.gradle:3. Adding the
:ReactAndroid project #:ReactAndroid project in android/settings.gradle:android/app/build.gradle to use the :ReactAndroid project instead of the pre-compiled library, e.g. - replace compile 'com.facebook.react:react-native:+' with compile project(':ReactAndroid'):android/app/build.gradle to use the :ReactAndroid project instead of the pre-compiled library, e.g. - replace compile 'com.facebook.react:react-native:+' with compile project(':ReactAndroid'):4. Making 3rd-party modules use your fork #
Error: more than one library with package name 'com.facebook.react'.android/app/build.gradle, and add:4. Making 3rd-party modules use your fork #
Error: more than one library with package name 'com.facebook.react'.android/app/build.gradle, and add:Building from Android Studio #
android folder of your app.npm start on the command line.Additional notes #
react-native version from your repo, the build directory may get deleted, and all the files are re-downloaded. To avoid this, you might want to change your build directory path by editing the ~/.gradle/init.gradle file:Building from Android Studio #
android folder of your app.npm start on the command line.Additional notes #
react-native version from your repo, the build directory may get deleted, and all the files are re-downloaded. To avoid this, you might want to change your build directory path by editing the ~/.gradle/init.gradle file:Animated #
Animated library is designed to make animations fluid, powerful, and
+Animated #
Animated library is designed to make animations fluid, powerful, and
easy to build and maintain. Animated focuses on declarative relationships
between inputs and outputs, with configurable transforms in between, and
simple start/stop methods to control time-based animation execution.Animated.Value, hook it up to one or more style attributes of an animated
-component, and then drive updates via animations using Animated.timing():Animated.timing():Animated in action.Overview #
Animated:Animated.Value() for single valuesAnimated.ValueXY() for vectorsAnimated.Value can bind to style properties or other props, and can be
interpolated as well. A single Animated.Value can drive any number of
properties.Configuring animations #
Animated provides three types of animation types. Each animation type
@@ -55,7 +55,7 @@ syntax so that values can be extracted from complex event objects. The first
level is an array to allow mapping across multiple args, and that array
contains nested objects.event.nativeEvent.contentOffset.x to
-scrollX (an Animated.Value):scrollX (an Animated.Value):duration: Length of animation (milliseconds). Default 500.easing: Easing function to define curve.
Default is Easing.inOut(Easing.ease).delay: Start the animation after delay (milliseconds). Default 0.useNativeDriver: Uses the native driver when true. Default false.static spring(value, config) #
toValue updates, and can be chained together.friction: Controls "bounciness"/overshoot. Default 7.tension: Controls speed. Default 40.useNativeDriver: Uses the native driver when true. Default false.static add(a, b) #
toValue updates, and can be chained together.friction: Controls "bounciness"/overshoot. Default 7.tension: Controls speed. Default 40.speed: Controls speed of the animation. Default 12.bounciness: Controls bounciness. Default 8.useNativeDriver: Uses the native driver when true. Default false.static add(a, b) #
static divide(a, b) #
static multiply(a, b) #
static modulo(a, modulus) #
static event(argMapping, config?) #
setValue on the mapped outputs. e.g.setValue on the mapped outputs. e.g.listener: Optional async listener.useNativeDriver: Uses the native driver when true. Default false.static createAnimatedComponent(Component) #
Animated.View, etc.static attachNativeEvent(viewRef, eventName, argMapping) #
animate(animation, callback) #
stopTracking() #
track(tracking) #
class AnimatedValueXY #
Animated.Value, but multiplexed. Contains two regular
-Animated.Values under the hood.Example #
Animated.Values under the hood.Example #
Methods #
constructor(valueIn?) #
setValue(value) #
setOffset(offset) #
flattenOffset() #
extractOffset() #
resetAnimation(callback?) #
stopAnimation(callback?) #
addListener(callback) #
removeListener(id) #
removeAllListeners() #
getLayout() #
{x, y} into {left, top} for use in style, e.g.getTranslateTransform() #
{x, y} into a useable translation transform, e.g.Methods #
constructor(valueIn?) #
setValue(value) #
setOffset(offset) #
flattenOffset() #
extractOffset() #
resetAnimation(callback?) #
stopAnimation(callback?) #
addListener(callback) #
removeListener(id) #
removeAllListeners() #
getLayout() #
{x, y} into {left, top} for use in style, e.g.getTranslateTransform() #
{x, y} into a useable translation transform, e.g.class AnimatedInterpolation #
Methods #
Animations #
Animations #
Animated for granular and interactive control of specific values, and
LayoutAnimation for animated global layout transactions.Animated API #Animated API is designed to make it very easy to concisely express a wide variety of interesting animation and interaction patterns in a very performant way.
-Animated focuses on declarative relationships between inputs and outputs, with configurable transforms in between, and simple start/stop methods to control time-based animation execution.Animated exports four animatable component types: View, Text, Image, and ScrollView, but you can also create your own using Animated.createAnimatedComponent().