Created
October 11, 2022 08:28
-
-
Save sturmenta/c23697ac7fb5d6b0cc763616f25051dc to your computer and use it in GitHub Desktop.
react-native progress indicator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {useTheme} from '@react-navigation/native'; | |
import {ProgressChart} from 'react-native-chart-kit'; | |
import {MyThemeInterfaceColors, getPercentageInHex} from '_utils'; | |
import {useComponentTrackTrace} from '_hooks'; | |
interface ShowProgressProps { | |
progress: number; | |
height?: number; | |
width?: number; | |
} | |
export const ShowProgress: React.FC<ShowProgressProps> = ({ | |
progress, | |
height = 50, | |
width = 50, | |
}: ShowProgressProps) => { | |
useComponentTrackTrace('Component_ShowProgress'); | |
const colors = useTheme().colors as unknown as MyThemeInterfaceColors; | |
return ( | |
<ProgressChart | |
data={{data: [progress]}} | |
width={width} | |
height={height} | |
strokeWidth={6} | |
radius={20} | |
chartConfig={{ | |
backgroundGradientFromOpacity: 0, | |
backgroundGradientToOpacity: 0, | |
color: (opacity = 1) => | |
colors.primary + getPercentageInHex(opacity * 100), | |
}} | |
hideLegend={true} | |
/> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use:
<ShowProgress progress={0.4} />