@react-native-oh/react-native-harmony 0.72.86 → 0.77.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LICENSE-Meta +21 -0
- package/Libraries/Alert/delegates/AlertDelegate.harmony.ts +84 -0
- package/Libraries/Alert/{AlertManager.ts → delegates/AlertManager.harmony.ts} +10 -4
- package/Libraries/Animated/shouldUseTurboAnimatedModule.harmony.ts +10 -0
- package/Libraries/Components/AccessibilityInfo/delegates/AccessibilityInfoDelegate.harmony.ts +44 -0
- package/Libraries/Components/AccessibilityInfo/{NativeAccessibilityInfoHarmony.ts → delegates/NativeAccessibilityInfoHarmony.harmony.ts} +9 -2
- package/Libraries/Components/Keyboard/delegates/KeyboardAvoidingViewDelegate.harmony.ts +42 -0
- package/Libraries/Components/RefreshControl/delegates/RefreshControlDelegate.harmony.tsx +29 -0
- package/Libraries/Components/SafeAreaView/SafeAreaView.harmony.tsx +93 -31
- package/Libraries/Components/ScrollView/delegates/ScrollViewDelegate.harmony.tsx +41 -0
- package/Libraries/Components/ScrollView/delegates/ScrollViewNativeComponentDelegate.harmony.ts +89 -0
- package/Libraries/Components/ScrollView/processDecelerationRate.harmony.ts +19 -0
- package/Libraries/Components/StatusBar/delegates/NativeStatusBarManagerHarmony.harmony.ts +53 -0
- package/Libraries/Components/StatusBar/delegates/StatusBarDelegate.harmony.ts +83 -0
- package/Libraries/Components/TextInput/delegates/TextInputDelegate.harmony.tsx +98 -0
- package/Libraries/Components/TextInput/delegates/TextInputStateDelegate.harmony.tsx +20 -0
- package/Libraries/Components/Touchable/delegates/TouchableHighlightDelegate.harmony.ts +14 -0
- package/Libraries/Components/Touchable/delegates/TouchableNativeFeedbackDelegate.harmony.ts +14 -0
- package/Libraries/Components/Touchable/delegates/TouchableWithoutFeedbackDelegate.harmony.ts +14 -0
- package/Libraries/Components/delegates/ButtonDelegate.harmony.ts +41 -0
- package/Libraries/Core/setUpPlatform.harmony.js +30 -0
- package/Libraries/Image/AssetSourceResolver.harmony.ts +1 -5
- package/Libraries/Image/Image.harmony.ts +17 -0
- package/Libraries/NativeComponent/BaseViewConfig.harmony.js +12 -326
- package/Libraries/NativeComponent/delegates/ViewConfigIgnoreDelegate.harmony.ts +13 -0
- package/Libraries/ReactNative/delegates/BridgelessUIManagerDelegate.harmony.ts +14 -0
- package/Libraries/ReactNative/delegates/I18nManagerDelegate.harmony.ts +22 -0
- package/Libraries/Settings/Settings.harmony.ts +20 -0
- package/Libraries/Share/delegates/ShareDelegate.harmony.ts +42 -0
- package/Libraries/StyleSheet/NativePlatformColor.harmony.ts +15 -0
- package/Libraries/StyleSheet/PlatformColorValueTypes.harmony.ts +8 -1
- package/Libraries/Utilities/BackHandler.harmony.ts +10 -0
- package/Libraries/Utilities/NativePlatformConstantsHarmony.harmony.ts +17 -0
- package/Libraries/Utilities/Platform.harmony.ts +38 -13
- package/Libraries/Vibration/delegates/VibrationDelegate.harmony.ts +14 -0
- package/NOTICE.md +846 -0
- package/README.md +2 -2
- package/index.js +53 -63
- package/jest.config.js +0 -7
- package/metro.config.d.ts +17 -0
- package/metro.config.js +398 -115
- package/package.json +58 -37
- package/react-native.config.js +57 -9
- package/react_native_openharmony.har +0 -0
- package/tsconfig.json +10 -4
- package/types/index.harmony.d.ts +99 -0
- package/Libraries/Alert/Alert.harmony.js +0 -77
- package/Libraries/Animated/NativeAnimatedHelper.harmony.js +0 -601
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.harmony.js +0 -441
- package/Libraries/Components/Button/Button.harmony.js +0 -451
- package/Libraries/Components/Image/Image.flow.harmony.js +0 -53
- package/Libraries/Components/Image/Image.harmony.js +0 -317
- package/Libraries/Components/Image/NativeImageLoaderHarmony.js +0 -38
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.harmony.js +0 -256
- package/Libraries/Components/RefreshControl/RefreshControl.harmony.js +0 -210
- package/Libraries/Components/ScrollView/ScrollView.harmony.js +0 -1951
- package/Libraries/Components/ScrollView/processDecelerationRate.harmony.js +0 -24
- package/Libraries/Components/StatusBar/NativeStatusBarManagerHarmony.js +0 -71
- package/Libraries/Components/StatusBar/StatusBar.harmony.js +0 -447
- package/Libraries/Components/TextInput/TextInput.harmony.js +0 -1716
- package/Libraries/Components/TextInput/TextInputState.harmony.js +0 -220
- package/Libraries/Components/Touchable/TouchableHighlight.harmony.js +0 -396
- package/Libraries/Components/Touchable/TouchableNativeFeedback.harmony.js +0 -364
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.harmony.js +0 -227
- package/Libraries/Components/View/View.harmony.js +0 -149
- package/Libraries/Core/setUpReactDevTools.harmony.js +0 -93
- package/Libraries/ReactNative/I18nManager.harmony.js +0 -78
- package/Libraries/ReactNative/UIManager.harmony.js +0 -210
- package/Libraries/Settings/Settings.harmony.js +0 -15
- package/Libraries/Share/Share.harmony.js +0 -174
- package/Libraries/StyleSheet/NativePlatformColor.ts +0 -8
- package/Libraries/Utilities/BackHandler.harmony.js +0 -109
- package/Libraries/Utilities/NativePlatformConstants.harmony.ts +0 -8
- package/Libraries/Utilities/Platform.d.ts +0 -117
- package/Libraries/Utilities/createPerformanceLogger.harmony.js +0 -328
- package/Libraries/Vibration/Vibration.harmony.js +0 -88
- package/harmony/.keep +0 -0
- package/harmony/rnoh-hvigor-plugin-0.2.0.tgz +0 -0
- package/react_native_openharmony_release.har +0 -0
- package/types/index.d.ts +0 -108
|
@@ -1,441 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow strict-local
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
// RNOH: patch
|
|
12
|
-
// COPIED FROM: https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js
|
|
13
|
-
|
|
14
|
-
import type { HostComponent } from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';
|
|
15
|
-
import type { EventSubscription } from 'react-native/Libraries/vendor/emitter/EventEmitter';
|
|
16
|
-
import type { ElementRef } from 'react';
|
|
17
|
-
|
|
18
|
-
// RNOH: patch - imports fixed
|
|
19
|
-
import RCTDeviceEventEmitter from 'react-native/Libraries/EventEmitter/RCTDeviceEventEmitter';
|
|
20
|
-
import { sendAccessibilityEvent } from 'react-native/Libraries/ReactNative/RendererProxy';
|
|
21
|
-
import Platform from '../../Utilities/Platform';
|
|
22
|
-
import legacySendAccessibilityEvent from 'react-native/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent';
|
|
23
|
-
// import NativeAccessibilityInfoAndroid from 'react-native/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo';
|
|
24
|
-
// import NativeAccessibilityManagerIOS from 'react-native/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager';
|
|
25
|
-
import NativeAccessibilityInfoHarmony from './NativeAccessibilityInfoHarmony';
|
|
26
|
-
|
|
27
|
-
// Events that are only supported on Android.
|
|
28
|
-
type AccessibilityEventDefinitionsAndroid = {
|
|
29
|
-
accessibilityServiceChanged: [boolean],
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// Events that are only supported on iOS.
|
|
33
|
-
type AccessibilityEventDefinitionsIOS = {
|
|
34
|
-
announcementFinished: [{ announcement: string, success: boolean }],
|
|
35
|
-
boldTextChanged: [boolean],
|
|
36
|
-
grayscaleChanged: [boolean],
|
|
37
|
-
invertColorsChanged: [boolean],
|
|
38
|
-
reduceTransparencyChanged: [boolean],
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
type AccessibilityEventDefinitions = {
|
|
42
|
-
...AccessibilityEventDefinitionsAndroid,
|
|
43
|
-
...AccessibilityEventDefinitionsIOS,
|
|
44
|
-
change: [boolean], // screenReaderChanged
|
|
45
|
-
reduceMotionChanged: [boolean],
|
|
46
|
-
screenReaderChanged: [boolean],
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
type AccessibilityEventTypes = 'click' | 'focus' | 'viewHoverEnter';
|
|
50
|
-
|
|
51
|
-
// Mapping of public event names to platform-specific event names.
|
|
52
|
-
// RNOH patch
|
|
53
|
-
const EventNames: Map<$Keys<AccessibilityEventDefinitions>, string> = new Map([
|
|
54
|
-
['accessibilityServiceChanged', 'accessibilityServiceChanged'],
|
|
55
|
-
['announcementFinished', 'announcementFinished'],
|
|
56
|
-
['boldTextChanged', 'boldTextChanged'],
|
|
57
|
-
['change', 'screenReaderChanged'],
|
|
58
|
-
['grayscaleChanged', 'grayscaleChanged'],
|
|
59
|
-
['invertColorsChanged', 'invertColorsChanged'],
|
|
60
|
-
['reduceMotionChanged', 'reduceMotionChanged'],
|
|
61
|
-
['reduceTransparencyChanged', 'reduceTransparencyChanged'],
|
|
62
|
-
['screenReaderChanged', 'screenReaderChanged'],
|
|
63
|
-
]);
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Sometimes it's useful to know whether or not the device has a screen reader
|
|
67
|
-
* that is currently active. The `AccessibilityInfo` API is designed for this
|
|
68
|
-
* purpose. You can use it to query the current state of the screen reader as
|
|
69
|
-
* well as to register to be notified when the state of the screen reader
|
|
70
|
-
* changes.
|
|
71
|
-
*
|
|
72
|
-
* See https://reactnative.dev/docs/accessibilityinfo
|
|
73
|
-
*/
|
|
74
|
-
const AccessibilityInfo = {
|
|
75
|
-
/**
|
|
76
|
-
* Query whether bold text is currently enabled.
|
|
77
|
-
*
|
|
78
|
-
* Returns a promise which resolves to a boolean.
|
|
79
|
-
* The result is `true` when bold text is enabled and `false` otherwise.
|
|
80
|
-
*
|
|
81
|
-
* See https://reactnative.dev/docs/accessibilityinfo#isBoldTextEnabled
|
|
82
|
-
*/
|
|
83
|
-
isBoldTextEnabled(): Promise<boolean> {
|
|
84
|
-
// RNOH patch
|
|
85
|
-
return NativeAccessibilityInfoHarmony.isBoldTextEnabled();
|
|
86
|
-
// if (Platform.OS === 'android') {
|
|
87
|
-
// return Promise.resolve(false);
|
|
88
|
-
// } else {
|
|
89
|
-
// return new Promise((resolve, reject) => {
|
|
90
|
-
// if (NativeAccessibilityManagerIOS != null) {
|
|
91
|
-
// NativeAccessibilityManagerIOS.getCurrentBoldTextState(
|
|
92
|
-
// resolve,
|
|
93
|
-
// reject
|
|
94
|
-
// );
|
|
95
|
-
// } else {
|
|
96
|
-
// reject(null);
|
|
97
|
-
// }
|
|
98
|
-
// });
|
|
99
|
-
// }
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Query whether grayscale is currently enabled.
|
|
104
|
-
*
|
|
105
|
-
* Returns a promise which resolves to a boolean.
|
|
106
|
-
* The result is `true` when grayscale is enabled and `false` otherwise.
|
|
107
|
-
*
|
|
108
|
-
* See https://reactnative.dev/docs/accessibilityinfo#isGrayscaleEnabled
|
|
109
|
-
*/
|
|
110
|
-
isGrayscaleEnabled(): Promise<boolean> {
|
|
111
|
-
// RNOH patch
|
|
112
|
-
return Promise.resolve(false);
|
|
113
|
-
// if (Platform.OS === 'android') {
|
|
114
|
-
// return Promise.resolve(false);
|
|
115
|
-
// } else {
|
|
116
|
-
// return new Promise((resolve, reject) => {
|
|
117
|
-
// if (NativeAccessibilityManagerIOS != null) {
|
|
118
|
-
// NativeAccessibilityManagerIOS.getCurrentGrayscaleState(
|
|
119
|
-
// resolve,
|
|
120
|
-
// reject
|
|
121
|
-
// );
|
|
122
|
-
// } else {
|
|
123
|
-
// reject(null);
|
|
124
|
-
// }
|
|
125
|
-
// });
|
|
126
|
-
// }
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Query whether inverted colors are currently enabled.
|
|
131
|
-
*
|
|
132
|
-
* Returns a promise which resolves to a boolean.
|
|
133
|
-
* The result is `true` when invert color is enabled and `false` otherwise.
|
|
134
|
-
*
|
|
135
|
-
* See https://reactnative.dev/docs/accessibilityinfo#isInvertColorsEnabled
|
|
136
|
-
*/
|
|
137
|
-
isInvertColorsEnabled(): Promise<boolean> {
|
|
138
|
-
// RNOH patch
|
|
139
|
-
return Promise.resolve(false);
|
|
140
|
-
// if (Platform.OS === 'android') {
|
|
141
|
-
// return Promise.resolve(false);
|
|
142
|
-
// } else {
|
|
143
|
-
// return new Promise((resolve, reject) => {
|
|
144
|
-
// if (NativeAccessibilityManagerIOS != null) {
|
|
145
|
-
// NativeAccessibilityManagerIOS.getCurrentInvertColorsState(
|
|
146
|
-
// resolve,
|
|
147
|
-
// reject
|
|
148
|
-
// );
|
|
149
|
-
// } else {
|
|
150
|
-
// reject(null);
|
|
151
|
-
// }
|
|
152
|
-
// });
|
|
153
|
-
// }
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Query whether reduced motion is currently enabled.
|
|
158
|
-
*
|
|
159
|
-
* Returns a promise which resolves to a boolean.
|
|
160
|
-
* The result is `true` when a reduce motion is enabled and `false` otherwise.
|
|
161
|
-
*
|
|
162
|
-
* See https://reactnative.dev/docs/accessibilityinfo#isReduceMotionEnabled
|
|
163
|
-
*/
|
|
164
|
-
isReduceMotionEnabled(): Promise<boolean> {
|
|
165
|
-
// RNOH patch
|
|
166
|
-
return Promise.resolve(false);
|
|
167
|
-
// return new Promise((resolve, reject) => {
|
|
168
|
-
// if (Platform.OS === 'android') {
|
|
169
|
-
// if (NativeAccessibilityInfoAndroid != null) {
|
|
170
|
-
// NativeAccessibilityInfoAndroid.isReduceMotionEnabled(resolve);
|
|
171
|
-
// } else {
|
|
172
|
-
// reject(null);
|
|
173
|
-
// }
|
|
174
|
-
// } else {
|
|
175
|
-
// if (NativeAccessibilityManagerIOS != null) {
|
|
176
|
-
// NativeAccessibilityManagerIOS.getCurrentReduceMotionState(
|
|
177
|
-
// resolve,
|
|
178
|
-
// reject
|
|
179
|
-
// );
|
|
180
|
-
// } else {
|
|
181
|
-
// reject(null);
|
|
182
|
-
// }
|
|
183
|
-
// }
|
|
184
|
-
// });
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Query whether reduce motion and prefer cross-fade transitions settings are currently enabled.
|
|
189
|
-
*
|
|
190
|
-
* Returns a promise which resolves to a boolean.
|
|
191
|
-
* The result is `true` when prefer cross-fade transitions is enabled and `false` otherwise.
|
|
192
|
-
*
|
|
193
|
-
* See https://reactnative.dev/docs/accessibilityinfo#prefersCrossFadeTransitions
|
|
194
|
-
*/
|
|
195
|
-
prefersCrossFadeTransitions(): Promise<boolean> {
|
|
196
|
-
// RNOH patch
|
|
197
|
-
return Promise.resolve(false);
|
|
198
|
-
// return new Promise((resolve, reject) => {
|
|
199
|
-
// if (Platform.OS === 'android') {
|
|
200
|
-
// return Promise.resolve(false);
|
|
201
|
-
// } else {
|
|
202
|
-
// if (
|
|
203
|
-
// NativeAccessibilityManagerIOS?.getCurrentPrefersCrossFadeTransitionsState !=
|
|
204
|
-
// null
|
|
205
|
-
// ) {
|
|
206
|
-
// NativeAccessibilityManagerIOS.getCurrentPrefersCrossFadeTransitionsState(
|
|
207
|
-
// resolve,
|
|
208
|
-
// reject
|
|
209
|
-
// );
|
|
210
|
-
// } else {
|
|
211
|
-
// reject(null);
|
|
212
|
-
// }
|
|
213
|
-
// }
|
|
214
|
-
// });
|
|
215
|
-
},
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Query whether reduced transparency is currently enabled.
|
|
219
|
-
*
|
|
220
|
-
* Returns a promise which resolves to a boolean.
|
|
221
|
-
* The result is `true` when a reduce transparency is enabled and `false` otherwise.
|
|
222
|
-
*
|
|
223
|
-
* See https://reactnative.dev/docs/accessibilityinfo#isReduceTransparencyEnabled
|
|
224
|
-
*/
|
|
225
|
-
isReduceTransparencyEnabled(): Promise<boolean> {
|
|
226
|
-
// RNOH patch
|
|
227
|
-
return Promise.resolve(false);
|
|
228
|
-
// if (Platform.OS === 'android') {
|
|
229
|
-
// return Promise.resolve(false);
|
|
230
|
-
// } else {
|
|
231
|
-
// return new Promise((resolve, reject) => {
|
|
232
|
-
// if (NativeAccessibilityManagerIOS != null) {
|
|
233
|
-
// NativeAccessibilityManagerIOS.getCurrentReduceTransparencyState(
|
|
234
|
-
// resolve,
|
|
235
|
-
// reject
|
|
236
|
-
// );
|
|
237
|
-
// } else {
|
|
238
|
-
// reject(null);
|
|
239
|
-
// }
|
|
240
|
-
// });
|
|
241
|
-
// }
|
|
242
|
-
},
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Query whether a screen reader is currently enabled.
|
|
246
|
-
*
|
|
247
|
-
* Returns a promise which resolves to a boolean.
|
|
248
|
-
* The result is `true` when a screen reader is enabled and `false` otherwise.
|
|
249
|
-
*
|
|
250
|
-
* See https://reactnative.dev/docs/accessibilityinfo#isScreenReaderEnabled
|
|
251
|
-
*/
|
|
252
|
-
isScreenReaderEnabled(): Promise<boolean> {
|
|
253
|
-
// RNOH patch
|
|
254
|
-
return NativeAccessibilityInfoHarmony.isScreenReaderEnabled();
|
|
255
|
-
// return new Promise((resolve, reject) => {
|
|
256
|
-
// if (Platform.OS === 'android') {
|
|
257
|
-
// if (NativeAccessibilityInfoAndroid != null) {
|
|
258
|
-
// NativeAccessibilityInfoAndroid.isTouchExplorationEnabled(resolve);
|
|
259
|
-
// } else {
|
|
260
|
-
// reject(null);
|
|
261
|
-
// }
|
|
262
|
-
// } else {
|
|
263
|
-
// if (NativeAccessibilityManagerIOS != null) {
|
|
264
|
-
// NativeAccessibilityManagerIOS.getCurrentVoiceOverState(
|
|
265
|
-
// resolve,
|
|
266
|
-
// reject
|
|
267
|
-
// );
|
|
268
|
-
// } else {
|
|
269
|
-
// reject(null);
|
|
270
|
-
// }
|
|
271
|
-
// }
|
|
272
|
-
// });
|
|
273
|
-
},
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Query whether Accessibility Service is currently enabled.
|
|
277
|
-
*
|
|
278
|
-
* Returns a promise which resolves to a boolean.
|
|
279
|
-
* The result is `true` when any service is enabled and `false` otherwise.
|
|
280
|
-
*
|
|
281
|
-
* @platform android
|
|
282
|
-
*
|
|
283
|
-
* See https://reactnative.dev/docs/accessibilityinfo/#isaccessibilityserviceenabled-android
|
|
284
|
-
*/
|
|
285
|
-
isAccessibilityServiceEnabled(): Promise<boolean> {
|
|
286
|
-
// RNOH patch
|
|
287
|
-
return NativeAccessibilityInfoHarmony.isAccessibilityServiceEnabled();
|
|
288
|
-
// return new Promise((resolve, reject) => {
|
|
289
|
-
// if (Platform.OS === 'android') {
|
|
290
|
-
// if (
|
|
291
|
-
// NativeAccessibilityInfoAndroid != null &&
|
|
292
|
-
// NativeAccessibilityInfoAndroid.isAccessibilityServiceEnabled != null
|
|
293
|
-
// ) {
|
|
294
|
-
// NativeAccessibilityInfoAndroid.isAccessibilityServiceEnabled(resolve);
|
|
295
|
-
// } else {
|
|
296
|
-
// reject(null);
|
|
297
|
-
// }
|
|
298
|
-
// } else {
|
|
299
|
-
// reject(null);
|
|
300
|
-
// }
|
|
301
|
-
// });
|
|
302
|
-
},
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Add an event handler. Supported events:
|
|
306
|
-
*
|
|
307
|
-
* - `reduceMotionChanged`: Fires when the state of the reduce motion toggle changes.
|
|
308
|
-
* The argument to the event handler is a boolean. The boolean is `true` when a reduce
|
|
309
|
-
* motion is enabled (or when "Transition Animation Scale" in "Developer options" is
|
|
310
|
-
* "Animation off") and `false` otherwise.
|
|
311
|
-
* - `screenReaderChanged`: Fires when the state of the screen reader changes. The argument
|
|
312
|
-
* to the event handler is a boolean. The boolean is `true` when a screen
|
|
313
|
-
* reader is enabled and `false` otherwise.
|
|
314
|
-
*
|
|
315
|
-
* These events are only supported on iOS:
|
|
316
|
-
*
|
|
317
|
-
* - `boldTextChanged`: iOS-only event. Fires when the state of the bold text toggle changes.
|
|
318
|
-
* The argument to the event handler is a boolean. The boolean is `true` when a bold text
|
|
319
|
-
* is enabled and `false` otherwise.
|
|
320
|
-
* - `grayscaleChanged`: iOS-only event. Fires when the state of the gray scale toggle changes.
|
|
321
|
-
* The argument to the event handler is a boolean. The boolean is `true` when a gray scale
|
|
322
|
-
* is enabled and `false` otherwise.
|
|
323
|
-
* - `invertColorsChanged`: iOS-only event. Fires when the state of the invert colors toggle
|
|
324
|
-
* changes. The argument to the event handler is a boolean. The boolean is `true` when a invert
|
|
325
|
-
* colors is enabled and `false` otherwise.
|
|
326
|
-
* - `reduceTransparencyChanged`: iOS-only event. Fires when the state of the reduce transparency
|
|
327
|
-
* toggle changes. The argument to the event handler is a boolean. The boolean is `true`
|
|
328
|
-
* when a reduce transparency is enabled and `false` otherwise.
|
|
329
|
-
* - `announcementFinished`: iOS-only event. Fires when the screen reader has
|
|
330
|
-
* finished making an announcement. The argument to the event handler is a
|
|
331
|
-
* dictionary with these keys:
|
|
332
|
-
* - `announcement`: The string announced by the screen reader.
|
|
333
|
-
* - `success`: A boolean indicating whether the announcement was
|
|
334
|
-
* successfully made.
|
|
335
|
-
*
|
|
336
|
-
* See https://reactnative.dev/docs/accessibilityinfo#addeventlistener
|
|
337
|
-
*/
|
|
338
|
-
addEventListener<K: $Keys<AccessibilityEventDefinitions>>(
|
|
339
|
-
eventName: K,
|
|
340
|
-
// $FlowIssue[incompatible-type] - Flow bug with unions and generics (T128099423)
|
|
341
|
-
handler: (...$ElementType<AccessibilityEventDefinitions, K>) => void
|
|
342
|
-
): EventSubscription {
|
|
343
|
-
const deviceEventName = EventNames.get(eventName);
|
|
344
|
-
return deviceEventName == null
|
|
345
|
-
? { remove(): void {} }
|
|
346
|
-
: // $FlowFixMe[incompatible-call]
|
|
347
|
-
RCTDeviceEventEmitter.addListener(deviceEventName, handler);
|
|
348
|
-
},
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Set accessibility focus to a React component.
|
|
352
|
-
*
|
|
353
|
-
* See https://reactnative.dev/docs/accessibilityinfo#setaccessibilityfocus
|
|
354
|
-
*/
|
|
355
|
-
setAccessibilityFocus(reactTag: number): void {
|
|
356
|
-
// RNOH patch
|
|
357
|
-
NativeAccessibilityInfoHarmony.setAccessibilityFocus(reactTag);
|
|
358
|
-
// legacySendAccessibilityEvent(reactTag, 'focus');
|
|
359
|
-
},
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* Send a named accessibility event to a HostComponent.
|
|
363
|
-
*/
|
|
364
|
-
sendAccessibilityEvent(
|
|
365
|
-
handle: ElementRef<HostComponent<mixed>>,
|
|
366
|
-
eventType: AccessibilityEventTypes
|
|
367
|
-
) {
|
|
368
|
-
// iOS only supports 'focus' event types
|
|
369
|
-
if (Platform.OS === 'ios' && eventType === 'click') {
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
// route through React renderer to distinguish between Fabric and non-Fabric handles
|
|
373
|
-
sendAccessibilityEvent(handle, eventType);
|
|
374
|
-
},
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Post a string to be announced by the screen reader.
|
|
378
|
-
*
|
|
379
|
-
* See https://reactnative.dev/docs/accessibilityinfo#announceforaccessibility
|
|
380
|
-
*/
|
|
381
|
-
announceForAccessibility(announcement: string): void {
|
|
382
|
-
// RNOH patch
|
|
383
|
-
NativeAccessibilityInfoHarmony.announceForAccessibility(announcement);
|
|
384
|
-
// if (Platform.OS === 'android') {
|
|
385
|
-
// NativeAccessibilityInfoAndroid?.announceForAccessibility(announcement);
|
|
386
|
-
// } else {
|
|
387
|
-
// NativeAccessibilityManagerIOS?.announceForAccessibility(announcement);
|
|
388
|
-
// }
|
|
389
|
-
},
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* Post a string to be announced by the screen reader.
|
|
393
|
-
* - `announcement`: The string announced by the screen reader.
|
|
394
|
-
* - `options`: An object that configures the reading options.
|
|
395
|
-
* - `queue`: The announcement will be queued behind existing announcements. iOS only.
|
|
396
|
-
*/
|
|
397
|
-
announceForAccessibilityWithOptions(
|
|
398
|
-
announcement: string,
|
|
399
|
-
options: { queue?: boolean }
|
|
400
|
-
): void {
|
|
401
|
-
// RNOH patch
|
|
402
|
-
// if (Platform.OS === 'android') {
|
|
403
|
-
// NativeAccessibilityInfoAndroid?.announceForAccessibility(announcement);
|
|
404
|
-
// } else {
|
|
405
|
-
// if (NativeAccessibilityManagerIOS?.announceForAccessibilityWithOptions) {
|
|
406
|
-
// NativeAccessibilityManagerIOS?.announceForAccessibilityWithOptions(
|
|
407
|
-
// announcement,
|
|
408
|
-
// options
|
|
409
|
-
// );
|
|
410
|
-
// } else {
|
|
411
|
-
// NativeAccessibilityManagerIOS?.announceForAccessibility(announcement);
|
|
412
|
-
// }
|
|
413
|
-
// }
|
|
414
|
-
},
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* Get the recommended timeout for changes to the UI needed by this user.
|
|
418
|
-
*
|
|
419
|
-
* See https://reactnative.dev/docs/accessibilityinfo#getrecommendedtimeoutmillis
|
|
420
|
-
*/
|
|
421
|
-
getRecommendedTimeoutMillis(originalTimeout: number): Promise<number> {
|
|
422
|
-
// RNOH patch
|
|
423
|
-
return Promise.resolve(0);
|
|
424
|
-
// if (Platform.OS === 'android') {
|
|
425
|
-
// return new Promise((resolve, reject) => {
|
|
426
|
-
// if (NativeAccessibilityInfoAndroid?.getRecommendedTimeoutMillis) {
|
|
427
|
-
// NativeAccessibilityInfoAndroid.getRecommendedTimeoutMillis(
|
|
428
|
-
// originalTimeout,
|
|
429
|
-
// resolve
|
|
430
|
-
// );
|
|
431
|
-
// } else {
|
|
432
|
-
// resolve(originalTimeout);
|
|
433
|
-
// }
|
|
434
|
-
// });
|
|
435
|
-
// } else {
|
|
436
|
-
// return Promise.resolve(originalTimeout);
|
|
437
|
-
// }
|
|
438
|
-
},
|
|
439
|
-
};
|
|
440
|
-
|
|
441
|
-
export default AccessibilityInfo;
|