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 type { ReactNode } from "react"; |
| 2 | import { useGT } from "gt-react-native"; |
| 3 | import { Pressable, View } from "react-native"; |
| 4 | |
| 5 | import { SymbolView } from "../../../components/ui/AppSymbol"; |
| 6 | import { AppText as Text } from "../../../components/ui/AppText"; |
| 7 | import { ThemedSwitch } from "../../../components/ui/ThemedSwitch"; |
| 8 | import { cn } from "../../../lib/cn"; |
| 9 | import { ConnectionStatusDot } from "../../connection/ConnectionStatusDot"; |
| 10 | |
| 11 | /** |
| 12 | * One integration in a settings list: its mark with a status dot, what state it is in, an |
| 13 | * optional switch, and its own page behind the row. The layout of the Environments list's rows. |
| 14 | */ |
| 15 | export function SettingsProviderRow(props: { |
| 16 | readonly icon: ReactNode; |
| 17 | readonly label: string; |
| 18 | readonly detail?: string | null; |
| 19 | readonly description: string; |
| 20 | readonly ready: boolean; |
| 21 | readonly separated: boolean; |
| 22 | /** Opens the integration's page; a row without one only reports. */ |
| 23 | readonly onPress?: () => void; |
| 24 | readonly toggle?: { |
| 25 | readonly accessibilityLabel: string; |
| 26 | readonly value: boolean; |
| 27 | readonly disabled: boolean; |
| 28 | readonly onValueChange: (value: boolean) => void; |
| 29 | }; |
| 30 | }) { |
| 31 | const gt = useGT(); |
| 32 | const summary = ( |
| 33 | <View className="min-w-0 flex-1 gap-0.5"> |
| 34 | <View className="flex-row items-center gap-2 overflow-hidden"> |
| 35 | <View className="size-5 items-center justify-center"> |
| 36 | {props.icon} |
| 37 | <View className="absolute -top-1 -left-1"> |
| 38 | <ConnectionStatusDot |
| 39 | state={props.ready ? "connected" : "available"} |
| 40 | pulse={false} |
| 41 | size={7} |
| 42 | /> |
| 43 | </View> |
| 44 | </View> |
| 45 | <Text className="shrink-0 text-base font-t3-bold leading-snug text-foreground"> |
| 46 | {props.label} |
| 47 | </Text> |
| 48 | {props.detail ? ( |
| 49 | <Text |
| 50 | className="min-w-0 shrink font-mono text-xs text-foreground-muted" |
| 51 | numberOfLines={1} |
| 52 | > |
| 53 | {props.detail} |
| 54 | </Text> |
| 55 | ) : null} |
| 56 | </View> |
| 57 | <Text className="text-xs text-foreground-muted" numberOfLines={2}> |
| 58 | {props.description} |
| 59 | </Text> |
| 60 | </View> |
| 61 | ); |
| 62 | return ( |
| 63 | <View |
| 64 | className={cn( |
| 65 | "flex-row items-center gap-3 bg-grouped-card px-4 py-3.5", |
| 66 | props.separated && "border-t border-border-subtle", |
| 67 | )} |
| 68 | > |
| 69 | {props.onPress ? ( |
| 70 | <Pressable |
| 71 | className="min-w-0 flex-1 active:opacity-70" |
| 72 | accessibilityRole="button" |
| 73 | accessibilityLabel={gt("Manage {provider}", { provider: props.label })} |
| 74 | accessibilityHint={props.description} |
| 75 | onPress={props.onPress} |
| 76 | > |
| 77 | {summary} |
| 78 | </Pressable> |
| 79 | ) : ( |
| 80 | summary |
| 81 | )} |
| 82 | {props.toggle ? ( |
| 83 | <ThemedSwitch |
| 84 | accessibilityLabel={props.toggle.accessibilityLabel} |
| 85 | style={{ alignSelf: "center" }} |
| 86 | disabled={props.toggle.disabled} |
| 87 | onValueChange={props.toggle.onValueChange} |
| 88 | value={props.toggle.value} |
| 89 | /> |
| 90 | ) : null} |
| 91 | {props.onPress ? ( |
| 92 | <Pressable |
| 93 | accessibilityElementsHidden |
| 94 | importantForAccessibility="no-hide-descendants" |
| 95 | onPress={props.onPress} |
| 96 | style={{ minWidth: 24, minHeight: 44, alignItems: "center", justifyContent: "center" }} |
| 97 | > |
| 98 | <SymbolView |
| 99 | name="chevron.right" |
| 100 | size={12} |
| 101 | tintColorClassName="accent-icon-subtle" |
| 102 | type="monochrome" |
| 103 | /> |
| 104 | </Pressable> |
| 105 | ) : null} |
| 106 | </View> |
| 107 | ); |
| 108 | } |