Live video on the AT Protocol
1import { Text, zero } from "@streamplace/components";
2import { Pressable, View, ViewStyle } from "react-native";
3
4interface ButtonSelectorProps {
5 text?: string;
6 values: { label: string; value: string }[];
7 selectedValue: string;
8 setSelectedValue: (value: any) => void;
9 style?: ViewStyle;
10}
11
12export default function ButtonSelector({
13 text,
14 values,
15 selectedValue,
16 setSelectedValue,
17 style,
18 ...props
19}: ButtonSelectorProps) {
20 return (
21 <View
22 style={[{ alignItems: "flex-start" }, zero.gap.all[2], zero.pt[2], style]}
23 {...props}
24 >
25 {text && (
26 <Text style={[{ fontSize: 16 }, { fontWeight: "600" }]}>{text}</Text>
27 )}
28 <View
29 style={[
30 zero.layout.flex.row,
31 zero.layout.flex.alignCenter,
32 zero.layout.flex.spaceAround,
33 zero.gap.all[1],
34 zero.w.percent[100],
35 zero.bg.gray[100],
36 zero.r.xl,
37 ]}
38 >
39 {values.map(({ label, value }) => (
40 <Pressable
41 key={value}
42 onPress={() => setSelectedValue(value)}
43 style={[
44 zero.flex.values[1],
45 zero.h[32], // height equivalent to "$2"
46 selectedValue === value
47 ? [
48 zero.borders.width.medium,
49 zero.borders.color.gray[300],
50 zero.r.lg,
51 ]
52 : [],
53 zero.layout.flex.center,
54 ]}
55 >
56 <Text
57 style={[
58 {
59 color:
60 selectedValue === value
61 ? zero.colors.gray[900]
62 : zero.colors.gray[500],
63 },
64 ]}
65 >
66 {label}
67 </Text>
68 </Pressable>
69 ))}
70 </View>
71 </View>
72 );
73}