UNPKG

@nexara/nativeflow

Version:

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

51 lines (50 loc) 1.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _reactNative = require("react-native"); var _ResponsiveCalculations = require("../../helpers/ResponsiveCalculations.js"); var _index = require("../../hooks/index.js"); var _color = _interopRequireDefault(require("color")); var _jsxRuntime = require("react/jsx-runtime"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } const Switch = ({ checked = true, color, disabled = false, size = 0.9, activeTrackColor, inactiveTrackColor, onChange, ...rest }) => { const { colors } = (0, _index.useTheme)(); const switchColor = disabled ? colors.states.disabled : color ?? colors.brand.primary; const disabledAndInActiveTrackColor = colors.palette.natural[200]; const generateActiveTrackColor = (0, _color.default)(colors.brand.primary).lighten(0).alpha(0.3).rgb().string(); return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, { children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Switch, { value: checked, trackColor: { true: disabled && disabledAndInActiveTrackColor || (activeTrackColor ?? generateActiveTrackColor), false: disabled && disabledAndInActiveTrackColor || (inactiveTrackColor ?? disabledAndInActiveTrackColor) }, thumbColor: switchColor, onValueChange: onChange, style: { transform: [{ scaleX: (0, _ResponsiveCalculations.verticalScale)(size) }, { scaleY: (0, _ResponsiveCalculations.verticalScale)(size) }] }, disabled: disabled, ...rest }) }); }; var _default = exports.default = Switch; //# sourceMappingURL=Switch.js.map