The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { useGT } from "gt-react-native"; |
| 2 | import { View } from "react-native"; |
| 3 | |
| 4 | import { RenderErrorBoundary, RenderFailureView } from "../../components/RenderErrorBoundary"; |
| 5 | import { PaneContext } from "../../components/ui/Pane"; |
| 6 | import { WorkspaceSlotOptionsContext } from "../../native/v5-workspace-context"; |
| 7 | import { InspectorCloseContext, useInspectorBarSlot } from "./inspector-bar-store"; |
| 8 | import { |
| 9 | useMountedInspectorPanes, |
| 10 | type InspectorContent, |
| 11 | type InspectorPane, |
| 12 | } from "./inspector-panes"; |
| 13 | |
| 14 | // AppBar draws the bar inline on Android; the slot keeps a pane's options off the thread's route. |
| 15 | function PaneContent(props: { |
| 16 | readonly pane: InspectorPane; |
| 17 | readonly resetKeys: ReadonlyArray<unknown> | undefined; |
| 18 | }) { |
| 19 | const gt = useGT(); |
| 20 | const { slot } = useInspectorBarSlot(); |
| 21 | return ( |
| 22 | <WorkspaceSlotOptionsContext value={slot}> |
| 23 | <RenderErrorBoundary |
| 24 | resetKeys={props.resetKeys} |
| 25 | renderFallback={(fallback) => ( |
| 26 | <RenderFailureView {...fallback} title={gt("The inspector couldn't be displayed")} /> |
| 27 | )} |
| 28 | > |
| 29 | {props.pane.render()} |
| 30 | </RenderErrorBoundary> |
| 31 | </WorkspaceSlotOptionsContext> |
| 32 | ); |
| 33 | } |
| 34 | |
| 35 | /** The inspector's panes, stacked in place: Android draws no native chrome a hidden pane could leave. */ |
| 36 | export function InspectorPanes(props: { |
| 37 | readonly content: InspectorContent | undefined; |
| 38 | readonly onClose: () => void; |
| 39 | }) { |
| 40 | const panes = useMountedInspectorPanes(props.content); |
| 41 | return ( |
| 42 | <InspectorCloseContext value={props.onClose}> |
| 43 | <PaneContext value="inspector"> |
| 44 | <View className="flex-1"> |
| 45 | {panes.map((pane) => { |
| 46 | const visible = pane.key === props.content?.active; |
| 47 | return ( |
| 48 | <View |
| 49 | key={pane.key} |
| 50 | accessibilityElementsHidden={!visible} |
| 51 | focusable={visible} |
| 52 | importantForAccessibility={visible ? "auto" : "no-hide-descendants"} |
| 53 | pointerEvents={visible ? "auto" : "none"} |
| 54 | style={{ |
| 55 | position: "absolute", |
| 56 | inset: 0, |
| 57 | opacity: visible ? 1 : 0, |
| 58 | // A lower zIndex puts the visible pane first in native order, where Material finds its scroll view. |
| 59 | zIndex: visible ? 0 : 1, |
| 60 | }} |
| 61 | > |
| 62 | <PaneContent pane={pane} resetKeys={props.content?.resetKeys} /> |
| 63 | </View> |
| 64 | ); |
| 65 | })} |
| 66 | </View> |
| 67 | </PaneContext> |
| 68 | </InspectorCloseContext> |
| 69 | ); |
| 70 | } |