From 74be9a2d6e195ea70c267ebe0575e0ab92c7d3f2 Mon Sep 17 00:00:00 2001 From: lon9 <815882449@qq.com> Date: Thu, 28 Aug 2025 20:47:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=9A=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=9B=B8=E6=9C=BA=E5=90=8C=E6=BA=90=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/Index.ets | 2 +- entry/src/main/ets/utils/CameraUtil.ets | 4 ++++ entry/src/main/ets/views/CommonView.ets | 24 ++++++++++++------------ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 9867354..b745df8 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -78,6 +78,7 @@ struct Index { // [EndExclude SelectCamera2] // Exit the half folded status page. if (this.isHalfFolded) { + this.isHalfFolded = false; this.cameraUtil.setXComponentRect(this.windowUtil.getWindowSize()); } else { if (foldStatus === display.FoldStatus.FOLD_STATUS_FOLDED || @@ -93,7 +94,6 @@ struct Index { } } // [StartExclude SelectCamera2] - this.isHalfFolded = false; this.oldFoldStatus = foldStatus; // [EndExclude SelectCamera2] } diff --git a/entry/src/main/ets/utils/CameraUtil.ets b/entry/src/main/ets/utils/CameraUtil.ets index 6aa127e..4467333 100644 --- a/entry/src/main/ets/utils/CameraUtil.ets +++ b/entry/src/main/ets/utils/CameraUtil.ets @@ -286,6 +286,10 @@ export class CameraUtil { this.xComponentController!.setXComponentSurfaceRect(rect); return; } + if (AppStorage.get('isHalfFolded')) { + this.setHalfFoldedRect(windowSize); + return; + } if (displayRotation === 0 || displayRotation === 180) { if (windowSize.height * 3 / 4 > windowSize.width) { rect.surfaceHeight = windowSize.width / 3 * 4; diff --git a/entry/src/main/ets/views/CommonView.ets b/entry/src/main/ets/views/CommonView.ets index d640d03..6c7b49e 100644 --- a/entry/src/main/ets/views/CommonView.ets +++ b/entry/src/main/ets/views/CommonView.ets @@ -124,14 +124,14 @@ export struct ShotAreaSm { .animation({ curve: curves.springMotion() }) .onClick(() => { if (this.photoUri !== '') { - this.cameraUtil?.previewPhoto(); + this.cameraUtil.previewPhoto(); } }) Image($r('app.media.icon_shoot')) .width(this.heightBp === HeightBreakpoint.HEIGHT_LG ? 76 : 46) .height(this.heightBp === HeightBreakpoint.HEIGHT_LG ? 76 : 46) .onClick(() => { - this.cameraUtil?.capture(); + this.cameraUtil.capture(); }) Image($r('app.media.icon_flip')) .width(this.heightBp === HeightBreakpoint.HEIGHT_LG ? 44 : 28) @@ -139,11 +139,11 @@ export struct ShotAreaSm { .onClick(() => { let isFront: boolean | undefined = AppStorage.get('isFront'); if (isFront) { - this.cameraUtil?.cameraShooting(this.surfaceId, this.context!, + this.cameraUtil.cameraShooting(this.surfaceId, this.context!, camera.CameraPosition.CAMERA_POSITION_BACK); return; } - this.cameraUtil?.cameraShooting(this.surfaceId, this.context!, camera.CameraPosition.CAMERA_POSITION_FRONT); + this.cameraUtil.cameraShooting(this.surfaceId, this.context!, camera.CameraPosition.CAMERA_POSITION_FRONT); }) } .width(this.heightBp === HeightBreakpoint.HEIGHT_LG ? 256 : 158) @@ -174,17 +174,17 @@ export struct ShotArea { .onClick(() => { let isFront: boolean | undefined = AppStorage.get('isFront'); if (isFront) { - this.cameraUtil?.cameraShooting(this.surfaceId, this.context!, + this.cameraUtil.cameraShooting(this.surfaceId, this.context!, camera.CameraPosition.CAMERA_POSITION_BACK); return; } - this.cameraUtil?.cameraShooting(this.surfaceId, this.context!, camera.CameraPosition.CAMERA_POSITION_FRONT); + this.cameraUtil.cameraShooting(this.surfaceId, this.context!, camera.CameraPosition.CAMERA_POSITION_FRONT); }) Image($r('app.media.icon_shoot')) .width(76) .height(76) .onClick(() => { - this.cameraUtil?.capture(); + this.cameraUtil.capture(); }) Image(this.photoUri) .width(44) @@ -195,7 +195,7 @@ export struct ShotArea { .animation({ curve: curves.springMotion() }) .onClick(() => { if (this.photoUri !== '') { - this.cameraUtil?.previewPhoto(); + this.cameraUtil.previewPhoto(); } }) } @@ -251,16 +251,16 @@ export struct ShotAreaHalfFolded { .onClick(() => { let isFront: boolean | undefined = AppStorage.get('isFront'); if (isFront) { - this.cameraUtil?.cameraShooting(this.surfaceId, this.context!, camera.CameraPosition.CAMERA_POSITION_BACK); + this.cameraUtil.cameraShooting(this.surfaceId, this.context!, camera.CameraPosition.CAMERA_POSITION_BACK); return; } - this.cameraUtil?.cameraShooting(this.surfaceId, this.context!, camera.CameraPosition.CAMERA_POSITION_FRONT); + this.cameraUtil.cameraShooting(this.surfaceId, this.context!, camera.CameraPosition.CAMERA_POSITION_FRONT); }) Image($r('app.media.icon_shoot')) .width(76) .height(76) .onClick(() => { - this.cameraUtil?.capture(); + this.cameraUtil.capture(); }) Image(this.photoUri) .width(44) @@ -271,7 +271,7 @@ export struct ShotAreaHalfFolded { .animation({ curve: curves.springMotion() }) .onClick(() => { if (this.photoUri !== '') { - this.cameraUtil?.previewPhoto(); + this.cameraUtil.previewPhoto(); } }) } -- Gitee