UNPKG

@nexara/nativeflow

Version:

Beautiful, responsive, and customizable UI components for React Native – built for performance and seamless experiences.

43 lines (42 loc) 1.22 kB
"use strict"; import React from "react"; import { Switch as NativeSwitch } from "react-native"; import LightenColorShades from "../../helpers/LightenColorShades.js"; import { moderateScale } from "../../helpers/ResponsiveCalculations.js"; import { useTheme } from "../../hooks/index.js"; import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime"; const Switch = ({ checked = true, color, disabled = false, size = 0.8, activeTrackColor, inactiveTrackColor = '#808080', onChange, ...rest }) => { const theme = useTheme(); const switchColor = disabled ? '#808080' : color ?? theme.colors.primary; return /*#__PURE__*/_jsx(_Fragment, { children: /*#__PURE__*/_jsx(NativeSwitch, { value: checked, trackColor: { true: LightenColorShades(activeTrackColor ?? switchColor, 50), false: LightenColorShades(inactiveTrackColor, 60) }, thumbColor: switchColor, onValueChange: onChange, style: { transform: [{ scaleX: moderateScale(size) }, { scaleY: moderateScale(size) }] }, disabled: disabled, ...rest }) }); }; export default Switch; //# sourceMappingURL=Switch.js.map