mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
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 https://github.com/react/react-native/issues/57384. ## Changelog: [GENERAL] [BREAKING] - Remove deprecated `StatusBar` `backgroundColor` / `translucent` / `networkActivityIndicatorVisible` props and `setBackgroundColor` / `setTranslucent` / `setNetworkActivityIndicatorVisible` methods Pull Request resolved: https://github.com/react/react-native/pull/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
This commit is contained in:
1 parent
642273788b
commit
6b45e579d6
18 files changed
+12
-525
No files matched your search
@@ -186,15 +186,8 @@ const NativeModules = {
|
||||
},
|
||||
},
|
||||
StatusBarManager: {
|
||||
setColor: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
|
||||
setStyle: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
|
||||
setHidden: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
|
||||
setNetworkActivityIndicatorVisible: jest.fn() as JestMockFn<
|
||||
$FlowFixMe,
|
||||
$FlowFixMe,
|
||||
>,
|
||||
setBackgroundColor: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
|
||||
setTranslucent: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
|
||||
getConstants: (): $FlowFixMe => ({
|
||||
HEIGHT: 42,
|
||||
}),
|
||||
|
||||
-6
@@ -89,12 +89,6 @@ class DrawerLayoutAndroid
|
||||
);
|
||||
const childrenWrapper = (
|
||||
<View style={styles.mainSubview} collapsable={false}>
|
||||
{drawStatusBar && (
|
||||
<StatusBar
|
||||
translucent
|
||||
backgroundColor={this.props.statusBarBackgroundColor}
|
||||
/>
|
||||
)}
|
||||
{drawStatusBar && (
|
||||
<View
|
||||
style={[
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
import type * as React from 'react';
|
||||
import {ColorValue} from '../../StyleSheet/StyleSheet';
|
||||
|
||||
export type StatusBarStyle =
|
||||
| 'default'
|
||||
@@ -19,13 +18,6 @@ export type StatusBarStyle =
|
||||
export type StatusBarAnimation = 'none' | 'fade' | 'slide';
|
||||
|
||||
export interface StatusBarPropsIOS {
|
||||
/**
|
||||
* If the network activity indicator should be visible.
|
||||
*
|
||||
* @platform ios
|
||||
*/
|
||||
networkActivityIndicatorVisible?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* The transition effect when showing and hiding the status bar using
|
||||
* the hidden prop. Defaults to 'fade'.
|
||||
@@ -35,34 +27,10 @@ export interface StatusBarPropsIOS {
|
||||
showHideTransition?: null | 'fade' | 'slide' | 'none' | undefined;
|
||||
}
|
||||
|
||||
export interface StatusBarPropsAndroid {
|
||||
/**
|
||||
* The background color of the status bar.
|
||||
*
|
||||
* Please note that this prop has no effect on Android 15+
|
||||
*
|
||||
* @platform android
|
||||
*/
|
||||
backgroundColor?: ColorValue | undefined;
|
||||
|
||||
/**
|
||||
* If the status bar is translucent. When translucent is set to true,
|
||||
* the app will draw under the status bar. This is useful when using a
|
||||
* semi transparent status bar color.
|
||||
*
|
||||
* Please note that this prop has no effect on Android 15+
|
||||
*
|
||||
* @platform android
|
||||
*/
|
||||
translucent?: boolean | undefined;
|
||||
}
|
||||
|
||||
export interface StatusBarProps
|
||||
extends StatusBarPropsIOS,
|
||||
StatusBarPropsAndroid {
|
||||
export interface StatusBarProps extends StatusBarPropsIOS {
|
||||
/**
|
||||
* If the transition between status bar property changes should be
|
||||
* animated. Supported for backgroundColor, barStyle and hidden.
|
||||
* animated. Supported for barStyle and hidden.
|
||||
*/
|
||||
animated?: boolean | undefined;
|
||||
|
||||
@@ -99,25 +67,6 @@ export class StatusBar extends React.Component<StatusBarProps> {
|
||||
*/
|
||||
static setBarStyle: (style: StatusBarStyle, animated?: boolean) => void;
|
||||
|
||||
/**
|
||||
* Control the visibility of the network activity indicator
|
||||
* @param visible Show the indicator.
|
||||
*/
|
||||
static setNetworkActivityIndicatorVisible: (visible: boolean) => void;
|
||||
|
||||
/**
|
||||
* Set the background color for the status bar
|
||||
* @param color Background color.
|
||||
* @param animated Animate the style change.
|
||||
*/
|
||||
static setBackgroundColor: (color: ColorValue, animated?: boolean) => void;
|
||||
|
||||
/**
|
||||
* Control the translucency of the status bar
|
||||
* @param translucent Set as translucent.
|
||||
*/
|
||||
static setTranslucent: (translucent: boolean) => void;
|
||||
|
||||
/**
|
||||
* Push a StatusBar entry onto the stack.
|
||||
* The return value should be passed to `popStackEntry` when complete.
|
||||
|
||||
@@ -8,15 +8,12 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import type {ColorValue} from '../../StyleSheet/StyleSheet';
|
||||
import type {EventSubscription} from '../../vendor/emitter/EventEmitter';
|
||||
|
||||
import processColor from '../../StyleSheet/processColor';
|
||||
import * as Appearance from '../../Utilities/Appearance';
|
||||
import Platform from '../../Utilities/Platform';
|
||||
import NativeStatusBarManagerAndroid from './NativeStatusBarManagerAndroid';
|
||||
import NativeStatusBarManagerIOS from './NativeStatusBarManagerIOS';
|
||||
import invariant from 'invariant';
|
||||
import * as React from 'react';
|
||||
|
||||
/**
|
||||
@@ -62,39 +59,7 @@ export type StatusBarAnimation = keyof {
|
||||
...
|
||||
};
|
||||
|
||||
export type StatusBarPropsAndroid = Readonly<{
|
||||
/**
|
||||
* The background color of the status bar.
|
||||
*
|
||||
* @deprecated Has no effect on API level 35+ (Android 15+) due to
|
||||
* edge-to-edge enforcement.
|
||||
*
|
||||
* @platform android
|
||||
*/
|
||||
backgroundColor?: ?ColorValue,
|
||||
|
||||
/**
|
||||
* If the status bar is translucent. When `true`, the app draws under the
|
||||
* status bar. This is useful when using a semi-transparent status bar color.
|
||||
*
|
||||
* @deprecated Has no effect on API level 35+ (Android 15+) due to
|
||||
* edge-to-edge enforcement.
|
||||
*
|
||||
* @default `false`
|
||||
* @platform android
|
||||
*/
|
||||
translucent?: ?boolean,
|
||||
}>;
|
||||
|
||||
export type StatusBarPropsIOS = Readonly<{
|
||||
/**
|
||||
* If the network activity indicator should be visible.
|
||||
*
|
||||
* @default `false`
|
||||
* @platform ios
|
||||
*/
|
||||
networkActivityIndicatorVisible?: ?boolean,
|
||||
|
||||
/**
|
||||
* The transition effect when showing and hiding the status bar using the
|
||||
* `hidden` prop.
|
||||
@@ -115,7 +80,7 @@ type StatusBarBaseProps = Readonly<{
|
||||
|
||||
/**
|
||||
* If the transition between status bar property changes should be animated.
|
||||
* Supported for `backgroundColor`, `barStyle`, and `hidden`.
|
||||
* Supported for `barStyle` and `hidden`.
|
||||
*
|
||||
* @default `false`
|
||||
*/
|
||||
@@ -130,27 +95,20 @@ type StatusBarBaseProps = Readonly<{
|
||||
}>;
|
||||
|
||||
export type StatusBarProps = Readonly<{
|
||||
...StatusBarPropsAndroid,
|
||||
...StatusBarPropsIOS,
|
||||
...StatusBarBaseProps,
|
||||
}>;
|
||||
|
||||
type StackProps = {
|
||||
backgroundColor: ?{
|
||||
value: StatusBarProps['backgroundColor'],
|
||||
animated: boolean,
|
||||
},
|
||||
barStyle: ?{
|
||||
value: StatusBarProps['barStyle'],
|
||||
animated: boolean,
|
||||
},
|
||||
translucent: StatusBarProps['translucent'],
|
||||
hidden: ?{
|
||||
value: boolean,
|
||||
animated: boolean,
|
||||
transition: StatusBarProps['showHideTransition'],
|
||||
},
|
||||
networkActivityIndicatorVisible: StatusBarProps['networkActivityIndicatorVisible'],
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -198,13 +156,6 @@ function createStackEntry(props: StatusBarProps): StackProps {
|
||||
const animated = props.animated ?? false;
|
||||
const showHideTransition = props.showHideTransition ?? 'fade';
|
||||
return {
|
||||
backgroundColor:
|
||||
props.backgroundColor != null
|
||||
? {
|
||||
value: props.backgroundColor,
|
||||
animated,
|
||||
}
|
||||
: null,
|
||||
barStyle:
|
||||
props.barStyle != null
|
||||
? {
|
||||
@@ -212,7 +163,6 @@ function createStackEntry(props: StatusBarProps): StackProps {
|
||||
animated,
|
||||
}
|
||||
: null,
|
||||
translucent: props.translucent,
|
||||
hidden:
|
||||
props.hidden != null
|
||||
? {
|
||||
@@ -221,7 +171,6 @@ function createStackEntry(props: StatusBarProps): StackProps {
|
||||
transition: showHideTransition,
|
||||
}
|
||||
: null,
|
||||
networkActivityIndicatorVisible: props.networkActivityIndicatorVisible,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -276,15 +225,8 @@ class StatusBar extends React.Component<StatusBarProps> {
|
||||
static _propsStack: Array<StackProps> = [];
|
||||
|
||||
static _defaultProps: any = createStackEntry({
|
||||
backgroundColor:
|
||||
Platform.OS === 'android'
|
||||
? (NativeStatusBarManagerAndroid.getConstants()
|
||||
.DEFAULT_BACKGROUND_COLOR ?? 'black')
|
||||
: 'black',
|
||||
barStyle: 'default',
|
||||
translucent: false,
|
||||
hidden: false,
|
||||
networkActivityIndicatorVisible: false,
|
||||
});
|
||||
|
||||
// Timer for updating the native module values at the end of the frame.
|
||||
@@ -347,67 +289,6 @@ class StatusBar extends React.Component<StatusBarProps> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DEPRECATED - The status bar network activity indicator is not supported in
|
||||
* iOS 13 and later. This will be removed in a future release.
|
||||
*
|
||||
* @param visible Show the indicator.
|
||||
*
|
||||
* @deprecated The status bar network activity indicator is not supported in
|
||||
* iOS 13 and later.
|
||||
*/
|
||||
static setNetworkActivityIndicatorVisible(visible: boolean) {
|
||||
if (Platform.OS !== 'ios') {
|
||||
console.warn(
|
||||
'`setNetworkActivityIndicatorVisible` is only available on iOS',
|
||||
);
|
||||
return;
|
||||
}
|
||||
StatusBar._defaultProps.networkActivityIndicatorVisible = visible;
|
||||
NativeStatusBarManagerIOS.setNetworkActivityIndicatorVisible(visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the background color for the status bar
|
||||
* @param color Background color.
|
||||
* @param animated Animate the style change.
|
||||
*/
|
||||
static setBackgroundColor(color: ColorValue, animated?: boolean): void {
|
||||
if (Platform.OS !== 'android') {
|
||||
console.warn('`setBackgroundColor` is only available on Android');
|
||||
return;
|
||||
}
|
||||
animated = animated || false;
|
||||
StatusBar._defaultProps.backgroundColor.value = color;
|
||||
|
||||
const processedColor = processColor(color);
|
||||
if (processedColor == null) {
|
||||
console.warn(
|
||||
`\`StatusBar.setBackgroundColor\`: Color ${String(color)} parsed to null or undefined`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
invariant(
|
||||
typeof processedColor === 'number',
|
||||
'Unexpected color given for StatusBar.setBackgroundColor',
|
||||
);
|
||||
|
||||
NativeStatusBarManagerAndroid.setColor(processedColor, animated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Control the translucency of the status bar
|
||||
* @param translucent Set as translucent.
|
||||
*/
|
||||
static setTranslucent(translucent: boolean) {
|
||||
if (Platform.OS !== 'android') {
|
||||
console.warn('`setTranslucent` is only available on Android');
|
||||
return;
|
||||
}
|
||||
StatusBar._defaultProps.translucent = translucent;
|
||||
NativeStatusBarManagerAndroid.setTranslucent(translucent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Push a StatusBar entry onto the stack.
|
||||
* The return value should be passed to `popStackEntry` when complete.
|
||||
@@ -532,46 +413,13 @@ class StatusBar extends React.Component<StatusBarProps> {
|
||||
: 'none',
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
!oldProps ||
|
||||
oldProps.networkActivityIndicatorVisible !==
|
||||
mergedProps.networkActivityIndicatorVisible
|
||||
) {
|
||||
NativeStatusBarManagerIOS.setNetworkActivityIndicatorVisible(
|
||||
mergedProps.networkActivityIndicatorVisible,
|
||||
);
|
||||
}
|
||||
} else if (Platform.OS === 'android') {
|
||||
//todo(T60684787): Add back optimization to only update bar style and
|
||||
//background color if the new value is different from the old value.
|
||||
//todo(T60684787): Add back optimization to only update bar style if the
|
||||
//new value is different from the old value.
|
||||
NativeStatusBarManagerAndroid.setStyle(mergedProps.barStyle.value);
|
||||
const processedColor = processColor(mergedProps.backgroundColor.value);
|
||||
if (processedColor == null) {
|
||||
console.warn(
|
||||
`\`StatusBar._updatePropsStack\`: Color ${mergedProps.backgroundColor.value} parsed to null or undefined`,
|
||||
);
|
||||
} else {
|
||||
invariant(
|
||||
typeof processedColor === 'number',
|
||||
'Unexpected color given in StatusBar._updatePropsStack',
|
||||
);
|
||||
NativeStatusBarManagerAndroid.setColor(
|
||||
processedColor,
|
||||
mergedProps.backgroundColor.animated,
|
||||
);
|
||||
}
|
||||
if (!oldProps || oldProps.hidden?.value !== mergedProps.hidden.value) {
|
||||
NativeStatusBarManagerAndroid.setHidden(mergedProps.hidden.value);
|
||||
}
|
||||
// Activities are not translucent by default, so always set if true.
|
||||
if (
|
||||
!oldProps ||
|
||||
oldProps.translucent !== mergedProps.translucent ||
|
||||
mergedProps.translucent
|
||||
) {
|
||||
NativeStatusBarManagerAndroid.setTranslucent(mergedProps.translucent);
|
||||
}
|
||||
}
|
||||
// Update the current prop values.
|
||||
StatusBar._currentValues = mergedProps;
|
||||
|
||||
-16
@@ -27,14 +27,6 @@ describe('StatusBar', () => {
|
||||
const component = await create(<StatusBar hidden={true} />);
|
||||
expect(component.toTree()?.props.hidden).toBe(true);
|
||||
});
|
||||
it('renders the statusbar with a background color', async () => {
|
||||
const component = await create(<StatusBar backgroundColor={'#fff'} />);
|
||||
expect(component.toTree()?.props.backgroundColor).toBe('#fff');
|
||||
expect(
|
||||
// $FlowFixMe[prop-missing]
|
||||
component.toTree()?.type._defaultProps.backgroundColor.animated,
|
||||
).toBe(false);
|
||||
});
|
||||
it('renders the statusbar with default barStyle', async () => {
|
||||
const component = await create(<StatusBar />);
|
||||
StatusBar.setBarStyle('default');
|
||||
@@ -84,12 +76,4 @@ describe('StatusBar', () => {
|
||||
'fade',
|
||||
);
|
||||
});
|
||||
it('renders the statusbar with networkActivityIndicatorVisible true', async () => {
|
||||
const component = await create(
|
||||
<StatusBar networkActivityIndicatorVisible={true} />,
|
||||
);
|
||||
expect(component.toTree()?.props.networkActivityIndicatorVisible).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -23,8 +23,6 @@ RCT_EXPORT_METHOD(setStyle : (NSString *)style animated : (BOOL)animated) {}
|
||||
|
||||
RCT_EXPORT_METHOD(setHidden : (BOOL)hidden withAnimation : (NSString *)withAnimation) {}
|
||||
|
||||
RCT_EXPORT_METHOD(setNetworkActivityIndicatorVisible : (BOOL)visible) {}
|
||||
|
||||
- (facebook::react::ModuleConstants<JS::NativeStatusBarManagerIOS::Constants>)getConstants
|
||||
{
|
||||
return facebook::react::typedConstants<JS::NativeStatusBarManagerIOS::Constants>({
|
||||
|
||||
@@ -175,17 +175,6 @@ RCT_EXPORT_METHOD(setHidden : (BOOL)hidden withAnimation : (NSString *)withAnima
|
||||
});
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(setNetworkActivityIndicatorVisible : (BOOL)visible)
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
// This is no longer supported in iOS 13 and later. We will remove this method in a future release.
|
||||
RCTSharedApplication().networkActivityIndicatorVisible = visible;
|
||||
#pragma clang diagnostic pop
|
||||
});
|
||||
}
|
||||
|
||||
- (facebook::react::ModuleConstants<JS::NativeStatusBarManagerIOS::Constants>)getConstants
|
||||
{
|
||||
return _constants;
|
||||
|
||||
-77
@@ -7,16 +7,12 @@
|
||||
|
||||
package com.facebook.react.modules.statusbar
|
||||
|
||||
import android.animation.ArgbEvaluator
|
||||
import android.animation.ValueAnimator
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import com.facebook.common.logging.FLog
|
||||
import com.facebook.fbreact.specs.NativeStatusBarManagerAndroidSpec
|
||||
import com.facebook.react.bridge.GuardedRunnable
|
||||
import com.facebook.react.bridge.NativeModule
|
||||
import com.facebook.react.bridge.ReactApplicationContext
|
||||
import com.facebook.react.bridge.UiThreadUtil
|
||||
@@ -25,9 +21,7 @@ import com.facebook.react.interfaces.ExtraWindowEventListener
|
||||
import com.facebook.react.module.annotations.ReactModule
|
||||
import com.facebook.react.uimanager.DisplayMetricsHolder.getStatusBarHeightPx
|
||||
import com.facebook.react.uimanager.PixelUtil
|
||||
import com.facebook.react.views.view.isEdgeToEdgeFeatureFlagOn
|
||||
import com.facebook.react.views.view.setStatusBarStyle
|
||||
import com.facebook.react.views.view.setStatusBarTranslucency
|
||||
import com.facebook.react.views.view.setStatusBarVisibility
|
||||
import java.util.Collections
|
||||
import java.util.WeakHashMap
|
||||
@@ -64,80 +58,10 @@ internal class StatusBarModule(reactContext: ReactApplicationContext?) :
|
||||
extraWindows.remove(window)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun getTypedExportedConstants(): Map<String, Any> {
|
||||
val currentActivity = reactApplicationContext.currentActivity
|
||||
val statusBarColor =
|
||||
currentActivity?.window?.statusBarColor?.let { color ->
|
||||
String.format("#%06X", 0xFFFFFF and color)
|
||||
} ?: "black"
|
||||
return mapOf(
|
||||
HEIGHT_KEY to PixelUtil.toDIPFromPixel(getStatusBarHeightPx(currentActivity).toFloat()),
|
||||
DEFAULT_BACKGROUND_COLOR_KEY to statusBarColor,
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun setColor(colorDouble: Double, animated: Boolean) {
|
||||
val color = colorDouble.toInt()
|
||||
val activity = reactApplicationContext.getCurrentActivity()
|
||||
if (activity == null) {
|
||||
FLog.w(
|
||||
ReactConstants.TAG,
|
||||
"StatusBarModule: Ignored status bar change, current activity is null.",
|
||||
)
|
||||
return
|
||||
}
|
||||
if (isEdgeToEdgeFeatureFlagOn) {
|
||||
FLog.w(
|
||||
ReactConstants.TAG,
|
||||
"StatusBarModule: Ignored status bar change, current activity is edge-to-edge.",
|
||||
)
|
||||
return
|
||||
}
|
||||
UiThreadUtil.runOnUiThread(
|
||||
object : GuardedRunnable(reactApplicationContext) {
|
||||
override fun runGuarded() {
|
||||
val window = activity.window ?: return
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
|
||||
if (animated) {
|
||||
val curColor = window.statusBarColor
|
||||
val colorAnimation = ValueAnimator.ofObject(ArgbEvaluator(), curColor, color)
|
||||
colorAnimation.addUpdateListener { animator ->
|
||||
activity.window?.statusBarColor = (animator.animatedValue as Int)
|
||||
}
|
||||
colorAnimation.setDuration(300).startDelay = 0
|
||||
colorAnimation.start()
|
||||
} else {
|
||||
window.statusBarColor = color
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun setTranslucent(translucent: Boolean) {
|
||||
val activity = reactApplicationContext.getCurrentActivity()
|
||||
if (activity == null) {
|
||||
FLog.w(
|
||||
ReactConstants.TAG,
|
||||
"StatusBarModule: Ignored status bar change, current activity is null.",
|
||||
)
|
||||
return
|
||||
}
|
||||
if (isEdgeToEdgeFeatureFlagOn) {
|
||||
FLog.w(
|
||||
ReactConstants.TAG,
|
||||
"StatusBarModule: Ignored status bar change, current activity is edge-to-edge.",
|
||||
)
|
||||
return
|
||||
}
|
||||
UiThreadUtil.runOnUiThread(
|
||||
object : GuardedRunnable(reactApplicationContext) {
|
||||
override fun runGuarded() {
|
||||
activity.window?.setStatusBarTranslucency(translucent)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -175,7 +99,6 @@ internal class StatusBarModule(reactContext: ReactApplicationContext?) :
|
||||
|
||||
companion object {
|
||||
private const val HEIGHT_KEY = "HEIGHT"
|
||||
private const val DEFAULT_BACKGROUND_COLOR_KEY = "DEFAULT_BACKGROUND_COLOR"
|
||||
const val NAME: String = NativeStatusBarManagerAndroidSpec.NAME
|
||||
private val extraWindows = Collections.newSetFromMap<Window>(WeakHashMap())
|
||||
}
|
||||
|
||||
+5
-23
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @generated SignedSource<<cd9e044d46b56e7d426d264274dc8533>>
|
||||
* @generated SignedSource<<67eb674c33870c82986054f0cee48385>>
|
||||
*
|
||||
* This file was generated by scripts/js-api/build-types/index.js.
|
||||
*/
|
||||
@@ -4790,12 +4790,6 @@ declare type StackFrame = {
|
||||
methodName: string
|
||||
}
|
||||
declare type StackProps = {
|
||||
backgroundColor:
|
||||
| undefined
|
||||
| {
|
||||
animated: boolean
|
||||
value: StatusBarProps["backgroundColor"]
|
||||
}
|
||||
barStyle:
|
||||
| undefined
|
||||
| {
|
||||
@@ -4809,8 +4803,6 @@ declare type StackProps = {
|
||||
transition: StatusBarProps["showHideTransition"]
|
||||
value: boolean
|
||||
}
|
||||
networkActivityIndicatorVisible: StatusBarProps["networkActivityIndicatorVisible"]
|
||||
translucent: StatusBarProps["translucent"]
|
||||
}
|
||||
declare type stagger = typeof stagger
|
||||
declare function startHeadlessTask(
|
||||
@@ -4855,11 +4847,8 @@ declare class StatusBar extends React.Component<StatusBarProps> {
|
||||
static pushStackEntry(props: StatusBarProps): StackProps
|
||||
render(): React.ReactNode
|
||||
static replaceStackEntry(entry: StackProps, props: StatusBarProps): StackProps
|
||||
static setBackgroundColor(color: ColorValue, animated?: boolean): void
|
||||
static setBarStyle(style: StatusBarStyle, animated?: boolean): void
|
||||
static setHidden(hidden: boolean, animation?: StatusBarAnimation): void
|
||||
static setNetworkActivityIndicatorVisible(visible: boolean): void
|
||||
static setTranslucent(translucent: boolean): void
|
||||
}
|
||||
declare type StatusBarAnimation = keyof {
|
||||
fade: string
|
||||
@@ -4872,15 +4861,8 @@ declare type StatusBarBaseProps = {
|
||||
readonly hidden?: boolean
|
||||
}
|
||||
declare type StatusBarInstance = StatusBar
|
||||
declare type StatusBarProps = Readonly<
|
||||
StatusBarPropsAndroid & StatusBarPropsIOS & StatusBarBaseProps
|
||||
>
|
||||
declare type StatusBarPropsAndroid = {
|
||||
readonly backgroundColor?: ColorValue
|
||||
readonly translucent?: boolean
|
||||
}
|
||||
declare type StatusBarProps = Readonly<StatusBarPropsIOS & StatusBarBaseProps>
|
||||
declare type StatusBarPropsIOS = {
|
||||
readonly networkActivityIndicatorVisible?: boolean
|
||||
readonly showHideTransition?: "fade" | "none" | "slide"
|
||||
}
|
||||
declare type StatusBarStyle = keyof {
|
||||
@@ -6135,10 +6117,10 @@ export {
|
||||
ShareActionSheetIOSOptions, // eff574f5
|
||||
ShareContent, // 7c627896
|
||||
ShareOptions, // 800c3a4e
|
||||
StatusBar, // 875b4eca
|
||||
StatusBar, // 81b4e92f
|
||||
StatusBarAnimation, // 7fd047e6
|
||||
StatusBarInstance, // 045e0c50
|
||||
StatusBarProps, // b72a9127
|
||||
StatusBarInstance, // 4e03048c
|
||||
StatusBarProps, // bfedeab1
|
||||
StatusBarStyle, // 78f53eea
|
||||
StyleProp, // fa0e9b4a
|
||||
StyleSheet, // cdddb9ae
|
||||
|
||||
@@ -1344,9 +1344,7 @@ class StatusBarTest extends React.Component {
|
||||
|
||||
console.log('height:', StatusBar.currentHeight);
|
||||
|
||||
return (
|
||||
<StatusBar backgroundColor="blue" barStyle="light-content" translucent />
|
||||
);
|
||||
return <StatusBar barStyle="light-content" />;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
-12
@@ -15,10 +15,7 @@ import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboMod
|
||||
export interface Spec extends TurboModule {
|
||||
readonly getConstants: () => {
|
||||
readonly HEIGHT: number,
|
||||
readonly DEFAULT_BACKGROUND_COLOR: number,
|
||||
};
|
||||
readonly setColor: (color: number, animated: boolean) => void;
|
||||
readonly setTranslucent: (translucent: boolean) => void;
|
||||
|
||||
/**
|
||||
* - statusBarStyles can be:
|
||||
@@ -35,7 +32,6 @@ let constants = null;
|
||||
const NativeStatusBarManager = {
|
||||
getConstants(): {
|
||||
readonly HEIGHT: number,
|
||||
readonly DEFAULT_BACKGROUND_COLOR?: number,
|
||||
} {
|
||||
if (constants == null) {
|
||||
constants = NativeModule.getConstants();
|
||||
@@ -43,14 +39,6 @@ const NativeStatusBarManager = {
|
||||
return constants;
|
||||
},
|
||||
|
||||
setColor(color: number, animated: boolean): void {
|
||||
NativeModule.setColor(color, animated);
|
||||
},
|
||||
|
||||
setTranslucent(translucent: boolean): void {
|
||||
NativeModule.setTranslucent(translucent);
|
||||
},
|
||||
|
||||
/**
|
||||
* - statusBarStyles can be:
|
||||
* - 'default'
|
||||
|
||||
-5
@@ -20,7 +20,6 @@ export interface Spec extends TurboModule {
|
||||
|
||||
// TODO(T47754272) Can we remove this method?
|
||||
readonly getHeight: (callback: (result: {height: number}) => void) => void;
|
||||
readonly setNetworkActivityIndicatorVisible: (visible: boolean) => void;
|
||||
readonly addListener: (eventType: string) => void;
|
||||
readonly removeListeners: (count: number) => void;
|
||||
|
||||
@@ -56,10 +55,6 @@ const NativeStatusBarManager = {
|
||||
NativeModule.getHeight(callback);
|
||||
},
|
||||
|
||||
setNetworkActivityIndicatorVisible(visible: boolean): void {
|
||||
NativeModule.setNetworkActivityIndicatorVisible(visible);
|
||||
},
|
||||
|
||||
addListener(eventType: string): void {
|
||||
NativeModule.addListener(eventType);
|
||||
},
|
||||
|
||||
@@ -47,7 +47,6 @@ import {
|
||||
ButtonProps,
|
||||
StatusBarProps,
|
||||
StatusBarPropsIOS,
|
||||
StatusBarPropsAndroid,
|
||||
SwitchProps,
|
||||
SwitchPropsIOS,
|
||||
} from 'react-native';
|
||||
@@ -175,9 +174,6 @@ export type StatusBarProperties = StatusBarProps;
|
||||
/** @deprecated Use StatusBarPropsIOS */
|
||||
export type StatusBarPropertiesIOS = StatusBarPropsIOS;
|
||||
|
||||
/** @deprecated Use StatusBarPropsAndroid */
|
||||
export type StatusBarPropertiesAndroid = StatusBarPropsAndroid;
|
||||
|
||||
/** @deprecated Use SwitchProps */
|
||||
export type SwitchProperties = SwitchProps;
|
||||
|
||||
|
||||
@@ -276,12 +276,7 @@ const RNTesterApp = ({
|
||||
|
||||
return (
|
||||
<RNTesterThemeContext.Provider value={theme}>
|
||||
{Platform.OS === 'android' ? (
|
||||
<StatusBar
|
||||
barStyle="dark-content"
|
||||
backgroundColor={theme.GroupedBackgroundColor}
|
||||
/>
|
||||
) : null}
|
||||
{Platform.OS === 'android' ? <StatusBar barStyle="dark-content" /> : null}
|
||||
{!shouldHideChrome && (
|
||||
<RNTTitleBar
|
||||
title={title}
|
||||
|
||||
@@ -22,8 +22,6 @@ import {
|
||||
View,
|
||||
} from 'react-native';
|
||||
|
||||
const colors = ['#ff0000', '#00ff00', '#0000ff', 'rgba(0, 0, 0, 0.4)'];
|
||||
|
||||
const barStyles = ['default', 'auto', 'light-content', 'dark-content'];
|
||||
|
||||
const showHideTransitions = ['fade', 'slide'];
|
||||
@@ -157,85 +155,6 @@ class StatusBarStyleExample extends React.Component<{...}, $FlowFixMe> {
|
||||
}
|
||||
}
|
||||
|
||||
class StatusBarBackgroundColorExample extends React.Component<
|
||||
{...},
|
||||
$FlowFixMe,
|
||||
> {
|
||||
state: $FlowFixMe | {animated: boolean, backgroundColor: string} = {
|
||||
animated: true,
|
||||
backgroundColor: getValue(colors, 0),
|
||||
};
|
||||
|
||||
_colorIndex = 0;
|
||||
|
||||
_onChangeBackgroundColor = () => {
|
||||
this._colorIndex++;
|
||||
this.setState({backgroundColor: getValue(colors, this._colorIndex)});
|
||||
};
|
||||
|
||||
_onChangeAnimated = () => {
|
||||
this.setState({animated: !this.state.animated});
|
||||
};
|
||||
|
||||
render(): React.Node {
|
||||
return (
|
||||
<View>
|
||||
<StatusBar
|
||||
backgroundColor={this.state.backgroundColor}
|
||||
animated={this.state.animated}
|
||||
/>
|
||||
<TouchableHighlight
|
||||
style={styles.wrapper}
|
||||
onPress={this._onChangeBackgroundColor}>
|
||||
<View style={styles.button}>
|
||||
<RNTesterText style={styles.buttonText}>
|
||||
backgroundColor: '{getValue(colors, this._colorIndex)}'
|
||||
</RNTesterText>
|
||||
</View>
|
||||
</TouchableHighlight>
|
||||
<TouchableHighlight
|
||||
style={styles.wrapper}
|
||||
onPress={this._onChangeAnimated}>
|
||||
<View style={styles.button}>
|
||||
<RNTesterText style={styles.buttonText}>
|
||||
animated: {this.state.animated ? 'true' : 'false'}
|
||||
</RNTesterText>
|
||||
</View>
|
||||
</TouchableHighlight>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class StatusBarTranslucentExample extends React.Component<{...}, $FlowFixMe> {
|
||||
state: $FlowFixMe | {translucent: boolean} = {
|
||||
translucent: false,
|
||||
};
|
||||
|
||||
_onChangeTranslucent = () => {
|
||||
this.setState({
|
||||
translucent: !this.state.translucent,
|
||||
});
|
||||
};
|
||||
|
||||
render(): React.Node {
|
||||
return (
|
||||
<View>
|
||||
<StatusBar translucent={this.state.translucent} />
|
||||
<TouchableHighlight
|
||||
style={styles.wrapper}
|
||||
onPress={this._onChangeTranslucent}>
|
||||
<View style={styles.button}>
|
||||
<RNTesterText style={styles.buttonText}>
|
||||
translucent: {this.state.translucent ? 'true' : 'false'}
|
||||
</RNTesterText>
|
||||
</View>
|
||||
</TouchableHighlight>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class StatusBarStaticIOSExample extends React.Component<{...}> {
|
||||
render(): React.Node {
|
||||
return (
|
||||
@@ -358,53 +277,6 @@ class StatusBarStaticAndroidExample extends React.Component<{...}> {
|
||||
(default is dark for iOS, light for Android)
|
||||
</RNTesterText>
|
||||
</View>
|
||||
<TouchableHighlight
|
||||
style={styles.wrapper}
|
||||
onPress={() => {
|
||||
StatusBar.setBackgroundColor('#ff00ff', true);
|
||||
}}>
|
||||
<View style={styles.button}>
|
||||
<RNTesterText style={styles.buttonText}>
|
||||
setBackgroundColor('#ff00ff', true)
|
||||
</RNTesterText>
|
||||
</View>
|
||||
</TouchableHighlight>
|
||||
<TouchableHighlight
|
||||
style={styles.wrapper}
|
||||
onPress={() => {
|
||||
StatusBar.setBackgroundColor('#00ff00', true);
|
||||
}}>
|
||||
<View style={styles.button}>
|
||||
<RNTesterText style={styles.buttonText}>
|
||||
setBackgroundColor('#00ff00', true)
|
||||
</RNTesterText>
|
||||
</View>
|
||||
</TouchableHighlight>
|
||||
<TouchableHighlight
|
||||
style={styles.wrapper}
|
||||
onPress={() => {
|
||||
StatusBar.setTranslucent(true);
|
||||
StatusBar.setBackgroundColor('rgba(0, 0, 0, 0.4)', true);
|
||||
}}>
|
||||
<View style={styles.button}>
|
||||
<RNTesterText style={styles.buttonText}>
|
||||
setTranslucent(true) and setBackgroundColor('rgba(0, 0, 0, 0.4)',
|
||||
true)
|
||||
</RNTesterText>
|
||||
</View>
|
||||
</TouchableHighlight>
|
||||
<TouchableHighlight
|
||||
style={styles.wrapper}
|
||||
onPress={() => {
|
||||
StatusBar.setTranslucent(false);
|
||||
StatusBar.setBackgroundColor('black', true);
|
||||
}}>
|
||||
<View style={styles.button}>
|
||||
<RNTesterText style={styles.buttonText}>
|
||||
setTranslucent(false) and setBackgroundColor('black', true)
|
||||
</RNTesterText>
|
||||
</View>
|
||||
</TouchableHighlight>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -473,20 +345,6 @@ exports.examples = [
|
||||
return <StatusBarStyleExample />;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'StatusBar background color',
|
||||
render(): React.Node {
|
||||
return <StatusBarBackgroundColorExample />;
|
||||
},
|
||||
platform: 'android',
|
||||
},
|
||||
{
|
||||
title: 'StatusBar translucent',
|
||||
render(): React.Node {
|
||||
return <StatusBarTranslucentExample />;
|
||||
},
|
||||
platform: 'android',
|
||||
},
|
||||
{
|
||||
title: 'StatusBar static API',
|
||||
render(): React.Node {
|
||||
|
||||
@@ -2550,7 +2550,6 @@ protocol NativeStatusBarManagerIOSSpec : public NSObjectRCTBridgeModule, public
|
||||
public virtual void getHeight:(RCTResponseSenderBlock callback);
|
||||
public virtual void removeListeners:(double count);
|
||||
public virtual void setHidden:withAnimation:(BOOL hidden, NSString* withAnimation);
|
||||
public virtual void setNetworkActivityIndicatorVisible:(BOOL visible);
|
||||
public virtual void setStyle:animated:(NSString* _Nullable statusBarStyle, BOOL animated);
|
||||
}
|
||||
|
||||
|
||||
@@ -2539,7 +2539,6 @@ protocol NativeStatusBarManagerIOSSpec : public NSObjectRCTBridgeModule, public
|
||||
public virtual void getHeight:(RCTResponseSenderBlock callback);
|
||||
public virtual void removeListeners:(double count);
|
||||
public virtual void setHidden:withAnimation:(BOOL hidden, NSString* withAnimation);
|
||||
public virtual void setNetworkActivityIndicatorVisible:(BOOL visible);
|
||||
public virtual void setStyle:animated:(NSString* _Nullable statusBarStyle, BOOL animated);
|
||||
}
|
||||
|
||||
|
||||
@@ -2550,7 +2550,6 @@ protocol NativeStatusBarManagerIOSSpec : public NSObjectRCTBridgeModule, public
|
||||
public virtual void getHeight:(RCTResponseSenderBlock callback);
|
||||
public virtual void removeListeners:(double count);
|
||||
public virtual void setHidden:withAnimation:(BOOL hidden, NSString* withAnimation);
|
||||
public virtual void setNetworkActivityIndicatorVisible:(BOOL visible);
|
||||
public virtual void setStyle:animated:(NSString* _Nullable statusBarStyle, BOOL animated);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user