Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

SettingsSwitchRow.tsx

42 lines1.3 KB

1import type { ComponentProps } from "react";
2import { Pressable } from "react-native";
3​
4import { AppText as Text } from "../../../components/AppText";
5import { ThemedSwitch } from "../../../components/ThemedSwitch";
6import { SettingsControlRow } from "./SettingsControlRow";
7​
8export function SettingsSwitchRow(
9 props: Omit<ComponentProps<typeof SettingsControlRow>, "children"> & {
10 readonly value: boolean | null;
11 readonly onValueChange: (value: boolean) => void;
12 },
13) {
14 return (
15 <SettingsControlRow
16 disabled={props.disabled}
17 icon={props.icon}
18 label={props.label}
19 subtitle={props.subtitle}
20 >
21 {props.value === null ? (
22 <Pressable
23 accessibilityLabel={`Set ${props.label} on for selected environments`}
24 accessibilityRole="button"
25 disabled={props.disabled}
26 className="rounded-full bg-subtle px-3 py-2 active:opacity-70"
27 onPress={() => props.onValueChange(true)}
28 >
29 <Text className="text-sm font-t3-medium text-foreground">Mixed · Set on</Text>
30 </Pressable>
31 ) : (
32 <ThemedSwitch
33 style={{ alignSelf: "center" }}
34 accessibilityLabel={props.label}
35 disabled={props.disabled}
36 onValueChange={props.onValueChange}
37 value={props.value}
38 />
39 )}
40 </SettingsControlRow>
41 );