expo-status-bar#StatusBarStyle TypeScript Examples
The following examples show how to use
expo-status-bar#StatusBarStyle.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomHeader.tsx From lexicon with MIT License | 4 votes |
export function CustomHeader(props: Props) {
const { colorScheme } = useColorScheme();
const navigation = useNavigation();
const styles = useStyles();
const { colors, fontSizes, navHeader } = useTheme();
const {
title,
color = 'background',
rightTitle = '',
rightIcon,
onPressRight,
noShadow = false,
disabled = false,
isLoading = false,
prevScreen,
} = props;
const statusBarStyle: StatusBarStyle =
colorScheme === 'light' ? 'dark' : 'light';
const headerRight = isLoading ? (
<ActivityIndicator style={styles.headerRight} />
) : (
onPressRight && (
<HeaderItem
label={rightTitle}
icon={rightIcon}
onPressItem={onPressRight}
disabled={disabled}
style={styles.headerRight}
/>
)
);
const routesLength = useNavigationState((state) => state.routes.length);
const headerLeft =
routesLength > 1 ? (
<HeaderBackButton
tintColor={isLoading ? colors.grey : colors.primary}
style={isLoading && { opacity: 0.5 }}
labelStyle={[
{
color: isLoading ? colors.grey : colors.primary,
fontSize: fontSizes.m,
},
]}
disabled={isLoading}
onPress={() => {
prevScreen
? navigation.navigate(prevScreen, {
backToTop: false,
})
: navigation.goBack();
}}
/>
) : null;
useLayoutEffect(() => {
navigation.setOptions({
title,
...navHeader,
headerStyle: {
backgroundColor: colors[color],
...(noShadow && { shadowOpacity: 0, elevation: 0 }),
},
headerLeft: () => headerLeft,
headerRight: () => headerRight,
});
}, [
color,
colors,
headerLeft,
headerRight,
navHeader,
navigation,
noShadow,
title,
]);
return <StatusBar style={statusBarStyle} />;
}