The best way to control Claude Code, Codex and more from any computer or phone

main
tsx 76 lines 2.75 KB
Raw
1 import { useGT } from "gt-react-native";
2 import { useId, useState } from "react";
3 import { Platform, View } from "react-native";
4 import { FormSheet, ScreenStack } from "react-native-screens";
5 import { useResolveClassNames } from "uniwind";
6
7 import { nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";
8 import { formSheetDetents } from "../../native/sheet-surface";
9 import { NativeHeader, NativeScreen } from "../../native/ThemedScreenStack";
10
11 const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
12
13 export type { SheetProps } from "./Sheet.types";
14 import type { SheetProps } from "./Sheet.types";
15
16 /** Native presentation. Scrollable children use automatic insets beneath the iOS header. */
17 export function Sheet(props: SheetProps) {
18 const gt = useGT();
19 const containerStyle = useResolveClassNames("bg-sheet");
20 const screenId = useId();
21 const [isOpen, setIsOpen] = useState(true);
22 const close = () => {
23 if (!props.dismissDisabled) setIsOpen(false);
24 };
25
26 return (
27 <FormSheet
28 isOpen={isOpen}
29 detents={formSheetDetents(0.5, 0.9)}
30 prefersGrabberVisible
31 preventNativeDismiss={props.dismissDisabled}
32 // The header holds the close button, so the Duo needs no rail inside this sheet.
33 prefersHorizontalBars
34 nativeContainerStyle={containerStyle}
35 onDismiss={props.onClose}
36 onNativeDismiss={props.onClose}
37 >
38 {/* Flex children are not bounded by the FormSheet host, so pin to its edges. */}
39 <View collapsable={false} className="absolute inset-0 bg-sheet">
40 <ScreenStack style={{ flex: 1 }}>
41 <NativeScreen
42 activityState={2}
43 enabled
44 isNativeStack
45 screenId={`app-sheet-${screenId}`}
46 scrollEdgeEffects={HEADER_SCROLL_EDGE_EFFECTS}
47 className="flex-1 bg-sheet"
48 >
49 {props.children}
50 <NativeHeader
51 backgroundColor="rgba(0,0,0,0)"
52 tintColorClassName="accent-foreground"
53 hideBackButton
54 hideShadow={false}
55 title={props.title}
56 titleColorClassName="accent-foreground"
57 titleFontSize={18}
58 titleFontWeight="800"
59 translucent
60 headerRightBarButtonItems={[
61 {
62 type: "button",
63 icon: { name: "xmark", type: "sfSymbol" },
64 accessibilityLabel: gt("Close {title}", { title: props.title }),
65 identifier: `app-sheet-close-${screenId}`,
66 disabled: props.dismissDisabled,
67 onPress: close,
68 },
69 ]}
70 />
71 </NativeScreen>
72 </ScreenStack>
73 </View>
74 </FormSheet>
75 );
76 }