Skip to content

Commit 501fb13

Browse files
(feat): add a tint color
1 parent e343ab4 commit 501fb13

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

index.d.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,20 @@ declare module 'react-native-circular-progress' {
4848
tintColor?: string;
4949

5050
/**
51-
* Change the fill color from tintColor to tintColorSecondary as animation progresses.
52-
*
51+
* Change the fill color from the first to the second color as animation progresses.
52+
*
53+
* @type {string}
54+
* @default 'undefined'
55+
*/
56+
secondTintColor?: string;
57+
58+
/**
59+
* Change the fill color from the second color to the third color as animation progresses.
60+
*
5361
* @type {string}
5462
* @default 'undefined'
5563
*/
56-
tintColorSecondary?: string;
64+
thirdTintColor?: string;
5765

5866
/**
5967
* Current progress / tint transparency
@@ -181,7 +189,7 @@ declare module 'react-native-circular-progress' {
181189

182190
export class AnimatedCircularProgress extends React.Component<
183191
AnimatedCircularProgressProps
184-
> {
192+
> {
185193
/**
186194
* Animate the progress bar to a specific value
187195
*

src/AnimatedCircularProgress.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default class AnimatedCircularProgress extends React.PureComponent {
3636
const duration = dur || this.props.duration;
3737
const easing = ease || this.props.easing;
3838
const useNativeDriver = this.props.useNativeDriver;
39-
39+
4040
const anim = Animated.timing(this.state.fillAnimation, {
4141
useNativeDriver,
4242
toValue,
@@ -49,13 +49,17 @@ export default class AnimatedCircularProgress extends React.PureComponent {
4949
}
5050

5151
animateColor() {
52-
if (!this.props.tintColorSecondary) {
52+
if (!this.props.secondTintColor) {
5353
return this.props.tintColor
5454
}
5555

56+
if (!this.props.thirdTintColor) {
57+
return this.props.secondTintColor
58+
}
59+
5660
const tintAnimation = this.state.fillAnimation.interpolate({
57-
inputRange: [0, 100],
58-
outputRange: [this.props.tintColor, this.props.tintColorSecondary]
61+
inputRange: [0, 50, 100],
62+
outputRange: [this.props.tintColor, this.props.secondTintColor, this.props.thirdTintColor]
5963
})
6064

6165
return tintAnimation

0 commit comments

Comments
 (0)