mirror of
https://github.com/status-im/react-native.git
synced 2025-01-17 04:50:59 +00:00
b64b9dbece
Summary: Flow doesn't check .android.js files yet anyway. I'm going to be adding suppressions in a followup diff. It would be nice to not have >1k suppressions saying that we can't do certain things in `flow strict` when we don't even typecheck with regular `flow` just yet I ran these commands to produce this diff: `find . -name '*.android.js' -exec sed -i 's/flow strict-local/flow/g' {} +` `find . -name '*.android.js' -exec sed -i 's/flow strict/flow/g' {} +` Followed https://unix.stackexchange.com/questions/112023/how-can-i-replace-a-string-in-a-files to do it. The controller you requested could not be found. Reviewed By: TheSavior Differential Revision: D9143783 fbshipit-source-id: e9af4fe695ebdba4db4083de1697cc248d48eb0d
85 lines
2.1 KiB
JavaScript
85 lines
2.1 KiB
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
* @flow
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const NativeModules = require('NativeModules');
|
|
const RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
|
|
const UIManager = require('UIManager');
|
|
|
|
const RCTAccessibilityInfo = NativeModules.AccessibilityInfo;
|
|
|
|
const TOUCH_EXPLORATION_EVENT = 'touchExplorationDidChange';
|
|
|
|
type ChangeEventName = $Enum<{
|
|
change: string,
|
|
}>;
|
|
|
|
const _subscriptions = new Map();
|
|
|
|
/**
|
|
* 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.
|
|
*
|
|
* See http://facebook.github.io/react-native/docs/accessibilityinfo.html
|
|
*/
|
|
|
|
const AccessibilityInfo = {
|
|
fetch: function(): Promise {
|
|
return new Promise((resolve, reject) => {
|
|
RCTAccessibilityInfo.isTouchExplorationEnabled(function(resp) {
|
|
resolve(resp);
|
|
});
|
|
});
|
|
},
|
|
|
|
addEventListener: function(
|
|
eventName: ChangeEventName,
|
|
handler: Function,
|
|
): void {
|
|
const listener = RCTDeviceEventEmitter.addListener(
|
|
TOUCH_EXPLORATION_EVENT,
|
|
enabled => {
|
|
handler(enabled);
|
|
},
|
|
);
|
|
_subscriptions.set(handler, listener);
|
|
},
|
|
|
|
removeEventListener: function(
|
|
eventName: ChangeEventName,
|
|
handler: Function,
|
|
): void {
|
|
const listener = _subscriptions.get(handler);
|
|
if (!listener) {
|
|
return;
|
|
}
|
|
listener.remove();
|
|
_subscriptions.delete(handler);
|
|
},
|
|
|
|
/**
|
|
* Set accessibility focus to a react component.
|
|
*
|
|
* See http://facebook.github.io/react-native/docs/accessibilityinfo.html#setaccessibilityfocus
|
|
*/
|
|
setAccessibilityFocus: function(reactTag: number): void {
|
|
UIManager.sendAccessibilityEvent(
|
|
reactTag,
|
|
UIManager.AccessibilityEventTypes.typeViewFocused,
|
|
);
|
|
},
|
|
};
|
|
|
|
module.exports = AccessibilityInfo;
|