2019-03-12 16:23:06 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { StatusBar as StatusBarRN } from 'react-native';
|
|
|
|
|
2022-04-07 14:10:03 +00:00
|
|
|
import { themes } from '../lib/constants';
|
2022-03-21 19:10:11 +00:00
|
|
|
import { useTheme } from '../theme';
|
|
|
|
|
|
|
|
const supportedStyles = {
|
|
|
|
'light-content': 'light-content',
|
|
|
|
'dark-content': 'dark-content'
|
|
|
|
};
|
2019-03-12 16:23:06 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
interface IStatusBar {
|
2022-03-21 19:10:11 +00:00
|
|
|
barStyle?: keyof typeof supportedStyles;
|
2022-01-17 16:10:39 +00:00
|
|
|
backgroundColor?: string;
|
2021-09-13 20:41:05 +00:00
|
|
|
}
|
|
|
|
|
2022-03-21 19:10:11 +00:00
|
|
|
const StatusBar = React.memo(({ barStyle, backgroundColor }: IStatusBar) => {
|
|
|
|
const { theme } = useTheme();
|
2020-06-26 20:22:56 +00:00
|
|
|
if (!barStyle) {
|
|
|
|
barStyle = 'light-content';
|
2020-07-06 20:56:28 +00:00
|
|
|
if (theme === 'light') {
|
2020-06-26 20:22:56 +00:00
|
|
|
barStyle = 'dark-content';
|
|
|
|
}
|
2019-03-12 16:23:06 +00:00
|
|
|
}
|
2022-03-21 19:10:11 +00:00
|
|
|
return <StatusBarRN backgroundColor={backgroundColor ?? themes[theme].headerBackground} barStyle={barStyle} animated />;
|
2019-03-12 16:23:06 +00:00
|
|
|
});
|
|
|
|
|
2022-03-21 19:10:11 +00:00
|
|
|
export default StatusBar;
|