Commit 61c8b04
Add StatusBar "auto" barStyle value (#56978)
Summary:
Adds support for `barStyle="auto"` on `StatusBar`. When set, the bar style is resolved against the current color scheme: `light-content` in dark mode, `dark-content` in light mode. The resolution re-runs when the system color scheme changes, while at least one `StatusBar` is mounted.
The behavior mirrors what `expo-status-bar` already exposes. The `'auto'` name is the one we use at Expo. It is not necessarily the right name for React Native core, happy to switch to something else if reviewers prefer.
## Changelog:
[GENERAL] [ADDED] - StatusBar: support `barStyle="auto"` to follow the current color scheme
Pull Request resolved: #56978
Test Plan:
- `yarn jest packages/react-native/Libraries/Components/StatusBar` passes, including a new test that asserts `setBarStyle('auto')` calls the native module with `dark-content` in light mode and `light-content` in dark mode.
- Play with it in the RNTester app
Reviewed By: cortinico
Differential Revision: D106535143
Pulled By: zeyap
fbshipit-source-id: eff3dea37a317f22af3364345d355908104c8c5a1 parent 833144f commit 61c8b04
5 files changed
Lines changed: 97 additions & 13 deletions
File tree
- packages
- react-native
- Libraries/Components/StatusBar
- __tests__
- rn-tester/js/examples/StatusBar
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
Lines changed: 58 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
28 | 35 | | |
29 | 36 | | |
30 | 37 | | |
| |||
105 | 112 | | |
106 | 113 | | |
107 | 114 | | |
108 | | - | |
| 115 | + | |
109 | 116 | | |
110 | 117 | | |
111 | 118 | | |
| |||
133 | 140 | | |
134 | 141 | | |
135 | 142 | | |
136 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
137 | 155 | | |
138 | 156 | | |
139 | 157 | | |
140 | 158 | | |
141 | 159 | | |
142 | | - | |
| 160 | + | |
143 | 161 | | |
144 | 162 | | |
145 | 163 | | |
| |||
150 | 168 | | |
151 | 169 | | |
152 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
153 | 177 | | |
154 | 178 | | |
155 | 179 | | |
| |||
247 | 271 | | |
248 | 272 | | |
249 | 273 | | |
250 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
251 | 277 | | |
252 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
253 | 284 | | |
254 | 285 | | |
255 | 286 | | |
| |||
289 | 320 | | |
290 | 321 | | |
291 | 322 | | |
| 323 | + | |
292 | 324 | | |
293 | | - | |
| 325 | + | |
294 | 326 | | |
295 | | - | |
| 327 | + | |
296 | 328 | | |
297 | 329 | | |
298 | 330 | | |
| |||
407 | 439 | | |
408 | 440 | | |
409 | 441 | | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
410 | 452 | | |
411 | 453 | | |
412 | 454 | | |
| |||
415 | 457 | | |
416 | 458 | | |
417 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
418 | 470 | | |
419 | 471 | | |
420 | 472 | | |
| |||
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
50 | 77 | | |
51 | 78 | | |
52 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
4948 | 4948 | | |
4949 | 4949 | | |
4950 | 4950 | | |
4951 | | - | |
| 4951 | + | |
4952 | 4952 | | |
4953 | 4953 | | |
4954 | 4954 | | |
| |||
4963 | 4963 | | |
4964 | 4964 | | |
4965 | 4965 | | |
| 4966 | + | |
4966 | 4967 | | |
4967 | 4968 | | |
4968 | 4969 | | |
| |||
6213 | 6214 | | |
6214 | 6215 | | |
6215 | 6216 | | |
6216 | | - | |
| 6217 | + | |
6217 | 6218 | | |
6218 | | - | |
6219 | | - | |
| 6219 | + | |
| 6220 | + | |
6220 | 6221 | | |
6221 | 6222 | | |
6222 | 6223 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
0 commit comments