Jelajahi Sumber

播放页上滑切换 做个开关

onecold 5 bulan lalu
induk
melakukan
cb778ea79a

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

@@ -108,6 +108,7 @@ export struct SettingPage {
   static readonly IS_SWIPE: string = 'isSwipe'
   static readonly IS_AUTO_HIDE_PROGRESS: string = 'IS_AUTO_HIDE_PROGRESS';
   public static OPEN_SKIPSONG_ANIMATE: string = 'openSkipSongAnimate';
+  static readonly IS_PLAYPAGE_SWIPE_NEXT: string = 'isPlayPageSwipeNext';
   @State autoParseMusicName: boolean = false
   @State defalut_home_type:number = 0
   private fastForwardSecond: FastForwardSecondInterface[] = [
@@ -180,6 +181,7 @@ export struct SettingPage {
   @State isPlayListBgGrass: boolean = true//是否播放列表玻璃透明效果
   @State is_auto_hide_progress: boolean = false
   @State openSkipSongAnimate: boolean = true//切歌动画效果
+  @State isPlayPageSwipeNext: boolean = true // 播放页上滑切歌
   @State isShowFileName: boolean = false//切歌动画效果
   @State isLongNameRoLL: boolean = true//长歌名滚动
 
@@ -307,6 +309,7 @@ export struct SettingPage {
     this.isSwipe = PreferencesUtil.getBooleanSync(SettingPage.IS_SWIPE, true)
     this.is_auto_hide_progress = PreferencesUtil.getBooleanSync(SettingPage.IS_AUTO_HIDE_PROGRESS, false)
     this.openSkipSongAnimate = PreferencesUtil.getBooleanSync(SettingPage.OPEN_SKIPSONG_ANIMATE, true)
+    this.isPlayPageSwipeNext = PreferencesUtil.getBooleanSync(SettingPage.IS_PLAYPAGE_SWIPE_NEXT, true)
     this.volumeSmall = PreferencesUtil.getBooleanSync('volumeSmall', false)
     this.autoParseMusicName = PreferencesUtil.getBooleanSync('autoParseMusicName', true)
     this.isShowFileName = PreferencesUtil.getBooleanSync('isShowFileName', false)
@@ -1305,6 +1308,37 @@ export struct SettingPage {
 
             Line().width('100%').height(0.3).backgroundColor($r('app.color.index_tab_unselected_font_color'))
 
+            // 播放页上滑切歌
+            Row() {
+              SymbolGlyph($r('sys.symbol.music_mic_stars'))
+                .fontSize(20)
+                .fontColor([this.themeColor])
+                .alignSelf(ItemAlign.Center)
+                .margin({ left: 15 })
+              Text('播放页上滑切歌')
+                .margin({ left: 8 })
+                .fontSize(15)
+                .fontColor(Color.Gray)
+                .fontWeight(480)
+                .layoutWeight(1)
+              Toggle({ type: ToggleType.Switch, isOn: this.isPlayPageSwipeNext })
+                .selectedColor(this.themeColor)
+                .switchPointColor(Color.White)
+                .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
+                .margin({ right: 18 })
+                .onChange((checked: boolean) => {
+                  this.isPlayPageSwipeNext = checked;
+                  PreferencesUtil.put(SettingPage.IS_PLAYPAGE_SWIPE_NEXT, this.isPlayPageSwipeNext)
+                  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'))
+
             // 圆形播放按钮
             Row() {
               SymbolGlyph($r('sys.symbol.circle'))
@@ -2537,6 +2571,9 @@ export struct SettingPage {
           .onChange((checked: boolean) => {
             this.showZMIndex = checked;
             PreferencesUtil.put('showZMIndex', this.showZMIndex)
+            if(this.showZMIndex){
+              ToastUtil.showToast('注意只在按名称排序中生效')
+            }
             this.sendChangeEvent()
           })
           .width(50)

+ 4 - 1
entry/src/main/ets/view/LocalMusic.ets

@@ -504,6 +504,7 @@ export struct LocalMusic {
   @State isCoverTopBig: boolean = false //顶部大封面部分手机显示会和播放控制页重叠
   @State isSwipe: boolean = false //listItem的左滑开关
   @State openSkipSongAnimate: boolean = true//切歌动画效果
+  @State isPlayPageSwipeNext: boolean = true // 播放页上滑切歌
   @State customizeBgPath: string | undefined = '';
   @State isDarkMode: boolean = false
   @State lyricTextWeight: number = 400
@@ -1382,6 +1383,7 @@ export struct LocalMusic {
     this.volume = PreferencesUtil.getNumberSync('DefalutVolume', this.volume)
     this.isSwipe = PreferencesUtil.getBooleanSync(SettingPage.IS_SWIPE, true)
     this.openSkipSongAnimate = PreferencesUtil.getBooleanSync(SettingPage.OPEN_SKIPSONG_ANIMATE, true)
+    this.isPlayPageSwipeNext = PreferencesUtil.getBooleanSync(SettingPage.IS_PLAYPAGE_SWIPE_NEXT, true)
     this.volumeSmall = PreferencesUtil.getBooleanSync('volumeSmall', false)
     this.autoParseMusicName = PreferencesUtil.getBooleanSync('autoParseMusicName', true)
     this.isShowFileName = PreferencesUtil.getBooleanSync('isShowFileName', false)
@@ -10649,7 +10651,8 @@ export struct LocalMusic {
 
           if (isSwipeUp) {
             // 向上滑动:切换下一首
-            const shouldSwitch = Math.abs(offsetY) > minDistance || Math.abs(velocity) > minVelocity;
+            const shouldSwitch = this.isPlayPageSwipeNext &&
+              (Math.abs(offsetY) > minDistance || Math.abs(velocity) > minVelocity);
 
             if (shouldSwitch) {
               // 直接切换下一首,无需动画(因为界面没有移动)