From 4d3b077d5d34e1d5c6da8b93ae3461a6426a6868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E4=B8=9C=E6=B5=B7?= Date: Wed, 18 Jun 2025 09:17:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=A0=87=E8=AF=86?= =?UTF-8?q?=E5=92=8C=E5=B8=B8=E9=87=8F=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- features/albumView/src/main/ets/views/AlbumView.ets | 9 ++++++++- features/pictureView/src/main/ets/view/CenterPart.ets | 8 +++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/features/albumView/src/main/ets/views/AlbumView.ets b/features/albumView/src/main/ets/views/AlbumView.ets index c751d05..e52410e 100644 --- a/features/albumView/src/main/ets/views/AlbumView.ets +++ b/features/albumView/src/main/ets/views/AlbumView.ets @@ -46,10 +46,12 @@ export struct AlbumView { // Save down setTimeOut timeOutDownDemo: number = 0 + // [Start get_grid_column] // Change the number of Grid columns based on the width of the Grid component. getGridColumn(value: Length): number { return Math.floor(2 * ((parseInt(JSON.stringify(value)) / 360) - 1) + 4); } + // [End get_grid_column] // PinchGesture up up() { @@ -157,7 +159,9 @@ export struct AlbumView { SideColumn() .width($r('app.float.side_width')) } + // [Start album_view_change] Flex({ direction: FlexDirection.Column }) { + // [StartExclude album_view_change] this.topRow() Flex() { Grid() { @@ -172,11 +176,12 @@ export struct AlbumView { }, (item: ImageData, index: number) => index + JSON.stringify(item)) } .columnsTemplate(new Array(this.gridColumn).fill(DEFAULT_GRID_TEMPLATE).join(' ')) - } + // [EndExclude album_view_change] .onAreaChange((oldValue: Area, newValue: Area) => { this.gridColumn = this.getGridColumn(newValue.width); }) + // [StartExclude album_view_change] .gesture(PinchGesture({ fingers: FINGER_NUMBER }).onActionUpdate((event: GestureEvent) => { if (event.scale > 1) { this.up() @@ -184,7 +189,9 @@ export struct AlbumView { this.down() } })) + // [EndExclude album_view_change] } + // [End album_view_change] } .padding({ top: deviceInfo.deviceType === BaseConstants.DEVICE_2IN1 ? $r('app.float.zero') : diff --git a/features/pictureView/src/main/ets/view/CenterPart.ets b/features/pictureView/src/main/ets/view/CenterPart.ets index 1f43091..10c72bc 100755 --- a/features/pictureView/src/main/ets/view/CenterPart.ets +++ b/features/pictureView/src/main/ets/view/CenterPart.ets @@ -16,8 +16,6 @@ import { BreakpointConstants } from '@ohos/commons'; import { Adaptive } from '../viewmodel/AdaptiveViewModel' -const FINGER_NUM: number = 2 - @Component export struct CenterPart { @StorageLink('currentBreakpoint') currentBp: string = BreakpointConstants.BREAKPOINT_MD; @@ -27,16 +25,19 @@ export struct CenterPart { build() { Flex({ direction: FlexDirection.Column }) { Blank() + // [Start center_part] Row() { Column() { Image($r('app.media.photo')) .autoResize(true) } } + // [StartExclude center_part] .height(Adaptive.PICTURE_HEIGHT(this.currentBp)) .width(Adaptive.PICTURE_WIDTH(this.currentBp)) + // [EndExclude center_part] .scale({ x: this.scaleValue, y: this.scaleValue, z: 1 }) - .gesture(PinchGesture({ fingers: FINGER_NUM }) + .gesture(PinchGesture({ fingers: 2 }) .onActionUpdate((event: GestureEvent | undefined) => { if (event) { this.scaleValue = this.pinchValue * event.scale; @@ -45,6 +46,7 @@ export struct CenterPart { .onActionEnd(() => { this.pinchValue = this.scaleValue; })) + // [End center_part] Blank() .height(this.currentBp === BreakpointConstants.BREAKPOINT_SM ? $r('app.float.center_blank_height_lg') : 0) -- Gitee