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