Skip to content

Commit b7b3553

Browse files
committed
v0.1.3 #1
1 parent bc9b5b5 commit b7b3553

File tree

6 files changed

+39
-12
lines changed

6 files changed

+39
-12
lines changed

.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
example/
2+
npm-debug.log
3+
node_modules
4+
.DS_Store
5+
.idea

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@ npm install rn-spinner --save
1616
var Spinner = require('rn-spinner');
1717
1818
// Use
19-
<Spinner max={10} min={2} onNumChange={(num)=>{console.log(num)}}
19+
<Spinner max={10}
20+
min={2}
21+
default={5}
22+
color="#f60"
23+
onNumChange={(num)=>{console.log(num)}}
2024
```
2125

2226
## Props
2327

2428
- max
2529
- min
30+
- default: default number of the Spinner
2631
- onNumChange: get the number of the Spinner
32+
- color: custom color of the Spinner
2733

2834
## Screenshot
2935

example.png

23.7 KB
Loading

index.js

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,32 @@ var styles = require('./style');
66
var {
77
View,
88
Text,
9-
TouchableOpacity
9+
TouchableOpacity,
10+
PropTypes
1011
} = React;
1112

1213
var Spinner = React.createClass({
14+
propTypes: {
15+
min: PropTypes.number,
16+
max: PropTypes.number,
17+
default: PropTypes.number,
18+
color: PropTypes.string
19+
},
20+
21+
getDefaultProps () {
22+
return {
23+
min: 0,
24+
max: 99,
25+
default: 0,
26+
color: '#33c9d6'
27+
}
28+
},
29+
1330
getInitialState () {
1431
return {
15-
min: this.props.min || 0,
16-
max: this.props.max || 99,
17-
num: this.props.default || 0
32+
min: this.props.min,
33+
max: this.props.max,
34+
num: this.props.default
1835
}
1936
},
2037

@@ -46,14 +63,14 @@ var Spinner = React.createClass({
4663

4764
render () {
4865
return (
49-
<View style={styles.container}>
50-
<TouchableOpacity style={styles.btn} onPress={this._decrease}>
66+
<View style={[styles.container, {borderColor:this.props.color}]}>
67+
<TouchableOpacity style={[styles.btn, {backgroundColor:this.props.color}]} onPress={this._decrease}>
5168
<Text style={styles.btnText}>-</Text>
5269
</TouchableOpacity>
5370
<View style={styles.num}>
5471
<Text style={styles.numText}>{this.state.num}</Text>
5572
</View>
56-
<TouchableOpacity style={styles.btn} onPress={this._increase}>
73+
<TouchableOpacity style={[styles.btn, {backgroundColor:this.props.color}]} onPress={this._increase}>
5774
<Text style={styles.btnText}>+</Text>
5875
</TouchableOpacity>
5976
</View>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rn-spinner",
3-
"version": "0.1.1",
3+
"version": "0.1.3",
44
"description": "Number spinner for react-native",
55
"keywords": ["react-native", "spinner", "react-component"],
66
"author": {

style.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ var React = require('react-native');
22

33
module.exports = React.StyleSheet.create({
44
container: {
5-
borderColor:'#33c9d6',
65
borderWidth:1,
76
borderRadius:4,
7+
width: 90,
88
flexDirection:'row'
99
},
1010

1111
btn: {
1212
paddingVertical:5,
13-
paddingHorizontal:10,
14-
backgroundColor:'#33c9d6'
13+
paddingHorizontal:10
1514
},
1615

1716
btnText: {

0 commit comments

Comments
 (0)