2019-03-12 16:23:06 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { StatusBar as StatusBarRN } from 'react-native';
|
|
|
|
|
2022-04-28 18:44:40 +00:00
|
|
|
import { themes } from '../lib/constants';
|
2022-03-29 18:53:27 +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-10-01 18:12:19 +00:00
|
|
|
interface IStatusBar {
|
2022-03-29 18:53:27 +00:00
|
|
|
barStyle?: keyof typeof supportedStyles;
|
2022-01-24 20:12:25 +00:00
|
|
|
backgroundColor?: string;
|
2021-10-01 18:12:19 +00:00
|
|
|
}
|
|
|
|
|
2022-03-29 18:53:27 +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-29 18:53:27 +00:00
|
|
|
return <StatusBarRN backgroundColor={backgroundColor ?? themes[theme].headerBackground} barStyle={barStyle} animated />;
|
2019-03-12 16:23:06 +00:00
|
|
|
});
|
|
|
|
|
2022-03-29 18:53:27 +00:00
|
|
|
export default StatusBar;
|