Skip to content

Commit 6b45e57

Browse files
zoontekmeta-codesync[bot]
authored andcommitted
Remove StatusBar deprecated props / methods (#57392)
Summary: Removes long-deprecated `StatusBar` APIs that no longer do anything: - Android: `backgroundColor` / `translucent` props and `setBackgroundColor()` / `setTranslucent()` (no effect under edge-to-edge, deprecated since 0.76). - iOS: `networkActivityIndicatorVisible` prop and `setNetworkActivityIndicatorVisible()` (unsupported since iOS 13, deprecated since 0.77). Also removes the now-unused native backing (`setColor`/`setTranslucent` Android, `setNetworkActivityIndicatorVisible` iOS, Android `DEFAULT_BACKGROUND_COLOR`). See #57384. ## Changelog: [GENERAL] [BREAKING] - Remove deprecated `StatusBar` `backgroundColor` / `translucent` / `networkActivityIndicatorVisible` props and `setBackgroundColor` / `setTranslucent` / `setNetworkActivityIndicatorVisible` methods Pull Request resolved: #57392 Test Plan: - `yarn flow check` — passes - `yarn jest StatusBar` — passes - `yarn test-typescript` — passes Reviewed By: Abbondanzo, javache Differential Revision: D110304943 Pulled By: cortinico fbshipit-source-id: f7383c6bbbf8fd40042195ef7064b32692940499
1 parent 6422737 commit 6b45e57

18 files changed

Lines changed: 12 additions & 525 deletions

File tree

packages/jest-preset/jest/mocks/NativeModules.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,8 @@ const NativeModules = {
186186
},
187187
},
188188
StatusBarManager: {
189-
setColor: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
190189
setStyle: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
191190
setHidden: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
192-
setNetworkActivityIndicatorVisible: jest.fn() as JestMockFn<
193-
$FlowFixMe,
194-
$FlowFixMe,
195-
>,
196-
setBackgroundColor: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
197-
setTranslucent: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
198191
getConstants: (): $FlowFixMe => ({
199192
HEIGHT: 42,
200193
}),

packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,6 @@ class DrawerLayoutAndroid
8989
);
9090
const childrenWrapper = (
9191
<View style={styles.mainSubview} collapsable={false}>
92-
{drawStatusBar && (
93-
<StatusBar
94-
translucent
95-
backgroundColor={this.props.statusBarBackgroundColor}
96-
/>
97-
)}
9892
{drawStatusBar && (
9993
<View
10094
style={[

packages/react-native/Libraries/Components/StatusBar/StatusBar.d.ts

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99

1010
import type * as React from 'react';
11-
import {ColorValue} from '../../StyleSheet/StyleSheet';
1211

1312
export type StatusBarStyle =
1413
| 'default'
@@ -19,13 +18,6 @@ export type StatusBarStyle =
1918
export type StatusBarAnimation = 'none' | 'fade' | 'slide';
2019

2120
export interface StatusBarPropsIOS {
22-
/**
23-
* If the network activity indicator should be visible.
24-
*
25-
* @platform ios
26-
*/
27-
networkActivityIndicatorVisible?: boolean | undefined;
28-
2921
/**
3022
* The transition effect when showing and hiding the status bar using
3123
* the hidden prop. Defaults to 'fade'.
@@ -35,34 +27,10 @@ export interface StatusBarPropsIOS {
3527
showHideTransition?: null | 'fade' | 'slide' | 'none' | undefined;
3628
}
3729

38-
export interface StatusBarPropsAndroid {
39-
/**
40-
* The background color of the status bar.
41-
*
42-
* Please note that this prop has no effect on Android 15+
43-
*
44-
* @platform android
45-
*/
46-
backgroundColor?: ColorValue | undefined;
47-
48-
/**
49-
* If the status bar is translucent. When translucent is set to true,
50-
* the app will draw under the status bar. This is useful when using a
51-
* semi transparent status bar color.
52-
*
53-
* Please note that this prop has no effect on Android 15+
54-
*
55-
* @platform android
56-
*/
57-
translucent?: boolean | undefined;
58-
}
59-
60-
export interface StatusBarProps
61-
extends StatusBarPropsIOS,
62-
StatusBarPropsAndroid {
30+
export interface StatusBarProps extends StatusBarPropsIOS {
6331
/**
6432
* If the transition between status bar property changes should be
65-
* animated. Supported for backgroundColor, barStyle and hidden.
33+
* animated. Supported for barStyle and hidden.
6634
*/
6735
animated?: boolean | undefined;
6836

@@ -99,25 +67,6 @@ export class StatusBar extends React.Component<StatusBarProps> {
9967
*/
10068
static setBarStyle: (style: StatusBarStyle, animated?: boolean) => void;
10169

102-
/**
103-
* Control the visibility of the network activity indicator
104-
* @param visible Show the indicator.
105-
*/
106-
static setNetworkActivityIndicatorVisible: (visible: boolean) => void;
107-
108-
/**
109-
* Set the background color for the status bar
110-
* @param color Background color.
111-
* @param animated Animate the style change.
112-
*/
113-
static setBackgroundColor: (color: ColorValue, animated?: boolean) => void;
114-
115-
/**
116-
* Control the translucency of the status bar
117-
* @param translucent Set as translucent.
118-
*/
119-
static setTranslucent: (translucent: boolean) => void;
120-
12170
/**
12271
* Push a StatusBar entry onto the stack.
12372
* The return value should be passed to `popStackEntry` when complete.

packages/react-native/Libraries/Components/StatusBar/StatusBar.js

Lines changed: 3 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@
88
* @format
99
*/
1010

11-
import type {ColorValue} from '../../StyleSheet/StyleSheet';
1211
import type {EventSubscription} from '../../vendor/emitter/EventEmitter';
1312

14-
import processColor from '../../StyleSheet/processColor';
1513
import * as Appearance from '../../Utilities/Appearance';
1614
import Platform from '../../Utilities/Platform';
1715
import NativeStatusBarManagerAndroid from './NativeStatusBarManagerAndroid';
1816
import NativeStatusBarManagerIOS from './NativeStatusBarManagerIOS';
19-
import invariant from 'invariant';
2017
import * as React from 'react';
2118

2219
/**
@@ -62,39 +59,7 @@ export type StatusBarAnimation = keyof {
6259
...
6360
};
6461

65-
export type StatusBarPropsAndroid = Readonly<{
66-
/**
67-
* The background color of the status bar.
68-
*
69-
* @deprecated Has no effect on API level 35+ (Android 15+) due to
70-
* edge-to-edge enforcement.
71-
*
72-
* @platform android
73-
*/
74-
backgroundColor?: ?ColorValue,
75-
76-
/**
77-
* If the status bar is translucent. When `true`, the app draws under the
78-
* status bar. This is useful when using a semi-transparent status bar color.
79-
*
80-
* @deprecated Has no effect on API level 35+ (Android 15+) due to
81-
* edge-to-edge enforcement.
82-
*
83-
* @default `false`
84-
* @platform android
85-
*/
86-
translucent?: ?boolean,
87-
}>;
88-
8962
export type StatusBarPropsIOS = Readonly<{
90-
/**
91-
* If the network activity indicator should be visible.
92-
*
93-
* @default `false`
94-
* @platform ios
95-
*/
96-
networkActivityIndicatorVisible?: ?boolean,
97-
9863
/**
9964
* The transition effect when showing and hiding the status bar using the
10065
* `hidden` prop.
@@ -115,7 +80,7 @@ type StatusBarBaseProps = Readonly<{
11580

11681
/**
11782
* If the transition between status bar property changes should be animated.
118-
* Supported for `backgroundColor`, `barStyle`, and `hidden`.
83+
* Supported for `barStyle` and `hidden`.
11984
*
12085
* @default `false`
12186
*/
@@ -130,27 +95,20 @@ type StatusBarBaseProps = Readonly<{
13095
}>;
13196

13297
export type StatusBarProps = Readonly<{
133-
...StatusBarPropsAndroid,
13498
...StatusBarPropsIOS,
13599
...StatusBarBaseProps,
136100
}>;
137101

138102
type StackProps = {
139-
backgroundColor: ?{
140-
value: StatusBarProps['backgroundColor'],
141-
animated: boolean,
142-
},
143103
barStyle: ?{
144104
value: StatusBarProps['barStyle'],
145105
animated: boolean,
146106
},
147-
translucent: StatusBarProps['translucent'],
148107
hidden: ?{
149108
value: boolean,
150109
animated: boolean,
151110
transition: StatusBarProps['showHideTransition'],
152111
},
153-
networkActivityIndicatorVisible: StatusBarProps['networkActivityIndicatorVisible'],
154112
};
155113

156114
/**
@@ -198,21 +156,13 @@ function createStackEntry(props: StatusBarProps): StackProps {
198156
const animated = props.animated ?? false;
199157
const showHideTransition = props.showHideTransition ?? 'fade';
200158
return {
201-
backgroundColor:
202-
props.backgroundColor != null
203-
? {
204-
value: props.backgroundColor,
205-
animated,
206-
}
207-
: null,
208159
barStyle:
209160
props.barStyle != null
210161
? {
211162
value: props.barStyle,
212163
animated,
213164
}
214165
: null,
215-
translucent: props.translucent,
216166
hidden:
217167
props.hidden != null
218168
? {
@@ -221,7 +171,6 @@ function createStackEntry(props: StatusBarProps): StackProps {
221171
transition: showHideTransition,
222172
}
223173
: null,
224-
networkActivityIndicatorVisible: props.networkActivityIndicatorVisible,
225174
};
226175
}
227176

@@ -276,15 +225,8 @@ class StatusBar extends React.Component<StatusBarProps> {
276225
static _propsStack: Array<StackProps> = [];
277226

278227
static _defaultProps: any = createStackEntry({
279-
backgroundColor:
280-
Platform.OS === 'android'
281-
? (NativeStatusBarManagerAndroid.getConstants()
282-
.DEFAULT_BACKGROUND_COLOR ?? 'black')
283-
: 'black',
284228
barStyle: 'default',
285-
translucent: false,
286229
hidden: false,
287-
networkActivityIndicatorVisible: false,
288230
});
289231

290232
// Timer for updating the native module values at the end of the frame.
@@ -347,67 +289,6 @@ class StatusBar extends React.Component<StatusBarProps> {
347289
}
348290
}
349291

350-
/**
351-
* DEPRECATED - The status bar network activity indicator is not supported in
352-
* iOS 13 and later. This will be removed in a future release.
353-
*
354-
* @param visible Show the indicator.
355-
*
356-
* @deprecated The status bar network activity indicator is not supported in
357-
* iOS 13 and later.
358-
*/
359-
static setNetworkActivityIndicatorVisible(visible: boolean) {
360-
if (Platform.OS !== 'ios') {
361-
console.warn(
362-
'`setNetworkActivityIndicatorVisible` is only available on iOS',
363-
);
364-
return;
365-
}
366-
StatusBar._defaultProps.networkActivityIndicatorVisible = visible;
367-
NativeStatusBarManagerIOS.setNetworkActivityIndicatorVisible(visible);
368-
}
369-
370-
/**
371-
* Set the background color for the status bar
372-
* @param color Background color.
373-
* @param animated Animate the style change.
374-
*/
375-
static setBackgroundColor(color: ColorValue, animated?: boolean): void {
376-
if (Platform.OS !== 'android') {
377-
console.warn('`setBackgroundColor` is only available on Android');
378-
return;
379-
}
380-
animated = animated || false;
381-
StatusBar._defaultProps.backgroundColor.value = color;
382-
383-
const processedColor = processColor(color);
384-
if (processedColor == null) {
385-
console.warn(
386-
`\`StatusBar.setBackgroundColor\`: Color ${String(color)} parsed to null or undefined`,
387-
);
388-
return;
389-
}
390-
invariant(
391-
typeof processedColor === 'number',
392-
'Unexpected color given for StatusBar.setBackgroundColor',
393-
);
394-
395-
NativeStatusBarManagerAndroid.setColor(processedColor, animated);
396-
}
397-
398-
/**
399-
* Control the translucency of the status bar
400-
* @param translucent Set as translucent.
401-
*/
402-
static setTranslucent(translucent: boolean) {
403-
if (Platform.OS !== 'android') {
404-
console.warn('`setTranslucent` is only available on Android');
405-
return;
406-
}
407-
StatusBar._defaultProps.translucent = translucent;
408-
NativeStatusBarManagerAndroid.setTranslucent(translucent);
409-
}
410-
411292
/**
412293
* Push a StatusBar entry onto the stack.
413294
* The return value should be passed to `popStackEntry` when complete.
@@ -532,46 +413,13 @@ class StatusBar extends React.Component<StatusBarProps> {
532413
: 'none',
533414
);
534415
}
535-
536-
if (
537-
!oldProps ||
538-
oldProps.networkActivityIndicatorVisible !==
539-
mergedProps.networkActivityIndicatorVisible
540-
) {
541-
NativeStatusBarManagerIOS.setNetworkActivityIndicatorVisible(
542-
mergedProps.networkActivityIndicatorVisible,
543-
);
544-
}
545416
} else if (Platform.OS === 'android') {
546-
//todo(T60684787): Add back optimization to only update bar style and
547-
//background color if the new value is different from the old value.
417+
//todo(T60684787): Add back optimization to only update bar style if the
418+
//new value is different from the old value.
548419
NativeStatusBarManagerAndroid.setStyle(mergedProps.barStyle.value);
549-
const processedColor = processColor(mergedProps.backgroundColor.value);
550-
if (processedColor == null) {
551-
console.warn(
552-
`\`StatusBar._updatePropsStack\`: Color ${mergedProps.backgroundColor.value} parsed to null or undefined`,
553-
);
554-
} else {
555-
invariant(
556-
typeof processedColor === 'number',
557-
'Unexpected color given in StatusBar._updatePropsStack',
558-
);
559-
NativeStatusBarManagerAndroid.setColor(
560-
processedColor,
561-
mergedProps.backgroundColor.animated,
562-
);
563-
}
564420
if (!oldProps || oldProps.hidden?.value !== mergedProps.hidden.value) {
565421
NativeStatusBarManagerAndroid.setHidden(mergedProps.hidden.value);
566422
}
567-
// Activities are not translucent by default, so always set if true.
568-
if (
569-
!oldProps ||
570-
oldProps.translucent !== mergedProps.translucent ||
571-
mergedProps.translucent
572-
) {
573-
NativeStatusBarManagerAndroid.setTranslucent(mergedProps.translucent);
574-
}
575423
}
576424
// Update the current prop values.
577425
StatusBar._currentValues = mergedProps;

packages/react-native/Libraries/Components/StatusBar/__tests__/StatusBar-test.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ describe('StatusBar', () => {
2727
const component = await create(<StatusBar hidden={true} />);
2828
expect(component.toTree()?.props.hidden).toBe(true);
2929
});
30-
it('renders the statusbar with a background color', async () => {
31-
const component = await create(<StatusBar backgroundColor={'#fff'} />);
32-
expect(component.toTree()?.props.backgroundColor).toBe('#fff');
33-
expect(
34-
// $FlowFixMe[prop-missing]
35-
component.toTree()?.type._defaultProps.backgroundColor.animated,
36-
).toBe(false);
37-
});
3830
it('renders the statusbar with default barStyle', async () => {
3931
const component = await create(<StatusBar />);
4032
StatusBar.setBarStyle('default');
@@ -84,12 +76,4 @@ describe('StatusBar', () => {
8476
'fade',
8577
);
8678
});
87-
it('renders the statusbar with networkActivityIndicatorVisible true', async () => {
88-
const component = await create(
89-
<StatusBar networkActivityIndicatorVisible={true} />,
90-
);
91-
expect(component.toTree()?.props.networkActivityIndicatorVisible).toBe(
92-
true,
93-
);
94-
});
9579
});

0 commit comments

Comments
 (0)