MyCustomDialog.ets
2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
@CustomDialog
export struct MyCustomDialog {
@State title: string = "标题"
@State titleShow: boolean = true
@State tipValue: string ="提示文字"
@State tipShow: boolean = true
@State cancelIsLeft :boolean = true//取消是否在左边
@State leftText: string = "取消"
@State rightText: string = "确认"
@State leftTextColor: Resource = $r('app.color.color_333333')
@State rightTextColor: Resource = $r('app.color.color_648DF2')
controller: CustomDialogController
cancel: () => void = () => {
}
confirm: () => void = () => {
}
build() {
Column() {
Column(){
if(this.titleShow){
Text(this.title)
.fontSize("32lpx")
.fontColor($r('app.color.color_333333'))
.lineHeight('50lpx')
.fontWeight(600)
}
if(this.tipShow){
Text(this.tipValue)
.margin({ top:this.titleShow?"10lpx":"0lpx" })
.fontSize("27lpx")
.fontWeight(400)
.lineHeight('38lpx')
.fontColor($r('app.color.color_999999'))
}
}.padding({top:"48lpx",bottom:"48lpx"})
.alignItems(HorizontalAlign.Center)
Divider()
.width("100%")
.strokeWidth('1lpx')
.height('1lpx')
.color($r('app.color.color_EEEEEE'))
Row(){
Text(this.leftText)
.fontSize('35lpx')
.fontWeight(400)
.fontColor(this.leftTextColor)
.onClick(() => {
if (this.controller != undefined){
if(this.cancelIsLeft){
this.controller.close()
this.cancel()
}else{
this.controller.close()
this.confirm()
}
}
}).layoutWeight(1)
.textAlign(TextAlign.Center)
Divider()
.width("1lpx")
.strokeWidth('1lpx')
.vertical(true)
.height('92lpx')
.color($r('app.color.color_EEEEEE'))
Text(this.rightText)
.fontSize('35lpx')
.textAlign(TextAlign.Center)
.fontWeight(400)
.fontColor(this.rightTextColor)
.onClick(() => {
if (this.controller != undefined) {
if(this.cancelIsLeft){
this.controller.close()
this.confirm()
}else{
this.controller.close()
this.cancel()
}
}
}).layoutWeight(1)
}
.alignItems(VerticalAlign.Center)
.height('96lpx')
}.borderRadius(10)
.width("518lpx")
.backgroundColor("#FFF")
}
}