File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ export default class SwitchButton extends Component{
26
26
onTintColor :PropTypes . string , //开启时的背景颜色
27
27
thumbTintColor :PropTypes . string , //原型按钮的背景颜色
28
28
tintColor :PropTypes . string , //关闭时的背景颜色
29
+ disabled :PropTypes . bool ,
29
30
}
30
31
//开关转换
31
32
toggleSwitch = ( ) => {
@@ -84,9 +85,9 @@ export default class SwitchButton extends Component{
84
85
}
85
86
}
86
87
render ( ) {
87
- let { onTintColor, tintColor, thumbTintColor} = this . props ;
88
+ let { onTintColor, tintColor, thumbTintColor, disabled } = this . props ;
88
89
return (
89
- < TouchableWithoutFeedback onPress = { this . toggleSwitch } >
90
+ < TouchableWithoutFeedback disabled = { disabled } onPress = { this . toggleSwitch } >
90
91
< Animated . View style = {
91
92
[ styles . container , { backgroundColor :this . state . animatedColor . interpolate ( {
92
93
inputRange : [ 0 , 0.1 , 1 ] ,
@@ -105,7 +106,8 @@ SwitchButton.defaultProps={
105
106
onValueChange :( ) => { } ,
106
107
onTintColor :'#00cc33' , //开启时的背景颜色
107
108
thumbTintColor :"#fff" , //原型按钮的背景颜色
108
- tintColor :'#DDD'
109
+ tintColor :'#DDD' ,
110
+ disabled :false
109
111
}
110
112
const styles = StyleSheet . create ( {
111
113
container :{
You can’t perform that action at this time.
0 commit comments