yeet
This commit is contained in:
162
node_modules/react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js
generated
vendored
Normal file
162
node_modules/react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js
generated
vendored
Normal file
@ -0,0 +1,162 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const RCTDeviceEventEmitter = require('../../EventEmitter/RCTDeviceEventEmitter');
|
||||
const UIManager = require('../../ReactNative/UIManager');
|
||||
|
||||
import NativeAccessibilityInfo from './NativeAccessibilityInfo';
|
||||
|
||||
const REDUCE_MOTION_EVENT = 'reduceMotionDidChange';
|
||||
const TOUCH_EXPLORATION_EVENT = 'touchExplorationDidChange';
|
||||
|
||||
type ChangeEventName = $Keys<{
|
||||
change: string,
|
||||
reduceMotionChanged: string,
|
||||
screenReaderChanged: 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 https://reactnative.dev/docs/accessibilityinfo.html
|
||||
*/
|
||||
|
||||
const AccessibilityInfo = {
|
||||
/**
|
||||
* iOS only
|
||||
*/
|
||||
isBoldTextEnabled: function(): Promise<boolean> {
|
||||
return Promise.resolve(false);
|
||||
},
|
||||
|
||||
/**
|
||||
* iOS only
|
||||
*/
|
||||
isGrayscaleEnabled: function(): Promise<boolean> {
|
||||
return Promise.resolve(false);
|
||||
},
|
||||
|
||||
/**
|
||||
* iOS only
|
||||
*/
|
||||
isInvertColorsEnabled: function(): Promise<boolean> {
|
||||
return Promise.resolve(false);
|
||||
},
|
||||
|
||||
isReduceMotionEnabled: function(): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityInfo) {
|
||||
NativeAccessibilityInfo.isReduceMotionEnabled(resolve);
|
||||
} else {
|
||||
reject(false);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* iOS only
|
||||
*/
|
||||
isReduceTransparencyEnabled: function(): Promise<boolean> {
|
||||
return Promise.resolve(false);
|
||||
},
|
||||
|
||||
isScreenReaderEnabled: function(): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityInfo) {
|
||||
NativeAccessibilityInfo.isTouchExplorationEnabled(resolve);
|
||||
} else {
|
||||
reject(false);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Deprecated
|
||||
*
|
||||
* Same as `isScreenReaderEnabled`
|
||||
*/
|
||||
get fetch(): () => Promise<boolean> {
|
||||
console.warn(
|
||||
'AccessibilityInfo.fetch is deprecated, call AccessibilityInfo.isScreenReaderEnabled instead',
|
||||
);
|
||||
return this.isScreenReaderEnabled;
|
||||
},
|
||||
|
||||
addEventListener: function(
|
||||
eventName: ChangeEventName,
|
||||
handler: Function,
|
||||
): void {
|
||||
let listener;
|
||||
|
||||
if (eventName === 'change' || eventName === 'screenReaderChanged') {
|
||||
listener = RCTDeviceEventEmitter.addListener(
|
||||
TOUCH_EXPLORATION_EVENT,
|
||||
enabled => {
|
||||
handler(enabled);
|
||||
},
|
||||
);
|
||||
} else if (eventName === 'reduceMotionChanged') {
|
||||
listener = RCTDeviceEventEmitter.addListener(
|
||||
REDUCE_MOTION_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 https://reactnative.dev/docs/accessibilityinfo.html#setaccessibilityfocus
|
||||
*/
|
||||
setAccessibilityFocus: function(reactTag: number): void {
|
||||
UIManager.sendAccessibilityEvent(
|
||||
reactTag,
|
||||
UIManager.getConstants().AccessibilityEventTypes.typeViewFocused,
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Post a string to be announced by the screen reader.
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#announceforaccessibility
|
||||
*/
|
||||
announceForAccessibility: function(announcement: string): void {
|
||||
if (NativeAccessibilityInfo) {
|
||||
NativeAccessibilityInfo.announceForAccessibility(announcement);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = AccessibilityInfo;
|
271
node_modules/react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js
generated
vendored
Normal file
271
node_modules/react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js
generated
vendored
Normal file
@ -0,0 +1,271 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const Promise = require('../../Promise');
|
||||
const RCTDeviceEventEmitter = require('../../EventEmitter/RCTDeviceEventEmitter');
|
||||
|
||||
import NativeAccessibilityManager from './NativeAccessibilityManager';
|
||||
|
||||
const CHANGE_EVENT_NAME = {
|
||||
announcementFinished: 'announcementFinished',
|
||||
boldTextChanged: 'boldTextChanged',
|
||||
grayscaleChanged: 'grayscaleChanged',
|
||||
invertColorsChanged: 'invertColorsChanged',
|
||||
reduceMotionChanged: 'reduceMotionChanged',
|
||||
reduceTransparencyChanged: 'reduceTransparencyChanged',
|
||||
screenReaderChanged: 'screenReaderChanged',
|
||||
};
|
||||
|
||||
type ChangeEventName = $Keys<{
|
||||
announcementFinished: string,
|
||||
boldTextChanged: string,
|
||||
change: string,
|
||||
grayscaleChanged: string,
|
||||
invertColorsChanged: string,
|
||||
reduceMotionChanged: string,
|
||||
reduceTransparencyChanged: string,
|
||||
screenReaderChanged: 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 https://reactnative.dev/docs/accessibilityinfo.html
|
||||
*/
|
||||
const AccessibilityInfo = {
|
||||
/**
|
||||
* Query whether bold text is currently enabled.
|
||||
*
|
||||
* Returns a promise which resolves to a boolean.
|
||||
* The result is `true` when bold text is enabled and `false` otherwise.
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#isBoldTextEnabled
|
||||
*/
|
||||
isBoldTextEnabled: function(): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityManager) {
|
||||
NativeAccessibilityManager.getCurrentBoldTextState(resolve, reject);
|
||||
} else {
|
||||
reject(reject);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Query whether grayscale is currently enabled.
|
||||
*
|
||||
* Returns a promise which resolves to a boolean.
|
||||
* The result is `true` when grayscale is enabled and `false` otherwise.
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#isGrayscaleEnabled
|
||||
*/
|
||||
isGrayscaleEnabled: function(): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityManager) {
|
||||
NativeAccessibilityManager.getCurrentGrayscaleState(resolve, reject);
|
||||
} else {
|
||||
reject(reject);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Query whether inverted colors are currently enabled.
|
||||
*
|
||||
* Returns a promise which resolves to a boolean.
|
||||
* The result is `true` when invert color is enabled and `false` otherwise.
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#isInvertColorsEnabled
|
||||
*/
|
||||
isInvertColorsEnabled: function(): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityManager) {
|
||||
NativeAccessibilityManager.getCurrentInvertColorsState(resolve, reject);
|
||||
} else {
|
||||
reject(reject);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Query whether reduced motion is currently enabled.
|
||||
*
|
||||
* Returns a promise which resolves to a boolean.
|
||||
* The result is `true` when a reduce motion is enabled and `false` otherwise.
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#isReduceMotionEnabled
|
||||
*/
|
||||
isReduceMotionEnabled: function(): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityManager) {
|
||||
NativeAccessibilityManager.getCurrentReduceMotionState(resolve, reject);
|
||||
} else {
|
||||
reject(reject);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Query whether reduced transparency is currently enabled.
|
||||
*
|
||||
* Returns a promise which resolves to a boolean.
|
||||
* The result is `true` when a reduce transparency is enabled and `false` otherwise.
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#isReduceTransparencyEnabled
|
||||
*/
|
||||
isReduceTransparencyEnabled: function(): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityManager) {
|
||||
NativeAccessibilityManager.getCurrentReduceTransparencyState(
|
||||
resolve,
|
||||
reject,
|
||||
);
|
||||
} else {
|
||||
reject(reject);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#isScreenReaderEnabled
|
||||
*/
|
||||
isScreenReaderEnabled: function(): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityManager) {
|
||||
NativeAccessibilityManager.getCurrentVoiceOverState(resolve, reject);
|
||||
} else {
|
||||
reject(reject);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Deprecated
|
||||
*
|
||||
* Same as `isScreenReaderEnabled`
|
||||
*/
|
||||
get fetch(): $FlowFixMe {
|
||||
console.warn(
|
||||
'AccessibilityInfo.fetch is deprecated, call AccessibilityInfo.isScreenReaderEnabled instead',
|
||||
);
|
||||
return this.isScreenReaderEnabled;
|
||||
},
|
||||
|
||||
/**
|
||||
* Add an event handler. Supported events:
|
||||
*
|
||||
* - `boldTextChanged`: iOS-only event. Fires when the state of the bold text toggle changes.
|
||||
* The argument to the event handler is a boolean. The boolean is `true` when a bold text
|
||||
* is enabled and `false` otherwise.
|
||||
* - `grayscaleChanged`: iOS-only event. Fires when the state of the gray scale toggle changes.
|
||||
* The argument to the event handler is a boolean. The boolean is `true` when a gray scale
|
||||
* is enabled and `false` otherwise.
|
||||
* - `invertColorsChanged`: iOS-only event. Fires when the state of the invert colors toggle
|
||||
* changes. The argument to the event handler is a boolean. The boolean is `true` when a invert
|
||||
* colors is enabled and `false` otherwise.
|
||||
* - `reduceMotionChanged`: Fires when the state of the reduce motion toggle changes.
|
||||
* The argument to the event handler is a boolean. The boolean is `true` when a reduce
|
||||
* motion is enabled (or when "Transition Animation Scale" in "Developer options" is
|
||||
* "Animation off") and `false` otherwise.
|
||||
* - `reduceTransparencyChanged`: iOS-only event. Fires when the state of the reduce transparency
|
||||
* toggle changes. The argument to the event handler is a boolean. The boolean is `true`
|
||||
* when a reduce transparency is enabled and `false` otherwise.
|
||||
* - `screenReaderChanged`: 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.
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#addeventlistener
|
||||
*/
|
||||
addEventListener: function(
|
||||
eventName: ChangeEventName,
|
||||
handler: Function,
|
||||
): Object {
|
||||
let listener;
|
||||
|
||||
if (eventName === 'change') {
|
||||
listener = RCTDeviceEventEmitter.addListener(
|
||||
CHANGE_EVENT_NAME.screenReaderChanged,
|
||||
handler,
|
||||
);
|
||||
} else if (CHANGE_EVENT_NAME[eventName]) {
|
||||
listener = RCTDeviceEventEmitter.addListener(eventName, handler);
|
||||
}
|
||||
|
||||
_subscriptions.set(handler, listener);
|
||||
return {
|
||||
remove: AccessibilityInfo.removeEventListener.bind(
|
||||
null,
|
||||
eventName,
|
||||
handler,
|
||||
),
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Set accessibility focus to a react component.
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#setaccessibilityfocus
|
||||
*/
|
||||
setAccessibilityFocus: function(reactTag: number): void {
|
||||
if (NativeAccessibilityManager) {
|
||||
NativeAccessibilityManager.setAccessibilityFocus(reactTag);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Post a string to be announced by the screen reader.
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#announceforaccessibility
|
||||
*/
|
||||
announceForAccessibility: function(announcement: string): void {
|
||||
if (NativeAccessibilityManager) {
|
||||
NativeAccessibilityManager.announceForAccessibility(announcement);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove an event handler.
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#removeeventlistener
|
||||
*/
|
||||
removeEventListener: function(
|
||||
eventName: ChangeEventName,
|
||||
handler: Function,
|
||||
): void {
|
||||
const listener = _subscriptions.get(handler);
|
||||
if (!listener) {
|
||||
return;
|
||||
}
|
||||
listener.remove();
|
||||
_subscriptions.delete(handler);
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = AccessibilityInfo;
|
27
node_modules/react-native/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js
generated
vendored
Normal file
27
node_modules/react-native/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 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 strict-local
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import type {TurboModule} from '../../TurboModule/RCTExport';
|
||||
import * as TurboModuleRegistry from '../../TurboModule/TurboModuleRegistry';
|
||||
|
||||
export interface Spec extends TurboModule {
|
||||
+isReduceMotionEnabled: (
|
||||
onSuccess: (isReduceMotionEnabled: boolean) => void,
|
||||
) => void;
|
||||
+isTouchExplorationEnabled: (
|
||||
onSuccess: (isScreenReaderEnabled: boolean) => void,
|
||||
) => void;
|
||||
+setAccessibilityFocus: (reactTag: number) => void;
|
||||
+announceForAccessibility: (announcement: string) => void;
|
||||
}
|
||||
|
||||
export default (TurboModuleRegistry.get<Spec>('AccessibilityInfo'): ?Spec);
|
59
node_modules/react-native/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js
generated
vendored
Normal file
59
node_modules/react-native/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* 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 '../../TurboModule/RCTExport';
|
||||
import * as TurboModuleRegistry from '../../TurboModule/TurboModuleRegistry';
|
||||
|
||||
export interface Spec extends TurboModule {
|
||||
+getCurrentBoldTextState: (
|
||||
onSuccess: (isBoldTextEnabled: boolean) => void,
|
||||
onError: (error: Object) => void,
|
||||
) => void;
|
||||
+getCurrentGrayscaleState: (
|
||||
onSuccess: (isGrayscaleEnabled: boolean) => void,
|
||||
onError: (error: Object) => void,
|
||||
) => void;
|
||||
+getCurrentInvertColorsState: (
|
||||
onSuccess: (isInvertColorsEnabled: boolean) => void,
|
||||
onError: (error: Object) => void,
|
||||
) => void;
|
||||
+getCurrentReduceMotionState: (
|
||||
onSuccess: (isReduceMotionEnabled: boolean) => void,
|
||||
onError: (error: Object) => void,
|
||||
) => void;
|
||||
+getCurrentReduceTransparencyState: (
|
||||
onSuccess: (isReduceTransparencyEnabled: boolean) => void,
|
||||
onError: (error: Object) => void,
|
||||
) => void;
|
||||
+getCurrentVoiceOverState: (
|
||||
onSuccess: (isScreenReaderEnabled: boolean) => void,
|
||||
onError: (error: Object) => void,
|
||||
) => void;
|
||||
+setAccessibilityContentSizeMultipliers: (JSMultipliers: {|
|
||||
+extraSmall?: ?number,
|
||||
+small?: ?number,
|
||||
+medium?: ?number,
|
||||
+large?: ?number,
|
||||
+extraLarge?: ?number,
|
||||
+extraExtraLarge?: ?number,
|
||||
+extraExtraExtraLarge?: ?number,
|
||||
+accessibilityMedium?: ?number,
|
||||
+accessibilityLarge?: ?number,
|
||||
+accessibilityExtraLarge?: ?number,
|
||||
+accessibilityExtraExtraLarge?: ?number,
|
||||
+accessibilityExtraExtraExtraLarge?: ?number,
|
||||
|}) => void;
|
||||
+setAccessibilityFocus: (reactTag: number) => void;
|
||||
+announceForAccessibility: (announcement: string) => void;
|
||||
}
|
||||
|
||||
export default (TurboModuleRegistry.get<Spec>('AccessibilityManager'): ?Spec);
|
Reference in New Issue
Block a user