Przeglądaj źródła

去掉List模式下 长按拖动代码,直接长按是菜单出来

onecold 7 miesięcy temu
rodzic
commit
ce434c6b20

+ 1 - 1
entry/src/main/ets/pages/PlaylistDetailPage.ets

@@ -897,7 +897,7 @@ export struct PlaylistDetailPage {
         width: { left: this.isPlaying && this.curIndex === index ? 3 : 0 },
         color: this.isDarkMode ? themeColorWithAlpha(this.themeColor, 0.8, this.isDarkMode) : this.themeColor
       })
-      .opacity(this.dragItem === index ? 0.5 : this.pageOpacity)
+      .opacity(this.dragItem === index ? 0.2 : this.pageOpacity)
       .translate({ x: 0, y: this.showContent ? 0 : 20 })
       .transition(TransitionEffect.OPACITY.animation({
         duration: 600,

+ 17 - 140
entry/src/main/ets/view/LocalMusic.ets

@@ -4819,23 +4819,6 @@ export struct LocalMusic {
               type: ShadowType.BLUR,
               color: 'on_primary'
             })
-            .gesture(LongPressGesture()
-              .onAction(async () => {
-                //如果是专辑和艺术家的首页,不能长按
-                if((this.modeType===2||this.modeType==3)&&!this.isCanBack)
-                  return
-                //如果是我的收藏 最近播放等也不能长按
-                if(item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
-                  item.name === LocalMusic.STR_HISTORY_MUSIC
-                )
-                  return
-                this.longItemFilePath = item.filePath
-                this.tempLyricContent = await this.getLyricContent(item)
-                LogUtil.info('长按this.tempLyricContent = '+this.tempLyricContent)
-              })
-              .onActionEnd((event: GestureEvent) => {
-
-              }))
             .onClick(()=>{
               if (this.isMultiSelect) {
                 const isChecked = this.selectedFiles.some(x => x.filePath == item.filePath);
@@ -4879,24 +4862,6 @@ export struct LocalMusic {
                 }
               })
 
-              .gesture(LongPressGesture()
-                .onAction(async () => {
-                  //如果是专辑和艺术家的首页,不能长按
-                  if((this.modeType===2||this.modeType==3)&&!this.isCanBack)
-                    return
-                  //如果是我的收藏 最近播放等也不能长按
-                  if(item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
-                    item.name === LocalMusic.STR_HISTORY_MUSIC
-                  )
-                    return
-                  this.longItemFilePath = item.filePath
-                  this.tempLyricContent = await this.getLyricContent(item)
-                  LogUtil.info('长按this.tempLyricContent = '+this.tempLyricContent)
-                })
-                .onActionEnd((event: GestureEvent) => {
-
-                })
-              )
             Row() {
               Column(){
                 Text(item.md5Str?.includes('Lossless')?
@@ -4934,24 +4899,6 @@ export struct LocalMusic {
                   Color.Gray)
                 .margin({ left: StrUtil.isEmpty(item.artist) ?0:10 })
             }
-            .gesture(LongPressGesture()
-              .onAction(async () => {
-                //如果是专辑和艺术家的首页,不能长按
-                if((this.modeType===2||this.modeType==3)&&!this.isCanBack)
-                  return
-                //如果是我的收藏 最近播放等也不能长按
-                if(item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
-                  item.name === LocalMusic.STR_HISTORY_MUSIC
-                )
-                  return
-                this.longItemFilePath = item.filePath
-                this.tempLyricContent = await this.getLyricContent(item)
-                LogUtil.info('长按this.tempLyricContent = '+this.tempLyricContent)
-              })
-              .onActionEnd((event: GestureEvent) => {
-
-              })
-            )
 
           }
           .height('100%')
@@ -4997,6 +4944,23 @@ export struct LocalMusic {
 
       }
     }
+    .gesture(LongPressGesture()
+      .onAction(async () => {
+        //如果是专辑和艺术家的首页,不能长按
+        if((this.modeType===2||this.modeType==3)&&!this.isCanBack)
+          return
+        //如果是我的收藏 最近播放等也不能长按
+        if(item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
+          item.name === LocalMusic.STR_HISTORY_MUSIC
+        )
+          return
+        this.longItemFilePath = item.filePath
+        this.tempLyricContent = await this.getLyricContent(item)
+        LogUtil.info('长按this.tempLyricContent = '+this.tempLyricContent)
+      })
+      .onActionEnd((event: GestureEvent) => {
+
+      }))
     .backgroundColor(Color.Transparent)
     .width('100%')
     .reuseId('file_item')
@@ -6314,93 +6278,6 @@ export struct LocalMusic {
 
         })
 
-        //拖动List关键代码开始
-        .scale({ x: this.scaleSelect(index), y: this.scaleSelect(index) })
-        .zIndex(this.dragItem === index ? 1 : 0)
-        .translate(this.dragItem === index ? { y: this.offsetY } : { y: 0 })
-        .gesture(
-          GestureGroup(GestureMode.Sequence,
-            LongPressGesture({ repeat: true })
-              .onAction((event?: GestureEvent) => {
-                animateTo({ curve: Curve.Friction, duration: 300 }, () => {
-                  this.scaleItem = index
-                })
-              })
-              .onActionEnd(() => {
-                animateTo({ curve: Curve.Friction, duration: 300 }, () => {
-                  this.scaleItem = -1
-
-                })
-
-              }),
-            PanGesture({ fingers: 1, direction: null, distance: 0 })
-              .onActionStart(() => {
-                this.dragItem = index // 记录当前拖动项索引
-                this.dragRefOffset = 0 // 重置偏移基准
-              })
-              .onActionUpdate((event: GestureEvent) => {
-                this.offsetY = event.offsetY - this.dragRefOffset;
-                this.neighborItem = -1;
-                let indexA = this.videoLocalList.indexOf(item);
-                // LogUtil.info('onecold indexA = '+indexA +'  index=='+index)
-                let curveValue: curves.ICurve = curves.initCurve(Curve.Sharp);
-                let value: number = 0;
-
-                if (this.offsetY < 0) {
-                  value = curveValue.interpolate(-this.offsetY / this.ITEM_INTV);
-                  this.neighborItem = indexA - 1;
-                  this.neighborScale = 1 - value / 20;
-                } else if (this.offsetY > 0) {
-                  value = curveValue.interpolate(this.offsetY / this.ITEM_INTV);
-                  this.neighborItem = indexA + 1;
-                  this.neighborScale = 1 - value / 20;
-                }
-
-
-                if (this.offsetY > this.ITEM_INTV / 2 && indexA + 1 < this.videoLocalList.length) {
-                  animateTo({ curve: curves.interpolatingSpring(0, 1, 400, 38) }, () => {
-                    this.offsetY -= this.ITEM_INTV;
-                    this.dragRefOffset += this.ITEM_INTV;
-                    this.itemMove(indexA, indexA + 1);
-                  });
-                } else if (this.offsetY < -this.ITEM_INTV / 2 && indexA - 1 >= 0) {
-                  animateTo({ curve: curves.interpolatingSpring(0, 1, 400, 38) }, () => {
-                    this.offsetY += this.ITEM_INTV;
-                    this.dragRefOffset -= this.ITEM_INTV;
-                    this.itemMove(indexA, indexA - 1);
-                  });
-                }
-
-
-              })
-              .onActionEnd((event: GestureEvent) => {
-                animateTo({ curve: curves.interpolatingSpring(0, 1, 400, 38) }, () => {
-                  this.dragItem = -1
-                  this.neighborItem = -1
-                })
-                animateTo({
-                  curve: curves.interpolatingSpring(14, 1, 170, 17), delay: 150
-                }, () => {
-                  this.scaleItem = -1
-                })
-
-
-              })
-
-          )
-            .onCancel(() => {
-              animateTo({ curve: curves.interpolatingSpring(0, 1, 400, 38) }, () => {
-                this.dragItem = -1
-                this.neighborItem = -1
-              })
-              animateTo({
-                curve: curves.interpolatingSpring(14, 1, 170, 17), delay: 150
-              }, () => {
-                this.scaleItem = -1
-              })
-            })
-        ) //拖动List关键代码结束
-
       }, (item: VideoItem) => item.filePath + '_' + this.listRefreshKey)
 
       // 加载中指示器