UNPKG

@nexara/nativeflow

Version:

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

62 lines (61 loc) 1.75 kB
"use strict"; import React, { useEffect, useMemo, useRef } from 'react'; import { Animated, StyleSheet } from "react-native"; import { moderateScale, verticalScale } from "../../helpers/ResponsiveCalculations.js"; import { StyledView } from "../StyledComponents/index.js"; import { useTheme } from "../../hooks/index.js"; import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime"; const Progress = ({ value = 50, thickness = 5, br = 100, trackColor = '#E8E8E8', progressColor }) => { const animatedWidth = useRef(new Animated.Value(value)).current; const theme = useTheme(); useEffect(() => { Animated.timing(animatedWidth, { toValue: value / 100, duration: 1000, useNativeDriver: true }).start(); }, [value]); const dynamicStyles = useMemo(() => ({ TRACK: { backgroundColor: trackColor, borderRadius: moderateScale(br), height: verticalScale(thickness) }, TRACK_ITEM: { backgroundColor: progressColor ?? theme?.colors.primary, borderRadius: moderateScale(br) } }), [br, trackColor, thickness, progressColor, theme]); const animatedViewStyle = { transform: [{ scaleX: animatedWidth }], transformOrigin: 'left' }; return /*#__PURE__*/_jsx(_Fragment, { children: /*#__PURE__*/_jsx(StyledView, { style: [STYLES.TRACK, dynamicStyles.TRACK], children: /*#__PURE__*/_jsx(Animated.View, { style: [STYLES.TRACK_ITEM, dynamicStyles.TRACK_ITEM, animatedViewStyle] }) }) }); }; export default Progress; const STYLES = StyleSheet.create({ TRACK: { overflow: 'hidden', width: '100%' }, TRACK_ITEM: { width: "100%", height: '100%' } }); //# sourceMappingURL=Progress.js.map