onecold 9 месяцев назад
Родитель
Сommit
3eec4d61c7
1 измененных файлов с 64 добавлено и 32 удалено
  1. 64 32
      entry/src/main/ets/view/LocalMusic.ets

+ 64 - 32
entry/src/main/ets/view/LocalMusic.ets

@@ -1384,7 +1384,8 @@ export struct LocalMusic {
       }
       }
       if(openItem){
       if(openItem){
         this.doPlay(openItem,0,false,true)
         this.doPlay(openItem,0,false,true)
-        this.setShowPlayPage()
+        this.isShowPlay = true
+        // this.setShowPlayTrue()
       }
       }
 
 
     }
     }
@@ -3854,7 +3855,7 @@ export struct LocalMusic {
                 this.handleFileSelection(item, !isChecked);
                 this.handleFileSelection(item, !isChecked);
               } else {
               } else {
                 this.doPlay(item,index)
                 this.doPlay(item,index)
-                this.setShowPlayPage()
+                this.setShowPlayTrue()
 
 
               }
               }
             })
             })
@@ -6132,7 +6133,7 @@ export struct LocalMusic {
     .bindContentCover($$this.isShowPlay, this.MusicPlayBuilder(), {
     .bindContentCover($$this.isShowPlay, this.MusicPlayBuilder(), {
       modalTransition: ModalTransition.NONE,
       modalTransition: ModalTransition.NONE,
       onWillDisappear: () => {
       onWillDisappear: () => {
-        this.setShowPlayPage()
+        this.setShowPlayFalse()
       },
       },
       // backgroundColor: 'rgba(0, 0, 0, 0.9)',
       // backgroundColor: 'rgba(0, 0, 0, 0.9)',
     })
     })
@@ -6217,20 +6218,28 @@ export struct LocalMusic {
     })
     })
   }
   }
 
 
-  setShowPlayPage(){
+  setShowPlayTrue(){
     this.getUIContext()?.animateTo({
     this.getUIContext()?.animateTo({
       duration: 500,
       duration: 500,
       curve: Curve.Friction
       curve: Curve.Friction
     }, () => {
     }, () => {
-      this.isShowPlay = !this.isShowPlay;
+      this.isShowPlay = true;
     });
     });
   }
   }
 
 
