import { SymbolView } from "../../../components/AppSymbol"; import type { ComponentProps } from "react"; import { Pressable, View } from "react-native"; import { useThemeColor } from "../../../lib/useThemeColor"; import { AppText as Text } from "../../../components/AppText"; import { cn } from "../../../lib/cn"; /* ─── 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 primaryFg = useThemeColor("--color-primary-foreground"); const dangerFg = useThemeColor("--color-danger-foreground"); const secondaryFg = useThemeColor("--color-secondary-foreground"); const tone = props.tone ?? "secondary"; const textColor = tone === "primary" ? primaryFg : tone === "danger" ? dangerFg : 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 "); }