@@ -14,6 +14,8 @@ export default class SimpleStepper extends Component {
14
14
valueChanged : PropTypes . func ,
15
15
tintOnIncrementImage : PropTypes . bool ,
16
16
tintOnDecrementImage : PropTypes . bool ,
17
+ imageHeight : PropTypes . number ,
18
+ imageWidth : PropTypes . number ,
17
19
incrementImage : PropTypes . oneOfType ( [
18
20
PropTypes . string ,
19
21
PropTypes . number
@@ -36,7 +38,9 @@ export default class SimpleStepper extends Component {
36
38
incrementImage : require ( './assets/increment.png' ) ,
37
39
tintOnIncrementImage : true ,
38
40
tintOnDecrementImage : true ,
39
- padding : 4
41
+ padding : 4 ,
42
+ imageHeight : 36 ,
43
+ imageWidth : 36
40
44
}
41
45
constructor ( props ) {
42
46
super ( props )
@@ -100,22 +104,38 @@ export default class SimpleStepper extends Component {
100
104
this . props . valueChanged ( value )
101
105
}
102
106
}
103
- render ( ) {
104
- var tintIncrementStyle
105
- var tintDecrementStyle
106
- if ( this . props . tintOnIncrementImage ) {
107
- tintIncrementStyle = { tintColor : this . props . tintColor }
107
+ tintStyle ( status ) {
108
+ if ( status ) {
109
+ return { tintColor : this . props . tintColor }
110
+ }
111
+ return null
112
+ }
113
+ imageSrc ( src ) {
114
+ if ( typeof src == 'string' ) {
115
+ return { 'uri' : src }
108
116
}
109
- if ( this . props . tintOnDecrementImage ) {
110
- tintDecrementStyle = { tintColor : this . props . tintColor }
117
+ return src
118
+ }
119
+ imageStyle ( src ) {
120
+ if ( typeof src == 'string' ) {
121
+ return { width : this . props . imageWidth , height : this . props . imageHeight }
111
122
}
123
+ return null
124
+ }
125
+ render ( ) {
126
+ var tintIncrementStyle = this . tintStyle ( this . props . tintOnIncrementImage )
127
+ var tintDecrementStyle = this . tintStyle ( this . props . tintOnDecrementImage )
128
+ var decrementImageSrc = this . imageSrc ( this . props . decrementImage )
129
+ var incrementImageSrc = this . imageSrc ( this . props . incrementImage )
130
+ var incrementStyle = this . imageStyle ( this . props . incrementImage )
131
+ var decrementStyle = this . imageStyle ( this . props . decrementImage )
112
132
return (
113
133
< View style = { [ styles . container , { backgroundColor : this . props . backgroundColor , borderColor : this . props . tintColor } ] } >
114
134
< TouchableHighlight style = { [ styles . leftButton , { opacity : this . state . decrementOpacity , borderColor : this . props . tintColor , padding : this . props . padding } ] } underlayColor = { this . props . underlayColor } onPress = { this . decrementAction } disabled = { this . state . hasReachedMin } >
115
- < Image style = { tintDecrementStyle } source = { this . props . decrementImage } resizeMode = "contain" />
135
+ < Image style = { [ decrementStyle , tintDecrementStyle ] } source = { decrementImageSrc } />
116
136
</ TouchableHighlight >
117
137
< TouchableHighlight style = { [ styles . rightButton , { opacity : this . state . incrementOpacity , borderColor : this . props . tintColor , padding : this . props . padding } ] } underlayColor = { this . props . underlayColor } onPress = { this . incrementAction } disabled = { this . state . hasReachedMax } >
118
- < Image style = { tintIncrementStyle } source = { this . props . incrementImage } resizeMode = "contain" />
138
+ < Image style = { [ incrementStyle , tintIncrementStyle ] } source = { incrementImageSrc } />
119
139
</ TouchableHighlight >
120
140
</ View >
121
141
)
@@ -128,7 +148,8 @@ var styles = StyleSheet.create({
128
148
justifyContent : 'center' ,
129
149
borderWidth : 1 ,
130
150
borderRadius : 3 ,
131
- overflow : 'hidden'
151
+ overflow : 'hidden' ,
152
+ alignItems : 'center'
132
153
} ,
133
154
leftButton : {
134
155
alignItems : 'center'
0 commit comments