diff --git a/halfscreenlaunchcomponent/interfaces/halfscreenlaunchcomponent.js b/halfscreenlaunchcomponent/interfaces/halfscreenlaunchcomponent.js index 51c24329f2e21e43fceb0e5057a4bb5cb5019111..17fe6058aeb67366f51528f2791fd5bcc8ca5b1f 100644 --- a/halfscreenlaunchcomponent/interfaces/halfscreenlaunchcomponent.js +++ b/halfscreenlaunchcomponent/interfaces/halfscreenlaunchcomponent.js @@ -209,12 +209,21 @@ export class HalfScreenLaunchComponent extends ViewPU { builder: () => { this.uiExtensionBuilder.call(this); } - }, { modalTransition: ModalTransition.NONE }); + }, { + modalTransition: ModalTransition.NONE, + enableSafeArea: true + }); }, Row); this.content.bind(this)(); Row.pop(); } uiExtensionBuilder(parent = null) { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + Column.height(LayoutPolicy.matchParent); + Column.width(LayoutPolicy.matchParent); + Column.ignoreLayoutSafeArea([LayoutSafeAreaType.SYSTEM], [LayoutSafeAreaEdge.TOP, LayoutSafeAreaEdge.BOTTOM]); + }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { UIExtensionComponent.create({ bundleName: `com.atomicservice.${this.appId}`, @@ -249,6 +258,7 @@ export class HalfScreenLaunchComponent extends ViewPU { this.handleOnReceiveEvent(data); }); }, UIExtensionComponent); + Column.pop(); } rerender() { this.updateDirtyElements(); diff --git a/halfscreenlaunchcomponent/source/halfscreenlaunchcomponent.ets b/halfscreenlaunchcomponent/source/halfscreenlaunchcomponent.ets index 778d8a0cd567f642249f52c7965061d3d3a5f941..cd00a3bc15743926ac524a3a3e0e20d1ba015d14 100644 --- a/halfscreenlaunchcomponent/source/halfscreenlaunchcomponent.ets +++ b/halfscreenlaunchcomponent/source/halfscreenlaunchcomponent.ets @@ -131,7 +131,7 @@ export struct HalfScreenLaunchComponent { } catch (err: BusinessError) { hilog.error(0x3900, LOG_TAG, 'AtomicServiceStartupRule failed: %{public}s', err.message); this.popUp(); - } + } } async popUp(): Promise { @@ -169,45 +169,53 @@ export struct HalfScreenLaunchComponent { hilog.info(0x3900, LOG_TAG, 'on start atomicservice'); this.checkAbility(); } - ).bindContentCover($$this.isShow, this.uiExtensionBuilder(), { modalTransition: ModalTransition.NONE }); - + ).bindContentCover($$this.isShow, this.uiExtensionBuilder(), + { + modalTransition: ModalTransition.NONE, + enableSafeArea: true + }); } @Builder uiExtensionBuilder() { - UIExtensionComponent({ - bundleName: `com.atomicservice.${this.appId}`, - flags: this.options?.flags, - parameters: this.options?.parameters - }, - { - windowModeFollowStrategy: WindowModeFollowStrategy.FOLLOW_UI_EXTENSION_ABILITY_WINDOW_MODE - }) - .height('100%') - .width('100%') - .backgroundColor(Color.Transparent) - .onError( - err => { - if (this.onError) { - this.onError(err); + Column() { + UIExtensionComponent({ + bundleName: `com.atomicservice.${this.appId}`, + flags: this.options?.flags, + parameters: this.options?.parameters + }, + { + windowModeFollowStrategy: WindowModeFollowStrategy.FOLLOW_HOST_WINDOW_MODE + }) + .height('100%') + .width('100%') + .backgroundColor(Color.Transparent) + .onError( + err => { + if (this.onError) { + this.onError(err); + } + this.isShow = false; + hilog.error(0x3900, LOG_TAG, 'call up UIExtension error!%{public}s', err.message); + if (err.code !== ERR_CODE_ABNORMAL) { + this.getUIContext().showAlertDialog({ + message: err.message + }); + } } + ) + .onTerminated(info => { this.isShow = false; - hilog.error(0x3900, LOG_TAG, 'call up UIExtension error!%{public}s', err.message); - if (err.code !== ERR_CODE_ABNORMAL) { - this.getUIContext().showAlertDialog({ - message: err.message - }); + if (this.onTerminated) { + this.onTerminated(info); } - } - ) - .onTerminated(info => { - this.isShow = false; - if (this.onTerminated) { - this.onTerminated(info); - } - }) - .onReceive(data => { - this.handleOnReceiveEvent(data); - }) + }) + .onReceive(data => { + this.handleOnReceiveEvent(data); + }) + } + .height(LayoutPolicy.matchParent) + .width(LayoutPolicy.matchParent) + .ignoreLayoutSafeArea([LayoutSafeAreaType.SYSTEM], [LayoutSafeAreaEdge.TOP, LayoutSafeAreaEdge.BOTTOM]) } } \ No newline at end of file diff --git a/innerfullscreenlaunchcomponent/interfaces/innerfullscreenlaunchcomponent.js b/innerfullscreenlaunchcomponent/interfaces/innerfullscreenlaunchcomponent.js index 36ac1f15cc8402cbe56377f6d7e41b4e932ba9e2..a554f80bb211a131628a4094acb430c1d40bb063 100644 --- a/innerfullscreenlaunchcomponent/interfaces/innerfullscreenlaunchcomponent.js +++ b/innerfullscreenlaunchcomponent/interfaces/innerfullscreenlaunchcomponent.js @@ -215,17 +215,28 @@ export class InnerFullScreenLaunchComponent extends ViewPU { Row.justifyContent(FlexAlign.Center); Row.bindContentCover({ value: this.isShow, changeEvent: k => { this.isShow = k; } }, { builder: () => { this.uiExtensionBuilder.call(this); - } }, { modalTransition: ModalTransition.DEFAULT }); + } }, { + modalTransition: ModalTransition.DEFAULT, + enableSafeArea: true + }); }, Row); this.content.bind(this)(this); Row.pop(); } uiExtensionBuilder(a = null) { + this.observeComponentCreation2((w20, x20) => { + Column.create(); + Column.height(LayoutPolicy.matchParent); + Column.width(LayoutPolicy.matchParent); + Column.ignoreLayoutSafeArea([LayoutSafeAreaType.SYSTEM], [LayoutSafeAreaEdge.TOP, LayoutSafeAreaEdge.BOTTOM]); + }, Column); this.observeComponentCreation2((c, d) => { UIExtensionComponent.create({ bundleName: `com.atomicservice.${this.appId}`, flags: this.options?.flags, parameters: this.options?.parameters + }, { + windowModeFollowStrategy: WindowModeFollowStrategy.FOLLOW_HOST_WINDOW_MODE }); UIExtensionComponent.backgroundColor({ 'id': -1, 'type': 10001, params: ['sys.color.ohos_id_color_titlebar_bg'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); UIExtensionComponent.defaultFocus(true); @@ -248,6 +259,7 @@ export class InnerFullScreenLaunchComponent extends ViewPU { this.handleOnReceiveEvent(data); }); }, UIExtensionComponent); + Column.pop(); } rerender() { this.updateDirtyElements(); diff --git a/innerfullscreenlaunchcomponent/source/innerfullscreenlaunchcomponent.ets b/innerfullscreenlaunchcomponent/source/innerfullscreenlaunchcomponent.ets index 3c8d260955037d4b7a9437513299f40afe27ac8b..bebd651c99bcb88c1f4ac86448b9b1bd48524ac1 100644 --- a/innerfullscreenlaunchcomponent/source/innerfullscreenlaunchcomponent.ets +++ b/innerfullscreenlaunchcomponent/source/innerfullscreenlaunchcomponent.ets @@ -143,7 +143,7 @@ export struct InnerFullScreenLaunchComponent { } catch (err: BusinessError) { hilog.error(0x3900, LOG_TAG, 'AtomicServiceStartupRule failed: %{public}s', err.message); this.popUp(); - } + } } async popUp(): Promise { @@ -177,39 +177,49 @@ export struct InnerFullScreenLaunchComponent { this.content(); } .justifyContent(FlexAlign.Center) - .bindContentCover($$this.isShow, this.uiExtensionBuilder()) + .bindContentCover($$this.isShow, this.uiExtensionBuilder(), { + modalTransition: ModalTransition.DEFAULT, + enableSafeArea: true + }) } @Builder uiExtensionBuilder() { - UIExtensionComponent({ - bundleName: `com.atomicservice.${this.appId}`, - flags: this.options?.flags, - parameters: this.options?.parameters - }) - .backgroundColor($r('sys.color.ohos_id_color_titlebar_bg')) - .defaultFocus(true) - .height('100%') - .width('100%') - .onRelease( - () => { - hilog.error(0x3900, LOG_TAG, 'onRelease'); - this.isShow = false; - } - ) - .onError( - err => { - this.isShow = false; - hilog.error(0x3900, LOG_TAG, 'call up UIExtension error! %{public}s', err.message); - if (err.code !== ERR_CODE_ABNORMAL) { - this.getUIContext().showAlertDialog({ - message: err.message - }); - } - } - ) - .onReceive(data => { - this.handleOnReceiveEvent(data); + Column() { + UIExtensionComponent({ + bundleName: `com.atomicservice.${this.appId}`, + flags: this.options?.flags, + parameters: this.options?.parameters + },{ + windowModeFollowStrategy: WindowModeFollowStrategy.FOLLOW_HOST_WINDOW_MODE }) + .backgroundColor($r('sys.color.ohos_id_color_titlebar_bg')) + .defaultFocus(true) + .height('100%') + .width('100%') + .onRelease( + () => { + hilog.error(0x3900, LOG_TAG, 'onRelease'); + this.isShow = false; + } + ) + .onError( + err => { + this.isShow = false; + hilog.error(0x3900, LOG_TAG, 'call up UIExtension error! %{public}s', err.message); + if (err.code !== ERR_CODE_ABNORMAL) { + this.getUIContext().showAlertDialog({ + message: err.message + }); + } + } + ) + .onReceive(data => { + this.handleOnReceiveEvent(data); + }) + } + .height(LayoutPolicy.matchParent) + .width(LayoutPolicy.matchParent) + .ignoreLayoutSafeArea([LayoutSafeAreaType.SYSTEM], [LayoutSafeAreaEdge.TOP, LayoutSafeAreaEdge.BOTTOM]) } } \ No newline at end of file