From 4f39c40614e406ad88d652fb2fe71b9a5e4d8095 Mon Sep 17 00:00:00 2001 From: Phillip Date: Wed, 22 Feb 2023 17:07:42 +1100 Subject: [PATCH 1/4] :sparkles: Support rendering an arc cutout of Circle --- Circle.js | 10 +++++++--- index.d.ts | 10 ++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Circle.js b/Circle.js index 79f0a9e..504d0a3 100644 --- a/Circle.js +++ b/Circle.js @@ -43,6 +43,7 @@ export class ProgressCircle extends Component { unfilledColor: PropTypes.string, endAngle: PropTypes.number, allowFontScaling: PropTypes.bool, + archPercentage: PropTypes.number, }; static defaultProps = { @@ -55,6 +56,7 @@ export class ProgressCircle extends Component { size: 40, thickness: 3, endAngle: 0.9, + archPercentage: 1, allowFontScaling: true, }; @@ -96,12 +98,14 @@ export class ProgressCircle extends Component { thickness, unfilledColor, endAngle, + archPercentage, allowFontScaling, ...restProps } = this.props; const border = borderWidth || (indeterminate ? 1 : 0); + const circle = CIRCLE * archPercentage; const radius = size / 2 - border; const offset = { top: border, @@ -114,8 +118,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(progress, circle) + : progress * circle; return ( @@ -143,7 +147,7 @@ export class ProgressCircle extends Component { radius={radius} offset={offset} startAngle={angle} - endAngle={CIRCLE} + endAngle={circle} direction={direction} stroke={unfilledColor} strokeWidth={thickness} diff --git a/index.d.ts b/index.d.ts index 76a62c0..c9fe1d4 100644 --- a/index.d.ts +++ b/index.d.ts @@ -242,6 +242,16 @@ declare module 'react-native-progress' { * @default 0.9 */ endAngle?: number; + + + /** + * A percentage of the circle to render. Value less than 1 renders an arc + * + * @type {number} + * @memberof CirclePropTypes + * @default 1 + */ + archPercentage?: number } /** From 852561cfc19b0c2113b7739a57e1e5da7bb23931 Mon Sep 17 00:00:00 2001 From: Phillip Date: Wed, 22 Feb 2023 17:07:55 +1100 Subject: [PATCH 2/4] :sparkles: Support rotating Circle progress --- Circle.js | 10 +++++++--- index.d.ts | 9 +++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Circle.js b/Circle.js index 504d0a3..c2054b5 100644 --- a/Circle.js +++ b/Circle.js @@ -90,6 +90,7 @@ export class ProgressCircle extends Component { indeterminate, progress, rotation, + rotationStatic, showsText, size, style, @@ -126,7 +127,7 @@ export class ProgressCircle extends Component { {unfilledColor && progressValue !== 1 ? ( Date: Thu, 23 Feb 2023 11:46:43 +1100 Subject: [PATCH 3/4] :recycle: Rename circleAngle variable --- Circle.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Circle.js b/Circle.js index c2054b5..61c1e2d 100644 --- a/Circle.js +++ b/Circle.js @@ -106,7 +106,7 @@ export class ProgressCircle extends Component { const border = borderWidth || (indeterminate ? 1 : 0); - const circle = CIRCLE * archPercentage; + const circleAngle = CIRCLE * archPercentage; const radius = size / 2 - border; const offset = { top: border, @@ -119,8 +119,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(progress, circleAngle) + : progress * circleAngle; return ( @@ -151,7 +151,7 @@ export class ProgressCircle extends Component { radius={radius} offset={offset} startAngle={angle} - endAngle={circle} + endAngle={circleAngle} direction={direction} stroke={unfilledColor} strokeWidth={thickness} From 3aded92d8fe4490c39c234ec0885a5c9f9eacc20 Mon Sep 17 00:00:00 2001 From: Phillip Date: Thu, 23 Feb 2023 12:05:31 +1100 Subject: [PATCH 4/4] :recycle: Add proptype for rotationStatic --- Circle.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Circle.js b/Circle.js index 61c1e2d..eaf39a3 100644 --- a/Circle.js +++ b/Circle.js @@ -34,6 +34,7 @@ export class ProgressCircle extends Component { PropTypes.instanceOf(Animated.Value), ]), rotation: PropTypes.instanceOf(Animated.Value), + rotationStatic: PropTypes.number, showsText: PropTypes.bool, size: PropTypes.number, style: PropTypes.any,