1
- 'use strict' ;
2
-
3
- var React = require ( 'react-native' ) ;
4
- var styles = require ( './style' ) ;
1
+ var React = require ( 'react-native' )
2
+ var styles = require ( './style' )
5
3
6
4
var {
7
5
View,
8
6
Text,
9
7
TouchableOpacity,
10
8
PropTypes
11
- } = React ;
9
+ } = React
12
10
13
11
var Spinner = React . createClass ( {
14
12
propTypes : {
@@ -54,34 +52,35 @@ var Spinner = React.createClass({
54
52
} ,
55
53
56
54
_onNumChange ( num ) {
57
- if ( this . props . onNumChange ) this . props . onNumChange ( num ) ;
55
+ if ( this . props . onNumChange ) this . props . onNumChange ( num )
58
56
} ,
59
57
60
58
_increase ( ) {
61
- if ( this . props . disabled ) return ;
59
+ if ( this . props . disabled ) return
62
60
63
61
if ( this . state . max > this . state . num ) {
64
- var num = this . state . num ;
62
+ var num = this . state . num
65
63
this . setState ( {
66
64
num : ++ num
67
- } ) ;
65
+ } )
68
66
69
- this . _onNumChange ( num ) ;
67
+ this . _onNumChange ( num )
70
68
}
71
- } ,
69
+ } ,
72
70
73
- _decrease ( ) {
74
- if ( this . props . disabled ) return ;
71
+ _decrease ( ) {
72
+ if ( this . props . disabled ) return
75
73
76
- if ( this . state . min < this . state . num ) {
77
- var num = this . state . num ;
78
- this . setState ( {
79
- num : -- num
80
- } ) ;
74
+ if ( this . state . min < this . state . num ) {
75
+ var num = this . state . num
81
76
82
- this . _onNumChange ( num ) ;
83
- }
84
- } ,
77
+ this . setState ( {
78
+ num : -- num
79
+ } )
80
+
81
+ this . _onNumChange ( num )
82
+ }
83
+ } ,
85
84
86
85
render ( ) {
87
86
return (
@@ -95,34 +94,26 @@ var Spinner = React.createClass({
95
94
{ height : this . props . height } ] }
96
95
onPress = { this . _decrease } >
97
96
< Text style = { [ styles . btnText ,
98
- {
99
- color : this . props . buttonTextColor ,
100
- fontSize : this . props . btnFontSize
101
- } ] } > -</ Text >
97
+ { color : this . props . buttonTextColor , fontSize : this . props . btnFontSize } ] } > -</ Text >
102
98
</ TouchableOpacity >
103
99
< View style = { [ styles . num ,
104
- {
105
- borderColor : this . props . showBorder ? this . props . color : 'transparent' ,
106
- backgroundColor : this . props . numBgColor ,
107
- height : this . props . height
100
+ { borderColor : this . props . showBorder ? this . props . color : 'transparent' , backgroundColor : this . props . numBgColor , height : this . props . height
108
101
} ] } >
109
- < Text style = { [ styles . numText , { color :this . props . numColor , fontSize : this . props . fontSize } ] } > { this . state . num } </ Text >
102
+ < Text style = { [ styles . numText , { color : this . props . numColor , fontSize : this . props . fontSize } ] } > { this . state . num } </ Text >
110
103
</ View >
111
104
< TouchableOpacity
112
105
style = { [ styles . btn ,
113
106
{ backgroundColor : this . props . color } ,
114
107
{ borderColor : this . props . showBorder ? this . props . color : 'transparent' } ,
115
- { height : this . props . height } ] }
108
+ { height : this . props . height } ] }
116
109
onPress = { this . _increase } >
117
110
< Text style = { [ styles . btnText ,
118
- {
119
- color : this . props . buttonTextColor ,
120
- fontSize : this . props . btnFontSize
111
+ { color : this . props . buttonTextColor , fontSize : this . props . btnFontSize
121
112
} ] } > +</ Text >
122
113
</ TouchableOpacity >
123
114
</ View >
124
- ) ;
115
+ )
125
116
}
126
- } ) ;
117
+ } )
127
118
128
- module . exports = Spinner ;
119
+ module . exports = Spinner
0 commit comments