Open History to see the last commit
1import { Pressable } from "react-native";
2
3import { AppText } from "./AppText";
4import { ListRowLayout, type ListRowContentProps } from "./ListRowLayout";
5import { ThemedSwitch } from "./ThemedSwitch";
6
7export function ListToggleRow(
8 props: Omit<ListRowContentProps, "detail"> & {
9 readonly value: boolean | null;
10 readonly onValueChange: (value: boolean) => void;
11 },
12) {
13 return (
14 <ListRowLayout
15 icon={props.icon}
16 label={props.label}
17 description={props.description}
18 disabled={props.disabled}
19 accessory={
20 props.value === null ? (
21 <Pressable
22 accessibilityLabel={`Set ${props.label} on for selected environments`}
23 accessibilityRole="button"
24 accessibilityHint={props.description}
25 accessibilityState={{ disabled: Boolean(props.disabled) }}
26 disabled={props.disabled}
27 className="rounded-full bg-subtle px-3 py-2 active:opacity-70"
28 onPress={() => props.onValueChange(true)}
29 >
30 <AppText className="text-sm font-t3-medium text-foreground">Mixed · Set on</AppText>
31 </Pressable>
32 ) : (
33 <ThemedSwitch
34 accessibilityLabel={props.label}
35 accessibilityHint={props.description}
36 disabled={props.disabled}
37 onValueChange={props.onValueChange}
38 value={props.value}
39 />
40 )
41 }
42 />
43 );
44}