2023-08-14 18:11:45 +00:00
|
|
|
import React from 'react';
|
2019-03-12 16:23:06 +00:00
|
|
|
import { StatusBar as StatusBarRN } from 'react-native';
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-08-14 18:11:45 +00:00
|
|
|
const StatusBar = ({ barStyle, backgroundColor }: IStatusBar) => {
|
2023-07-18 21:01:31 +00:00
|
|
|
const { theme, colors } = useTheme();
|
2023-08-14 18:11:45 +00:00
|
|
|
if (!barStyle) {
|
|
|
|
barStyle = 'light-content';
|
|
|
|
if (theme === 'light') {
|
|
|
|
barStyle = 'dark-content';
|
2023-07-25 13:21:55 +00:00
|
|
|
}
|
2023-08-14 18:11:45 +00:00
|
|
|
}
|
2024-04-18 10:19:54 +00:00
|
|
|
return <StatusBarRN backgroundColor={backgroundColor ?? colors.surfaceNeutral} barStyle={barStyle} animated />;
|
2023-08-14 18:11:45 +00:00
|
|
|
};
|
2019-03-12 16:23:06 +00:00
|
|
|
|
2022-03-21 19:10:11 +00:00
|
|
|
export default StatusBar;
|