自定义警告弹窗
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
|
||||
@CustomDialog
|
||||
export struct DefaultHintProWindows {
|
||||
@Prop title: string = '温馨提示';
|
||||
@Prop titleFont: number = 18;
|
||||
@Prop message: string = '';
|
||||
@Prop messageFont: number = 16;
|
||||
@Prop cancleTitle: string = '取消';
|
||||
@Prop cancleTitleColor:ResourceStr = '#666666';
|
||||
@Prop confirmTitle:string = '确定';
|
||||
@Prop confirmTitleColor:ResourceStr = '#000000';
|
||||
@Prop cancleColor:ResourceStr = '#FFFFFF';
|
||||
@Prop confirmColor:ResourceStr = '#FFFFFF';
|
||||
controller: CustomDialogController;
|
||||
|
||||
// 添加回调函数属性
|
||||
private selectedButton: (index: number) => void = () => {};
|
||||
|
||||
// 修改构造函数
|
||||
constructor(controller: CustomDialogController, selectedButton: (index:number) => void) {
|
||||
super();
|
||||
this.controller = controller;
|
||||
this.selectedButton = selectedButton;
|
||||
}
|
||||
|
||||
build() {
|
||||
Row(){
|
||||
Column() {
|
||||
Text(this.title)
|
||||
.fontSize(this.titleFont)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
.textAlign(TextAlign.Center)
|
||||
.margin({ top: 20 })
|
||||
|
||||
Text(this.message)
|
||||
.fontSize(this.messageFont)
|
||||
.textAlign(TextAlign.Center)
|
||||
.margin({ top: 10 })
|
||||
|
||||
Row({ space: 20 }) {
|
||||
Button({ buttonStyle: ButtonStyleMode.TEXTUAL }) {
|
||||
Text(this.cancleTitle)
|
||||
.fontSize(15)
|
||||
.fontColor(this.cancleTitleColor)
|
||||
}
|
||||
.width('45%').height(30).backgroundColor(this.cancleColor)
|
||||
.onClick(() => {
|
||||
this.selectedButton(0)
|
||||
})
|
||||
.visibility(this.cancleTitle?Visibility.Visible:Visibility.None)
|
||||
|
||||
Button({ buttonStyle: ButtonStyleMode.TEXTUAL }) {
|
||||
Text(this.confirmTitle)
|
||||
.fontSize(15)
|
||||
.fontColor(this.confirmTitleColor)
|
||||
}.width('45%').height(30).backgroundColor(this.cancleColor)
|
||||
.onClick(() => {
|
||||
this.selectedButton(1)
|
||||
})
|
||||
}.margin({ top: 20, bottom: 20 })
|
||||
}
|
||||
.width('100%').backgroundColor(Color.White)
|
||||
}.borderRadius(24)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user