From 269882f4c5776c88a01a68f4363ca6fd44d16246 Mon Sep 17 00:00:00 2001 From: "OWNEROR-41FNVD0\\lenovo" Date: Tue, 3 Jun 2025 16:20:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20MultipleImage=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/Index.ets | 51 +++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 2548f86..c4f944c 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -55,23 +55,25 @@ struct Index { this.data = new DataSource(list); } + // [Start progress_component] @Builder progressComponent() { - Row({ space: CommonConstants.ROW_SPACE }) { + Row({ space: 5 }) { ForEach(this.progressData, (item: PhotoData, index: number) => { Stack({ alignContent: Alignment.Start }) { + // [StartExclude progress_component] Row() .zIndex(CommonConstants.Z_INDEX_0) .width(CommonConstants.FULL_PERCENT) .height($r('app.float.row_height')) .borderRadius($r('app.float.row_borderRadius')) .backgroundColor(Color.Grey) + // [EndExclude progress_component] Row() - .zIndex(CommonConstants.Z_INDEX_1) - .width(this.currentIndex >= index && !this.slide ? CommonConstants.FULL_PERCENT : - CommonConstants.NONE_PERCENT) - .height($r('app.float.row_height')) - .borderRadius($r('app.float.row_borderRadius')) + .zIndex(1) + .width(this.currentIndex >= index && !this.slide ? '100%' : '0') + .height(2) + .borderRadius(2) .backgroundColor(Color.White) .animation(!this.slide ? { duration: this.duration - 400, @@ -87,6 +89,7 @@ struct Index { } : { duration: 0 }) + // [StartExclude progress_component] Row() .zIndex(CommonConstants.Z_INDEX_2) .width(this.currentIndex >= index && this.slide ? CommonConstants.FULL_PERCENT : @@ -94,13 +97,19 @@ struct Index { .height($r('app.float.row_height')) .borderRadius($r('app.float.row_borderRadius')) .backgroundColor(Color.White) + // [EndExclude progress_component] } - .layoutWeight(CommonConstants.LAYOUT_WEIGHT) + .width('100%') + .height(2) + .borderRadius(2) + .backgroundColor(this.currentIndex >= index && this.slide ? Color.White : Color.Grey) + .layoutWeight(1) }, (item: PhotoData) => JSON.stringify(item)) } - .width(CommonConstants.FULL_PERCENT) - .height(CommonConstants.PROGRESS_WRAP_HEIGHT) + .width('100%') + .height(50) } + // [End progress_component] build() { Column() { @@ -118,22 +127,28 @@ struct Index { Scroll() { List() { ListItem() { + // [Start on_gesture_swipe] + // [Start image_swiper] Swiper(this.swiperController) { + // [StartExclude on_gesture_swipe] LazyForEach(this.data, (item: PhotoData, index: number) => { Image($r(`app.media.` + item.id)) - .width(this.foldStatus === 2 ? CommonConstants.FULL_PERCENT: CommonConstants.Foldable_PERCENT) - .height(CommonConstants.FULL_PERCENT) + .width(this.foldStatus === 2 ? '100%' : '70%') + .height('100%') }, (item: PhotoData) => JSON.stringify(item)) + // [EndExclude on_gesture_swipe] } + // [StartExclude on_gesture_swipe] + .loop(!this.slide ? true : false) + .autoPlay(!this.slide ? true : false) + .interval(3000) + .indicator(false) + // [End image_swiper] .cachedCount(CommonConstants.SWIPER_CACHED_COUNT) .index($$this.slideIndex) - .autoPlay(!this.slide ? true : false) - .interval(CommonConstants.INTERVAL) - .loop(!this.slide ? true : false) .indicatorInteractive(false) .duration(CommonConstants.IMAGE_DURATION) .itemSpace(CommonConstants.ITEM_SPACE) - .indicator(false) .displayArrow(false) .curve(Curve.Linear) .onChange((index: number) => { @@ -143,16 +158,22 @@ struct Index { .onAppear(() => { this.currentIndex = 0; }) + // [EndExclude on_gesture_swipe] .onGestureSwipe((index: number, extraInfo: SwiperAnimationEvent) => { + // [StartExclude on_gesture_swipe] if (extraInfo.currentOffset > 0 && index === 0 && !this.slide) { let context = this.getUIContext().getHostContext() as common.UIAbilityContext; context.terminateSelf(); } + // [EndExclude on_gesture_swipe] this.slide = true; + // [StartExclude on_gesture_swipe] if (extraInfo.currentOffset > 0 && this.currentIndex > 0) { this.currentIndex = index - 1; } + // [EndExclude on_gesture_swipe] }) + // [End on_gesture_swipe] } .width(CommonConstants.FULL_PERCENT) .height(this.swiperMaxHeight) -- Gitee