Open History to see the last commit
1import { Select, T, useGT, Var, plural, part } from "gt-react-native";
2import { Pressable, View } from "react-native";
3
4import { AppText } from "../../components/ui/AppText";
5import { SymbolView } from "../../components/ui/AppSymbol";
6
7export function DevicePreviewButton(props: {
8 readonly count: number;
9 readonly onPress: () => void;
10 readonly compact?: boolean;
11}) {
12 const compact = props.compact ?? true;
13 const gt = useGT();
14 return (
15 <Pressable
16 accessibilityRole="button"
17 accessibilityLabel={gt`${plural(
18 { count: props.count },
19 {
20 "=1": "View device",
21 other: part`View ${{ count: props.count }} devices`,
22 },
23 )}`}
24 accessibilityHint={gt`Watch and control devices open in this thread`}
25 onPress={props.onPress}
26 className={
27 compact
28 ? "size-11 shrink-0 items-center justify-center rounded-full active:bg-subtle"
29 : "h-11 shrink-0 flex-row items-center justify-center gap-2 rounded-full px-4 active:bg-subtle"
30 }
31 >
32 <SymbolView
33 name={{ ios: "iphone", android: "smartphone" }}
34 size={20}
35 tintColorClassName="accent-icon"
36 type="monochrome"
37 />
38 {!compact ? (
39 <AppText className="font-t3-medium text-xs text-foreground">
40 <T>
41 <Select value={props.count === 1 ? "singular" : "other"} singular="One device open">
42 <Var>{props.count}</Var> devices open
43 </Select>
44 </T>
45 </AppText>
46 ) : props.count > 1 ? (
47 <View className="absolute right-1.5 top-1.5 min-w-4 items-center rounded-full bg-primary px-1">
48 <AppText className="text-2xs font-t3-bold text-primary-foreground">{props.count}</AppText>
49 </View>
50 ) : null}
51 </Pressable>
52 );
53}