From f901af9947e2e88c220c2beb83ab900bcd0dc6ed Mon Sep 17 00:00:00 2001 From: Shane Fitzpatrick Date: Mon, 13 Nov 2017 14:40:50 -0800 Subject: [PATCH] react-native: Add AccessibilityInfo API --- types/react-native/index.d.ts | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 1c0cb7d0e8..dc4c6bc4f4 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -6258,6 +6258,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; + + /** + * 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: Function): void; + + /** + * Remove an event handler. + */ + removeEventListener(eventName: AccessibilityChangeEventName, handler: Function): 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 + */ + announceFoAccessibility(announcement: string): void; +} + /** * @see https://facebook.github.io/react-native/docs/alert.html#content */ @@ -8410,6 +8455,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