王士厅

图集滑动优化

@@ -114,7 +114,32 @@ export struct MultiPictureDetailPageComponent { @@ -114,7 +114,32 @@ export struct MultiPictureDetailPageComponent {
114 114
115 build() { 115 build() {
116 RelativeContainer() { 116 RelativeContainer() {
117 - this.init() 117 + if (this.contentDetailData.rmhPlatform == 1) {
  118 + this.rmh()
  119 + }
  120 + if (this.contentDetailData?.photoList && this.contentDetailData?.photoList?.length > 0) {
  121 + this.imgSwiper()
  122 + }
  123 + if (this.netStatus !== undefined) {
  124 + this.noNet()
  125 + }
  126 + if (this.isOffLine) {
  127 + this.offLine()
  128 + }
  129 + Column() {
  130 + if (!this.showDownload) {
  131 + this.NShowDownload()
  132 + }
  133 + if (this.showDownload) {
  134 + this.YShowDownload()
  135 + }
  136 + }
  137 + .zIndex(10)
  138 + .id('e_swiper_bottom')
  139 + .alignRules({
  140 + bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
  141 + middle: { anchor: "__container__", align: HorizontalAlign.Center }
  142 + })
118 CommentDialogView({ 143 CommentDialogView({
119 index: $index, 144 index: $index,
120 currentIndex: $currentIndex, 145 currentIndex: $currentIndex,
@@ -131,8 +156,7 @@ export struct MultiPictureDetailPageComponent { @@ -131,8 +156,7 @@ export struct MultiPictureDetailPageComponent {
131 } 156 }
132 157
133 @Builder 158 @Builder
134 - init() {  
135 - if (this.contentDetailData.rmhPlatform == 1) { 159 + rmh() {
136 if (!this.showDownload) { 160 if (!this.showDownload) {
137 Row() { 161 Row() {
138 Row({ space: 8 }) { 162 Row({ space: 8 }) {
@@ -275,9 +299,10 @@ export struct MultiPictureDetailPageComponent { @@ -275,9 +299,10 @@ export struct MultiPictureDetailPageComponent {
275 TransitionEffect.translate({ x: 0, y: `-${this.topSafeHeight + 12}px` }) 299 TransitionEffect.translate({ x: 0, y: `-${this.topSafeHeight + 12}px` })
276 )) 300 ))
277 } 301 }
278 -  
279 } 302 }
280 - if (this.contentDetailData?.photoList && this.contentDetailData?.photoList?.length > 0) { 303 +
  304 + @Builder
  305 + imgSwiper() {
281 Swiper(this.swiperController) { 306 Swiper(this.swiperController) {
282 ForEach(this.contentDetailData.photoList, (item: PhotoListBean) => { 307 ForEach(this.contentDetailData.photoList, (item: PhotoListBean) => {
283 Swiper(this.swiperControllerItem) { 308 Swiper(this.swiperControllerItem) {
@@ -290,6 +315,7 @@ export struct MultiPictureDetailPageComponent { @@ -290,6 +315,7 @@ export struct MultiPictureDetailPageComponent {
290 .cachedCount(1) 315 .cachedCount(1)
291 .indicator(false) 316 .indicator(false)
292 .displayCount(1) 317 .displayCount(1)
  318 + .loop(false)
293 .onGestureSwipe((index: number, extraInfo: SwiperAnimationEvent) => { 319 .onGestureSwipe((index: number, extraInfo: SwiperAnimationEvent) => {
294 console.info("onGestureSwipe current offset: " + extraInfo.currentOffset) 320 console.info("onGestureSwipe current offset: " + extraInfo.currentOffset)
295 this.currentOffset = Math.abs(extraInfo.currentOffset) 321 this.currentOffset = Math.abs(extraInfo.currentOffset)
@@ -315,7 +341,7 @@ export struct MultiPictureDetailPageComponent { @@ -315,7 +341,7 @@ export struct MultiPictureDetailPageComponent {
315 .indicator(false) 341 .indicator(false)
316 .displayCount(1) 342 .displayCount(1)
317 .loop(false) 343 .loop(false)
318 - .effectMode(EdgeEffect.None) 344 + .effectMode(EdgeEffect.Spring)
319 .id('e_swiper_content') 345 .id('e_swiper_content')
320 .alignRules({ 346 .alignRules({
321 center: { anchor: "__container__", align: VerticalAlign.Center }, 347 center: { anchor: "__container__", align: VerticalAlign.Center },
@@ -329,33 +355,9 @@ export struct MultiPictureDetailPageComponent { @@ -329,33 +355,9 @@ export struct MultiPictureDetailPageComponent {
329 this.showDownload = !this.showDownload 355 this.showDownload = !this.showDownload
330 }) 356 })
331 } 357 }
332 - if (this.netStatus !== undefined) {  
333 - EmptyComponent({  
334 - emptyType: 1, emptyButton: true, retry: () => {  
335 - this.getContentDetailData()  
336 - }  
337 - })  
338 - .id('e_empty_content')  
339 - .alignRules({  
340 - center: { anchor: "__container__", align: VerticalAlign.Center },  
341 - middle: { anchor: "__container__", align: HorizontalAlign.Center }  
342 - })  
343 - }  
344 - if (this.isOffLine) {  
345 - EmptyComponent({  
346 - emptyType: 15, emptyButton: true, retry: () => {  
347 - this.getContentDetailData  
348 - }  
349 - })  
350 - .id('e_empty_content')  
351 - .alignRules({  
352 - center: { anchor: "__container__", align: VerticalAlign.Center },  
353 - middle: { anchor: "__container__", align: HorizontalAlign.Center }  
354 - })  
355 - .backgroundColor(Color.Black)  
356 - }  
357 - Column() {  
358 - if (!this.showDownload) { 358 +
  359 + @Builder
  360 + NShowDownload() {
359 Column() { 361 Column() {
360 Row() { 362 Row() {
361 Scroll(this.scroller) { 363 Scroll(this.scroller) {
@@ -421,7 +423,9 @@ export struct MultiPictureDetailPageComponent { @@ -421,7 +423,9 @@ export struct MultiPictureDetailPageComponent {
421 } 423 }
422 .scrollable(ScrollDirection.Vertical) 424 .scrollable(ScrollDirection.Vertical)
423 .scrollBarWidth(0) 425 .scrollBarWidth(0)
424 - .height(px2vp(this.titleHeight)) 426 + .constraintSize({
  427 + maxHeight: px2vp(this.titleHeight)
  428 + })
425 .align(Alignment.Bottom) 429 .align(Alignment.Bottom)
426 } 430 }
427 431
@@ -442,7 +446,9 @@ export struct MultiPictureDetailPageComponent { @@ -442,7 +446,9 @@ export struct MultiPictureDetailPageComponent {
442 TransitionEffect.translate({ x: 0, y: `-${this.bottomSafeHeight}px` }) 446 TransitionEffect.translate({ x: 0, y: `-${this.bottomSafeHeight}px` })
443 )) 447 ))
444 } 448 }
445 - if (this.showDownload) { 449 +
  450 + @Builder
  451 + YShowDownload() {
446 Column() { 452 Column() {
447 Row() { 453 Row() {
448 Flex({ 454 Flex({
@@ -488,13 +494,34 @@ export struct MultiPictureDetailPageComponent { @@ -488,13 +494,34 @@ export struct MultiPictureDetailPageComponent {
488 TransitionEffect.translate({ x: 0, y: `${this.bottomSafeHeight}px` }) 494 TransitionEffect.translate({ x: 0, y: `${this.bottomSafeHeight}px` })
489 )) 495 ))
490 } 496 }
  497 +
  498 + @Builder
  499 + noNet() {
  500 + EmptyComponent({
  501 + emptyType: 1, emptyButton: true, retry: () => {
  502 + this.getContentDetailData()
  503 + }
  504 + })
  505 + .id('e_empty_content')
  506 + .alignRules({
  507 + center: { anchor: "__container__", align: VerticalAlign.Center },
  508 + middle: { anchor: "__container__", align: HorizontalAlign.Center }
  509 + })
491 } 510 }
492 - .zIndex(10)  
493 - .id('e_swiper_bottom') 511 +
  512 + @Builder
  513 + offLine() {
  514 + EmptyComponent({
  515 + emptyType: 15, emptyButton: true, retry: () => {
  516 + this.getContentDetailData
  517 + }
  518 + })
  519 + .id('e_empty_content')
494 .alignRules({ 520 .alignRules({
495 - bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, 521 + center: { anchor: "__container__", align: VerticalAlign.Center },
496 middle: { anchor: "__container__", align: HorizontalAlign.Center } 522 middle: { anchor: "__container__", align: HorizontalAlign.Center }
497 }) 523 })
  524 + .backgroundColor(Color.Black)
498 } 525 }
499 526
500 getContentDetailData() { 527 getContentDetailData() {