Skip to content
This repository has been archived by the owner on Jan 3, 2021. It is now read-only.

add clockwise progress #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ render() {
| percent | The percentage used for displaying the progress | Number | ✓ | |
| radius | The radius in `px` of the component (including border) | Number | ✓ | |
| borderWidth | The border width in `px` | Number | ✓ | |
| upendProgress | Clockwise progress | Boolean | | false |
| color | The border color | String | | ![#f00](https://placehold.it/15/f00/000000?text=+) `'#f00'` |
| shadowColor | The background color of the border | String | | ![#999](https://placehold.it/15/999/000000?text=+) `'#999'` |
| bgColor | The inner background color of the component | String | | ![#e9e9ef](https://placehold.it/15/e9e9ef/000000?text=+) `'#e9e9ef'` |
Expand Down
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default class PercentageCircle extends Component {
radius: PropTypes.number.isRequired,
borderWidth: PropTypes.number,
percent: PropTypes.number.isRequired, // eslint-disable-line react/no-unused-prop-types
upendProgress: PropTypes.bool,
children: PropTypes.node,
containerStyle: ViewPropTypesStyle,
outerCircleStyle: ViewPropTypesStyle
Expand All @@ -55,6 +56,7 @@ export default class PercentageCircle extends Component {
borderWidth: 2,
children: null,
containerStyle: null,
upendProgress: false
};

computeDerivedState() {
Expand Down Expand Up @@ -86,6 +88,10 @@ export default class PercentageCircle extends Component {
}

renderHalfCircle(rotateDegrees, halfCircleStyles) {
if (this.props.upendProgress) {
rotateDegrees = -rotateDegrees + 180;
}

const { radius, color } = this.props
const key = I18nManager.isRTL ? 'right' : 'left';
return (
Expand Down