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 { useGT } from "gt-react-native"; |
| 2 | import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView"; |
| 3 | |
| 4 | import { useNavigation } from "@react-navigation/native"; |
| 5 | import type { EnvironmentId } from "@t3tools/contracts"; |
| 6 | import { Fragment, useState } from "react"; |
| 7 | import { View } from "react-native"; |
| 8 | import { useSafeAreaInsets } from "react-native-safe-area-context"; |
| 9 | |
| 10 | import { AppBar } from "../../components/ui/AppBar"; |
| 11 | import { useRemoteConnections } from "../../state/use-remote-environment-registry"; |
| 12 | import { LocalEnvironmentList } from "./LocalEnvironmentList"; |
| 13 | import { PullRequestRoutingSettings } from "./PullRequestRoutingSettings"; |
| 14 | import { LinkedEnvironmentsSection } from "./LinkedEnvironmentsSection"; |
| 15 | import { LinkSeveralEnvironmentsAction } from "./LinkSeveralEnvironments"; |
| 16 | |
| 17 | export function ConnectionsRouteScreen() { |
| 18 | const gt = useGT(); |
| 19 | const { |
| 20 | connectedEnvironments, |
| 21 | onReconnectEnvironment, |
| 22 | onRemoveEnvironmentPress, |
| 23 | onSetEnvironmentEnabled, |
| 24 | onUpdateEnvironment, |
| 25 | } = useRemoteConnections(); |
| 26 | const navigation = useNavigation(); |
| 27 | const insets = useSafeAreaInsets(); |
| 28 | const [expandedId, setExpandedId] = useState<EnvironmentId | null>(null); |
| 29 | const handleToggle = (environmentId: EnvironmentId) => { |
| 30 | setExpandedId((prev) => (prev === environmentId ? null : environmentId)); |
| 31 | }; |
| 32 | |
| 33 | return ( |
| 34 | <View collapsable={false} className="flex-1 bg-sheet"> |
| 35 | <AppBar |
| 36 | title={gt("Environments")} |
| 37 | onClose={() => navigation.goBack()} |
| 38 | closeAccessibilityLabel={gt("Close environments")} |
| 39 | actions={[ |
| 40 | { |
| 41 | accessibilityLabel: gt("Add environment"), |
| 42 | icon: "plus", |
| 43 | onPress: () => navigation.navigate("ConnectionsNew"), |
| 44 | }, |
| 45 | ]} |
| 46 | /> |
| 47 | <ScrollView |
| 48 | contentInsetAdjustmentBehavior="automatic" |
| 49 | showsVerticalScrollIndicator={false} |
| 50 | className="flex-1" |
| 51 | contentContainerStyle={{ |
| 52 | paddingBottom: Math.max(insets.bottom, 18) + 18, |
| 53 | paddingHorizontal: 20, |
| 54 | paddingTop: 16, |
| 55 | }} |
| 56 | > |
| 57 | <LocalEnvironmentList |
| 58 | environments={connectedEnvironments} |
| 59 | expandedId={expandedId} |
| 60 | onToggle={handleToggle} |
| 61 | onReconnect={onReconnectEnvironment} |
| 62 | onRemove={onRemoveEnvironmentPress} |
| 63 | onSetEnabled={onSetEnvironmentEnabled} |
| 64 | onUpdate={onUpdateEnvironment} |
| 65 | /> |
| 66 | {connectedEnvironments |
| 67 | .filter((environment) => environment.connectionState === "connected") |
| 68 | .map((environment) => ( |
| 69 | <Fragment key={environment.environmentId}> |
| 70 | <LinkedEnvironmentsSection |
| 71 | environmentId={environment.environmentId} |
| 72 | environmentLabel={environment.environmentLabel} |
| 73 | /> |
| 74 | <LinkSeveralEnvironmentsAction |
| 75 | environmentId={environment.environmentId} |
| 76 | environmentLabel={environment.environmentLabel} |
| 77 | /> |
| 78 | </Fragment> |
| 79 | ))} |
| 80 | <PullRequestRoutingSettings /> |
| 81 | </ScrollView> |
| 82 | </View> |
| 83 | ); |
| 84 | } |