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

SettingsSwitchRow.tsx

43 lines1.3 KB

1import type { ComponentProps } from "react";
2import { View } from "react-native";
3​
4import { SymbolView } from "../../../components/AppSymbol";
5import { AppText as Text } from "../../../components/AppText";
6import { ThemedSwitch } from "../../../components/ThemedSwitch";
7import { useThemeColor } from "../../../lib/useThemeColor";
8​
9type SymbolName = ComponentProps<typeof SymbolView>["name"];
10​
11export function SettingsSwitchRow(props: {
12 readonly disabled?: boolean;
13 readonly icon: SymbolName;
14 readonly label: string;
15 readonly subtitle?: string;
16 readonly value: boolean;
17 readonly onValueChange: (value: boolean) => void;
18}) {
19 const icon = useThemeColor("--color-icon");
20​
21 return (
22 <View
23 className={
24 props.disabled
25 ? "flex-row items-center gap-4 p-4 opacity-[0.45]"
26 : "flex-row items-center gap-4 p-4"
27 }
28 >
29 <SymbolView name={props.icon} size={22} tintColor={icon} type="monochrome" weight="regular" />
30 <View className="min-w-0 flex-1">
31 <Text className="text-lg text-foreground">{props.label}</Text>
32 {props.subtitle ? (
33 <Text className="text-sm text-foreground-muted">{props.subtitle}</Text>
34 ) : null}
35 </View>
36 <ThemedSwitch
37 disabled={props.disabled}
38 onValueChange={props.onValueChange}
39 value={props.value}
40 />
41 </View>
42 );