import MaterialIcons from '@expo/vector-icons/MaterialIcons';
import { View, StyleSheet, Pressable } from 'react-native';
import { useColors } from '@/hooks/useColorScheme';
import Logo from '@/assets/images/logo.svg';
import { ThemedText } from '@/components/themed/ThemedText';
type HeaderButton = {
icon: keyof typeof MaterialIcons.glyphMap;
onPress: () => void;
position: 'left' | 'right';
}
interface IAndroidHeaderProps {
title: string;
headerButtons?: HeaderButton[];
/** Optional callback when title is pressed (enables dropdown mode) */
onTitlePress?: () => void;
/** Show dropdown arrow expanded state */
isDropdownOpen?: boolean;
/** Optional subtitle shown next to title (e.g., item count) */
subtitle?: string;
}
/**
* Custom header component for Android that includes the AliasVault logo.
* @param {IAndroidHeaderProps} props - The component props
* @returns {React.ReactNode} The Android header component
*/
export function AndroidHeader({ title, headerButtons = [], onTitlePress, isDropdownOpen, subtitle }: IAndroidHeaderProps): React.ReactNode {
const colors = useColors();
const styles = StyleSheet.create({
dropdownIcon: {
marginLeft: -4,
},
headerButton: {
padding: 4,
},
headerContainer: {
alignItems: 'center',
flexDirection: 'row',
gap: 8,
verticalAlign: 'middle',
},
headerTitle: {
fontSize: 22,
fontWeight: 'bold',
},
headerSubtitle: {
color: colors.textMuted,
fontSize: 16,
},
leftButton: {
marginRight: 'auto',
},
logo: {
marginBottom: 0,
},
rightButton: {
marginLeft: 'auto',
},
titleContainer: {
alignItems: 'center',
flexDirection: 'row',
gap: 4,
},
});
const titleContent = (
{title}
{subtitle && (
{subtitle}
)}
{onTitlePress && (
)}
);
return (
{headerButtons.find(b => b.position === 'left') && (
b.position === 'left')?.onPress}
hitSlop={100}
android_ripple={{ color: 'lightgray' }}
pressRetentionOffset={100}
>
b.position === 'left')?.icon ?? 'add'}
size={28}
color={colors.primary}
/>
)}
{onTitlePress ? (
{titleContent}
) : (
titleContent
)}
{headerButtons.find(b => b.position === 'right') && (
b.position === 'right')?.onPress}
hitSlop={100}
android_ripple={{ color: 'lightgray' }}
pressRetentionOffset={100}
>
b.position === 'right')?.icon ?? 'add'}
size={28}
color={colors.primary}
/>
)}
);
}