Merge pull request #21495 from Fitzpasd/react_native_accessibility_info

react-native: Add AccessibilityInfo API
This commit is contained in:
Eloy Durán 2017-11-14 23:42:12 +01:00 committed by GitHub
commit 84197d2a64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6262,6 +6262,51 @@ export interface ShareStatic {
dismissedAction: string
}
type AccessibilityChangeEventName = 'change' | 'announcementFinished';
/**
* @see https://facebook.github.io/react-native/docs/accessibilityinfo.html
*/
export interface AccessibilityInfoStatic {
/**
* 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.
*/
fetch: () => Promise<boolean>;
/**
* 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.
*
* - announcementFinished: iOS-only event. Fires when the screen reader has finished making an announcement.
* The argument to the event handler is a dictionary with these keys:
* - announcement: The string announced by the screen reader.
* - success: A boolean indicating whether the announcement was successfully made.
*/
addEventListener: (eventName: AccessibilityChangeEventName, handler: () => void) => void;
/**
* Remove an event handler.
*/
removeEventListener: (eventName: AccessibilityChangeEventName, handler: () => void) => void;
/**
* Set acessibility focus to a react component.
*
* @platform ios
*/
setAccessibilityFocus: (reactTag: number) => void;
/**
* Post a string to be announced by the screen reader.
*
* @platform ios
*/
announceForAccessibility: (announcement: string) => void;
}
/**
* @see https://facebook.github.io/react-native/docs/alert.html#content
*/
@ -8416,6 +8461,9 @@ export type Share = ShareStatic
export var AdSupportIOS: AdSupportIOSStatic
export type AdSupportIOS = AdSupportIOSStatic
export var AccessibilityInfo: AccessibilityInfoStatic
export type AccessibilityInfo = AccessibilityInfoStatic
export var Alert: AlertStatic
export type Alert = AlertStatic