import { SymbolView } from "expo-symbols"; import type { ComponentProps } from "react"; import { Pressable, View } from "react-native"; import { useThemeColor } from "../../../lib/useThemeColor"; import { AppText as Text } from "../../../components/AppText"; /* ─── Shared sheet components ──────────────────────────────────────── */ export function SheetActionButton(props: { readonly icon: ComponentProps["name"]; readonly label: string; readonly disabled?: boolean; readonly tone?: "primary" | "secondary" | "danger"; readonly onPress: () => void; }) { const primaryBg = useThemeColor("--color-primary"); const primaryFg = useThemeColor("--color-primary-foreground"); const dangerBg = useThemeColor("--color-danger"); const dangerBorder = useThemeColor("--color-danger-border"); const dangerFg = useThemeColor("--color-danger-foreground"); const secondaryBg = useThemeColor("--color-secondary"); const secondaryBorder = useThemeColor("--color-secondary-border"); const secondaryFg = useThemeColor("--color-secondary-foreground"); const tone = props.tone ?? "secondary"; const colors = tone === "primary" ? { backgroundColor: primaryBg, borderColor: "transparent", textColor: primaryFg, } : tone === "danger" ? { backgroundColor: dangerBg, borderColor: dangerBorder, textColor: dangerFg, } : { backgroundColor: secondaryBg, borderColor: secondaryBorder, textColor: secondaryFg, }; return ( {props.label} ); } export function MetaCard(props: { readonly label: string; readonly value: string }) { return ( {props.label} {props.value} ); } export function SheetListRow(props: { readonly icon: ComponentProps["name"]; readonly title: string; readonly subtitle?: string | null; readonly disabled?: boolean; readonly onPress: () => void; }) { const iconColor = useThemeColor("--color-icon"); const iconSubtleColor = useThemeColor("--color-icon-subtle"); return ( {props.title} {props.subtitle ? ( {props.subtitle} ) : null} ); } /* ─── Shared utilities ──────────────────────────────────────────────── */ export function menuItemIconName( icon: "commit" | "push" | "pr", ): ComponentProps["name"] { if (icon === "commit") return "checkmark.circle"; if (icon === "push") return "arrow.up.circle"; return "arrow.up.right.circle"; } export function statusSummary( gitStatus: { readonly isRepo?: boolean; readonly hasWorkingTreeChanges?: boolean; readonly workingTree?: { readonly files: readonly { readonly path: string }[] }; readonly aheadCount?: number; readonly behindCount?: number; readonly pr?: { readonly state?: string; readonly number?: number } | null; } | null, ): string { if (!gitStatus) { return "Loading branch status\u2026"; } if (!gitStatus.isRepo) { return "Not a git repository"; } const parts: string[] = []; if (gitStatus.hasWorkingTreeChanges) { const fileCount = gitStatus.workingTree?.files.length ?? 0; parts.push(`${fileCount} file${fileCount === 1 ? "" : "s"} changed`); } else { parts.push("Clean"); } if ((gitStatus.aheadCount ?? 0) > 0) { parts.push(`${gitStatus.aheadCount} ahead`); } if ((gitStatus.behindCount ?? 0) > 0) { parts.push(`${gitStatus.behindCount} behind`); } if (gitStatus.pr?.state === "open") { parts.push(`PR #${gitStatus.pr.number} open`); } return parts.join(" \u00b7 "); }