Rocket.Chat.ReactNative/app/containers/StatusBar.tsx

34 lines
804 B
TypeScript
Raw Normal View History

import React, { useEffect } from 'react';
2019-03-12 16:23:06 +00:00
import { StatusBar as StatusBarRN } from 'react-native';
import { useTheme } from '../theme';
const supportedStyles = {
'light-content': 'light-content',
'dark-content': 'dark-content'
};
2019-03-12 16:23:06 +00:00
interface IStatusBar {
barStyle?: keyof typeof supportedStyles;
backgroundColor?: string;
}
const StatusBar = React.memo(({ barStyle, backgroundColor }: IStatusBar) => {
const { theme, colors } = useTheme();
useEffect(() => {
if (!barStyle) {
barStyle = 'light-content';
if (theme === 'light') {
barStyle = 'dark-content';
}
}
StatusBarRN.setBackgroundColor(backgroundColor ?? colors.headerBackground);
StatusBarRN.setBarStyle(barStyle, true);
}, [theme, barStyle, backgroundColor]);
return <StatusBarRN />;
2019-03-12 16:23:06 +00:00
});
export default StatusBar;