@@ -8,7 +8,7 @@ officialDoc: https://reactnative.dev/docs/accessibilityinfo
88
99### ` announcementResult `
1010
11- Passed to the handler of the `` ` announcementFinished ` ` event.
11+ Passed to the handler of the ` # announcementFinished` event.
1212
1313``` rescript
1414type announcementResult = {
@@ -22,131 +22,82 @@ is a `bool` indicating whether the announcement was successfully made.
2222
2323## Methods
2424
25- ### ` isBoldTextEnabled `
25+ ### Query methods
2626
27- _ iOS only _
27+ Each of these returns ` promise<bool> ` :
2828
29- To query whether bold text is currently enabled. Promise resolves to ` true ` when
30- bold text is enabled and ` false ` otherwise.
29+ | Method | Notes |
30+ | --- | --- |
31+ | ` isBoldTextEnabled ` | iOS |
32+ | ` isGrayscaleEnabled ` | iOS |
33+ | ` isInvertColorsEnabled ` | iOS |
34+ | ` isReduceMotionEnabled ` | |
35+ | ` isReduceTransparencyEnabled ` | iOS |
36+ | ` isScreenReaderEnabled ` | |
37+ | ` isHighTextContrastEnabled ` | |
38+ | ` isDarkerSystemColorsEnabled ` | |
39+ | ` isAccessibilityServiceEnabled ` | |
40+ | ` prefersCrossFadeTransitions ` | |
3141
3242``` rescript
33- isBoldTextEnabled : unit => Js.Promise.t( bool)
43+ isScreenReaderEnabled : unit => promise< bool>
3444```
3545
36- ### ` isGrayscaleEnabled `
37-
38- _ iOS only_
39-
40- To query whether grayscale is currently enabled. Promise resolves to ` true ` when
41- grayscale is enabled and ` false ` otherwise.
42-
43- ``` rescript
44- isGrayscaleEnabled: unit => Js.Promise.t(bool)
45- ```
46-
47- ### ` isInvertColorsEnabled `
48-
49- _ iOS only_
50-
51- To query whether invert colors is currently enabled. Promise resolves to ` true `
52- when invert colors is enabled and ` false ` otherwise.
46+ ### ` getRecommendedTimeoutMillis `
5347
5448``` rescript
55- isInvertColorsEnabled: unit => Js.Promise.t(bool)
49+ getRecommendedTimeoutMillis: float => promise<float>
5650```
5751
58- ### ` isReduceMotionEnabled `
59-
60- To query whether reduce motion is currently enabled. Promise resolves to ` true `
61- when reduce motion is enabled and ` false ` otherwise.
62-
63- ``` rescript
64- isReduceMotionEnabled: unit => Js.Promise.t(bool)
65- ```
66-
67- ### ` isReduceTransparencyEnabled `
68-
69- _ iOS only_
70-
71- To query whether reduce transparency is currently enabled. Promise resolves to
72- ` true ` when reduce transparency is enabled and ` false ` otherwise.
73-
74- ``` rescript
75- isReduceTransparencyEnabled: unit => Js.Promise.t(bool)
76- ```
77-
78- ### ` isScreenReaderEnabled `
79-
80- To query whether screen reader is currently enabled. Promise resolves to ` true `
81- when screen reader is enabled and ` false ` otherwise.
52+ ### ` announceForAccessibility `
8253
8354``` rescript
84- isScreenReaderEnabled: unit => Js.Promise.t(bool)
55+ announceForAccessibility: string => unit
56+ announceForAccessibilityWithOptions: (string, {queue?: bool}) => unit
8557```
8658
8759### ` setAccessibilityFocus `
8860
89- To set accessibility focus to a React component, identified by its ` nodeHandle ` .
90- On Android, this is equivalent to
91- ` UIManager.sendAccessibilityEvent(reactTag, UIManager.AccessibilityEventTypes.typeViewFocused) `
61+ @deprecated Prefer ` sendAccessibilityEvent ` with ` #focus ` .
9262
9363``` rescript
9464setAccessibilityFocus: NativeTypes.nodeHandle => unit
9565```
9666
97- ### ` announceForAccessibility `
98-
99- To post a string to be announced by the screen reader.
67+ ### ` sendAccessibilityEvent `
10068
10169``` rescript
102- announceForAccessibility: string => unit
70+ sendAccessibilityEvent: (
71+ Ref.t<DOMAPI.element<'nativeElement>>,
72+ [#click | #focus | #viewHoverEnter | #windowStateChange],
73+ ) => unit
10374```
10475
10576### ` addEventListener `
10677
107- Add an event handler.
78+ Add an event handler. Returns an [ ` EventSubscription ` ] ( /docs/eventsubscription )
79+ — call ` .remove() ` to unsubscribe.
10880
10981``` rescript
11082addEventListener: [
111- | #boldTextChanged(bool => unit)
112- | #grayscaleChanged(bool => unit)
113- | #invertColorsChanged(bool => unit)
114- | #reduceMotionChanged(bool => unit)
115- | #screenReaderChanged(bool => unit)
116- | #reduceTransparencyChanged(bool => unit)
117- | #announcementFinished(announcementResult => unit)
118- ] => unit
83+ | #boldTextChanged(bool => unit)
84+ | #grayscaleChanged(bool => unit)
85+ | #invertColorsChanged(bool => unit)
86+ | #reduceMotionChanged(bool => unit)
87+ | #screenReaderChanged(bool => unit)
88+ | #reduceTransparencyChanged(bool => unit)
89+ | #highTextContrastChanged(bool => unit)
90+ | #darkerSystemColorsChanged(bool => unit)
91+ | #accessibilityServiceChanged(bool => unit)
92+ | #announcementFinished(announcementResult => unit)
93+ ] => EventSubscription.t
11994```
12095
121- Supported events:
122-
123- - ` boldTextChanged(bool => unit) ` : _ iOS only_ . Fires when state of the bold text
124- toggle changes. The argument to the event handler is a ` bool ` which is ` true `
125- when bold text is enabled and ` false ` otherwise.
126- - ` grayscaleChanged(bool => unit) ` : _ iOS only_ . Fires when state of the gray
127- scale toggle changes. The argument to the event handler is a ` bool ` which is
128- ` true ` when gray scale is enabled and ` false ` otherwise.
129- - ` invertColorsChanged(bool => unit) ` : _ iOS only_ . Fires when state of the
130- invert colors toggle changes. The argument to the event handler is a ` bool `
131- which is ` true ` when invert colors is enabled and ` false ` otherwise.
132- - ` reduceMotionChanged(bool => unit) ` : Fires when state of the reduce motion
133- toggle changes. The argument to the event handler is a ` bool ` which is ` true `
134- when reduce motion is enabled (or when "Transition Animation Scale" in
135- "Developer options" is "Animation off") and ` false ` otherwise.
136- - ` screenReaderChanged(bool => unit) ` : Fires when state of the screen reader
137- changes. The argument to the event handler is a ` bool ` which is ` true ` when a
138- screen reader is enabled and ` false ` otherwise.
139- - ` reduceTransparencyChanged(bool => unit) ` : _ iOS only_ . Fires when state of the
140- reduce transparency toggle changes. The argument to the event handler is a
141- ` bool ` which is ` true ` when reduce transparency is enabled and ` false `
142- otherwise.
143- - ` announcementFinished(announcementResult => unit) ` : _ iOS only_ . Fires when the
144- screen reader has finished making an announcement. The argument to the event
145- handler is of type [ ` announcementResult ` ] ( #announcementResult ) .
146-
147- ### ` removeEventListener `
148-
149- To remove an event handler.
150-
151- See [ ` addEventListener ` ] ( #addEventListener ) for more details on supported
152- events.
96+ ``` rescript
97+ React.useEffect0(() => {
98+ let sub = AccessibilityInfo.addEventListener(#screenReaderChanged(enabled => {
99+ Console.log(enabled)
100+ }))
101+ Some(() => sub->EventSubscription.remove)
102+ })
103+ ```
0 commit comments