Files
address-verification-app/ProgressBar.tsx
Aman Singh ec07eca1f1 TP-82644 | Tele master hard release (#967)
Co-authored-by: Aman Chaturvedi <aman.chaturvedi@navi.com>
Co-authored-by: yashmantri <mantri.ramkishor@navi.com>
Co-authored-by: Varnit Goyal <varnit.goyal@navi.com>
Co-authored-by: github-cicd <github.cicd@navi.com>
Co-authored-by: Ashish Deo <ashish.deo@navi.com>
2024-10-08 17:34:39 +05:30

52 lines
1.1 KiB
TypeScript

import { COLORS } from '@rn-ui-lib/colors';
import React, { useState, useEffect } from 'react';
import { View, Animated, StyleSheet } from 'react-native';
type ProgressBarProps = {
progress: number;
height?: number;
color?: string;
};
const ProgressBar = ({ progress, height = 10, color = COLORS.TEXT.BLUE }: ProgressBarProps) => {
const [animatedWidth] = useState(new Animated.Value(0));
console.log({ progress });
useEffect(() => {
Animated.timing(animatedWidth, {
toValue: progress * 100,
useNativeDriver: false,
}).start();
}, [progress]);
return (
<View style={[styles.container, { height }]}>
<Animated.View
style={[
styles.fill,
{
width: animatedWidth.interpolate({
inputRange: [0, 100],
outputRange: ['0%', '100%'],
}),
backgroundColor: color,
},
]}
/>
</View>
);
};
const styles = StyleSheet.create({
container: {
backgroundColor: '#e0e0e0',
borderRadius: 8,
overflow: 'hidden',
},
fill: {
height: '100%',
},
});
export default ProgressBar;