UNPKG

@nexara/nativeflow

Version:

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

67 lines (66 loc) 2.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _react = require("react"); var _reactNative = require("react-native"); var _ResponsiveCalculations = require("../../helpers/ResponsiveCalculations.js"); var _index = require("../StyledComponents/index.js"); var _index2 = require("../../hooks/index.js"); var _jsxRuntime = require("react/jsx-runtime"); const Progress = ({ value = 50, thickness = 5, br = 100, trackColor, progressColor }) => { const animatedWidth = (0, _react.useRef)(new _reactNative.Animated.Value(value)).current; const theme = (0, _index2.useTheme)(); trackColor = trackColor ?? theme?.colors.palette.natural[200]; (0, _react.useEffect)(() => { _reactNative.Animated.timing(animatedWidth, { toValue: value / 100, duration: 1000, useNativeDriver: true }).start(); }, [value]); const dynamicStyles = (0, _react.useMemo)(() => ({ TRACK: { backgroundColor: trackColor, borderRadius: (0, _ResponsiveCalculations.verticalScale)(br), height: (0, _ResponsiveCalculations.verticalScale)(thickness) }, TRACK_ITEM: { backgroundColor: progressColor ?? theme?.colors.brand.primary, borderRadius: (0, _ResponsiveCalculations.verticalScale)(br) } }), [br, trackColor, thickness, progressColor, theme]); const animatedViewStyle = { transform: [{ scaleX: animatedWidth }], transformOrigin: 'left' }; return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, { children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.StyledView, { style: [STYLES.TRACK, dynamicStyles.TRACK], children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, { style: [STYLES.TRACK_ITEM, dynamicStyles.TRACK_ITEM, animatedViewStyle] }) }) }); }; var _default = exports.default = Progress; const STYLES = _reactNative.StyleSheet.create({ TRACK: { overflow: 'hidden', width: '100%' }, TRACK_ITEM: { width: "100%", height: '100%' } }); //# sourceMappingURL=Progress.js.map