/** * AppHeader Component * * Application header with menu button and app title. * * Features: * - Menu button triggers sidebar drawer * - Hidden developer mode toggle (tap "co" title 7 times in 2 seconds) * - Responsive to safe area insets * - Conditionally hides when no messages present */ import React, { useRef, useState } from 'react'; import { View, Text, TouchableOpacity, StyleSheet, Platform, Alert } from 'react-native'; import { Ionicons } from '@expo/vector-icons'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import type { Theme } from '../theme'; interface AppHeaderProps { theme: Theme; colorScheme: 'light' | 'dark'; hasMessages: boolean; onMenuPress: () => void; developerMode: boolean; onDeveloperModeToggle: () => void; } export function AppHeader({ theme, colorScheme, hasMessages, onMenuPress, developerMode, onDeveloperModeToggle, }: AppHeaderProps) { const insets = useSafeAreaInsets(); const [headerClickCount, setHeaderClickCount] = useState(0); const headerClickTimeoutRef = useRef(null); const handleTitlePress = () => { setHeaderClickCount(prev => prev + 1); if (headerClickTimeoutRef.current) { clearTimeout(headerClickTimeoutRef.current); } headerClickTimeoutRef.current = setTimeout(() => { if (headerClickCount >= 6) { onDeveloperModeToggle(); if (Platform.OS === 'web') { window.alert(developerMode ? 'Developer mode disabled' : 'Developer mode enabled'); } else { Alert.alert('Developer Mode', developerMode ? 'Disabled' : 'Enabled'); } } setHeaderClickCount(0); }, 2000); }; return ( {hasMessages && ( <> co )} ); } const styles = StyleSheet.create({ header: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: 16, paddingBottom: 6, borderBottomWidth: 1, }, menuButton: { padding: 6, }, headerCenter: { flex: 1, alignItems: 'center', }, headerTitle: { fontSize: 36, fontFamily: 'Lexend_700Bold', }, headerSpacer: { width: 34, // Balance the menu button width }, }); export default AppHeader;