From 5c2d1b2ebc4d44ca26bd9debfb80feeab8682db2 Mon Sep 17 00:00:00 2001 From: yxk2026 <10178404+yxk2026@user.noreply.gitee.com> Date: Sat, 30 Aug 2025 14:53:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E3=80=90=E7=B3=BB=E7=BB=9F=E5=85=AC?= =?UTF-8?q?=E5=85=B1=E4=BA=8B=E4=BB=B6=E3=80=91=E9=80=82=E9=85=8D=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 | 24 +++++++++++++++++++ entry/src/main/ets/pages/MainPage.ets | 6 +++++ 2 files changed, 30 insertions(+) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 6f5e6cd..a073ae0 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,6 +1,7 @@ import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; import { window } from '@kit.ArkUI'; import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError } from '@kit.BasicServicesKit'; export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { @@ -20,6 +21,29 @@ export default class EntryAbility extends UIAbility { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; } + let windowClass: window.Window | undefined = undefined; + windowStage.getMainWindow((err: BusinessError, data) => { + let errCode: number = err.code; + if (errCode) { + hilog.error(0x0000, 'testTag', 'Failed to obtain the main window. Cause: ', JSON.stringify(err)); + return; + } + try { + windowClass = data; + let isLayoutFullScreen = true; + windowClass.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => { + hilog.info(0x0000, 'testTag', 'Succeeded in setting the window layout to full-screen mode.'); + }); + let avoidArea = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); + // Set the height of the status bar. + AppStorage.setOrCreate('statusBarHeight', data.getUIContext().px2vp(avoidArea.topRect.height)); + AppStorage.setOrCreate('bottomHeight', data.getUIContext() + .px2vp(windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR).bottomRect.height)); + } catch (exception) { + hilog.error(0x0000, '[EntryAbility]', + `Failed to set the system bar to be invisible. Cause code: ${exception.code}, message: ${exception.message}`); + } + }) hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); }); } diff --git a/entry/src/main/ets/pages/MainPage.ets b/entry/src/main/ets/pages/MainPage.ets index 4d88027..aa321c4 100644 --- a/entry/src/main/ets/pages/MainPage.ets +++ b/entry/src/main/ets/pages/MainPage.ets @@ -19,10 +19,16 @@ import CommonEventListComponent from '../view/CommonEventListComponent'; @Entry @Component struct MainPage { + @StorageLink('statusBarHeight') statusBarHeight: number = 0; + @StorageLink('bottomHeight') bottomHeight: number = 0; build() { Row() { CommonEventListComponent() } + .padding({ + top: this.statusBarHeight, + bottom: this.bottomHeight + }) .height(CommonConstants.FULL_SCREEN_HEIGHT) .backgroundColor($r('app.color.global_bg_color')) } -- Gitee From 54689fc1b1e43b659a3b6a8b1b1b50e2e8fa87f4 Mon Sep 17 00:00:00 2001 From: yxk2026 <10178404+yxk2026@user.noreply.gitee.com> Date: Sat, 30 Aug 2025 15:00:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E3=80=90=E7=B3=BB=E7=BB=9F=E5=85=AC?= =?UTF-8?q?=E5=85=B1=E4=BA=8B=E4=BB=B6=E3=80=91=E4=BB=A3=E7=A0=81=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/entryability/EntryAbility.ets | 15 +++++++++++++++ .../main/ets/view/CommonEventListComponent.ets | 1 - entry/src/main/ets/viewmodel/CommonEventItem.ets | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index a073ae0..8650648 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; import { window } from '@kit.ArkUI'; import { hilog } from '@kit.PerformanceAnalysisKit'; diff --git a/entry/src/main/ets/view/CommonEventListComponent.ets b/entry/src/main/ets/view/CommonEventListComponent.ets index 990f0e6..322be2c 100644 --- a/entry/src/main/ets/view/CommonEventListComponent.ets +++ b/entry/src/main/ets/view/CommonEventListComponent.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -import { promptAction } from '@kit.ArkUI'; import { CommonEventItem } from '../viewmodel/CommonEventItem'; import { CommonConstants } from '../common/constants/CommonConst'; import CommonEventUtil from '../common/utils/CommonEventUtil'; diff --git a/entry/src/main/ets/viewmodel/CommonEventItem.ets b/entry/src/main/ets/viewmodel/CommonEventItem.ets index 765eaec..bee900a 100644 --- a/entry/src/main/ets/viewmodel/CommonEventItem.ets +++ b/entry/src/main/ets/viewmodel/CommonEventItem.ets @@ -15,6 +15,7 @@ import { commonEventManager } from '@kit.BasicServicesKit'; import { CommonConstants } from '../common/constants/CommonConst'; + /** * ButtonList item information */ -- Gitee