diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index c4f944c3afbde5648f9a1f12134f2cf771383f15..cbaaea3783a33a561fc5285defbf77b6265296d8 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -15,7 +15,6 @@ import { DataSource, PhotoData } from '../util/DataSource'; import { CommonConstants } from '../common//CommonConstants'; -import { common } from '@kit.AbilityKit'; import { display } from '@kit.ArkUI'; @Entry @@ -71,44 +70,33 @@ struct Index { // [EndExclude progress_component] Row() .zIndex(1) - .width(this.currentIndex >= index && !this.slide ? '100%' : '0') + .width(this.currentIndex === index ? '100%' : '0') .height(2) .borderRadius(2) .backgroundColor(Color.White) - .animation(!this.slide ? { - duration: this.duration - 400, + .animation({ + duration: this.currentIndex === index ? this.duration : 0, curve: Curve.Linear, iterations: 1, - playMode: PlayMode.Normal, - onFinish: () => { - if (this.currentIndex === this.progressData.length - 1) { - this.duration = 400; - this.currentIndex = -1; - } - } - } : { - duration: 0 + playMode: PlayMode.Normal }) // [StartExclude progress_component] Row() .zIndex(CommonConstants.Z_INDEX_2) - .width(this.currentIndex >= index && this.slide ? CommonConstants.FULL_PERCENT : + .width(this.currentIndex > index ? CommonConstants.FULL_PERCENT : CommonConstants.NONE_PERCENT) .height($r('app.float.row_height')) .borderRadius($r('app.float.row_borderRadius')) .backgroundColor(Color.White) // [EndExclude progress_component] } - .width('100%') - .height(2) - .borderRadius(2) - .backgroundColor(this.currentIndex >= index && this.slide ? Color.White : Color.Grey) .layoutWeight(1) }, (item: PhotoData) => JSON.stringify(item)) } .width('100%') .height(50) } + // [End progress_component] build() { @@ -139,8 +127,9 @@ struct Index { // [EndExclude on_gesture_swipe] } // [StartExclude on_gesture_swipe] - .loop(!this.slide ? true : false) - .autoPlay(!this.slide ? true : false) + .loop(true) + .autoPlay(true) + //.autoPlay(this.slide ? false : true) .interval(3000) .indicator(false) // [End image_swiper] @@ -152,27 +141,16 @@ struct Index { .displayArrow(false) .curve(Curve.Linear) .onChange((index: number) => { - this.duration = 3000; this.currentIndex = 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] - }) + // // [EndExclude on_gesture_swipe] + // .onGestureSwipe((index: number, extraInfo: SwiperAnimationEvent) => { + // this.slide = true; + // }) + // [End on_gesture_swipe] } .width(CommonConstants.FULL_PERCENT)