Open History to see the last commit
1import { SymbolView } from "../../components/AppSymbol";
2import { Platform, Pressable } from "react-native";
3import { useThemeColor } from "../../lib/useThemeColor";
4
5import { AppText as Text } from "../../components/AppText";
6import { cn } from "../../lib/cn";
7
8const CARD_SHADOW = Platform.select({
9 ios: {
10 shadowColor: "rgba(23,23,23,0.08)",
11 shadowOffset: { width: 0, height: 4 },
12 shadowOpacity: 1,
13 shadowRadius: 16,
14 },
15 android: { elevation: 3 },
16});
17
18const CARD_SHADOW_DARK = Platform.select({
19 ios: {
20 shadowColor: "#000",
21 shadowOffset: { width: 0, height: 2 },
22 shadowOpacity: 0.18,
23 shadowRadius: 8,
24 },
25 android: { elevation: 4 },
26});
27
28export { CARD_SHADOW, CARD_SHADOW_DARK };
29
30export function ConnectionSheetButton(props: {
31 readonly icon: React.ComponentProps<typeof SymbolView>["name"];
32 readonly label: string;
33 readonly disabled?: boolean;
34 readonly tone?: "primary" | "secondary" | "danger";
35 readonly compact?: boolean;
36 readonly onPress: () => void;
37}) {
38 const tone = props.tone ?? "secondary";
39
40 const primaryFg = useThemeColor("--color-primary-foreground");
41 const dangerFg = useThemeColor("--color-danger-foreground");
42 const secondaryFg = useThemeColor("--color-secondary-foreground");
43
44 const textColor = tone === "primary" ? primaryFg : tone === "danger" ? dangerFg : secondaryFg;
45
46 const primaryShadow =
47 tone === "primary"
48 ? Platform.select({
49 ios: {
50 shadowColor: "#000",
51 shadowOffset: { width: 0, height: 3 },
52 shadowOpacity: 0.14,
53 shadowRadius: 6,
54 },
55 android: { elevation: 3 },
56 })
57 : undefined;
58
59 return (
60 <Pressable
61 className={cn(
62 props.compact
63 ? "min-h-[42px] flex-row items-center justify-center gap-1.5 rounded-[14px] px-3.5 py-2.5"
64 : "min-h-[48px] flex-row items-center justify-center gap-2 rounded-[16px] px-4 py-3",
65 "disabled:opacity-50",
66 tone === "primary"
67 ? "bg-primary"
68 : tone === "danger"
69 ? "border border-danger-border bg-danger"
70 : "border border-border bg-secondary",
71 )}
72 disabled={props.disabled}
73 onPress={props.onPress}
74 style={primaryShadow}
75 >
76 <SymbolView
77 name={props.icon}
78 size={props.compact ? 13 : 14}
79 tintColor={textColor}
80 type="monochrome"
81 />
82 <Text
83 className={cn(
84 "text-xs font-t3-bold tracking-[0.8px] uppercase",
85 tone === "primary"
86 ? "text-primary-foreground"
87 : tone === "danger"
88 ? "text-danger-foreground"
89 : "text-secondary-foreground",
90 )}
91 >
92 {props.label}
93 </Text>
94 </Pressable>
95 );
96}