Button('点击我可以获取一个文本滑动选择器弹窗')
.onClick(() => {
TextPickerDialog.show({
range: ['苹果', '香蕉', '火龙果'],
selected: 0,
// range: [['苹果', '香蕉', '火龙果'], ['上海', '江苏']],
// selected: [0, 0],
defaultPickerItemHeight: 60, // 每个项的高度
alignment: DialogAlignment.Center,
disappearTextStyle: {
color: Color.Orange,
font: {
size: 20,
weight: FontWeight.Lighter
}
},
textStyle: {
color: Color.Black,
font: {
size: 20,
weight: FontWeight.Normal
}
},
selectedTextStyle: {
color: Color.Green,
font: {
size: 30,
weight: FontWeight.Bolder
}
},
onAccept: val => {
console.log('onAccept', JSON.stringify(val))
},
onCancel: () => {
console.log('onCancel')
},
onChange: val => {
console.log('onChange', JSON.stringify(val))
},
onDidAppear: () => {
console.log('onDidAppear')
},
onDidDisappear: () => {
console.log('onDidDisappear')
},
onWillAppear: () => {
console.log('onWillAppear')
},
onWillDisappear: () => {
console.log('onWillDisappear')
},
// 按钮默认是文字按钮,可以设置背景的
acceptButtonStyle: {
type: ButtonType.Normal, // 按钮形状
style: ButtonStyleMode.EMPHASIZED, // 按钮背景
role: ButtonRole.NORMAL, // 按钮背景,有警告色红色
backgroundColor: Color.Black, // 按钮背景,会覆盖上面两个背景
borderRadius: 10 // 只能在type=normal时生效
},
cancelButtonStyle: {
type: ButtonType.Capsule,
style: ButtonStyleMode.NORMAL
}
})
})