diff --git a/src/SegmentedArc.js b/src/SegmentedArc.js index c06f972..9d56934 100644 --- a/src/SegmentedArc.js +++ b/src/SegmentedArc.js @@ -27,6 +27,7 @@ export const SegmentedArc = ({ rangesTextStyle = styles.rangeTextStyle, capInnerColor = '#28E037', capOuterColor = '#FFFFFF', + angleStart = 0, children }) => { const [arcAnimatedValue] = useState(new Animated.Value(0)); @@ -41,7 +42,7 @@ export const SegmentedArc = ({ const totalSpacing = totalSpaces * spaceBetweenSegments; const arcSegmentDegree = (arcDegree - totalSpacing) / totalArcs; - const arcsStart = 90 - arcDegree / 2; + const arcsStart = angleStart || 90 - arcDegree / 2; const effectiveRadius = radius + Math.max(filledArcWidth, emptyArcWidth); const margin = 12; @@ -216,7 +217,8 @@ SegmentedArc.propTypes = { rangesTextColor: PropTypes.string, rangesTextStyle: PropTypes.object, capInnerColor: PropTypes.string, - capOuterColor: PropTypes.string + capOuterColor: PropTypes.string, + angleStart: PropTypes.number }; export { SegmentedArcContext }; export default SegmentedArc; diff --git a/src/__tests__/SegmentedArc.spec.js b/src/__tests__/SegmentedArc.spec.js index f6fe786..03783b0 100644 --- a/src/__tests__/SegmentedArc.spec.js +++ b/src/__tests__/SegmentedArc.spec.js @@ -154,4 +154,10 @@ describe('SegmentedArc', () => { expect(Animated.timing).toHaveBeenCalledTimes(1); expect(Easing.out).toHaveBeenCalledWith(Easing.ease); }); + + it('sets the arc starting point', () => { + props.angleStart = 420; + wrapper = getWrapper(props); + expect(wrapper.getByTestId(testId).props).toMatchSnapshot(); + }); }); diff --git a/src/__tests__/__snapshots__/SegmentedArc.spec.js.snap b/src/__tests__/__snapshots__/SegmentedArc.spec.js.snap index 21e4c7b..f1eeced 100644 --- a/src/__tests__/__snapshots__/SegmentedArc.spec.js.snap +++ b/src/__tests__/__snapshots__/SegmentedArc.spec.js.snap @@ -742,6 +742,132 @@ exports[`SegmentedArc renders with middle content 1`] = ` } `; +exports[`SegmentedArc sets the arc starting point 1`] = ` +{ + "children": [ + + + + + + + + + , + undefined, + ], + "style": { + "alignItems": "center", + }, + "testID": "container", +} +`; + exports[`SegmentedArc sets the last segment for lastFilledSegment prop when fillValue is equal or greater than 100% 1`] = ` { "children": [