import { useCallback, type ReactNode } from "react"; import { useTranslation } from "react-i18next"; import { Pressable } from "react-native"; import { router } from "expo-router"; import { StyleSheet, useUnistyles } from "react-native-unistyles"; import { ArrowLeft } from "lucide-react-native"; import { ScreenHeader } from "./screen-header"; import { ScreenTitle } from "./screen-title"; interface BackHeaderProps { title?: string; titleAccessory?: ReactNode; rightContent?: ReactNode; onBack?: () => void; } function goBack(): void { router.back(); } export function BackHeader({ title, titleAccessory, rightContent, onBack }: BackHeaderProps) { const { theme } = useUnistyles(); const { t } = useTranslation(); const handleBack = useCallback(() => { if (onBack) { onBack(); return; } goBack(); }, [onBack]); return ( {title && {title}} {titleAccessory} } right={rightContent} leftStyle={styles.left} /> ); } const styles = StyleSheet.create((theme) => ({ left: { gap: theme.spacing[2], }, backButton: { padding: { xs: theme.spacing[3], md: theme.spacing[2], }, borderRadius: theme.borderRadius.lg, }, }));