Skip to content

Commit 17ba197

Browse files
committed
add disabled prop
1 parent bdc94b1 commit 17ba197

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/SwitchButton.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default class SwitchButton extends Component{
2626
onTintColor:PropTypes.string,//开启时的背景颜色
2727
thumbTintColor:PropTypes.string,//原型按钮的背景颜色
2828
tintColor:PropTypes.string,//关闭时的背景颜色
29+
disabled:PropTypes.bool,
2930
}
3031
//开关转换
3132
toggleSwitch=()=>{
@@ -84,9 +85,9 @@ export default class SwitchButton extends Component{
8485
}
8586
}
8687
render(){
87-
let {onTintColor,tintColor,thumbTintColor} = this.props;
88+
let {onTintColor,tintColor,thumbTintColor,disabled} = this.props;
8889
return(
89-
<TouchableWithoutFeedback onPress={this.toggleSwitch}>
90+
<TouchableWithoutFeedback disabled={disabled} onPress={this.toggleSwitch}>
9091
<Animated.View style={
9192
[styles.container, {backgroundColor:this.state.animatedColor.interpolate({
9293
inputRange: [0,0.1,1],
@@ -105,7 +106,8 @@ SwitchButton.defaultProps={
105106
onValueChange:()=>{},
106107
onTintColor:'#00cc33',//开启时的背景颜色
107108
thumbTintColor:"#fff",//原型按钮的背景颜色
108-
tintColor:'#DDD'
109+
tintColor:'#DDD',
110+
disabled:false
109111
}
110112
const styles = StyleSheet.create({
111113
container:{

0 commit comments

Comments
 (0)