PublicPopupDialogView.ets
1.18 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
import { PublicDialogManager } from './PublicDialogManager'
/*
* 公共自定义弹出框,上层赋值showPopup变量,决定是否显示
*
* 当上层需要关闭,调用 PublicDialogManager.shareInstance().closeDialog(dialogController) 关闭
*
* ===> customBuilder 当前传值有问题,用不了
*/
@Component
struct PublicPopupDialogView {
// 决定是否显示变量
@Link @Watch('showPopupAction') showPopup: boolean
// 自定义弹框的 @CustomDialog
private customBuilder: Object | null = null
private autoCancel: boolean = false
dialogController: CustomDialogController = new CustomDialogController({
builder: this.customBuilder,
autoCancel: this.autoCancel,
cancel: () => {
this.showPopup = false
},
customStyle: true,
alignment: DialogAlignment.Bottom,
})
showPopupAction(val: boolean) {
if (this.showPopup) {
PublicDialogManager.shareInstance().openDialog(this.dialogController, this.closeAction)
} else {
PublicDialogManager.shareInstance().closeDialog(this.dialogController)
}
}
@Builder emptyBuild() {
}
closeAction() {
this.showPopup = false
}
build() {
this.emptyBuild()
}
}