From 348174c4c8501fd647a5fdf69a1a11062715fca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=8B=A4=E6=B0=91?= Date: Tue, 15 Oct 2024 18:47:21 +0800 Subject: [PATCH] fix --- src/main/ets/utils/WindowHelper.ets | 9 ++++++--- src/main/ets/view/SafeView.ets | 30 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 src/main/ets/view/SafeView.ets diff --git a/src/main/ets/utils/WindowHelper.ets b/src/main/ets/utils/WindowHelper.ets index 02fedfa..87bd776 100644 --- a/src/main/ets/utils/WindowHelper.ets +++ b/src/main/ets/utils/WindowHelper.ets @@ -78,9 +78,12 @@ export class WindowHelper { WindowHelper._windowClass = value; if (WindowHelper._windowClass) { let avoidArea = WindowHelper._windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR); - WindowHelper._bottomRectHeight = avoidArea.bottomRect.height + WindowHelper._bottomRectHeight = px2vp(avoidArea.bottomRect.height) let avoidArea2 = WindowHelper._windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_CUTOUT); - WindowHelper._topRectHeight = avoidArea2.topRect.height + WindowHelper._topRectHeight = px2vp(avoidArea2.topRect.height) + let avoidArea3 = WindowHelper._windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); + const a = px2vp(avoidArea3.topRect.height) + WindowHelper._topRectHeight = a > WindowHelper._topRectHeight ? a : WindowHelper._topRectHeight // console.log('=====>', WindowHelper._topRectHeight) } } @@ -106,7 +109,7 @@ export class WindowHelper { * @returns */ public static get topRectHeight(): number { - return WindowHelper._isFullScreen?WindowHelper._topRectHeight:0 + return WindowHelper._isFullScreen ? WindowHelper._topRectHeight : 0 } diff --git a/src/main/ets/view/SafeView.ets b/src/main/ets/view/SafeView.ets new file mode 100644 index 0000000..2c37403 --- /dev/null +++ b/src/main/ets/view/SafeView.ets @@ -0,0 +1,30 @@ +@Preview +@Component +export struct SafeView { + @Link isLoading: boolean + + @Builder + doNothingBuilder() { + } + + @BuilderParam customBuilderParam: () => void = this.doNothingBuilder + + build() { + Stack() { + this.customBuilderParam() + Column() { + LoadingProgress() + .color(Color.White) + .width(80).height(80) + Text('努力加载中..') + .fontSize(16) + .fontColor(Color.White) + } + .visibility(this.isLoading ? Visibility.Visible : Visibility.None) + .width('100%') + .height('100%') + .backgroundColor('#40000000') + .justifyContent(FlexAlign.Center) + } + } +} \ No newline at end of file