import React, {useEffect, useRef} from 'react';
import {View, StyleSheet, Text, Animated} from 'react-native';
import Svg, {Defs, Rect} from 'react-native-svg';
import {styles} from './styles';
import LinearGradient from '../common/LinearGradient';
import {
useAnimatedThreeDBar,
animatedBarPropTypes,
trianglePropTypes,
} from 'gifted-charts-core';
const TriangleCorner = (props: trianglePropTypes) => {
return (
);
};
const triangleStyles = StyleSheet.create({
triangleCorner: {
width: 0,
height: 0,
backgroundColor: 'transparent',
borderStyle: 'solid',
borderRightColor: 'transparent',
transform: [{rotate: '90deg'}],
},
});
const AnimatedThreeDBar = (props: animatedBarPropTypes) => {
const {height, side} = props;
const {
isAnimated,
animationDuration,
item,
index,
barWidth,
sideWidth,
barStyle,
barBackgroundPattern,
barInnerComponent,
patternId,
intactTopLabel,
showValuesAsTopLabel,
topLabelContainerStyle,
topLabelTextStyle,
containerHeight,
} = props;
const {
showGradient,
gradientColor,
frontColor,
sideColor,
topColor,
opacity,
} = useAnimatedThreeDBar(props);
const animatedHeight = useRef(new Animated.Value(0)).current;
const elevate = () => {
Animated.timing(animatedHeight, {
toValue: height,
duration: animationDuration,
useNativeDriver: false,
}).start();
};
useEffect(() => {
if (isAnimated) {
elevate();
}
}, []);
return (
{/******************* Top View *****************/}
{props.height ? (
<>
>
) : null}
{/*******************************************************************/}
{showGradient && (
)}
{barBackgroundPattern && (
)}
{barInnerComponent ? (
{barInnerComponent(item, index)}
) : null}
{/******************* Top Label *****************/}
{(item.topLabelComponent || showValuesAsTopLabel) && (
{showValuesAsTopLabel ? (
{item.value}
) : (
item.topLabelComponent?.()
)}
)}
{/*******************************************************************/}
);
};
export default AnimatedThreeDBar;