<ListItemWithSwitch
containerStyle={{ height: 72 }}
showSeparator={false}
title={PluginStrings.childLockSwitch}
value={this.state.controlLocked}
onTintColor={this.state.colorScheme == 'dark' ? '#544FE0' : "#706BF9"}
subtitle={PluginStrings.childLockSwitchTips}
onValueChange={(value) => {
if (this.state.homeVal.switchMessage) {
this.setState({
controlLocked: !value
});
}
specFunc.setDevicePropsValue(4, 1, value);
}}
titleStyle={{ fontSize: 16, color: this.state.colorScheme == 'dark' ? 'rgba(255,255,255,0.9)' : '#000' }}
subtitleStyle={{ fontSize: 13, color: this.state.colorScheme == 'dark' ? 'rgba(255,255,255,0.4)' : 'rgba(0,0,0,0.6)' }}
/>
Switch 还有两个事件回调函数
onValueChange
和 onChange
。前者当开关的值发生改变时触发,参数是 开关变更后的新值。 后者当用户尝试改变开关状态时触发,参数是 事件。