-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #359 from backbonelabs/v2-posture-monitor
V2 posture monitor
- Loading branch information
Showing
18 changed files
with
737 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
app/components/posture/postureMonitor/AnimatedCircularProgress.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React, { Component, PropTypes } from 'react'; | ||
import { View, Animated } from 'react-native'; | ||
import CircularProgress from './CircularProgress'; | ||
|
||
const AnimatedProgress = Animated.createAnimatedComponent(CircularProgress); | ||
|
||
export default class AnimatedCircularProgress extends Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
chartFillAnimation: new Animated.Value(props.prefill || 0), | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
this.animateFill(); | ||
} | ||
|
||
componentDidUpdate(prevProps) { | ||
if (prevProps.fill !== this.props.fill) { | ||
this.animateFill(); | ||
} | ||
} | ||
|
||
animateFill() { | ||
const { tension, friction } = this.props; | ||
|
||
Animated.spring( | ||
this.state.chartFillAnimation, | ||
{ | ||
toValue: this.props.fill, | ||
tension, | ||
friction, | ||
} | ||
).start(); | ||
} | ||
|
||
performLinearAnimation(toValue, duration) { | ||
Animated.timing(this.state.chartFillAnimation, { | ||
toValue, | ||
duration, | ||
}).start(); | ||
} | ||
|
||
render() { | ||
const { fill, prefill, ...other } = this.props; // eslint-disable-line | ||
|
||
return ( | ||
<AnimatedProgress | ||
{...other} | ||
fill={this.state.chartFillAnimation} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
AnimatedCircularProgress.propTypes = { | ||
style: View.propTypes.style, | ||
size: PropTypes.number.isRequired, | ||
fill: PropTypes.number, | ||
prefill: PropTypes.number, | ||
width: PropTypes.number.isRequired, | ||
tintColor: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), | ||
backgroundColor: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), | ||
tension: PropTypes.number, | ||
friction: PropTypes.number, | ||
}; | ||
|
||
AnimatedCircularProgress.defaultProps = { | ||
tension: 7, | ||
friction: 10, | ||
}; |
Oops, something went wrong.