Files
carry-your-live/carry-your-live/src/components/Header.tsx
T
2026-08-09 21:42:54 +02:00

70 lines
1.7 KiB
TypeScript

import React from 'react';
import { View, Text, StyleSheet, StatusBar, Platform } from 'react-native';
import { useSettings } from '@/theme';
interface HeaderProps {
title: string;
showLogo: boolean;
rightAction?: React.ReactNode;
}
export function Header({ title, showLogo, rightAction }: HeaderProps) {
const { theme } = useSettings();
const topInset = Platform.OS === 'android' ? (StatusBar.currentHeight ?? 24) : 0;
return (
<View style={[styles.header, { backgroundColor: theme.background, paddingTop: topInset }]}>
<View style={styles.headerContent}>
{showLogo && (
<View style={[styles.logoContainer, { backgroundColor: theme.accent }]}>
<Text style={[styles.logoText, { color: theme.accentText }]}></Text>
</View>
)}
<Text style={[styles.title, { color: theme.text }]} accessibilityRole="header">{title}</Text>
<View style={styles.spacer}>{rightAction}</View>
</View>
</View>
);
}
const styles = StyleSheet.create({
header: {
borderBottomLeftRadius: 16,
borderBottomRightRadius: 16,
shadowColor: '#000',
shadowOffset: { width: 0, height: 1 },
shadowOpacity: 0.04,
shadowRadius: 4,
elevation: 1,
},
headerContent: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
paddingHorizontal: 20,
height: 48,
},
logoContainer: {
width: 32,
height: 32,
borderRadius: 10,
alignItems: 'center',
justifyContent: 'center',
},
logoText: {
fontSize: 18,
fontWeight: '700',
},
title: {
fontSize: 20,
fontWeight: '700',
position: 'absolute',
left: 0,
right: 0,
textAlign: 'center',
},
spacer: {
width: 32,
alignItems: 'flex-end',
},
});