From 615cbb71c26ffb9ac87c76f0333cb422d08f9771 Mon Sep 17 00:00:00 2001 From: sfchu Date: Sat, 20 Sep 2025 16:50:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=BE=85=E5=8A=9E=E4=BA=8B?= =?UTF-8?q?=E9=A1=B9=E5=88=97=E8=A1=A8=20=E5=B7=A5=E7=A8=8B=20=E6=B2=89?= =?UTF-8?q?=E6=B5=B8=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/ets/entryability/EntryAbility.ets | 25 +++++++++++++++++++ entry/src/main/ets/pages/ToDoListPage.ets | 3 +++ 2 files changed, 28 insertions(+) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 7c23c4a..80395d0 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -28,7 +28,32 @@ export default class EntryAbility extends UIAbility { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; } + // Immersive Adaptation + this.immersionFuc(windowStage); hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); }); } + + /** + * Page immersion. + */ + immersionFuc(windowStage: window.WindowStage): void { + try { + let windowClass: window.Window = windowStage.getMainWindowSync(); + windowClass.setWindowLayoutFullScreen(true).catch((err: BusinessError) => { + hilog.error(0x0000, 'testTag', '%{public}s', + `SetWindowLayoutFullScreen failed. Cause code: ${err.code}, message: ${err.message}`); + }); + let navigationBarArea: window.AvoidArea = + windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR); + let area: window.AvoidArea = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); + AppStorage.setOrCreate('naviIndicatorHeight', + windowClass.getUIContext().px2vp(navigationBarArea.bottomRect.height)); + AppStorage.setOrCreate('statusBarHeight', windowClass.getUIContext().px2vp(area.topRect.height)); + AppStorage.setOrCreate('windowClass', windowClass); + } catch (err) { + hilog.error(0x0000, 'testTag', '%{public}s', + `immersionFuc failed, error code=${err.code}, message=${err.message}`); + } + } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/ToDoListPage.ets b/entry/src/main/ets/pages/ToDoListPage.ets index 452a321..46e51dd 100644 --- a/entry/src/main/ets/pages/ToDoListPage.ets +++ b/entry/src/main/ets/pages/ToDoListPage.ets @@ -46,5 +46,8 @@ struct ToDoListPage { .width(CommonConstants.FULL_LENGTH) .height(CommonConstants.FULL_LENGTH) .backgroundColor($r('app.color.page_background')) + .padding({ + top: AppStorage.get('statusBarHeight') + }) } } \ No newline at end of file -- Gitee