Skip to content
Open
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
27 changes: 14 additions & 13 deletions ProgressBar.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var React = require('react-native');
import React,{Component} from 'react';

var {
import {
Animated,
Easing,
StyleSheet,
View
} = React;
} from 'react-native';

var styles = StyleSheet.create({
background: {
Expand All @@ -19,27 +19,28 @@ var styles = StyleSheet.create({
}
});

var ProgressBar = React.createClass({
class ProgressBar extends Component{

state:any
constructor(props){
super(props);
this.state = {progress:new Animated.Value(0)}
}
getDefaultProps() {
return {
style: styles,
easing: Easing.inOut(Easing.ease),
easingDuration: 500
};
},
}


getInitialState() {
return {
progress: new Animated.Value(this.props.initialProgress || 0)
};
},

componentDidUpdate(prevProps, prevState) {
if (this.props.progress >= 0 && this.props.progress != prevProps.progress) {
this.update();
}
},
}

render() {

Expand All @@ -53,7 +54,7 @@ var ProgressBar = React.createClass({
<Animated.View style={[styles.fill, this.props.fillStyle, { width: fillWidth }]}/>
</View>
);
},
}

update() {
Animated.timing(this.state.progress, {
Expand All @@ -62,6 +63,6 @@ var ProgressBar = React.createClass({
toValue: this.props.progress
}).start();
}
});
}

module.exports = ProgressBar;