diff --git a/hadss_dialog/src/main/ets/model/adapter/proxy/base/PopupProxy.ets b/hadss_dialog/src/main/ets/model/adapter/proxy/base/PopupProxy.ets index ba325eda69dd0184ed24ac5a08e521a94cfe498a..cb452a2822d584a95fd74e031c5f1caff382f5dc 100644 --- a/hadss_dialog/src/main/ets/model/adapter/proxy/base/PopupProxy.ets +++ b/hadss_dialog/src/main/ets/model/adapter/proxy/base/PopupProxy.ets @@ -70,9 +70,7 @@ export class PopupProxy extends CustomProxy { } setComponentTargetId(targetCompId: string) { - if (CompUtils.JudgeID(this.uiContext, targetCompId)) { - this.builderOptions.targetCompId = targetCompId - } + this.builderOptions.targetCompId = targetCompId return this } } diff --git a/hadss_dialog/src/main/ets/model/adapter/proxy/base/SheetProxy.ets b/hadss_dialog/src/main/ets/model/adapter/proxy/base/SheetProxy.ets index 6aa563344fc11690cf14a8fb8d7221abc80110e1..0baf3235202cf4e4da720a2cefca5e498469e04b 100644 --- a/hadss_dialog/src/main/ets/model/adapter/proxy/base/SheetProxy.ets +++ b/hadss_dialog/src/main/ets/model/adapter/proxy/base/SheetProxy.ets @@ -49,9 +49,7 @@ export class SheetProxy extends DialogAdaptorProxy { } setComponentTargetId(targetCompId: string) { - if (CompUtils.JudgeID(this.uiContext, targetCompId)) { - this.builderOptions.targetCompId = targetCompId - } + this.builderOptions.targetCompId = targetCompId return this } diff --git a/hadss_dialog/src/main/ets/model/dialog/base/PopupDialog.ets b/hadss_dialog/src/main/ets/model/dialog/base/PopupDialog.ets index 1999f65ed65d22c9081ec9b5d7ca11011a15ef0f..a1290c7d9483c880269cb628c86f8e55c90820de 100644 --- a/hadss_dialog/src/main/ets/model/dialog/base/PopupDialog.ets +++ b/hadss_dialog/src/main/ets/model/dialog/base/PopupDialog.ets @@ -17,8 +17,8 @@ import { InfPopup } from '../interface/InfPopup'; import { CustomDialog } from './CustomDialog'; import { DimensionUtils } from '../../../common/util/DimensionUtils'; import { DialogLifeCycle } from '../../lifecycle/DialogLifeCycle'; -import { ObjectUtils } from '../../../common/util/ObjectUtils'; import { display, inspector } from '@kit.ArkUI'; +import { CompUtils } from '../../../common/util/CompUtils'; /** * 基于系统CommonDialog封装对外提供的customDialog,支持更新自定义内容 @@ -44,11 +44,23 @@ export class PopupDialog extends CustomDialog implements InfPopup { this.updateDialogPosition(); } + public show(isInsideCall?: boolean | undefined): boolean { + let compId = (this.builderOptions as PopupOption).targetCompId; + if (compId) { + CompUtils.JudgeID(this.uiContext, compId) + } + return super.show(isInsideCall) + } + private observeDialogComponent() { - this.targetCompListener = inspector.createComponentObserver((this.builderOptions as PopupOption).targetCompId); - this.targetCompListener?.on('layout', this.onTargetCompLayoutComplete); this.dialogCompListener = inspector.createComponentObserver(this.dialogId); this.dialogCompListener?.on('layout', this.onDialogCompLayoutComplete); + + let compId = (this.builderOptions as PopupOption).targetCompId; + if (compId) { + this.targetCompListener = inspector.createComponentObserver(compId); + this.targetCompListener?.on('layout', this.onTargetCompLayoutComplete); + } } public updateDialogPosition() { @@ -201,7 +213,7 @@ export class PopupDialog extends CustomDialog implements InfPopup { let defaultOffset = DimensionUtils.length2px((this.builderOptions as PopupOption).arrowOffset, maxValue); let arrowWidth = DimensionUtils.length2px((this.builderOptions as PopupOption).arrowWidth, display.getDefaultDisplaySync().width); - let afterOffset = (maxValue- arrowWidth) / 2 + defaultOffset; // 默认居中,在居中上偏移,如不默认居中,不需要此行代码 + let afterOffset = (maxValue - arrowWidth) / 2 + defaultOffset; // 默认居中,在居中上偏移,如不默认居中,不需要此行代码 let maxOffset = maxValue - arrowWidth - vp2px(5); let validOffset = px2vp(Math.max(Math.min(maxOffset, afterOffset), vp2px(5))); return validOffset; diff --git a/hadss_dialog/src/main/ets/model/dialog/base/SheetDialog.ets b/hadss_dialog/src/main/ets/model/dialog/base/SheetDialog.ets index 1697e9318c5b403c0dc75629e07a82be5c928e77..602300da3a94f5468fc5083c9af8cdd82fe8f087 100644 --- a/hadss_dialog/src/main/ets/model/dialog/base/SheetDialog.ets +++ b/hadss_dialog/src/main/ets/model/dialog/base/SheetDialog.ets @@ -15,6 +15,7 @@ import { SheetOption } from '../../../common/been/option/base/SheetOption'; import { SheetStyle } from '../../../common/been/style/SheetStyle'; import { DialogStatus } from '../../../common/constant/DialogStatus'; +import { CompUtils } from '../../../common/util/CompUtils'; import { DialogLifeCycle } from '../../lifecycle/DialogLifeCycle'; import { SheetLifeCycleHelper } from '../../lifecycle/DialogLifeCycleHelper'; import { GlobalDialogLifeCycleHelper } from '../../lifecycle/GlobalDialogLifeCycleHelper'; @@ -27,10 +28,12 @@ import { CommonDialog } from './CommonDialog'; * 基于系统BindSheet封装的弹窗实例 * */ export class SheetDialog extends CommonDialog implements InfSheet { + private uiContext: UIContext; protected lifeCycleHelper: SheetLifeCycleHelper = new SheetLifeCycleHelper(); constructor(uiContext: UIContext, options: SheetOption, lifeCycle: SheetLifeCycle) { super(uiContext, options, lifeCycle); + this.uiContext = uiContext; //sheet内置方法关闭时同步弹窗状态 this.dialogExecutor = new BindSheetExecutor(uiContext, options as SheetOption, () => { this.isShown = false; @@ -66,4 +69,12 @@ export class SheetDialog extends CommonDialog implements InfSheet { public updateStyle(style: SheetStyle): void { super.updateStyle(style) } + + public show(isInsideCall?: boolean | undefined): boolean { + let compId = (this.builderOptions as SheetOption).targetCompId; + if (compId) { + CompUtils.JudgeID(this.uiContext, compId) + } + return super.show(isInsideCall) + } } \ No newline at end of file