fix: Android status bar theme on the first open isn't working properly (#5132)
* fix: status bar color and text color update properly * change how to set the status bar * add colors
This commit is contained in:
parent
192d5db179
commit
456344029c
|
@ -1,7 +1,6 @@
|
||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { StatusBar as StatusBarRN } from 'react-native';
|
import { StatusBar as StatusBarRN } from 'react-native';
|
||||||
|
|
||||||
import { themes } from '../lib/constants';
|
|
||||||
import { useTheme } from '../theme';
|
import { useTheme } from '../theme';
|
||||||
|
|
||||||
const supportedStyles = {
|
const supportedStyles = {
|
||||||
|
@ -15,14 +14,20 @@ interface IStatusBar {
|
||||||
}
|
}
|
||||||
|
|
||||||
const StatusBar = React.memo(({ barStyle, backgroundColor }: IStatusBar) => {
|
const StatusBar = React.memo(({ barStyle, backgroundColor }: IStatusBar) => {
|
||||||
const { theme } = useTheme();
|
const { theme, colors } = useTheme();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
if (!barStyle) {
|
if (!barStyle) {
|
||||||
barStyle = 'light-content';
|
barStyle = 'light-content';
|
||||||
if (theme === 'light') {
|
if (theme === 'light') {
|
||||||
barStyle = 'dark-content';
|
barStyle = 'dark-content';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return <StatusBarRN backgroundColor={backgroundColor ?? themes[theme].headerBackground} barStyle={barStyle} animated />;
|
StatusBarRN.setBackgroundColor(backgroundColor ?? colors.headerBackground);
|
||||||
|
StatusBarRN.setBarStyle(barStyle, true);
|
||||||
|
}, [theme, barStyle, backgroundColor]);
|
||||||
|
|
||||||
|
return <StatusBarRN />;
|
||||||
});
|
});
|
||||||
|
|
||||||
export default StatusBar;
|
export default StatusBar;
|
||||||
|
|
Loading…
Reference in New Issue