import type { ReactNode } from "react"; import { View, type StyleProp, type ViewStyle } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { StyleSheet, UnistylesRuntime } from "react-native-unistyles"; import { HEADER_INNER_HEIGHT, HEADER_INNER_HEIGHT_MOBILE, HEADER_TOP_PADDING_MOBILE, } from "@/constants/layout"; import { useTauriDragHandlers } from "@/utils/tauri-window"; interface ScreenHeaderProps { left?: ReactNode; right?: ReactNode; leftStyle?: StyleProp; rightStyle?: StyleProp; } /** * Shared frame for the home/back headers so we only maintain padding, border, * and safe-area logic in one place. */ export function ScreenHeader({ left, right, leftStyle, rightStyle, }: ScreenHeaderProps) { const insets = useSafeAreaInsets(); const isMobile = UnistylesRuntime.breakpoint === "xs" || UnistylesRuntime.breakpoint === "sm"; // Only add extra padding on mobile for better touch targets; on desktop, only use safe area insets const topPadding = isMobile ? HEADER_TOP_PADDING_MOBILE : 0; // On Tauri macOS, enable window dragging and double-click to maximize // Left padding for traffic lights is handled by _layout.tsx when sidebar is collapsed const dragHandlers = useTauriDragHandlers(); return ( {left} {right} ); } const styles = StyleSheet.create((theme) => ({ header: { backgroundColor: theme.colors.surface0, }, inner: {}, row: { height: { xs: HEADER_INNER_HEIGHT_MOBILE, md: HEADER_INNER_HEIGHT, }, flexDirection: "row", alignItems: "center", justifyContent: "space-between", paddingHorizontal: theme.spacing[2], borderBottomWidth: theme.borderWidth[1], borderBottomColor: theme.colors.border, userSelect: "none", }, left: { flex: 1, flexDirection: "row", alignItems: "center", gap: theme.spacing[2], }, right: { flexDirection: "row", alignItems: "center", gap: theme.spacing[2], }, }));