Open History to see the last commit
1import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
2import type { PullRequestActor } from "@t3tools/contracts";
3import IconAlertTriangle from "@tabler/icons-react-native/IconAlertTriangle";
4import { Image } from "expo-image";
5import { View } from "react-native";
6import { useResolveClassNames } from "uniwind";
7
8import { AppText as Text } from "../../components/ui/AppText";
9import { cn } from "../../lib/cn";
10import { EmptyState } from "../../components/ui/EmptyState";
11
12export function PullRequestReadStatus(props: {
13 readonly pending: boolean;
14 readonly error: string | null;
15}) {
16 return props.pending ? (
17 <AppActivityIndicator className="my-12" colorClassName="accent-icon" />
18 ) : props.error ? (
19 <EmptyState title="Couldn't load this pull request" detail={props.error} variant="plain" />
20 ) : null;
21}
22
23export function PullRequestConflictBadge(props: { readonly surfaceClassName: string }) {
24 const { color } = useResolveClassNames("text-danger-foreground");
25 const { color: surface } = useResolveClassNames(props.surfaceClassName);
26 return (
27 <View pointerEvents="none" className="absolute -right-1 -bottom-1">
28 <IconAlertTriangle size={15} strokeWidth={2.5} color={surface} fill={surface} />
29 <View className="absolute inset-0">
30 <IconAlertTriangle size={15} strokeWidth={2.5} color={color} />
31 </View>
32 </View>
33 );
34}
35
36export function PullRequestAvatar(props: {
37 readonly actor: PullRequestActor | null;
38 readonly size?: number;
39}) {
40 const size = props.size ?? 24;
41 return props.actor?.avatarUrl ? (
42 <Image
43 source={{ uri: props.actor.avatarUrl }}
44 recyclingKey={props.actor.avatarUrl}
45 accessibilityLabel={props.actor.login}
46 style={{ width: size, height: size, borderRadius: size / 2 }}
47 cachePolicy="memory-disk"
48 />
49 ) : (
50 <View
51 className="items-center justify-center rounded-full bg-grouped-card"
52 style={{ width: size, height: size }}
53 >
54 <Text className="font-t3-medium text-foreground-muted" style={{ fontSize: size * 0.45 }}>
55 {props.actor?.login.slice(0, 1).toUpperCase() ?? "?"}
56 </Text>
57 </View>
58 );
59}
60
61export function PullRequestDiffStats(props: {
62 readonly additions: number;
63 readonly deletions: number;
64 readonly compact?: boolean;
65}) {
66 const textSize = props.compact ? "text-2xs" : "text-xs";
67 return (
68 <View className="shrink-0 flex-row items-center gap-2">
69 {!props.compact || props.additions > 0 ? (
70 <Text className={cn(textSize, "font-t3-medium tabular-nums text-adaptive-emerald-600-400")}>
71 +{props.additions.toLocaleString()}
72 </Text>
73 ) : null}
74 {!props.compact || props.deletions > 0 ? (
75 <Text className={cn(textSize, "font-t3-medium tabular-nums text-danger-foreground")}>
76 −{props.deletions.toLocaleString()}
77 </Text>
78 ) : null}
79 </View>
80 );
81}