+  setShowPlayFalse(){
+    this.getUIContext()?.animateTo({
+      duration: 500,
+      curve: Curve.Friction
+    }, () => {
+      this.isShowPlay = false;
+    });
+  }
   //打开播放页
   //打开播放页
   showPlayerView() {
   showPlayerView() {
 
 
     if (ArrayUtil.isNotEmpty(this.songList)) {
     if (ArrayUtil.isNotEmpty(this.songList)) {
-      this.setShowPlayPage()
+      this.setShowPlayTrue()
       let lyricPath = this.videoUrl.substring(0, this.videoUrl.lastIndexOf('.')) + '.lrc';
       let lyricPath = this.videoUrl.substring(0, this.videoUrl.lastIndexOf('.')) + '.lrc';
       this.initLyric(lyricPath);
       this.initLyric(lyricPath);
       this.startAutoHide();
       this.startAutoHide();
@@ -8136,11 +8145,21 @@ export struct LocalMusic {
           if (event) {
           if (event) {
             // 只允许向下滑动,向上滑动时限制为0
             // 只允许向下滑动,向上滑动时限制为0
             this.translateY = Math.max(0, event.offsetY);
             this.translateY = Math.max(0, event.offsetY);
+
+            this.getUIContext().animateTo({
+              duration: 500,
+              curve: Curve.Sharp
+            }, () => {
+              this.scaleValueImage = Math.min(1, Math.max(0.3, 1 - event.offsetY / 260));
+              console.info('onecold scaleValueImage:', this.scaleValueImage)
+
+              this.scaleValueText =Math.min(1, Math.max(0.6, 1 - event.offsetY / 300));
+            })
           }
           }
         })
         })
         .onActionEnd((event?: GestureEvent) => {
         .onActionEnd((event?: GestureEvent) => {
           // 使用更低的阈值和滑动速度判断
           // 使用更低的阈值和滑动速度判断
-          const minDistance = 100; // 最小滑动距离 100vp
+          const minDistance = 300; // 最小滑动距离 100vp
           const minVelocity = 500; // 最小滑动速度
           const minVelocity = 500; // 最小滑动速度
 
 
           // 获取滑动速度(如果可用)
           // 获取滑动速度(如果可用)
@@ -8152,18 +8171,22 @@ export struct LocalMusic {
           if (shouldClose) {
           if (shouldClose) {
             // 添加关闭动画
             // 添加关闭动画
             this.getUIContext().animateTo({
             this.getUIContext().animateTo({
-              duration: 300,
-              curve: Curve.Smooth
+              duration: 600,
+              curve: Curve.Friction
             }, () => {
             }, () => {
               this.isShowPlay = false;
               this.isShowPlay = false;
+              this.scaleValueImage = 1
+              this.scaleValueText = 1
               this.translateY = 0;
               this.translateY = 0;
             })
             })
           } else {
           } else {
             // 回弹动画
             // 回弹动画
             this.getUIContext().animateTo({
             this.getUIContext().animateTo({
-              duration: 300,
-              curve: Curve.Smooth
+              duration: 600,
+              curve: Curve.Friction
             }, () => {
             }, () => {
+              this.scaleValueImage = 1
+              this.scaleValueText = 1
               this.translateY = 0;
               this.translateY = 0;
             })
             })
           }
           }
@@ -9715,6 +9738,7 @@ export struct LocalMusic {
   @State isCoverTop: boolean = true
   @State isCoverTop: boolean = true
   // 添加控制缩放的状态变量
   // 添加控制缩放的状态变量
   @State scaleValueImage: number = 1
   @State scaleValueImage: number = 1
+  @State scaleValueText: number = 1
   @Builder
   @Builder
   CoverInfo() {
   CoverInfo() {
     Column() {
     Column() {
@@ -9757,21 +9781,24 @@ export struct LocalMusic {
           })
           })
 
 
         Column() {
         Column() {
-          if (this.isCoverTop && !this.isCoverOpacity() && this.isCoverRectangle) {
+          if (this.isCoverTop  && this.isCoverRectangle) {
             Image(this.cover)
             Image(this.cover)
-              .height(this.isHiCar()?(px2vp(this.windowHeight)*0.46):'auto')
-              .width(this.isHiCar()?'auto':this.isBigScreen() ? '72%' : this.isCoverTopBig ? '100%' : '88%')
+              .height(this.isHiCar()?(px2vp(this.windowHeight)*0.46):
+                this.isCoverOpacity()?(px2vp(this.windowHeight)*0.6):'auto')
+              .width(this.isHiCar()||this.isCoverOpacity()?'auto':this.isBigScreen() ? '72%' : this.isCoverTopBig ? '100%' : '88%')
               .objectFit(this.isCoverRectangle ? ImageFit.Contain : ImageFit.Auto)
               .objectFit(this.isCoverRectangle ? ImageFit.Contain : ImageFit.Auto)
               .alt($r('app.media.alt'))
               .alt($r('app.media.alt'))
               .margin({ right: 8, left: 8, top: 8 })
               .margin({ right: 8, left: 8, top: 8 })
               .aspectRatio(1)
               .aspectRatio(1)
-              .opacity(this.opacityValueImage)
               .geometryTransition('cover') // 绑定标识符
               .geometryTransition('cover') // 绑定标识符
-              .scale({ x: this.scaleValueImage, y: this.scaleValueImage }) // 添加缩放效果
+              .opacity(this.opacityValueImage)
+              .scale({ x: this.scaleValueImage, y: this.scaleValueImage,
+                // 设置左下角为缩放中心点
+                centerX: '0%',
+                centerY: '100%' })
               .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.8 })
               .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.8 })
               .visibility(this.isPuraWP() ? Visibility.None : Visibility.Visible)
               .visibility(this.isPuraWP() ? Visibility.None : Visibility.Visible)
               .borderRadius(this.isCoverRectangle ? 20 : '100%')
               .borderRadius(this.isCoverRectangle ? 20 : '100%')
-              .align(Alignment.Center)//
               .clip(true)
               .clip(true)
               .rotate({
               .rotate({
                 x: 0,
                 x: 0,
@@ -9823,11 +9850,14 @@ export struct LocalMusic {
                 (this.isCoverOpacity() ? (px2vp(this.windowHeight)*0.62) : this.isCoverRectangle ? 320 : 162))
                 (this.isCoverOpacity() ? (px2vp(this.windowHeight)*0.62) : this.isCoverRectangle ? 320 : 162))
               .objectFit(this.isCoverRectangle ? ImageFit.Contain : ImageFit.Auto)
               .objectFit(this.isCoverRectangle ? ImageFit.Contain : ImageFit.Auto)
               .alt($r('app.media.alt'))
               .alt($r('app.media.alt'))
+              .geometryTransition('cover') // 绑定标识符
               .margin({ right: 20, left: 20,top:this.isCoverRectangle||this.isLandscape?0:43 })
               .margin({ right: 20, left: 20,top:this.isCoverRectangle||this.isLandscape?0:43 })
               .aspectRatio(1)
               .aspectRatio(1)
               .opacity(this.opacityValueImage)
               .opacity(this.opacityValueImage)
-              .geometryTransition('cover') // 绑定标识符
-              .scale({ x: this.scaleValueImage, y: this.scaleValueImage }) // 添加缩放效果
+              .scale({ x: this.scaleValueImage, y: this.scaleValueImage,
+                // 设置左下角为缩放中心点
+                centerX: '0%',
+                centerY: '100%' })
               .visibility(this.isPuraWP() ? Visibility.None : Visibility.Visible)
               .visibility(this.isPuraWP() ? Visibility.None : Visibility.Visible)
               .borderRadius(this.isCoverRectangle ? 20 : '100%')
               .borderRadius(this.isCoverRectangle ? 20 : '100%')
               .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.8 })
               .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.8 })
@@ -9847,24 +9877,26 @@ export struct LocalMusic {
               .onClick(() => {
               .onClick(() => {
 
 
               })
               })
-            if (this.isPhoneLan()) {
-              Text(this.name)
-                .fontSize(18)
-                .fontWeight(FontWeight.Bold)
-                .margin({ top: 13 })
-                .textOverflow({ overflow: TextOverflow.Ellipsis })
-                .maxLines(1)
-                .width('99%')
-                .textAlign(TextAlign.Center)
-                .fontColor(Color.White)
 
 
-            }
+          }
+
+          if (this.isPhoneLan()) {
+            Text(this.name)
+              .fontSize(18)
+              .fontWeight(FontWeight.Bold)
+              .margin({ top: 13 })
+              .textOverflow({ overflow: TextOverflow.Ellipsis })
+              .maxLines(1)
+              .width('99%')
+              .textAlign(TextAlign.Center)
+              .fontColor(Color.White)
 
 
           }
           }
 
 
 
 
         }
         }
 
 
+
         // 唱针以左上角为点选择逆时针40度
         // 唱针以左上角为点选择逆时针40度
         Image($r('app.media.ic_music_cover_hand'))
         Image($r('app.media.ic_music_cover_hand'))
           .height(130)
           .height(130)
@@ -9951,7 +9983,6 @@ export struct LocalMusic {
       .geometryTransition('name') // 绑定标识符
       .geometryTransition('name') // 绑定标识符
       .layoutWeight(1)
       .layoutWeight(1)
       .margin({ left: 15 })
       .margin({ left: 15 })
-      .scale({ x: this.scaleValueImage, y: this.scaleValueImage }) // 添加缩放效果
       Blank()
       Blank()
       Row(){
       Row(){
 
 
@@ -9982,6 +10013,7 @@ export struct LocalMusic {
 
 
     }
     }
     .width('90%')
     .width('90%')
+    .scale({ x: this.scaleValueText, y: this.scaleValueText }) // 添加缩放效果
     .margin({ top: this.isCoverOpacity() ? 10 : isHidden ? 20 : 10 })
     .margin({ top: this.isCoverOpacity() ? 10 : isHidden ? 20 : 10 })
     .visibility(this.isCoverOpacity() || isHidden ? Visibility.None : Visibility.Visible)
     .visibility(this.isCoverOpacity() || isHidden ? Visibility.None : Visibility.Visible)
   }
   }
@@ -10009,7 +10041,7 @@ export struct LocalMusic {
       .clickEffect({ level: ClickEffectLevel.LIGHT, scale: 0.5 })
       .clickEffect({ level: ClickEffectLevel.LIGHT, scale: 0.5 })
       .visibility(this.isHide ? Visibility.Hidden : Visibility.Visible)
       .visibility(this.isHide ? Visibility.Hidden : Visibility.Visible)
       .onClick(() => {
       .onClick(() => {
-        this.setShowPlayPage()
+        this.setShowPlayFalse()
 
 
       })
       })