From b2f465552419e5bc5d80dcfe56ebad4877f473d9 Mon Sep 17 00:00:00 2001 From: yxk2026 <10178404+yxk2026@user.noreply.gitee.com> Date: Thu, 27 Mar 2025 10:38:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E3=80=90HMOSWorld=E6=95=B4=E6=94=B9?= =?UTF-8?q?=E3=80=91=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/Index.ets | 84 +++++++++++++++--------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index f5a4d05..ee2d3b6 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -22,7 +22,6 @@ import { BreakpointType, CommonConstants } from '../common//CommonConstants'; @Entry @Component struct Index { - private swiperController: SwiperController = new SwiperController(); @State progressData: PhotoData[] = []; @State data: DataSource = new DataSource([]); @State currentIndex: number = CommonConstants.INITIALLY_CURRENT_INDEX; @@ -110,53 +109,54 @@ struct Index { .height(CommonConstants.PROGRESS_WRAP_HEIGHT) } + @Builder + image(item: PhotoData) { + Image($r(`app.media.` + item.id)) + .width(CommonConstants.FULL_PERCENT) + } + build() { Column() { Stack({ alignContent: Alignment.BottomStart }) { Scroll() { - List() { - ListItem() { - Swiper(this.swiperController) { - LazyForEach(this.data, (item: PhotoData, index: number) => { - Image($r(`app.media.` + item.id)) - .width(CommonConstants.FULL_PERCENT) - }, (item: PhotoData) => JSON.stringify(item)) - } - .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) => { - this.duration = 3000; - this.currentIndex = index; - }) - .onAppear(() => { - this.currentIndex = 0; - }) - .onGestureSwipe((index: number, extraInfo: SwiperAnimationEvent) => { - if (extraInfo.currentOffset > 0 && index === 0 && !this.slide) { - let context = getContext(this) as common.UIAbilityContext; - context.terminateSelf(); - } - this.slide = true; - if (extraInfo.currentOffset > 0 && this.currentIndex > 0) { - this.currentIndex = index - 1; - } - }) - } - .width(CommonConstants.FULL_PERCENT) - .height(CommonConstants.FULL_PERCENT) + Swiper() { + LazyForEach(this.data, (item: PhotoData) => { + this.image(item) + }, (item: string) => item) } - .width(CommonConstants.FULL_PERCENT) - .height(CommonConstants.FULL_PERCENT) + .onAnimationStart(() => { + }) + .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) => { + this.duration = 3000; + this.currentIndex = index; + }) + .onAppear(() => { + this.currentIndex = 0; + }) + .onGestureSwipe((index: number, extraInfo: SwiperAnimationEvent) => { + if (extraInfo.currentOffset > 0 && index === 0 && !this.slide) { + let context = getContext(this) as common.UIAbilityContext; + context.terminateSelf(); + } + this.slide = true; + if (extraInfo.currentOffset > 0 && this.currentIndex > 0) { + this.currentIndex = index - 1; + } + }) } + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) Column() { Column({ space: CommonConstants.COLUMN_SPACE }) { -- Gitee From 2f2e5d9f69493ae6baa1c77eee7b48f75c805122 Mon Sep 17 00:00:00 2001 From: yxk2026 <10178404+yxk2026@user.noreply.gitee.com> Date: Thu, 27 Mar 2025 11:52:49 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E3=80=90HMOSWorld=E6=95=B4=E6=94=B9?= =?UTF-8?q?=E3=80=91=E5=86=97=E4=BD=99=E4=BB=A3=E7=A0=81=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/CommonConstants.ets | 45 ------------------- entry/src/main/ets/pages/Index.ets | 4 -- 2 files changed, 49 deletions(-) diff --git a/entry/src/main/ets/common/CommonConstants.ets b/entry/src/main/ets/common/CommonConstants.ets index ed6c206..b9d46bd 100644 --- a/entry/src/main/ets/common/CommonConstants.ets +++ b/entry/src/main/ets/common/CommonConstants.ets @@ -54,21 +54,6 @@ export class CommonConstants { */ public static readonly ITEM_SPACE: number = 0; - /** - * Swiper interval duration. - */ - public static readonly INITIALLY_DURATION: number = 300; - - /** - * Swiper duration. - */ - public static readonly NO_DURATION: number = 0; - - /** - * Swiper max height. - */ - public static readonly SWIPER_MAX_HEIGHT: number = 333; - /** * Swiper cached count. */ @@ -94,31 +79,11 @@ export class CommonConstants { */ public static readonly Z_INDEX_2: number = 2; - /** - * zIndex. - */ - public static readonly Z_INDEX_3: number = 3; - - /** - * Swiper initially Index. - */ - public static readonly INITIALLY_INDEX: number = 0; - /** * Layout weight. */ public static readonly LAYOUT_WEIGHT: number = 1; - /** - * Column height. - */ - public static readonly COLUMN_HEIGHT: number = 100; - - /** - * Multipart form text weight. - */ - public static readonly FORM_TEXT_FONT_WEIGHT: number = 500; - /** * Row space. */ @@ -137,16 +102,6 @@ export class CommonConstants { * Breakpoint sm. */ public static readonly BREAK_POINT_SM: string = 'sm'; - - /** - * Breakpoint md. - */ - public static readonly BREAK_POINT_MD: string = 'md'; - - /** - * Breakpoint lg. - */ - public static readonly BREAK_POINT_LG: string = 'lg'; } export class BreakpointType { diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index ee2d3b6..0ccf681 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -27,15 +27,11 @@ struct Index { @State currentIndex: number = CommonConstants.INITIALLY_CURRENT_INDEX; @State slideIndex: number = CommonConstants.SLIDE_INDEX; @State duration: number = CommonConstants.DURATION; - @State swiperMaxHeight: number = CommonConstants.SWIPER_MAX_HEIGHT; - @State progressHeight: number = CommonConstants.PROGRESS_WRAP_HEIGHT; @State slide: boolean = false; @State foldStatus: number = 2; @State isFoldable: boolean = false; @StorageProp('bottomRectHeight') bottomRectHeight: number = 0; - @StorageProp('topRectHeight') topRectHeight: number = 0; @StorageProp('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; - scroller: Scroller = new Scroller(); aboutToAppear(): void { try { -- Gitee