Open History to see the last commit
1import { SymbolView } from "expo-symbols";
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 primaryBg = useThemeColor("--color-primary");
41 const primaryFg = useThemeColor("--color-primary-foreground");
42 const dangerBg = useThemeColor("--color-danger");
43 const dangerBorderColor = useThemeColor("--color-danger-border");
44 const dangerFg = useThemeColor("--color-danger-foreground");
45 const secondaryBg = useThemeColor("--color-secondary");
46 const secondaryFg = useThemeColor("--color-secondary-foreground");
47 const borderColor = useThemeColor("--color-border");
48
49 const colors =
50 tone === "primary"
51 ? {
52 backgroundColor: primaryBg,
53 borderColor: "transparent",
54 textColor: primaryFg,
55 }
56 : tone === "danger"
57 ? {
58 backgroundColor: dangerBg,
59 borderColor: dangerBorderColor,
60 textColor: dangerFg,
61 }
62 : {
63 backgroundColor: secondaryBg,
64 borderColor: borderColor,
65 textColor: secondaryFg,
66 };
67
68 const primaryShadow =
69 tone === "primary"
70 ? Platform.select({
71 ios: {
72 shadowColor: "#000",
73 shadowOffset: { width: 0, height: 3 },
74 shadowOpacity: 0.14,
75 shadowRadius: 6,
76 },
77 android: { elevation: 3 },
78 })
79 : undefined;
80
81 return (
82 <Pressable
83 className={cn(
84 props.compact
85 ? "min-h-[42px] flex-row items-center justify-center gap-1.5 rounded-[14px] px-3.5 py-2.5"
86 : "min-h-[48px] flex-row items-center justify-center gap-2 rounded-[16px] px-4 py-3",
87 )}
88 disabled={props.disabled}
89 onPress={props.onPress}
90 style={[
91 {
92 backgroundColor: colors.backgroundColor,
93 borderWidth: tone === "primary" ? 0 : 1,
94 borderColor: colors.borderColor,
95 opacity: props.disabled ? 0.5 : 1,
96 },
97 primaryShadow,
98 ]}
99 >
100 <SymbolView
101 name={props.icon}
102 size={props.compact ? 13 : 14}
103 tintColor={colors.textColor}
104 type="monochrome"
105 />
106 <Text
107 className="text-xs font-t3-bold uppercase"
108 style={{ color: colors.textColor, letterSpacing: 0.8 }}
109 >
110 {props.label}
111 </Text>
112 </Pressable>
113 );
114}