修复弹窗闪退问题

Signed-off-by: 王鑫 <wangxin601@huawei.com>
This commit is contained in:
王鑫 2024-05-29 09:35:57 +08:00
parent d82b9778a9
commit 7b6baa68e9

View File

@ -514,28 +514,34 @@ struct CustomDialogExample {
@Component
struct LookupFilterMenuItem {
@State item: string = "";
@State handlePopup: boolean = false
dialogController: CustomDialogController = new CustomDialogController({
builder: CustomDialogDetails({
item: $item
}),
offset: { dx: 0, dy: 220 },
autoCancel: true,
})
build() {
MenuItem({ content: this.item })
.bindPopup(this.handlePopup, {
message: 'Filters:\n' + imageEffect.lookupFilters(this.item),
messageOptions: {
font: {
size: '14vp',
style: FontStyle.Italic
},
},
placementOnTop: false,
onStateChange: (e) => {
console.log(e.isVisible.toString())
if (!e.isVisible) {
this.handlePopup = false
}
}
})
.onClick(() => {
this.handlePopup = !this.handlePopup
if (this.dialogController != null) {
this.dialogController.open()
}
})
}
}
@CustomDialog
struct CustomDialogDetails {
@Link item: string
controller?: CustomDialogController
build() {
Column() {
Text('Filters:\n' + imageEffect.lookupFilters(this.item))
.fontSize(16)
}
}
}