Sfoglia il codice sorgente

切换封面动画效果可以在设置里面设置开关

onecold 1 anno fa
parent
commit
a18ef22516

+ 25 - 0
entry/src/main/ets/pages/SettingPage.ets

@@ -845,6 +845,31 @@ export struct SettingPage {
                 curve: 'ease-in-out' // 可选动画曲线
               })
 
+            Line().width('100%').height(0.3).backgroundColor($r('app.color.index_tab_unselected_font_color'))
+
+            // 切歌动画效果
+            Row() {
+              Text('切歌动画效果')
+                .margin({ left: 18 })
+                .fontSize(15)
+                .fontColor(Color.Gray)
+                .fontWeight(480)
+                .layoutWeight(1)
+              Toggle({ type: ToggleType.Switch, isOn: this.openSkipSongAnimate })
+                .selectedColor(this.themeColor)
+                .switchPointColor(Color.White)
+                .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
+                .margin({ right: 18 })
+                .onChange((checked: boolean) => {
+                  this.openSkipSongAnimate = checked;
+                  PreferencesUtil.put(SettingPage.OPEN_SKIPSONG_ANIMATE, this.openSkipSongAnimate)
+                  this.sendChangeEvent()
+                })
+                .width(50)
+                .height(30);
+            }
+            .height(55)
+            .clickEffect({ level: ClickEffectLevel.HEAVY })
 
             Line().width('100%').height(0.3).backgroundColor($r('app.color.index_tab_unselected_font_color'))
 

+ 29 - 23
entry/src/main/ets/view/LocalMusic.ets

@@ -139,7 +139,6 @@ const ITEM_HEIGHT_BIG: number = 78; // 列表项大高度
 @Component
 export struct LocalMusic {
   @State opacityValueImage: number = 1;
-  @State isAnimating: boolean = false;
   @State tipPopup:boolean = false
   @Consume mType: number;
   @StorageProp('themeColor') themeColor: string =
@@ -196,6 +195,7 @@ export struct LocalMusic {
   @State isMemoryLastPlay: boolean = false //是否启用应用退出记忆最后一首的播放进度
   @State isCoverTopBig: boolean = false //顶部大封面部分手机显示会和播放控制页重叠
   @State isSwipe: boolean = false //listItem的左滑开关
+  @State openSkipSongAnimate: boolean = true//切歌动画效果
   @State customizeBgPath: string | undefined = '';
   @State isDarkMode: boolean = false
   @State lyricTextWeight: number = 400
@@ -621,6 +621,7 @@ export struct LocalMusic {
     this.isShowHeader = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_HEADER, true)
     this.volume = PreferencesUtil.getNumberSync('DefalutVolume', this.volume)
     this.isSwipe = PreferencesUtil.getBooleanSync(SettingPage.IS_SWIPE, true)
+    this.openSkipSongAnimate = PreferencesUtil.getBooleanSync(SettingPage.OPEN_SKIPSONG_ANIMATE, true)
     //如果是hicar连接状态,这些都是false
     if(this.isHiCarStatus){
       this.isShowTitleBar = false//不显示导航栏
@@ -7315,9 +7316,9 @@ export struct LocalMusic {
               .aspectRatio(1)
               .opacity(this.opacityValueImage)
               .scale({ x: this.scaleValueImage, y: this.scaleValueImage }) // 添加缩放效果
+              .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.8 })
               .visibility(this.isPuraWP() ? Visibility.None : Visibility.Visible)
               .borderRadius(this.isCoverRectangle ? 20 : '100%')
-              .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.8 })
               .align(Alignment.Center)//
               .clip(true)
               .rotate({
@@ -7453,7 +7454,6 @@ export struct LocalMusic {
     }
     .margin({ top: this.isCoverOpacity() ? 20 : isHidden ? 40 : 20 })
     .zIndex(1)
-    // .opacity(this.opacityValueImage)
     .scale({ x: this.scaleValueImage, y: this.scaleValueImage }) // 添加缩放效果
     .visibility(this.isCoverOpacity() || isHidden ? Visibility.None : Visibility.Visible)
   }
@@ -10440,30 +10440,36 @@ export struct LocalMusic {
   }
 
   changeImageAnimation() {
-    // 第一步:淡出动画
-    this.getUIContext()?.animateTo({
-      duration: 500,
-      curve: Curve.EaseOut,
-    }, () => {
-      this.opacityValueImage = 0.1;
-      if(this.isCoverRectangle){
-        this.scaleValueImage = 0.88
-      }
-
-    });
-
-    // 第二步:切换图片后淡入
-    setTimeout(() => {
-      this.cover = this.songList[this.curIndex].pixelMapPath
+    if(this.openSkipSongAnimate){
+      // 第一步:淡出动画
       this.getUIContext()?.animateTo({
         duration: 500,
-        curve: Curve.EaseIn,
+        curve: Curve.EaseOut,
       }, () => {
-        this.opacityValueImage = 1;
-        this.scaleValueImage = 1 // 图标恢复到原始大小
-        this.startPlayOrResumePlay()
+        this.opacityValueImage = 0.1;
+        if(this.isCoverRectangle){
+          this.scaleValueImage = 0.88
+        }
+
       });
-    }, 500);
+
+      // 第二步:切换图片后淡入
+      setTimeout(() => {
+        this.cover = this.songList[this.curIndex].pixelMapPath
+        this.getUIContext()?.animateTo({
+          duration: 500,
+          curve: Curve.EaseIn,
+        }, () => {
+          this.opacityValueImage = 1;
+          this.scaleValueImage = 1 // 图标恢复到原始大小
+          this.startPlayOrResumePlay()
+        });
+      }, 500);
+    }else{
+      this.cover = this.songList[this.curIndex].pixelMapPath
+      this.startPlayOrResumePlay()
+    }
+
   }
 
   // 存储已播放的歌曲索引