Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TM] Add spec for AccessibilityManager #24885

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@

'use strict';

const NativeModules = require('../../BatchedBridge/NativeModules');
const Promise = require('../../Promise');
const RCTDeviceEventEmitter = require('../../EventEmitter/RCTDeviceEventEmitter');

const AccessibilityManager = NativeModules.AccessibilityManager;
const NativeAccessibilityManager = require('./NativeAccessibilityManager');

const CHANGE_EVENT_NAME = {
announcementFinished: 'announcementFinished',
Expand Down Expand Up @@ -59,7 +57,7 @@ const AccessibilityInfo = {
*/
isBoldTextEnabled: function(): Promise<boolean> {
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
return new Promise((resolve, reject) => {
AccessibilityManager.getCurrentBoldTextState(resolve, reject);
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
NativeAccessibilityManager.getCurrentBoldTextState(resolve, reject);
});
},

Expand All @@ -73,7 +71,7 @@ const AccessibilityInfo = {
*/
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
isGrayscaleEnabled: function(): Promise<boolean> {
return new Promise((resolve, reject) => {
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
AccessibilityManager.getCurrentGrayscaleState(resolve, reject);
NativeAccessibilityManager.getCurrentGrayscaleState(resolve, reject);
});
},

Expand All @@ -87,7 +85,7 @@ const AccessibilityInfo = {
*/
isInvertColorsEnabled: function(): Promise<boolean> {
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
return new Promise((resolve, reject) => {
AccessibilityManager.getCurrentInvertColorsState(resolve, reject);
NativeAccessibilityManager.getCurrentInvertColorsState(resolve, reject);
});
},

Expand All @@ -101,7 +99,7 @@ const AccessibilityInfo = {
*/
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
isReduceMotionEnabled: function(): Promise<boolean> {
return new Promise((resolve, reject) => {
AccessibilityManager.getCurrentReduceMotionState(resolve, reject);
NativeAccessibilityManager.getCurrentReduceMotionState(resolve, reject);
});
},

Expand All @@ -115,7 +113,10 @@ const AccessibilityInfo = {
*/
isReduceTransparencyEnabled: function(): Promise<boolean> {
return new Promise((resolve, reject) => {
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
AccessibilityManager.getCurrentReduceTransparencyState(resolve, reject);
NativeAccessibilityManager.getCurrentReduceTransparencyState(
resolve,
reject,
);
});
},

michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -129,7 +130,7 @@ const AccessibilityInfo = {
*/
isScreenReaderEnabled: function(): Promise<boolean> {
return new Promise((resolve, reject) => {
AccessibilityManager.getCurrentVoiceOverState(resolve, reject);
NativeAccessibilityManager.getCurrentVoiceOverState(resolve, reject);
});
},
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -204,7 +205,7 @@ const AccessibilityInfo = {
* See http://facebook.github.io/react-native/docs/accessibilityinfo.html#setaccessibilityfocus
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
*/
setAccessibilityFocus: function(reactTag: number): void {
AccessibilityManager.setAccessibilityFocus(reactTag);
NativeAccessibilityManager.setAccessibilityFocus(reactTag);
},
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved

/**
Expand All @@ -213,7 +214,7 @@ const AccessibilityInfo = {
* See http://facebook.github.io/react-native/docs/accessibilityinfo.html#announceforaccessibility
michalchudziak marked this conversation as resolved.
Show resolved Hide resolved
*/
announceForAccessibility: function(announcement: string): void {
AccessibilityManager.announceForAccessibility(announcement);
NativeAccessibilityManager.announceForAccessibility(announcement);
},

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/

'use strict';

import type {TurboModule} from 'RCTExport';
import * as TurboModuleRegistry from 'TurboModuleRegistry';

export interface Spec extends TurboModule {
+getCurrentBoldTextState: (
resolve: (isBoldTextEnabled: boolean) => void,
reject: (error: Object) => void,
) => void;
+getCurrentGrayscaleState: (
resolve: (isGrayscaleEnabled: boolean) => void,
reject: (error: Object) => void,
) => void;
+getCurrentInvertColorsState: (
resolve: (isInvertColorsEnabled: boolean) => void,
reject: (error: Object) => void,
) => void;
+getCurrentReduceMotionState: (
resolve: (isReduceMotionEnabled: boolean) => void,
reject: (error: Object) => void,
) => void;
+getCurrentReduceTransparencyState: (
resolve: (isReduceTransparencyEnabled: boolean) => void,
reject: (error: Object) => void,
) => void;
+getCurrentVoiceOverState: (
resolve: (isScreenReaderEnabled: boolean) => void,
reject: (error: Object) => void,
) => void;
+setAccessibilityFocus: (reactTag: number) => void;
+announceForAccessibility: (announcement: string) => void;

// RCTDeviceEventEmitter
+addListener: (eventName: string, handler: Function) => Object;
+removeListeners: (eventName: string, handler: Function) => void;
}

export default TurboModuleRegistry.getEnforcing<Spec>('AccessibilityManager');