From cfe511d0acf7631d029b368e2689384171b6257d Mon Sep 17 00:00:00 2001 From: ywcoder <1104410818@qq.com> Date: Wed, 23 Jul 2025 09:41:58 +0800 Subject: [PATCH 1/4] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E4=B8=8D?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=91=BD=E5=90=8D=E3=80=81=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=97=A0=E7=94=A8=E6=96=B9=E6=B3=95updateDialog()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets/pages/PopUpAgainInCustomPopUps.ets | 35 ++++++------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/ArkUI/entry/src/main/ets/pages/PopUpAgainInCustomPopUps.ets b/ArkUI/entry/src/main/ets/pages/PopUpAgainInCustomPopUps.ets index 8f8a80d..55b9762 100644 --- a/ArkUI/entry/src/main/ets/pages/PopUpAgainInCustomPopUps.ets +++ b/ArkUI/entry/src/main/ets/pages/PopUpAgainInCustomPopUps.ets @@ -22,11 +22,11 @@ import { ComponentContent, promptAction, UIContext } from '@kit.ArkUI'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { BusinessError } from '@kit.BasicServicesKit'; -let dialogA_ContentNode: ComponentContent; -let dialogB_ContentNode: ComponentContent; +let dialogAContentNode: ComponentContent; +let dialogBContentNode: ComponentContent; @Builder -function dialogA_Component() { +function dialogA() { Column() { Column() { Text('dialog A') @@ -41,7 +41,7 @@ function dialogA_Component() { .fontColor('#0A59F7') .onClick(() => { // close dialog A. - PromptActionClass.closeDialog(dialogA_ContentNode); + PromptActionClass.closeDialog(dialogAContentNode); }) .width('50%') .height('100%') @@ -51,7 +51,7 @@ function dialogA_Component() { .fontColor('#0A59F7') .onClick(() => { // Open dialog B. - PromptActionClass.setContentNode(dialogB_ContentNode); + PromptActionClass.setContentNode(dialogBContentNode); PromptActionClass.openDialog(); }) .width('50%') @@ -66,7 +66,7 @@ function dialogA_Component() { } @Builder -function dialogB_Component() { +function dialogB() { Column() { Column() { Text('dialog B') @@ -81,7 +81,7 @@ function dialogB_Component() { .fontColor('#0A59F7') .onClick(() => { // close dialog B. - PromptActionClass.closeDialog(dialogB_ContentNode); + PromptActionClass.closeDialog(dialogBContentNode); }) .width('50%') .height('100%') @@ -99,8 +99,8 @@ function dialogB_Component() { struct PopUpAgainInCustomPopUps { aboutToAppear(): void { let uiContext = this.getUIContext(); - dialogA_ContentNode = new ComponentContent(uiContext, wrapBuilder(dialogA_Component)); - dialogB_ContentNode = new ComponentContent(uiContext, wrapBuilder(dialogB_Component)); + dialogAContentNode = new ComponentContent(uiContext, wrapBuilder(dialogA)); + dialogBContentNode = new ComponentContent(uiContext, wrapBuilder(dialogB)); } build() { @@ -110,7 +110,7 @@ struct PopUpAgainInCustomPopUps { // Open dialog A. let uiContext = this.getUIContext(); PromptActionClass.setContext(uiContext); - PromptActionClass.setContentNode(dialogA_ContentNode); + PromptActionClass.setContentNode(dialogAContentNode); PromptActionClass.openDialog(); }) } @@ -168,21 +168,6 @@ export class PromptActionClass { }) } } - - static updateDialog(options: promptAction.BaseDialogOptions) { - if (PromptActionClass.contentNode !== null) { - PromptActionClass.ctx.getPromptAction() - .updateCustomDialog(PromptActionClass.contentNode, options) - .then(() => { - hilog.info(0xFF00, 'TAG', 'UpdateCustomDialog complete'); - }) - .catch((error: BusinessError) => { - let message = (error as BusinessError).message; - let code = (error as BusinessError).code; - hilog.info(0xFF00, 'TAG', `UpdateCustomDialog args error code is ${code}, message is ${message}`); - }) - } - } } // [End pop_up_again_in_custom_pop_ups] \ No newline at end of file -- Gitee From f5764e5a60f38922cf0e8cf95ab5966e844d4502 Mon Sep 17 00:00:00 2001 From: ywcoder <1104410818@qq.com> Date: Wed, 23 Jul 2025 10:33:41 +0800 Subject: [PATCH 2/4] =?UTF-8?q?1=E3=80=81=E7=AE=80=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets/pages/PopUpAgainInCustomPopUps.ets | 196 +++++++----------- 1 file changed, 75 insertions(+), 121 deletions(-) diff --git a/ArkUI/entry/src/main/ets/pages/PopUpAgainInCustomPopUps.ets b/ArkUI/entry/src/main/ets/pages/PopUpAgainInCustomPopUps.ets index 55b9762..6563753 100644 --- a/ArkUI/entry/src/main/ets/pages/PopUpAgainInCustomPopUps.ets +++ b/ArkUI/entry/src/main/ets/pages/PopUpAgainInCustomPopUps.ets @@ -19,99 +19,102 @@ // [Start pop_up_again_in_custom_pop_ups] import { ComponentContent, promptAction, UIContext } from '@kit.ArkUI'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { BusinessError } from '@kit.BasicServicesKit'; -let dialogAContentNode: ComponentContent; -let dialogBContentNode: ComponentContent; - -@Builder -function dialogA() { - Column() { +@Component +struct DialogAComponent { + build() { Column() { - Text('dialog A') - .fontSize(20) - .fontWeight(FontWeight.Bold) - } - .justifyContent(FlexAlign.Center) - .height(120) - - Row() { - Text('close') - .fontColor('#0A59F7') - .onClick(() => { - // close dialog A. - PromptActionClass.closeDialog(dialogAContentNode); - }) - .width('50%') - .height('100%') - .textAlign(TextAlign.Center) - - Text('open dialog B') - .fontColor('#0A59F7') - .onClick(() => { - // Open dialog B. - PromptActionClass.setContentNode(dialogBContentNode); - PromptActionClass.openDialog(); - }) - .width('50%') - .height('100%') - .textAlign(TextAlign.Center) + Column() { + Text('dialog A') + .fontSize(20) + .fontWeight(FontWeight.Bold) + } + .justifyContent(FlexAlign.Center) + .height(120) + + Row() { + Text('close') + .fontColor('#0A59F7') + .onClick(() => { + // close self. + this.getDialogController()?.close(); + }) + .width('50%') + .height('100%') + .textAlign(TextAlign.Center) + + Text('open dialog B') + .fontColor('#0A59F7') + .onClick(() => { + // Open dialog B. + let uiContext = this.getUIContext(); + let promptAction = uiContext.getPromptAction(); + promptAction.openCustomDialog(new ComponentContent(uiContext, wrapBuilder(dialogBBuilder))); + }) + .width('50%') + .height('100%') + .textAlign(TextAlign.Center) + } + .height(50) } - .height(50) + .width(360) + .borderRadius(32) + .backgroundColor(Color.White) } - .width(360) - .borderRadius(32) - .backgroundColor(Color.White) } @Builder -function dialogB() { - Column() { - Column() { - Text('dialog B') - .fontSize(20) - .fontWeight(FontWeight.Bold) - } - .justifyContent(FlexAlign.Center) - .height(120) +function dialogABuilder() { + DialogAComponent() +} - Row() { - Text('close') - .fontColor('#0A59F7') - .onClick(() => { - // close dialog B. - PromptActionClass.closeDialog(dialogBContentNode); - }) - .width('50%') - .height('100%') - .textAlign(TextAlign.Center) +@Component +struct DialogBComponent { + build() { + Column() { + Column() { + Text('dialog B') + .fontSize(20) + .fontWeight(FontWeight.Bold) + } + .justifyContent(FlexAlign.Center) + .height(120) + + Row() { + Text('close') + .fontColor('#0A59F7') + .onClick(() => { + // close self. + this.getDialogController()?.close(); + }) + .width('50%') + .height('100%') + .textAlign(TextAlign.Center) + } + .height(50) } - .height(50) + .width(360) + .borderRadius(32) + .backgroundColor(Color.White) } - .width(360) - .borderRadius(32) - .backgroundColor(Color.White) +} + +@Builder +function dialogBBuilder() { + DialogBComponent() } @Entry @Component struct PopUpAgainInCustomPopUps { - aboutToAppear(): void { - let uiContext = this.getUIContext(); - dialogAContentNode = new ComponentContent(uiContext, wrapBuilder(dialogA)); - dialogBContentNode = new ComponentContent(uiContext, wrapBuilder(dialogB)); - } - build() { Column() { Button('open Dialog A') .onClick(() => { // Open dialog A. let uiContext = this.getUIContext(); - PromptActionClass.setContext(uiContext); - PromptActionClass.setContentNode(dialogAContentNode); - PromptActionClass.openDialog(); + let promptAction = uiContext.getPromptAction(); + promptAction.openCustomDialog(new ComponentContent(uiContext, wrapBuilder(dialogABuilder))); }) } .width('100%') @@ -121,53 +124,4 @@ struct PopUpAgainInCustomPopUps { } } -// Dialog class for functions such as opening, closing, and updating packages. -export class PromptActionClass { - static ctx: UIContext; - static contentNode: ComponentContent; - static options: promptAction.BaseDialogOptions; - - static setContext(context: UIContext) { - PromptActionClass.ctx = context; - } - - static setContentNode(node: ComponentContent) { - PromptActionClass.contentNode = node; - } - - static setOptions(options: promptAction.BaseDialogOptions) { - PromptActionClass.options = options; - } - - static openDialog() { - if (PromptActionClass.contentNode !== null) { - PromptActionClass.ctx.getPromptAction() - .openCustomDialog(PromptActionClass.contentNode, PromptActionClass.options) - .then(() => { - hilog.info(0xFF00, 'TAG', 'OpenCustomDialog complete'); - }) - .catch((error: BusinessError) => { - let message = (error as BusinessError).message; - let code = (error as BusinessError).code; - hilog.info(0xFF00, 'TAG', `OpenCustomDialog args error code is ${code}, message is ${message}`); - }) - } - } - - static closeDialog(contentNode: ComponentContent) { - if (PromptActionClass.contentNode !== null) { - PromptActionClass.ctx.getPromptAction() - .closeCustomDialog(contentNode) - .then(() => { - hilog.info(0xFF00, 'TAG', 'CloseCustomDialog complete'); - }) - .catch((error: BusinessError) => { - let message = (error as BusinessError).message; - let code = (error as BusinessError).code; - hilog.info(0xFF00, 'TAG', `CloseCustomDialog args error code is ${code}, message is ${message}`); - }) - } - } -} - // [End pop_up_again_in_custom_pop_ups] \ No newline at end of file -- Gitee From 308f3dc63a3e58fa81cfc108edcb6d345ce16b02 Mon Sep 17 00:00:00 2001 From: ywcoder <1104410818@qq.com> Date: Wed, 23 Jul 2025 11:08:07 +0800 Subject: [PATCH 3/4] =?UTF-8?q?1=E3=80=81=E5=8E=BB=E6=8E=89=E5=A4=9A?= =?UTF-8?q?=E4=BD=99import=E3=80=81=E4=BF=AE=E6=94=B9=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=90=8D=E3=80=81=E5=BC=B9=E7=AA=97B=E5=AE=BD=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...nCustomPopUps.ets => PopUpDialogAgainInCustomDialog.ets} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename ArkUI/entry/src/main/ets/pages/{PopUpAgainInCustomPopUps.ets => PopUpDialogAgainInCustomDialog.ets} (96%) diff --git a/ArkUI/entry/src/main/ets/pages/PopUpAgainInCustomPopUps.ets b/ArkUI/entry/src/main/ets/pages/PopUpDialogAgainInCustomDialog.ets similarity index 96% rename from ArkUI/entry/src/main/ets/pages/PopUpAgainInCustomPopUps.ets rename to ArkUI/entry/src/main/ets/pages/PopUpDialogAgainInCustomDialog.ets index 6563753..5cae9e3 100644 --- a/ArkUI/entry/src/main/ets/pages/PopUpAgainInCustomPopUps.ets +++ b/ArkUI/entry/src/main/ets/pages/PopUpDialogAgainInCustomDialog.ets @@ -18,7 +18,7 @@ */ // [Start pop_up_again_in_custom_pop_ups] -import { ComponentContent, promptAction, UIContext } from '@kit.ArkUI'; +import { ComponentContent } from '@kit.ArkUI'; @Component struct DialogAComponent { @@ -93,7 +93,7 @@ struct DialogBComponent { } .height(50) } - .width(360) + .width(320) .borderRadius(32) .backgroundColor(Color.White) } @@ -106,7 +106,7 @@ function dialogBBuilder() { @Entry @Component -struct PopUpAgainInCustomPopUps { +struct PopUpDialogAgainInCustomDialog { build() { Column() { Button('open Dialog A') -- Gitee From b3aab4935dfcb8da07b656c9491f7998cbfec9d8 Mon Sep 17 00:00:00 2001 From: ywcoder <1104410818@qq.com> Date: Wed, 23 Jul 2025 11:33:09 +0800 Subject: [PATCH 4/4] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=B0=8F=E9=A9=BC=E5=B3=B0=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/pages/XComponentSurfaceRenderFit.ets | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ArkUI/entry/src/main/ets/pages/XComponentSurfaceRenderFit.ets b/ArkUI/entry/src/main/ets/pages/XComponentSurfaceRenderFit.ets index 3ecc76c..be3772e 100644 --- a/ArkUI/entry/src/main/ets/pages/XComponentSurfaceRenderFit.ets +++ b/ArkUI/entry/src/main/ets/pages/XComponentSurfaceRenderFit.ets @@ -20,8 +20,8 @@ @Entry @Component struct XComponentSurfaceRenderFit { - @State xc_width: number = 500; - @State xc_height: number = 700; + @State xcWidth: number = 500; + @State xcHeight: number = 700; myXComponentController: XComponentController = new XComponentController(); build() { @@ -31,8 +31,8 @@ struct XComponentSurfaceRenderFit { type: XComponentType.SURFACE, controller: this.myXComponentController }) - .width(this.xc_width) - .height(this.xc_height) + .width(this.xcWidth) + .height(this.xcHeight) .renderFit(RenderFit.CENTER) } .width('100%') -- Gitee