Open History to see the last commit
1import { SymbolView } from "../../components/AppSymbol";
2import { Platform, Pressable } from "react-native";
3
4import { AppText as Text } from "../../components/AppText";
5import { cn } from "../../lib/cn";
6import { MaterialButton } from "../../components/MaterialButton";
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 fullWidth?: boolean;
37 readonly onPress: () => void;
38}) {
39 if (Platform.OS === "android")
40 return (
41 <MaterialButton
42 label={props.label}
43 disabled={props.disabled}
44 onPress={props.onPress}
45 tone={props.tone}
46 fullWidth={props.fullWidth}
47 />
48 );
49 const tone = props.tone ?? "secondary";
50
51 const textColorClassName =
52 tone === "primary"
53 ? "accent-primary-foreground"
54 : tone === "danger"
55 ? "accent-danger-foreground"
56 : "accent-secondary-foreground";
57
58 const primaryShadow =
59 tone === "primary"
60 ? Platform.select({
61 ios: {
62 shadowColor: "#000",
63 shadowOffset: { width: 0, height: 3 },
64 shadowOpacity: 0.14,
65 shadowRadius: 6,
66 },
67 android: { elevation: 3 },
68 })
69 : undefined;
70
71 return (
72 <Pressable
73 accessibilityLabel={props.label}
74 accessibilityRole="button"
75 accessibilityState={{ disabled: props.disabled ?? false }}
76 className={cn(
77 props.compact
78 ? "min-h-[42px] flex-row items-center justify-center gap-1.5 rounded-[14px] px-3.5 py-2.5"
79 : "min-h-[48px] flex-row items-center justify-center gap-2 rounded-[16px] px-4 py-3",
80 "disabled:opacity-50",
81 tone === "primary"
82 ? "bg-primary"
83 : tone === "danger"
84 ? "border border-danger-border bg-danger"
85 : "border border-border bg-secondary",
86 )}
87 disabled={props.disabled}
88 onPress={props.onPress}
89 style={primaryShadow}
90 >
91 <SymbolView
92 name={props.icon}
93 size={props.compact ? 13 : 14}
94 tintColorClassName={textColorClassName}
95 type="monochrome"
96 />
97 <Text
98 className={cn(
99 "text-xs font-t3-bold tracking-[0.8px] uppercase",
100 tone === "primary"
101 ? "text-primary-foreground"
102 : tone === "danger"
103 ? "text-danger-foreground"
104 : "text-secondary-foreground",
105 )}
106 >
107 {props.label}
108 </Text>
109 </Pressable>
110 );
111}