From f901af9947e2e88c220c2beb83ab900bcd0dc6ed Mon Sep 17 00:00:00 2001 From: Shane Fitzpatrick Date: Mon, 13 Nov 2017 14:40:50 -0800 Subject: [PATCH 1/4] 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 From e0eda64a9cf8ecf16bafecd30eec7d30dc92ba54 Mon Sep 17 00:00:00 2001 From: Shane Fitzpatrick Date: Mon, 13 Nov 2017 15:45:50 -0800 Subject: [PATCH 2/4] Remove trailing whitespace --- types/react-native/index.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index dc4c6bc4f4..10670c010b 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -6265,18 +6265,18 @@ type AccessibilityChangeEventName = 'change' | 'announcementFinished'; */ export interface AccessibilityInfoStatic { /** - * Query whether a screen reader is currently enabled. + * 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. + * - 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. + * + * - 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. @@ -6290,14 +6290,14 @@ export interface AccessibilityInfoStatic { /** * 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; From 6dcc3a21e64efb37d148681081532aff4287cac9 Mon Sep 17 00:00:00 2001 From: Shane Fitzpatrick Date: Mon, 13 Nov 2017 15:48:49 -0800 Subject: [PATCH 3/4] PR feedback --- types/react-native/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 10670c010b..672723249b 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -6268,7 +6268,7 @@ 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; + fetch: () => Promise; /** * Add an event handler. Supported events: @@ -6281,26 +6281,26 @@ export interface AccessibilityInfoStatic { * - announcement: The string announced by the screen reader. * - success: A boolean indicating whether the announcement was successfully made. */ - addEventListener(eventName: AccessibilityChangeEventName, handler: Function): void; + addEventListener: (eventName: AccessibilityChangeEventName, handler: Function) => void; /** * Remove an event handler. */ - removeEventListener(eventName: AccessibilityChangeEventName, handler: Function): void; + removeEventListener: (eventName: AccessibilityChangeEventName, handler: Function) => void; /** * Set acessibility focus to a react component. * * @platform ios */ - setAccessibilityFocus(reactTag: number): void; + setAccessibilityFocus: (reactTag: number) => void; /** * Post a string to be announced by the screen reader. * * @platform ios */ - announceFoAccessibility(announcement: string): void; + announceForAccessibility: (announcement: string) => void; } /** From fd5911ba422750eebaf6722a2e7c04e39ac2fb63 Mon Sep 17 00:00:00 2001 From: Shane Fitzpatrick Date: Tue, 14 Nov 2017 14:02:15 -0800 Subject: [PATCH 4/4] Replace 'Function' with '() => void' --- types/react-native/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 672723249b..9854c8e441 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -6281,12 +6281,12 @@ export interface AccessibilityInfoStatic { * - announcement: The string announced by the screen reader. * - success: A boolean indicating whether the announcement was successfully made. */ - addEventListener: (eventName: AccessibilityChangeEventName, handler: Function) => void; + addEventListener: (eventName: AccessibilityChangeEventName, handler: () => void) => void; /** * Remove an event handler. */ - removeEventListener: (eventName: AccessibilityChangeEventName, handler: Function) => void; + removeEventListener: (eventName: AccessibilityChangeEventName, handler: () => void) => void; /** * Set acessibility focus to a react component.