aboutsummaryrefslogtreecommitdiff
path: root/src/components/common/GradientProgressBar.tsx
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-07-23 18:53:15 -0400
committerGitHub <noreply@github.com>2021-07-23 18:53:15 -0400
commit88b8d6c732d871ddf48bb6a4a1bb8cfb27f0bc1d (patch)
tree0e36f5b9258a2104d35bb929546575df4b0bfd22 /src/components/common/GradientProgressBar.tsx
parent14c151ba80672938fecd4768b30f5812bd0a996e (diff)
parente39fcbd9e35f6a5e36afe248e24bea0dd3859202 (diff)
Merge branch 'master' into tma985-moment-view-count
Diffstat (limited to 'src/components/common/GradientProgressBar.tsx')
-rw-r--r--src/components/common/GradientProgressBar.tsx48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/components/common/GradientProgressBar.tsx b/src/components/common/GradientProgressBar.tsx
new file mode 100644
index 00000000..fc62bd3c
--- /dev/null
+++ b/src/components/common/GradientProgressBar.tsx
@@ -0,0 +1,48 @@
+import React, {FC} from 'react';
+import {StyleSheet, ViewProps, ViewStyle} from 'react-native';
+import LinearGradient from 'react-native-linear-gradient';
+import Animated, {useAnimatedStyle} from 'react-native-reanimated';
+import {
+ TAGG_LIGHT_BLUE_2,
+ TAGG_LIGHT_BLUE_3,
+ TAGG_PURPLE,
+} from '../../constants';
+import {normalize} from '../../utils';
+
+interface GradientProgressBarProps extends ViewProps {
+ progress: Animated.SharedValue<number>;
+}
+
+const GradientProgressBar: FC<GradientProgressBarProps> = ({
+ style,
+ progress,
+}) => {
+ const animatedProgressStyle = useAnimatedStyle<ViewStyle>(() => ({
+ width: `${(1 - progress.value) * 100}%`,
+ }));
+ return (
+ <LinearGradient
+ style={[styles.bar, style]}
+ useAngle={true}
+ colors={[TAGG_PURPLE, TAGG_LIGHT_BLUE_2]}>
+ <Animated.View style={[styles.blank, animatedProgressStyle]} />
+ </LinearGradient>
+ );
+};
+const styles = StyleSheet.create({
+ container: {
+ borderRadius: 6.5,
+ },
+ bar: {
+ height: normalize(10),
+ borderRadius: 6.5,
+ },
+ blank: {
+ alignSelf: 'flex-end',
+ height: normalize(10),
+ width: '80%',
+ backgroundColor: TAGG_LIGHT_BLUE_3,
+ },
+});
+
+export default GradientProgressBar;