The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator"; |
| 2 | import type { ChangeRequestTerminology } from "@t3tools/client-runtime/source-control-clients"; |
| 3 | import type { PullRequestActor } from "@t3tools/contracts"; |
| 4 | import IconAlertTriangle from "@tabler/icons-react-native/IconAlertTriangle"; |
| 5 | import { Image } from "expo-image"; |
| 6 | import { useGT } from "gt-react-native"; |
| 7 | import { View } from "react-native"; |
| 8 | import { useResolveClassNames } from "uniwind"; |
| 9 | |
| 10 | import { AppText as Text } from "../../components/ui/AppText"; |
| 11 | import { cn } from "../../lib/cn"; |
| 12 | import { changeRequestTermKind } from "../../lib/changeRequestTerm"; |
| 13 | import { EmptyState } from "../../components/ui/EmptyState"; |
| 14 | |
| 15 | export function PullRequestReadStatus(props: { |
| 16 | readonly pending: boolean; |
| 17 | readonly error: string | null; |
| 18 | readonly terminology: ChangeRequestTerminology; |
| 19 | }) { |
| 20 | const gt = useGT(); |
| 21 | return props.pending ? ( |
| 22 | <AppActivityIndicator className="my-12" colorClassName="accent-icon" /> |
| 23 | ) : props.error ? ( |
| 24 | <EmptyState |
| 25 | title={gt( |
| 26 | "Couldn't load this {term, select, mr {merge request} cr {change request} other {pull request}}", |
| 27 | { |
| 28 | term: changeRequestTermKind(props.terminology), |
| 29 | }, |
| 30 | )} |
| 31 | detail={props.error} |
| 32 | variant="plain" |
| 33 | /> |
| 34 | ) : null; |
| 35 | } |
| 36 | |
| 37 | export function PullRequestConflictBadge(props: { readonly surfaceClassName: string }) { |
| 38 | const { color } = useResolveClassNames("text-danger-foreground"); |
| 39 | const { color: surface } = useResolveClassNames(props.surfaceClassName); |
| 40 | return ( |
| 41 | <View pointerEvents="none" className="absolute -right-1 -bottom-1"> |
| 42 | <IconAlertTriangle size={15} strokeWidth={2.5} color={surface} fill={surface} /> |
| 43 | <View className="absolute inset-0"> |
| 44 | <IconAlertTriangle size={15} strokeWidth={2.5} color={color} /> |
| 45 | </View> |
| 46 | </View> |
| 47 | ); |
| 48 | } |
| 49 | |
| 50 | export function PullRequestAvatar(props: { |
| 51 | readonly actor: PullRequestActor | null; |
| 52 | readonly size?: number; |
| 53 | }) { |
| 54 | const size = props.size ?? 24; |
| 55 | return props.actor?.avatarUrl ? ( |
| 56 | <Image |
| 57 | source={{ uri: props.actor.avatarUrl }} |
| 58 | recyclingKey={props.actor.avatarUrl} |
| 59 | accessibilityLabel={props.actor.login} |
| 60 | style={{ width: size, height: size, borderRadius: size / 2 }} |
| 61 | cachePolicy="memory-disk" |
| 62 | /> |
| 63 | ) : ( |
| 64 | <View |
| 65 | className="items-center justify-center rounded-full bg-grouped-card" |
| 66 | style={{ width: size, height: size }} |
| 67 | > |
| 68 | <Text className="font-t3-medium text-foreground-muted" style={{ fontSize: size * 0.45 }}> |
| 69 | {props.actor?.login.slice(0, 1).toUpperCase() ?? "?"} |
| 70 | </Text> |
| 71 | </View> |
| 72 | ); |
| 73 | } |
| 74 | |
| 75 | export function PullRequestDiffStats(props: { |
| 76 | readonly additions: number; |
| 77 | readonly deletions: number; |
| 78 | readonly compact?: boolean; |
| 79 | }) { |
| 80 | const textSize = props.compact ? "text-2xs" : "text-xs"; |
| 81 | return ( |
| 82 | <View className="shrink-0 flex-row items-center gap-2"> |
| 83 | {!props.compact || props.additions > 0 ? ( |
| 84 | <Text className={cn(textSize, "font-t3-medium tabular-nums text-adaptive-emerald-600-400")}> |
| 85 | +{props.additions.toLocaleString()} |
| 86 | </Text> |
| 87 | ) : null} |
| 88 | {!props.compact || props.deletions > 0 ? ( |
| 89 | <Text className={cn(textSize, "font-t3-medium tabular-nums text-danger-foreground")}> |
| 90 | −{props.deletions.toLocaleString()} |
| 91 | </Text> |
| 92 | ) : null} |
| 93 | </View> |
| 94 | ); |
| 95 | } |