Skip to content

Commit 1bbb716

Browse files
authored
reason-react-native: Add documentation for AccessibilityInfo (#598)
1 parent d2173f6 commit 1bbb716

File tree

1 file changed

+131
-35
lines changed

1 file changed

+131
-35
lines changed
Lines changed: 131 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,168 @@
11
---
22
id: apis/AccessibilityInfo
33
title: AccessibilityInfo
4-
wip: true
4+
officialDoc: https://facebook.github.io/react-native/docs/accessibilityinfo
55
---
66

7+
## Types
8+
9+
### `announcementResult`
10+
11+
Passed to the handler of the `` `announcementFinished `` event.
12+
713
```reason
814
type announcementResult = {
915
.
1016
"announcement": string,
1117
"success": bool,
12-
};
18+
}
19+
```
20+
21+
where `announcement` is the string announced by the screen reader and `success`
22+
is a `bool` indicating whether the announcement was successfully made.
23+
24+
## Methods
25+
26+
### `isBoldTextEnabled`
1327

14-
[@bs.scope "AccessibilityInfo"] [@bs.module "react-native"]
15-
external isBoldTextEnabled: unit => Js.Promise.t(bool) = "";
28+
_iOS only_
1629

17-
[@bs.scope "AccessibilityInfo"] [@bs.module "react-native"]
18-
external isGrayscaleEnabled: unit => Js.Promise.t(bool) = "";
30+
To query whether bold text is currently enabled. Promise resolves to `true` when
31+
bold text is enabled and `false` otherwise.
1932

20-
[@bs.scope "AccessibilityInfo"] [@bs.module "react-native"]
21-
external isInvertColorsEnabled: unit => Js.Promise.t(bool) = "";
33+
```reason
34+
isBoldTextEnabled: unit => Js.Promise.t(bool)
35+
```
36+
37+
### `isGrayscaleEnabled`
38+
39+
_iOS only_
2240

23-
[@bs.scope "AccessibilityInfo"] [@bs.module "react-native"]
41+
To query whether grayscale is currently enabled. Promise resolves to `true` when
42+
grayscale is enabled and `false` otherwise.
43+
44+
```reason
45+
isGrayscaleEnabled: unit => Js.Promise.t(bool)
46+
```
47+
48+
### `isInvertColorsEnabled`
49+
50+
_iOS only_
51+
52+
To query whether invert colors is currently enabled. Promise resolves to `true`
53+
when invert colors is enabled and `false` otherwise.
54+
55+
```reason
56+
isInvertColorsEnabled: unit => Js.Promise.t(bool)
57+
```
58+
59+
### `isReduceMotionEnabled`
60+
61+
To query whether reduce motion is currently enabled. Promise resolves to `true`
62+
when reduce motion is enabled and `false` otherwise.
63+
64+
```reason
65+
[@bs.scope "AccesibilityInfo"] [@bs.module "react-native"]
2466
external isReduceMotionEnabled: unit => Js.Promise.t(bool) = "";
67+
```
68+
69+
### `isReduceTransparencyEnabled`
70+
71+
_iOS only_
2572

26-
[@bs.scope "AccessibilityInfo"] [@bs.module "react-native"]
73+
To query whether reduce transparency is currently enabled. Promise resolves to
74+
`true` when reduce transparency is enabled and `false` otherwise.
75+
76+
```reason
77+
[@bs.scope "AccesibilityInfo"] [@bs.module "react-native"]
2778
external isReduceTransparencyEnabled: unit => Js.Promise.t(bool) = "";
79+
```
80+
81+
### `isScreenReaderEnabled`
2882

29-
[@bs.scope "AccessibilityInfo"] [@bs.module "react-native"]
83+
To query whether screen reader is currently enabled. Promise resolves to `true`
84+
when screen reader is enabled and `false` otherwise.
85+
86+
```reason
87+
[@bs.scope "AccesibilityInfo"] [@bs.module "react-native"]
3088
external isScreenReaderEnabled: unit => Js.Promise.t(bool) = "";
89+
```
3190

32-
[@bs.scope "AccessibilityInfo"] [@bs.module "react-native"]
33-
external setAccessibilityFocus: NativeTypes.nodeHandle => unit = "";
91+
### `setAccessibilityFocus`
3492

35-
[@bs.scope "AccessibilityInfo"] [@bs.module "react-native"]
36-
external announceForAccessibility: string => unit = "";
93+
To set accessibility focus to a React component, identified by its `nodeHandle`.
94+
On Android, this is equivalent to
95+
`UIManager.sendAccessibilityEvent(reactTag, UIManager.AccessibilityEventTypes.typeViewFocused)`;
3796

38-
[@bs.scope "AccessibilityInfo"] [@bs.module "react-native"]
39-
external addEventListener:
40-
(
41-
[@bs.string]
42-
[
97+
```reason
98+
setAccessibilityFocus: NativeTypes.nodeHandle => unit
99+
```
100+
101+
### `announceForAccessibility`
102+
103+
To post a string to be announced by the screen reader.
104+
105+
```reason
106+
announceForAccessibility: string => unit
107+
```
108+
109+
### `addEventListener`
110+
111+
Add an event handler.
112+
113+
```reason
114+
addEventListener: [
43115
| `boldTextChanged(bool => unit)
44116
| `grayscaleChanged(bool => unit)
45117
| `invertColorsChanged(bool => unit)
46118
| `reduceMotionChanged(bool => unit)
47119
| `screenReaderChanged(bool => unit)
48120
| `reduceTransparencyChanged(bool => unit)
49121
| `announcementFinished(announcementResult => unit)
50-
]
51-
) =>
52-
unit =
53-
"";
54-
55-
[@bs.scope "AccessibilityInfo"] [@bs.module "react-native"]
56-
external removeEventListener:
57-
(
58-
[@bs.string]
59-
[
122+
] => unit
123+
```
124+
125+
Supported events:
126+
127+
- `boldTextChanged(bool => unit)`: _iOS only_. Fires when state of the bold text
128+
toggle changes. The argument to the event handler is a `bool` which is `true`
129+
when bold text is enabled and `false` otherwise.
130+
- `grayscaleChanged(bool => unit)`: _iOS only_. Fires when state of the gray
131+
scale toggle changes. The argument to the event handler is a `bool` which is
132+
`true` when gray scale is enabled and `false` otherwise.
133+
- `invertColorsChanged(bool => unit)`: _iOS only_. Fires when state of the
134+
invert colors toggle changes. The argument to the event handler is a `bool`
135+
which is `true` when invert colors is enabled and `false` otherwise.
136+
- `reduceMotionChanged(bool => unit)`: Fires when state of the reduce motion
137+
toggle changes. The argument to the event handler is a `bool` which is `true`
138+
when reduce motion is enabled (or when "Transition Animation Scale" in
139+
"Developer options" is "Animation off") and `false` otherwise.
140+
- `screenReaderChanged(bool => unit)`: Fires when state of the screen reader
141+
changes. The argument to the event handler is a `bool` which is `true` when a
142+
screen reader is enabled and `false` otherwise.
143+
- `reduceTransparencyChanged(bool => unit)`: _iOS only_. Fires when state of the
144+
reduce transparency toggle changes. The argument to the event handler is a
145+
`bool` which is `true` when reduce transparency is enabled and `false`
146+
otherwise.
147+
- `announcementFinished(announcementResult => unit)`: _iOS only_. Fires when the
148+
screen reader has finished making an announcement. The argument to the event
149+
handler is of type [`announcementResult`](#announcementResult).
150+
151+
### `removeEventListener`
152+
153+
To remove an event handler.
154+
155+
```reason
156+
addEventListener: [
60157
| `boldTextChanged(bool => unit)
61158
| `grayscaleChanged(bool => unit)
62159
| `invertColorsChanged(bool => unit)
63160
| `reduceMotionChanged(bool => unit)
64161
| `screenReaderChanged(bool => unit)
65162
| `reduceTransparencyChanged(bool => unit)
66163
| `announcementFinished(announcementResult => unit)
67-
]
68-
) =>
69-
unit =
70-
"";
71-
164+
] => unit
72165
```
166+
167+
See [`addEventListener`](#addEventListener) for more details on supported
168+
events.

0 commit comments

Comments
 (0)