The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { Button } from "../../../components/ui/Button"; |
| 2 | import type { PullRequestReviewGuide } from "@t3tools/contracts"; |
| 3 | import { stopFilePaths } from "@t3tools/client-runtime/review-guide-tour"; |
| 4 | import { useGT } from "gt-react-native"; |
| 5 | import { Pressable, View } from "react-native"; |
| 6 | import { AppText as Text } from "../../../components/ui/AppText"; |
| 7 | import { SymbolView } from "../../../components/ui/AppSymbol"; |
| 8 | import { PullRequestMarkdown } from "../PullRequestMarkdown"; |
| 9 | import { Menu } from "../../../components/ui/Menu"; |
| 10 | |
| 11 | import { useAppearancePreferences } from "../../settings/appearance/AppearancePreferencesProvider"; |
| 12 | |
| 13 | export function GuideOutline({ |
| 14 | guide, |
| 15 | onOpen, |
| 16 | onRewrite, |
| 17 | }: { |
| 18 | readonly guide: PullRequestReviewGuide; |
| 19 | readonly onOpen: (position: number) => void; |
| 20 | readonly onRewrite?: () => void; |
| 21 | }) { |
| 22 | const gt = useGT(); |
| 23 | const { appearance, setCodeWordBreak } = useAppearancePreferences(); |
| 24 | const files = new Set(guide.stops.flatMap(stopFilePaths)); |
| 25 | return ( |
| 26 | <View> |
| 27 | <View className="mb-5 flex-row items-center justify-between"> |
| 28 | <View className="flex-row items-baseline gap-2"> |
| 29 | <Text className="text-base font-t3-semibold"> |
| 30 | {gt("{count, plural, one {{count} stops} other {{count} stops}}", { |
| 31 | count: guide.stops.length, |
| 32 | })} |
| 33 | </Text> |
| 34 | <Text className="text-sm text-foreground-muted"> |
| 35 | {gt("{count, plural, one {through {count} file} other {through {count} files}}", { |
| 36 | count: files.size, |
| 37 | })} |
| 38 | </Text> |
| 39 | </View> |
| 40 | <Menu |
| 41 | title={gt("Guide options")} |
| 42 | actions={[ |
| 43 | { |
| 44 | id: "word-wrap", |
| 45 | title: gt("Word wrap"), |
| 46 | image: "text.alignleft", |
| 47 | state: appearance.codeWordBreak ? "on" : "off", |
| 48 | }, |
| 49 | ...(onRewrite |
| 50 | ? [{ id: "rewrite", title: gt("Rewrite guide"), image: "arrow.clockwise" }] |
| 51 | : []), |
| 52 | ]} |
| 53 | onPressAction={({ nativeEvent }) => |
| 54 | nativeEvent.event === "word-wrap" |
| 55 | ? setCodeWordBreak(!appearance.codeWordBreak) |
| 56 | : onRewrite?.() |
| 57 | } |
| 58 | > |
| 59 | <Pressable |
| 60 | accessibilityRole="button" |
| 61 | accessibilityLabel={gt("Guide options")} |
| 62 | className="h-11 w-11 items-center justify-center rounded-full active:bg-grouped-card" |
| 63 | > |
| 64 | <SymbolView name="ellipsis" size={20} tintColorClassName="accent-icon-muted" /> |
| 65 | </Pressable> |
| 66 | </Menu> |
| 67 | </View> |
| 68 | {guide.stops[0]?.summary ? ( |
| 69 | <View className="mb-6"> |
| 70 | <PullRequestMarkdown lineBreaks={false} markdown={guide.stops[0].summary} /> |
| 71 | </View> |
| 72 | ) : null} |
| 73 | {guide.stops.map((stop, position) => { |
| 74 | const paths = stopFilePaths(stop); |
| 75 | const firstPath = paths[0]; |
| 76 | const filename = firstPath?.split("/").at(-1); |
| 77 | return ( |
| 78 | <Pressable |
| 79 | key={`${guide.headSha}:${JSON.stringify(stop)}`} |
| 80 | accessibilityRole="button" |
| 81 | accessibilityLabel={gt("Stop {position}: {title}", { |
| 82 | position: position + 1, |
| 83 | title: stop.title, |
| 84 | })} |
| 85 | onPress={() => onOpen(position)} |
| 86 | className="flex-row gap-4 active:opacity-60" |
| 87 | > |
| 88 | <View className="w-8 items-center"> |
| 89 | <View className="h-8 w-8 items-center justify-center rounded-full border border-border bg-grouped-card"> |
| 90 | <Text className="text-sm font-t3-medium tabular-nums">{position + 1}</Text> |
| 91 | </View> |
| 92 | {position < guide.stops.length - 1 ? ( |
| 93 | <View className="min-h-5 w-px flex-1 bg-border-subtle" /> |
| 94 | ) : null} |
| 95 | </View> |
| 96 | <View className="min-w-0 flex-1 gap-2 pb-7 pt-0.5"> |
| 97 | <Text className="text-base leading-6 font-t3-medium">{stop.title}</Text> |
| 98 | <View className="flex-row items-center gap-1.5"> |
| 99 | {stop.attention ? ( |
| 100 | <SymbolView name="eye" size={14} tintColorClassName="accent-warning-foreground" /> |
| 101 | ) : null} |
| 102 | <Text className="shrink text-xs text-foreground-muted" numberOfLines={1}> |
| 103 | {filename ?? gt("Context", { $context: "guide stop with no file" })} |
| 104 | {paths.length > 1 ? ` +${paths.length - 1}` : ""} |
| 105 | </Text> |
| 106 | </View> |
| 107 | </View> |
| 108 | <View className="pt-2"> |
| 109 | <SymbolView name="chevron.right" size={12} tintColorClassName="accent-icon-muted" /> |
| 110 | </View> |
| 111 | </Pressable> |
| 112 | ); |
| 113 | })} |
| 114 | {guide.stops.length ? ( |
| 115 | <View className="self-end"> |
| 116 | <Button |
| 117 | label={gt("Start tour")} |
| 118 | tone="text" |
| 119 | onPress={() => onOpen(0)} |
| 120 | icon="arrow.right" |
| 121 | /> |
| 122 | </View> |
| 123 | ) : null} |
| 124 | </View> |
| 125 | ); |
| 126 | } |