Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions Circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -43,6 +44,7 @@ export class ProgressCircle extends Component {
unfilledColor: PropTypes.string,
endAngle: PropTypes.number,
allowFontScaling: PropTypes.bool,
archPercentage: PropTypes.number,
};

static defaultProps = {
Expand All @@ -55,6 +57,7 @@ export class ProgressCircle extends Component {
size: 40,
thickness: 3,
endAngle: 0.9,
archPercentage: 1,
allowFontScaling: true,
};

Expand Down Expand Up @@ -88,6 +91,7 @@ export class ProgressCircle extends Component {
indeterminate,
progress,
rotation,
rotationStatic,
showsText,
size,
style,
Expand All @@ -96,12 +100,14 @@ export class ProgressCircle extends Component {
thickness,
unfilledColor,
endAngle,
archPercentage,
allowFontScaling,
...restProps
} = this.props;

const border = borderWidth || (indeterminate ? 1 : 0);

const circleAngle = CIRCLE * archPercentage;
const radius = size / 2 - border;
const offset = {
top: border,
Expand All @@ -114,15 +120,15 @@ 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 (
<View style={[styles.container, style]} {...restProps}>
<Surface
width={size}
height={size}
style={
style={[
indeterminate && rotation
? {
transform: [
Expand All @@ -134,16 +140,19 @@ export class ProgressCircle extends Component {
},
],
}
: undefined
}
: undefined,
rotationStatic ? {
transform: [{ rotate: `${rotationStatic}rad` }]
} : undefined
]}
>
{unfilledColor && progressValue !== 1 ? (
<Shape
fill={fill}
radius={radius}
offset={offset}
startAngle={angle}
endAngle={CIRCLE}
endAngle={circleAngle}
direction={direction}
stroke={unfilledColor}
strokeWidth={thickness}
Expand Down
19 changes: 19 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,25 @@ 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

/**
* Static amount in radians to rotate the circle
*
* @type {number}
* @memberof CirclePropTypes
* @default None
*/
rotationStatic?: number
}

/**
Expand Down