Showing
3 changed files
with
85 additions
and
78 deletions
| @@ -7,6 +7,7 @@ import { windowSizeManager } from '../utils/Managers'; | @@ -7,6 +7,7 @@ import { windowSizeManager } from '../utils/Managers'; | ||
| 7 | import { runWithAnimation } from '../utils/FuncUtils'; | 7 | import { runWithAnimation } from '../utils/FuncUtils'; |
| 8 | import { PhotoListBean } from 'wdBean/Index'; | 8 | import { PhotoListBean } from 'wdBean/Index'; |
| 9 | import { http } from '@kit.NetworkKit'; | 9 | import { http } from '@kit.NetworkKit'; |
| 10 | +import { router } from '@kit.ArkUI'; | ||
| 10 | 11 | ||
| 11 | const TAG = 'MultiPictureDetailItemComponent'; | 12 | const TAG = 'MultiPictureDetailItemComponent'; |
| 12 | 13 | ||
| @@ -27,12 +28,15 @@ export struct MultiPictureDetailItemComponent { | @@ -27,12 +28,15 @@ export struct MultiPictureDetailItemComponent { | ||
| 27 | private MultiPictureDetailItem: PhotoListBean = {} as PhotoListBean | 28 | private MultiPictureDetailItem: PhotoListBean = {} as PhotoListBean |
| 28 | //alt app.media.picture_loading 设计稿尺寸 | 29 | //alt app.media.picture_loading 设计稿尺寸 |
| 29 | @State imageWidth:string | number = 167 | 30 | @State imageWidth:string | number = 167 |
| 30 | - private scroller: Scroller = new Scroller() | 31 | + private swiperControllerItem: SwiperController = new SwiperController() |
| 32 | + @State currentOffset: number = 0 | ||
| 33 | + @Consume duration: number | ||
| 31 | 34 | ||
| 32 | 35 | ||
| 33 | async aboutToAppear() { | 36 | async aboutToAppear() { |
| 34 | this.imageUri = this.MultiPictureDetailItem.picPath | 37 | this.imageUri = this.MultiPictureDetailItem.picPath |
| 35 | this.getPicture() | 38 | this.getPicture() |
| 39 | + console.log(TAG, JSON.stringify(this.MultiPictureDetailItem)) | ||
| 36 | } | 40 | } |
| 37 | 41 | ||
| 38 | /** | 42 | /** |
| @@ -179,54 +183,79 @@ export struct MultiPictureDetailItemComponent { | @@ -179,54 +183,79 @@ export struct MultiPictureDetailItemComponent { | ||
| 179 | } | 183 | } |
| 180 | 184 | ||
| 181 | build() { | 185 | build() { |
| 182 | - Row() { | ||
| 183 | - Scroll(this.scroller) { | ||
| 184 | - if(this.imageUri != null && (this.imageUri.includes('.gif') || this.imageUri.includes('.GIF'))){ | ||
| 185 | - Image(this.imageUri)// TODO:知识点:宽高只根据其尺寸设置一个,通过保持宽高比来设置另一个属性 | ||
| 186 | - .alt($r('app.media.datail_imageLoading_w')) | ||
| 187 | - .width(this.imageWidth) | ||
| 188 | - .objectFit(ImageFit.Auto)// TODO:知识点:保持宽高比进行缩放,可以超出父组件,以便实现多图切换的增强功能 | ||
| 189 | - .interpolation(ImageInterpolation.High) | ||
| 190 | - .autoResize(false) | ||
| 191 | - .transform(this.matrix)// TODO:知识点:通过matrix控制图片的缩放 | ||
| 192 | - .defaultFocus(true) | ||
| 193 | - .offset({ | ||
| 194 | - // TODO:知识点:通过offset控制图片的偏移 | ||
| 195 | - x: this.imageOffsetInfo.currentX, | ||
| 196 | - y: this.imageOffsetInfo.currentY | ||
| 197 | - }) | ||
| 198 | - .onComplete(event => { | ||
| 199 | - this.imageWidth = '100%' | ||
| 200 | - }) | ||
| 201 | - }else{ | ||
| 202 | - Image(this.imagePixelMap || 'app.media.datail_imageLoading_w')// TODO:知识点:宽高只根据其尺寸设置一个,通过保持宽高比来设置另一个属性 | ||
| 203 | - .alt($r('app.media.datail_imageLoading_w')) | ||
| 204 | - .width(this.imageWidth) | ||
| 205 | - .objectFit(ImageFit.Auto)// TODO:知识点:保持宽高比进行缩放,可以超出父组件,以便实现多图切换的增强功能 | ||
| 206 | - .interpolation(ImageInterpolation.High) | ||
| 207 | - .autoResize(false) | ||
| 208 | - .transform(this.matrix)// TODO:知识点:通过matrix控制图片的缩放 | ||
| 209 | - .defaultFocus(true) | ||
| 210 | - .offset({ | ||
| 211 | - // TODO:知识点:通过offset控制图片的偏移 | ||
| 212 | - x: this.imageOffsetInfo.currentX, | ||
| 213 | - y: this.imageOffsetInfo.currentY | ||
| 214 | - }) | ||
| 215 | - .onComplete(event => { | ||
| 216 | - this.imageWidth = '100%' | ||
| 217 | - }) | 186 | + Swiper(this.swiperControllerItem){ |
| 187 | + Row(){ // 居中显示 | ||
| 188 | + List(){ | ||
| 189 | + ListItem(){ | ||
| 190 | + if(this.imageUri != null && (this.imageUri.includes('.gif') || this.imageUri.includes('.GIF'))){ | ||
| 191 | + Image(this.imageUri)// TODO:知识点:宽高只根据其尺寸设置一个,通过保持宽高比来设置另一个属性 | ||
| 192 | + .alt($r('app.media.datail_imageLoading_w')) | ||
| 193 | + .width(this.imageWidth) | ||
| 194 | + .objectFit(ImageFit.Auto)// TODO:知识点:保持宽高比进行缩放,可以超出父组件,以便实现多图切换的增强功能 | ||
| 195 | + .interpolation(ImageInterpolation.High) | ||
| 196 | + .autoResize(false) | ||
| 197 | + .transform(this.matrix)// TODO:知识点:通过matrix控制图片的缩放 | ||
| 198 | + .defaultFocus(true) | ||
| 199 | + .offset({ | ||
| 200 | + // TODO:知识点:通过offset控制图片的偏移 | ||
| 201 | + x: this.imageOffsetInfo.currentX, | ||
| 202 | + y: this.imageOffsetInfo.currentY | ||
| 203 | + | ||
| 204 | + }) | ||
| 205 | + .onComplete(event => { | ||
| 206 | + this.imageWidth = '100%' | ||
| 207 | + }) | ||
| 208 | + } else { | ||
| 209 | + Image(this.imagePixelMap || 'app.media.datail_imageLoading_w')// TODO:知识点:宽高只根据其尺寸设置一个,通过保持宽高比来设置另一个属性 | ||
| 210 | + .alt($r('app.media.datail_imageLoading_w')) | ||
| 211 | + .width(this.imageWidth) | ||
| 212 | + .objectFit(ImageFit.Auto)// TODO:知识点:保持宽高比进行缩放,可以超出父组件,以便实现多图切换的增强功能 | ||
| 213 | + .interpolation(ImageInterpolation.High) | ||
| 214 | + .autoResize(false) | ||
| 215 | + .transform(this.matrix)// TODO:知识点:通过matrix控制图片的缩放 | ||
| 216 | + .defaultFocus(true) | ||
| 217 | + .offset({ | ||
| 218 | + // TODO:知识点:通过offset控制图片的偏移 | ||
| 219 | + x: this.imageOffsetInfo.currentX, | ||
| 220 | + y: this.imageOffsetInfo.currentY | ||
| 221 | + }) | ||
| 222 | + .onComplete(event => { | ||
| 223 | + this.imageWidth = '100%' | ||
| 224 | + }) | ||
| 225 | + } | ||
| 226 | + } | ||
| 218 | } | 227 | } |
| 228 | + .alignListItem(ListItemAlign.Center) | ||
| 229 | + .scrollBarWidth(0) | ||
| 219 | } | 230 | } |
| 220 | - .scrollable(ScrollDirection.Vertical) | ||
| 221 | - .scrollBarWidth(0) | ||
| 222 | - // .height(this.imageDefaultSize.height || "100%") | 231 | + .justifyContent(FlexAlign.Center) |
| 223 | } | 232 | } |
| 233 | + .height('100%') | ||
| 234 | + .vertical(true) | ||
| 235 | + .autoPlay(false) | ||
| 236 | + .cachedCount(1) | ||
| 237 | + .indicator(false) | ||
| 238 | + .displayCount(1) | ||
| 239 | + .loop(false) | ||
| 240 | + .zIndex(10) | ||
| 241 | + .onGestureSwipe((index: number, extraInfo: SwiperAnimationEvent) => { | ||
| 242 | + console.info("onGestureSwipe current offset: " + extraInfo.currentOffset) | ||
| 243 | + this.currentOffset = Math.abs(extraInfo.currentOffset) | ||
| 244 | + }) | ||
| 245 | + .onTouch((event: TouchEvent) => { | ||
| 246 | + if (this.duration === 0) { | ||
| 247 | + this.duration = 500 | ||
| 248 | + } | ||
| 249 | + if (event.type === 1) { | ||
| 250 | + // if(this.currentOffset > px2vp((this.windowHeight - item.height)/2 - 100)) { | ||
| 251 | + if (this.currentOffset > 160) { | ||
| 252 | + router.back() | ||
| 253 | + } | ||
| 254 | + } | ||
| 255 | + }) | ||
| 224 | .onBlur(() => { | 256 | .onBlur(() => { |
| 225 | this.resetCurrentImageInfo(); | 257 | this.resetCurrentImageInfo(); |
| 226 | }) | 258 | }) |
| 227 | - .height('100%') | ||
| 228 | - .width('100%') | ||
| 229 | - .justifyContent(FlexAlign.Center) | ||
| 230 | .gesture( | 259 | .gesture( |
| 231 | GestureGroup( | 260 | GestureGroup( |
| 232 | GestureMode.Exclusive, | 261 | GestureMode.Exclusive, |
| @@ -326,5 +355,6 @@ export struct MultiPictureDetailItemComponent { | @@ -326,5 +355,6 @@ export struct MultiPictureDetailItemComponent { | ||
| 326 | // }) | 355 | // }) |
| 327 | ), | 356 | ), |
| 328 | ) | 357 | ) |
| 358 | + // .height(this.imageDefaultSize.height || "100%") | ||
| 329 | } | 359 | } |
| 330 | } | 360 | } |
| @@ -24,6 +24,7 @@ export struct MultiPictureListPage { | @@ -24,6 +24,7 @@ export struct MultiPictureListPage { | ||
| 24 | @Provide bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | 24 | @Provide bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 |
| 25 | @Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 | 25 | @Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 |
| 26 | // @Provide bgc: Color = Color.White; | 26 | // @Provide bgc: Color = Color.White; |
| 27 | + @Provide duration: number = 0 | ||
| 27 | 28 | ||
| 28 | aboutToAppear(): void { | 29 | aboutToAppear(): void { |
| 29 | //获取宽高尺寸 | 30 | //获取宽高尺寸 |
| 1 | -import { NetworkUtil, Logger, NetworkType, SPHelper, WindowModel, StringUtils } from 'wdKit'; | 1 | +import { NetworkUtil, Logger, SPHelper, StringUtils } from 'wdKit'; |
| 2 | import { ResponseDTO } from 'wdNetwork'; | 2 | import { ResponseDTO } from 'wdNetwork'; |
| 3 | import { | 3 | import { |
| 4 | ContentDetailDTO, | 4 | ContentDetailDTO, |
| @@ -9,11 +9,9 @@ import { | @@ -9,11 +9,9 @@ import { | ||
| 9 | Params, | 9 | Params, |
| 10 | InteractDataDTO | 10 | InteractDataDTO |
| 11 | } from 'wdBean'; | 11 | } from 'wdBean'; |
| 12 | -import display from '@ohos.display'; | ||
| 13 | import { DateTimeUtils } from 'wdKit/Index'; | 12 | import { DateTimeUtils } from 'wdKit/Index'; |
| 14 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | 13 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; |
| 15 | import { SpConstants } from 'wdConstant/Index'; | 14 | import { SpConstants } from 'wdConstant/Index'; |
| 16 | -import { router } from '@kit.ArkUI'; | ||
| 17 | import { common } from '@kit.AbilityKit'; | 15 | import { common } from '@kit.AbilityKit'; |
| 18 | import { CommentDialogView } from 'wdDetailPlayShortVideo/Index'; | 16 | import { CommentDialogView } from 'wdDetailPlayShortVideo/Index'; |
| 19 | import { EmptyComponent, | 17 | import { EmptyComponent, |
| @@ -44,7 +42,6 @@ export struct MultiPictureDetailPageComponent { | @@ -44,7 +42,6 @@ export struct MultiPictureDetailPageComponent { | ||
| 44 | @Consume topSafeHeight: number | 42 | @Consume topSafeHeight: number |
| 45 | @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01' | 43 | @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01' |
| 46 | private swiperController: SwiperController = new SwiperController() | 44 | private swiperController: SwiperController = new SwiperController() |
| 47 | - private swiperControllerItem: SwiperController = new SwiperController() | ||
| 48 | @State swiperIndex: number = 0; | 45 | @State swiperIndex: number = 0; |
| 49 | @Provide followStatus: string | undefined = '0' // 关注状态 | 46 | @Provide followStatus: string | undefined = '0' // 关注状态 |
| 50 | @Provide showCommentList: boolean = false | 47 | @Provide showCommentList: boolean = false |
| @@ -56,14 +53,13 @@ export struct MultiPictureDetailPageComponent { | @@ -56,14 +53,13 @@ export struct MultiPictureDetailPageComponent { | ||
| 56 | @State showDownload: Boolean = false // 控制是否显示下载默认隐藏 | 53 | @State showDownload: Boolean = false // 控制是否显示下载默认隐藏 |
| 57 | @State publishCommentModel: publishCommentModel = new publishCommentModel() | 54 | @State publishCommentModel: publishCommentModel = new publishCommentModel() |
| 58 | @State operationButtonList: string[] = ['comment', 'like', 'collect', 'share'] | 55 | @State operationButtonList: string[] = ['comment', 'like', 'collect', 'share'] |
| 59 | - @State currentOffset: number = 0 | ||
| 60 | - @State duration: number = 0 | ||
| 61 | @Provide interactData: InteractDataDTO = {} as InteractDataDTO | 56 | @Provide interactData: InteractDataDTO = {} as InteractDataDTO |
| 62 | pageParam: ParamType = {} | 57 | pageParam: ParamType = {} |
| 63 | followUserId: string = '' | 58 | followUserId: string = '' |
| 64 | followUserName: string = '' | 59 | followUserName: string = '' |
| 65 | @State isEnableSwipe: boolean = true; | 60 | @State isEnableSwipe: boolean = true; |
| 66 | @State isScrollerTop: boolean = false; | 61 | @State isScrollerTop: boolean = false; |
| 62 | + @Provide duration: number = 0 | ||
| 67 | 63 | ||
| 68 | //watch监听页码回调 | 64 | //watch监听页码回调 |
| 69 | onCurrentPageNumUpdated(): void { | 65 | onCurrentPageNumUpdated(): void { |
| @@ -300,32 +296,9 @@ export struct MultiPictureDetailPageComponent { | @@ -300,32 +296,9 @@ export struct MultiPictureDetailPageComponent { | ||
| 300 | imgSwiper() { | 296 | imgSwiper() { |
| 301 | Swiper(this.swiperController) { | 297 | Swiper(this.swiperController) { |
| 302 | ForEach(this.contentDetailData.photoList, (item: PhotoListBean) => { | 298 | ForEach(this.contentDetailData.photoList, (item: PhotoListBean) => { |
| 303 | - Swiper(this.swiperControllerItem) { | ||
| 304 | - MultiPictureDetailItemComponent({ MultiPictureDetailItem: item, isEnableSwipe: this.isEnableSwipe }) | ||
| 305 | - } | ||
| 306 | - .width('100%') | ||
| 307 | - .height('100%') | ||
| 308 | - .vertical(true) | ||
| 309 | - .autoPlay(false) | ||
| 310 | - .cachedCount(1) | ||
| 311 | - .indicator(false) | ||
| 312 | - .displayCount(1) | ||
| 313 | - .loop(false) | ||
| 314 | - .onGestureSwipe((index: number, extraInfo: SwiperAnimationEvent) => { | ||
| 315 | - console.info("onGestureSwipe current offset: " + extraInfo.currentOffset) | ||
| 316 | - this.currentOffset = Math.abs(extraInfo.currentOffset) | ||
| 317 | - }) | ||
| 318 | - .onTouch((event: TouchEvent) => { | ||
| 319 | - if (this.duration === 0) { | ||
| 320 | - this.duration = 500 | ||
| 321 | - } | ||
| 322 | - if (event.type === 1) { | ||
| 323 | - // if(this.currentOffset > px2vp((this.windowHeight - item.height)/2 - 100)) { | ||
| 324 | - if (this.currentOffset > 160) { | ||
| 325 | - router.back() | ||
| 326 | - } | ||
| 327 | - } | ||
| 328 | - }) | 299 | + MultiPictureDetailItemComponent( |
| 300 | + { MultiPictureDetailItem: item, isEnableSwipe: this.isEnableSwipe } | ||
| 301 | + ) | ||
| 329 | }) | 302 | }) |
| 330 | } | 303 | } |
| 331 | .index(this.swiperIndex) | 304 | .index(this.swiperIndex) |
| @@ -425,9 +398,9 @@ export struct MultiPictureDetailPageComponent { | @@ -425,9 +398,9 @@ export struct MultiPictureDetailPageComponent { | ||
| 425 | 398 | ||
| 426 | Scroll(this.scroller) { | 399 | Scroll(this.scroller) { |
| 427 | Column() { | 400 | Column() { |
| 428 | - Row() | 401 | + /*Row() |
| 429 | .width("100%") | 402 | .width("100%") |
| 430 | - .height(this.contentDetailData.photoList?.[this.swiperIndex].picDesc ? 90 : 130) | 403 | + .height(this.contentDetailData.photoList?.[this.swiperIndex].picDesc ? 90 : 130)*/ |
| 431 | Flex({ | 404 | Flex({ |
| 432 | direction: FlexDirection.Column | 405 | direction: FlexDirection.Column |
| 433 | }) { | 406 | }) { |
| @@ -451,7 +424,10 @@ export struct MultiPictureDetailPageComponent { | @@ -451,7 +424,10 @@ export struct MultiPictureDetailPageComponent { | ||
| 451 | }) | 424 | }) |
| 452 | } | 425 | } |
| 453 | } | 426 | } |
| 454 | - .height(230) | 427 | + .constraintSize({ |
| 428 | + maxHeight: 230 | ||
| 429 | + }) | ||
| 430 | + // .height(230) | ||
| 455 | .edgeEffect(EdgeEffect.None) | 431 | .edgeEffect(EdgeEffect.None) |
| 456 | .scrollBarWidth(0) | 432 | .scrollBarWidth(0) |
| 457 | .scrollBar(BarState.Off) | 433 | .scrollBar(BarState.Off) |
-
Please register or login to post a comment