diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 7c23c4a714b7286d7e3938e50427f7bce4715e8a..80395d0f593cb56906d93704101d71b42d079b79 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 452a32195c80200650266f4df5edee7d5defdee9..46e51ddbb767f572edc82f56bcfa60b32b3fddd2 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