Skip to content

Commit

Permalink
isVisible property added
Browse files Browse the repository at this point in the history
  • Loading branch information
maxs15 committed Aug 23, 2015
1 parent 2e16bc3 commit e240d43
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
13 changes: 11 additions & 2 deletions Example/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ var Example = React.createClass({
index: 0,
types: ['CircleFlip', 'Bounce', 'Wave', 'WanderingCubes', 'Pulse', 'ChasingDots', 'ThreeBounce', 'Circle', '9CubeGrid', 'WordPress', 'FadingCircle', 'FadingCircleAlt', 'Arc', 'ArcAlt'],
size: 100,
color: "#FFFFFF"
color: "#FFFFFF",
isVisible: true
}
},

Expand All @@ -35,12 +36,16 @@ var Example = React.createClass({
this.setState({color: '#'+Math.floor(Math.random()*16777215).toString(16)});
},

changeVisibility() {
this.setState({isVisible: !this.state.isVisible});
},

render() {
var type = this.state.types[this.state.index];

return (
<View style={styles.container}>
<Spinner style={styles.spinner} size={this.state.size} type={type} color={this.state.color}/>
<Spinner style={styles.spinner} isVisible={this.state.isVisible} size={this.state.size} type={type} color={this.state.color}/>

<Text style={styles.text}>Type: {type}</Text>

Expand All @@ -55,6 +60,10 @@ var Example = React.createClass({
<TouchableOpacity style={styles.btn} onPress={this.changeColor}>
<Text style={styles.text}>Change color</Text>
</TouchableOpacity>

<TouchableOpacity style={styles.btn} onPress={this.changeVisibility}>
<Text style={styles.text}>Change visibility</Text>
</TouchableOpacity>
</View>
);
}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Check [index.ios.js](https://github.com/maxs15/react-native-spinkit/blob/master/

| Prop | Default | Type | Description |
| :------------ |:---------------:| :---------------:| :-----|
| isVisible | `true` | `boolean` | Visibility of the spinner |
| color | #000000 | `string` | Color of the spinner |
| size | 37 | `number` | Size of the spinner |
| type | Plane | `string` | Style type of the spinner |
Expand Down
9 changes: 7 additions & 2 deletions index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@ var React = require('React');
var {PropTypes} = React;

var requireNativeComponent = require('requireNativeComponent');
var View = require('View');


var Spinkit = React.createClass({
propTypes: {
type: PropTypes.string,
color: PropTypes.string,
size: PropTypes.number
size: PropTypes.number,
isVisible: PropTypes.bool
},

getDefaultProps() {
return {
size: 37,
color: "#000000"
color: "#000000",
isVisible: true
};
},

render() {
var size = {height: this.props.size, width: this.props.size};

if (!this.props.isVisible) return <View/>;
return (
<RNSpinkit
type={this.props.type}
Expand Down

0 comments on commit e240d43

Please sign in to comment.