@@ -55,7 +55,7 @@ export type StatusBarAnimation = $Keys<{
5555 ...
5656} > ;
5757
58- type AndroidProps = $ReadOnly < {
58+ export type StatusBarPropsAndroid = $ReadOnly < {
5959 /**
6060 * The background color of the status bar.
6161 * @platform android
@@ -71,7 +71,7 @@ type AndroidProps = $ReadOnly<{
7171 translucent ?: ?boolean ,
7272} > ;
7373
74- type IOSProps = $ReadOnly < {
74+ export type StatusBarPropsIOS = $ReadOnly < {
7575 /**
7676 * If the network activity indicator should be visible.
7777 *
@@ -87,9 +87,7 @@ type IOSProps = $ReadOnly<{
8787 showHideTransition ?: ?( 'fade' | 'slide' | 'none' ) ,
8888} > ;
8989
90- type Props = $ReadOnly < {
91- ...AndroidProps ,
92- ...IOSProps ,
90+ type StatusBarBaseProps = $ReadOnly < {
9391 /**
9492 * If the status bar is hidden.
9593 */
@@ -105,22 +103,28 @@ type Props = $ReadOnly<{
105103 barStyle ?: ?( 'default' | 'light-content' | 'dark-content' ) ,
106104} > ;
107105
106+ export type StatusBarProps = $ReadOnly < {
107+ ...StatusBarPropsAndroid ,
108+ ...StatusBarPropsIOS ,
109+ ...StatusBarBaseProps ,
110+ } > ;
111+
108112type StackProps = {
109113 backgroundColor : ?{
110- value : Props [ 'backgroundColor' ] ,
114+ value : StatusBarProps [ 'backgroundColor' ] ,
111115 animated : boolean ,
112116 } ,
113117 barStyle : ?{
114- value : Props [ 'barStyle' ] ,
118+ value : StatusBarProps [ 'barStyle' ] ,
115119 animated : boolean ,
116120 } ,
117- translucent : Props [ 'translucent' ] ,
121+ translucent : StatusBarProps [ 'translucent' ] ,
118122 hidden : ?{
119123 value : boolean ,
120124 animated : boolean ,
121- transition : Props [ 'showHideTransition' ] ,
125+ transition : StatusBarProps [ 'showHideTransition' ] ,
122126 } ,
123- networkActivityIndicatorVisible : Props [ 'networkActivityIndicatorVisible' ] ,
127+ networkActivityIndicatorVisible : StatusBarProps [ 'networkActivityIndicatorVisible' ] ,
124128} ;
125129
126130/**
@@ -147,7 +151,7 @@ function mergePropsStack(
147151 * Returns an object to insert in the props stack from the props
148152 * and the transition/animation info.
149153 */
150- function createStackEntry ( props : Props ) : StackProps {
154+ function createStackEntry ( props : StatusBarProps ) : StackProps {
151155 const animated = props . animated ?? false ;
152156 const showHideTransition = props . showHideTransition ?? 'fade' ;
153157 return {
@@ -220,7 +224,7 @@ function createStackEntry(props: Props): StackProps {
220224 *
221225 * `currentHeight` (Android only) The height of the status bar.
222226 */
223- class StatusBar extends React . Component < Props > {
227+ class StatusBar extends React . Component < StatusBarProps > {
224228 static _propsStack : Array < StackProps > = [ ] ;
225229
226230 static _defaultProps : any = createStackEntry ( {
@@ -309,7 +313,7 @@ class StatusBar extends React.Component<Props> {
309313 * @param color Background color.
310314 * @param animated Animate the style change.
311315 */
312- static setBackgroundColor ( color : string , animated ? : boolean ) : void {
316+ static setBackgroundColor ( color : ColorValue , animated ? : boolean ) : void {
313317 if ( Platform . OS !== 'android' ) {
314318 console . warn ( '`setBackgroundColor` is only available on Android' ) ;
315319 return ;
@@ -320,7 +324,7 @@ class StatusBar extends React.Component<Props> {
320324 const processedColor = processColor ( color ) ;
321325 if ( processedColor == null ) {
322326 console . warn (
323- `\`StatusBar.setBackgroundColor\`: Color ${ color } parsed to null or undefined` ,
327+ `\`StatusBar.setBackgroundColor\`: Color ${ String ( color ) } parsed to null or undefined` ,
324328 ) ;
325329 return ;
326330 }
@@ -351,7 +355,7 @@ class StatusBar extends React.Component<Props> {
351355 *
352356 * @param props Object containing the StatusBar props to use in the stack entry.
353357 */
354- static pushStackEntry ( props : any ) : any {
358+ static pushStackEntry ( props : StatusBarProps ) : StackProps {
355359 const entry = createStackEntry ( props ) ;
356360 StatusBar . _propsStack . push ( entry ) ;
357361 StatusBar . _updatePropsStack ( ) ;
@@ -363,7 +367,7 @@ class StatusBar extends React.Component<Props> {
363367 *
364368 * @param entry Entry returned from `pushStackEntry`.
365369 */
366- static popStackEntry ( entry : any ) {
370+ static popStackEntry ( entry : StackProps ) {
367371 const index = StatusBar . _propsStack . indexOf ( entry ) ;
368372 if ( index !== - 1 ) {
369373 StatusBar . _propsStack . splice ( index , 1 ) ;
@@ -377,7 +381,10 @@ class StatusBar extends React.Component<Props> {
377381 * @param entry Entry returned from `pushStackEntry` to replace.
378382 * @param props Object containing the StatusBar props to use in the replacement stack entry.
379383 */
380- static replaceStackEntry ( entry : any , props : any ) : any {
384+ static replaceStackEntry (
385+ entry : StackProps ,
386+ props : StatusBarProps ,
387+ ) : StackProps {
381388 const newEntry = createStackEntry ( props ) ;
382389 const index = StatusBar . _propsStack . indexOf ( entry ) ;
383390 if ( index !== - 1 ) {
@@ -400,14 +407,18 @@ class StatusBar extends React.Component<Props> {
400407 componentWillUnmount ( ) {
401408 // When a StatusBar is unmounted, remove itself from the stack and update
402409 // the native bar with the next props.
403- StatusBar . popStackEntry ( this . _stackEntry ) ;
410+ if ( this . _stackEntry != null ) {
411+ StatusBar . popStackEntry ( this . _stackEntry ) ;
412+ }
404413 }
405414
406415 componentDidUpdate ( ) {
407- this . _stackEntry = StatusBar . replaceStackEntry (
408- this . _stackEntry ,
409- this . props ,
410- ) ;
416+ if ( this . _stackEntry != null ) {
417+ this . _stackEntry = StatusBar . replaceStackEntry (
418+ this . _stackEntry ,
419+ this . props ,
420+ ) ;
421+ }
411422 }
412423
413424 /**
0 commit comments