import { ActivityIndicator, Pressable, Text, View } from 'react-native' import { AlertTriangle, Check, ChevronRight, CircleDot, GitPullRequest, MessageSquare, X } from 'lucide-react-native' import { colors } from '../theme/mobile-theme' import { statusColor } from '../components/pr-sidebar/pr-sidebar-status-color' import { hubStyles } from './mobile-source-control-hub-styles' import type { MobilePrChipRollup, MobilePrChipSummary } from './mobile-pr-chip-summary' type Props = { summary: MobilePrChipSummary onPress: () => void } // The glanceable PR status line on the branch card. Tapping it switches to the // Pull Request segment. Rendered only when the repo supports hosted review — the // parent gates on that, so this component always has something meaningful to show. export function MobileSourceControlPrChip({ summary, onPress }: Props) { return ( [hubStyles.chip, pressed && hubStyles.chipPressed]} onPress={onPress} accessibilityRole="button" accessibilityLabel={chipAccessibilityLabel(summary)} > {summary.kind === 'loading' ? ( <> Loading pull request… ) : summary.kind === 'none' ? ( <> Create pull request ) : summary.kind === 'unavailable' ? ( <> {summary.message} ) : ( <> #{summary.number} {summary.stateLabel} {summary.commentCount != null && summary.commentCount > 0 ? ( {summary.commentCount} ) : null} )} ) } function ChipRollup({ rollup }: { rollup: MobilePrChipRollup }) { const color = statusColor(rollup.token) return ( {rollup.text} ) } function RollupIcon({ kind, color }: { kind: MobilePrChipRollup['kind']; color: string }) { const size = 13 const strokeWidth = 2.3 switch (kind) { case 'conflict': return case 'failing': return case 'running': return case 'passed': return case 'none': return null } } function chipAccessibilityLabel(summary: MobilePrChipSummary): string { switch (summary.kind) { case 'loading': return 'Loading pull request' case 'none': return 'Create pull request' case 'unavailable': return `Pull request unavailable: ${summary.message}` case 'ready': { const comments = summary.commentCount != null && summary.commentCount > 0 ? `, ${summary.commentCount} unresolved comments` : '' return `Pull request #${summary.number}, ${summary.stateLabel}, ${summary.rollup.text}${comments}. Open pull request.` } } }