Massive/Switch.tsx
Brandon Presley 94a5fa4ac7 Remove track color setting from Switch
This must have been considered a bug in the
React Native Paper codebase, but this was me fixing
the track color being wrong when system theme and app
theme weren't the same.
2023-08-22 11:53:12 +12:00

39 lines
843 B
TypeScript

import React from "react";
import { Platform, Pressable } from "react-native";
import { Switch as PaperSwitch, Text, useTheme } from "react-native-paper";
import { MARGIN } from "./constants";
function Switch({
value,
onChange,
title,
}: {
value?: boolean;
onChange: (value: boolean) => void;
title: string;
}) {
const { colors } = useTheme();
return (
<Pressable
onPress={() => onChange(!value)}
style={{
flexDirection: "row",
flexWrap: "wrap",
alignItems: "center",
marginBottom: Platform.OS === "ios" ? MARGIN : null,
}}
>
<PaperSwitch
color={colors.primary}
style={{ marginRight: MARGIN }}
value={value}
onValueChange={onChange}
/>
<Text>{title}</Text>
</Pressable>
);
}
export default React.memo(Switch);