Commit 01f1780
Expose static methods to manipulate the StatusBar stack imperatively (facebook#21206)
Summary:
This PR exposes three static methods (`pushStackEntry`, `popStackEntry`, and `replaceStackEntry`) on StatusBar that enable imperative manipulation of the StatusBar style within the stack established by mounted StatusBar components.
Motivation:
----------
The StatusBar **component** provides a sensible API for manipulating that StatusBar style: every time a StatusBar component is mounted, its props are pushed onto a stack, and the props from the most recently mounted component are applied.
However, there are some scenarios where you may need to manipulate the StatusBar style from imperative code — particularly when invoking imperative third-party APIs that cause UI to appear. (For example, a user feedback utility or bug reporter that launches a full-screen modal.)
In modern iOS development, `UIViewControllerBasedStatusBarAppearance` is typically set to `YES`, which allows the third-party UIViewController to specify its preferred status bar style. However, as has been discussed at length in facebook#11710, React Native has disabled this setting, which means that either the app's code or the third-party's React Native wrapper needs to manually manipulate React Native's StatusBar API to achieve the desired outcome.
The existing imperative StatusBar APIs are not a good fit for these needs because they simply overwrite the existing StatusBar styles, and provide no means of reverting StatusBar style changes when the third-party UI is dismissed.
To improve upon this situation, this PR makes it possible to call `StatusBar.pushStackEntry` before launching the third-party UI, wait for the UI to dismiss, and then call `StatusBar.popStackEntry` (supplying the token returned from the push call).
I've featured the new stack-based imperative methods in the documentation, but stopped short of explicitly deprecating the older imperative methods — though I can think of no reason not to deprecate them. Feedback is welcome on this point.
Release Notes:
--------------
[GENERAL] [ENHANCEMENT] [StatusBar] - Add static methods to manipulate StatusBar stack imperatively
Pull Request resolved: facebook#21206
Differential Revision: D9945247
Pulled By: cpojer
fbshipit-source-id: ec118268cff5b47e87be81d0b9e1728ecc3a9b021 parent 638d672 commit 01f1780
1 file changed
+79
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
190 | 213 | | |
191 | 214 | | |
192 | 215 | | |
| |||
300 | 323 | | |
301 | 324 | | |
302 | 325 | | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
303 | 368 | | |
304 | 369 | | |
305 | 370 | | |
| |||
311 | 376 | | |
312 | 377 | | |
313 | 378 | | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
| 379 | + | |
| 380 | + | |
318 | 381 | | |
319 | 382 | | |
320 | 383 | | |
321 | 384 | | |
322 | 385 | | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
| 386 | + | |
327 | 387 | | |
328 | 388 | | |
329 | 389 | | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
335 | 394 | | |
336 | 395 | | |
337 | 396 | | |
338 | 397 | | |
339 | 398 | | |
340 | | - | |
| 399 | + | |
341 | 400 | | |
342 | 401 | | |
343 | 402 | | |
| |||
355 | 414 | | |
356 | 415 | | |
357 | 416 | | |
358 | | - | |
| 417 | + | |
359 | 418 | | |
360 | 419 | | |
361 | 420 | | |
| |||
0 commit comments