From d204116ed78fda45841310f8cbf174a2629afefb Mon Sep 17 00:00:00 2001 From: christiannicoletti Date: Thu, 10 Feb 2022 16:30:09 -0800 Subject: [PATCH 1/3] add: unfilledEndAngle prop to Circle.js, for dynamic instead of constant CIRCLE end angle --- Circle.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Circle.js b/Circle.js index 79f0a9e..ea45476 100644 --- a/Circle.js +++ b/Circle.js @@ -42,6 +42,7 @@ export class ProgressCircle extends Component { thickness: PropTypes.number, unfilledColor: PropTypes.string, endAngle: PropTypes.number, + unfilledEndAngle: PropTypes.number, allowFontScaling: PropTypes.bool, }; @@ -55,6 +56,7 @@ export class ProgressCircle extends Component { size: 40, thickness: 3, endAngle: 0.9, + unfilledEndAngle: 0.9, allowFontScaling: true, }; @@ -96,6 +98,7 @@ export class ProgressCircle extends Component { thickness, unfilledColor, endAngle, + unfilledEndAngle, allowFontScaling, ...restProps } = this.props; @@ -116,6 +119,9 @@ export class ProgressCircle extends Component { const angle = animated ? Animated.multiply(progress, CIRCLE) : progress * CIRCLE; + const endUnfilledAngleValue = animated + ? Animated.multiply(unfilledEndAngle, CIRCLE) + : unfilledEndAngle * CIRCLE; return ( @@ -143,7 +149,7 @@ export class ProgressCircle extends Component { radius={radius} offset={offset} startAngle={angle} - endAngle={CIRCLE} + endAngle={unfilledEndAngle >= progress._value ? endUnfilledAngleValue : angle} direction={direction} stroke={unfilledColor} strokeWidth={thickness} From e89b7c6cb44dbe2ef831b021980658c8faba7a10 Mon Sep 17 00:00:00 2001 From: christiannicoletti Date: Fri, 11 Feb 2022 12:36:08 -0800 Subject: [PATCH 2/3] fix: unfilledEndAngle wasn't updating properly & removed progressValue check --- Circle.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Circle.js b/Circle.js index ea45476..293d111 100644 --- a/Circle.js +++ b/Circle.js @@ -117,8 +117,8 @@ export class ProgressCircle extends Component { const Shape = animated ? AnimatedArc : Arc; const progressValue = animated ? this.progressValue : progress; const angle = animated - ? Animated.multiply(progress, CIRCLE) - : progress * CIRCLE; + ? Animated.multiply(Animated.multiply(progress, CIRCLE), unfilledEndAngle) + : progress * CIRCLE * unfilledEndAngle; const endUnfilledAngleValue = animated ? Animated.multiply(unfilledEndAngle, CIRCLE) : unfilledEndAngle * CIRCLE; @@ -143,13 +143,13 @@ export class ProgressCircle extends Component { : undefined } > - {unfilledColor && progressValue !== 1 ? ( + {unfilledColor ? ( = progress._value ? endUnfilledAngleValue : angle} + endAngle={endUnfilledAngleValue} direction={direction} stroke={unfilledColor} strokeWidth={thickness} From 095f68ff904851e948c5a08fbdf2074625ee6f30 Mon Sep 17 00:00:00 2001 From: christiannicoletti Date: Fri, 11 Feb 2022 12:38:01 -0800 Subject: [PATCH 3/3] remove: whitespace --- Circle.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Circle.js b/Circle.js index 293d111..3888fd4 100644 --- a/Circle.js +++ b/Circle.js @@ -117,8 +117,8 @@ export class ProgressCircle extends Component { const Shape = animated ? AnimatedArc : Arc; const progressValue = animated ? this.progressValue : progress; const angle = animated - ? Animated.multiply(Animated.multiply(progress, CIRCLE), unfilledEndAngle) - : progress * CIRCLE * unfilledEndAngle; + ? Animated.multiply(Animated.multiply(progress, CIRCLE), unfilledEndAngle) + : progress * CIRCLE * unfilledEndAngle; const endUnfilledAngleValue = animated ? Animated.multiply(unfilledEndAngle, CIRCLE) : unfilledEndAngle * CIRCLE;