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

main
tsx 59 lines 2.1 KB
Raw
1 import { msg, useGT, useMessages } from "gt-react-native";
2 import { Platform, Pressable } from "react-native";
3
4 import { SymbolView } from "../../../components/ui/AppSymbol";
5 import { AppText as Text } from "../../../components/ui/AppText";
6 import { Menu } from "../../../components/ui/Menu";
7 import { useAndroidControlSizing } from "../../../components/ui/useAndroidControlSizing";
8 import { isSharedSlotTab, type SharedSlotTab } from "./navigation-tab-order";
9 import { useSelectWorkspaceTab } from "./useSelectWorkspaceTab";
10
11 const TITLES = {
12 pullRequests: msg("Pull requests"),
13 issues: msg("Issues", { $context: "screen title, list of issues" }),
14 } as const;
15
16 /** The header title of the tab pull requests and issues share: names the list and switches it. */
17 export function SharedSlotTitle(props: { readonly tab: SharedSlotTab }) {
18 const gt = useGT();
19 const messages = useMessages();
20 const selectTab = useSelectWorkspaceTab();
21 const { scale } = useAndroidControlSizing();
22 return (
23 <Menu
24 actions={Object.entries(TITLES).map(([id, title]) => ({
25 id,
26 title: messages(title),
27 state: id === props.tab ? ("on" as const) : ("off" as const),
28 }))}
29 onPressAction={({ nativeEvent }) => {
30 const id = nativeEvent.event;
31 if (isSharedSlotTab(id) && id !== props.tab) selectTab(id);
32 }}
33 >
34 <Pressable
35 accessibilityRole="button"
36 accessibilityLabel={gt("{list}, switch list", { list: messages(TITLES[props.tab]) })}
37 hitSlop={8}
38 className="flex-row items-center gap-1.5"
39 >
40 <Text
41 allowFontScaling={Platform.OS === "ios"}
42 maxFontSizeMultiplier={1.4}
43 numberOfLines={1}
44 className="font-t3-bold text-foreground"
45 style={{ fontSize: 20 * scale, letterSpacing: -0.4 * scale }}
46 >
47 {messages(TITLES[props.tab])}
48 </Text>
49 <SymbolView
50 name="chevron.down"
51 size={Math.round(12 * scale)}
52 tintColorClassName="accent-icon-muted"
53 type="monochrome"
54 weight="semibold"
55 />
56 </Pressable>
57 </Menu>
58 );
59 }