由于是旧项目,需要维护,所以暂时还没有迁移到小程序
设计目标,在弹窗页面中,通过滑动条和TouchOpacity来修改testValue,并通过Text显示
测试结果发现:拖动滑条后通过加减,Text的组件均不会发生改变,通过日志是可以发现testValue的值有修改成功的
Code: Select all
/* 以下是代码示例片段 */
_popupView=()=>{
const {testValue}=this.state;
const ActiveThemeColor = '#0277ED';
Popup.custom({
title:"测试",
content:(
<View style={{width:'100%',height:cx(320),backgroundColor:'#ffffff',borderRadius:cx(10),padding:cx(20),display:'flex',flexDirection:'column'}}>
<View style={{width:'100%',height:cx(60),display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center'}}>
<Text style={{fontSize:12,color:'#3B4051',height:cx(15)}}>{(testValue-100)/10}%</Text>
<View style={{width:'100%',height:cx(40),display:'flex',flexDirection:'row',alignItems:'center',justifyContent:'space-between',marginBottom:cx(10)}}
onPress={()=>{
let value = testValue-10;
if(value<0){
value=0;
}
this.setState({
testValue:value
})
}}
>
<TouchableOpacity style={{width:'5%',backgroundColor:ActiveFontColor,justifyContent:'center',alignItems:'center',borderRadius:cx(6)}}>
<Text style={{color:'white',fontSize:Math.max(13, cx(13)),fontWeight:'400'}}>-</Text>
</TouchableOpacity>
<Slider value={testValue} onValueChange={(value)=>{
console.log('滑动了'+value)
this.setState({
testValue:value
})
}
}
style={{width:'80%',height:cx(40)}}
minimumValue={0}
maximumValue={200}
stepValue={1}
minimumTrackTintColor={ActiveThemeColor}
thumbTintColor={ActiveThemeColor}
thumbStyle={{borderWidth:6,backgroundColor:'white',borderColor:ActiveThemeColor}}
/>
<TouchableOpacity style={{width:'5%',backgroundColor:ActiveFontColor,justifyContent:'center',alignItems:'center',borderRadius:cx(6)}}
onPress={()=>{
let value = testValue+10;
if(value>200){
value=200;
}
this.setState({
testValue:value
})
}}
>
<Text style={{color:'white',fontSize:Math.max(13, cx(13)),fontWeight:'400'}}>+</Text>
</TouchableOpacity>
</View>
</View>
</View>
),
onMaskPress:({close})=>{close()},
motionType:'none',
footer: <View style={{marginBottom:cx(10)}}></View>,
})
}