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

main
tsx 88 lines 2.66 KB
Raw
1 import { useGT } from "gt-react-native";
2 import { useEffect } from "react";
3 import { AccessibilityInfo, Platform, Pressable, View } from "react-native";
4
5 import { cn } from "../../lib/cn";
6 import { AppText } from "./AppText";
7 import { SymbolView, type AppSymbolName } from "./AppSymbol";
8 import { GlassSurface } from "./GlassSurface";
9
10 export function Notice(props: {
11 readonly message: string;
12 readonly tone?: "default" | "danger";
13 readonly icon?: AppSymbolName;
14 readonly iconTone?: "default" | "danger";
15 readonly floating?: boolean;
16 readonly onDismiss?: () => void;
17 readonly dismissLabel?: string;
18 }) {
19 const gt = useGT();
20 const danger = props.tone === "danger";
21 // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- announces the message to VoiceOver through AccessibilityInfo
22 useEffect(() => {
23 // Live regions reach TalkBack; VoiceOver needs an explicit announcement.
24 if (Platform.OS === "ios") AccessibilityInfo.announceForAccessibility(props.message);
25 }, [props.message]);
26
27 const content = (
28 <View className="flex-row items-start gap-3">
29 {props.icon ? (
30 <View className="pt-0.5">
31 <SymbolView
32 name={props.icon}
33 size={16}
34 tintColorClassName={
35 danger || props.iconTone === "danger"
36 ? "accent-danger-foreground"
37 : "accent-icon-muted"
38 }
39 />
40 </View>
41 ) : null}
42 <AppText
43 selectable
44 textRole="footnote"
45 accessibilityLiveRegion="polite"
46 className={cn(
47 "min-w-0 flex-1",
48 danger ? "text-danger-foreground" : "text-foreground",
49 !props.floating && "font-t3-medium",
50 )}
51 >
52 {props.message}
53 </AppText>
54 {props.onDismiss ? (
55 <Pressable
56 accessibilityRole="button"
57 accessibilityLabel={props.dismissLabel ?? gt("Dismiss message")}
58 onPress={props.onDismiss}
59 hitSlop={10}
60 className="min-h-6 min-w-6 items-center justify-center active:opacity-60"
61 >
62 <SymbolView
63 name="xmark"
64 size={14}
65 tintColorClassName={danger ? "accent-danger-foreground" : "accent-icon-muted"}
66 />
67 </Pressable>
68 ) : null}
69 </View>
70 );
71 if (props.floating && Platform.OS === "ios")
72 return (
73 <GlassSurface className="p-4" style={{ borderRadius: 20 }}>
74 {content}
75 </GlassSurface>
76 );
77 return (
78 <View
79 className={cn(
80 "rounded-2xl border px-3.5 py-3",
81 danger ? "border-danger-border bg-danger" : "border-border bg-card",
82 props.floating && "p-4",
83 )}
84 >
85 {content}
86 </View>
87 );
88 }