import { Pressable, Text, View } from 'react-native' import { GitBranch } from 'lucide-react-native' import { colors } from '../theme/mobile-theme' import { styles } from './mobile-source-control-styles' import { MobileSourceControlPrChip } from './MobileSourceControlPrChip' import type { MobilePrChipSummary } from './mobile-pr-chip-summary' import { mobileConflictAbortLabel } from './mobile-source-control-conflict-abort' type Props = { branchLabel: string syncLabel: string | null unstagedCount: number stagedCount: number branchCount: number conflictOperation: string | null // True while any serial git IO is in flight — disables Abort so ops don't race. conflictBusy: boolean // True only while abort-merge / abort-rebase itself is running (label accuracy). conflictAborting: boolean onAbortConflict: (operation: string) => void // The PR chip is shown only on repos with a hosted-review remote; null hides it. prChip: MobilePrChipSummary | null onOpenPr: () => void } // Persistent card at the top of every hub segment: branch identity, sync/counts, // conflict state, and the PR chip. Shared so PR/History see the same status the // Changes lens does without re-deriving it. export function MobileSourceControlBranchCard({ branchLabel, syncLabel, unstagedCount, stagedCount, branchCount, conflictOperation, conflictBusy, conflictAborting, onAbortConflict, prChip, onOpenPr }: Props) { const showConflict = conflictOperation !== null && conflictOperation !== 'unknown' return ( {branchLabel} {syncLabel ? {syncLabel} : null} {unstagedCount} changed {stagedCount} staged {branchCount > 0 ? {branchCount} on branch : null} {/* Own row so Abort never overflows past the card when counts are long. */} {showConflict ? ( {conflictOperation} {conflictOperation === 'merge' || conflictOperation === 'rebase' ? ( [ styles.abortButton, conflictBusy && styles.abortButtonDisabled, pressed && !conflictBusy && styles.abortPressed ]} disabled={conflictBusy} onPress={() => onAbortConflict(conflictOperation)} > {mobileConflictAbortLabel(conflictOperation, conflictAborting)} ) : null} ) : null} {prChip ? : null} ) }