xref: /MusicFree/src/components/base/statusBar.tsx (revision 6cfecf1cdd150fc94c5ad42fede7d65068b9ea40)
1import React, {useEffect} from 'react';
2import {StatusBar, StatusBarProps, View} from 'react-native';
3import useColors from '@/hooks/useColors';
4
5interface IStatusBarProps extends StatusBarProps {}
6
7export default function (props: IStatusBarProps) {
8    const colors = useColors();
9    const {backgroundColor, barStyle} = props;
10
11    useEffect(() => {
12        if (barStyle) {
13            StatusBar.setBarStyle(barStyle);
14        }
15    }, [barStyle]);
16
17    return (
18        <View
19            style={{
20                zIndex: 10000,
21                position: 'absolute',
22                top: 0,
23                backgroundColor:
24                    backgroundColor ?? colors.appBar ?? colors.primary,
25                width: '100%',
26                height: StatusBar.currentHeight,
27            }}
28        />
29    );
30}
31