Browse Source

播放列表的背景可以设置 是否玻璃背景效果

onecold 1 năm trước cách đây
mục cha
commit
a4125c1b73

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

@@ -53,6 +53,8 @@ export struct SettingPage {
   public static THEME_COLOR_KEY: string = 'THEME_COLOR';
   public static TWO_FINGER_TYPE: string = 'twoFingerType';
   public static LONG_PRESS_SPEED: string = 'longPressSpeed';
+  public static IS_PLAYLIST_BG_GRASS: string = 'isPlayListBgGrass';
+
   public static THEME_COLOR_LIST: Array<ThemeColorItem> = [
     { name: '玫瑰粉', color: '#FF4081', isVip: false },
     { name: '经典蓝', color: '#0A59F7', isVip: false },
@@ -107,6 +109,8 @@ export struct SettingPage {
   @State isSavePlayMode: boolean = true
   @State isCoverTop: boolean = true
   @State isCoverTopBig: boolean = false//顶部大封面部分手机显示会和播放控制页重叠
+  @State isPlayListBgGrass: boolean = true//是否播放列表玻璃透明效果
+
 
   @State customizeBgPath: string | undefined = '';
   context = getContext(this);
@@ -224,6 +228,7 @@ export struct SettingPage {
     this.longPressSpeed = PreferencesUtil.getNumberSync(SettingPage.LONG_PRESS_SPEED, 3)
     this.isShowHeader = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_HEADER, true)
     this.isCoverRectangle = PreferencesUtil.getBooleanSync(SettingPage.IS_COVER_RECTANGLE, true)
+    this.isPlayListBgGrass = PreferencesUtil.getBooleanSync(SettingPage.IS_PLAYLIST_BG_GRASS, true)
     // 只用 themeMode 控制主题
     this.themeMode = PreferencesUtil.getNumberSync(SettingPage.THEME_MODE, 0)
     this.applyThemeMode(this.themeMode)
@@ -712,6 +717,31 @@ export struct SettingPage {
             .height(55)
             .clickEffect({ level: ClickEffectLevel.HEAVY })
 
+            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.isPlayListBgGrass })
+                .selectedColor(this.themeColor)
+                .switchPointColor(Color.White)
+                .margin({ right: 18 })
+                .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
+                .onChange((checked: boolean) => {
+                  this.isPlayListBgGrass = checked;
+                  PreferencesUtil.put(SettingPage.IS_PLAYLIST_BG_GRASS, this.isPlayListBgGrass)
+                  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'))
 
             // 网格封面大

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

@@ -177,6 +177,7 @@ export struct LocalMusic {
   @State isStartAutoPlay: boolean = false //启动后自动播放
   @State isShowPlayPageBack: boolean = false //是否显示播放页返回键
   @State isShowHeader: boolean = true
+  @State isPlayListBgGrass: boolean = true//是否播放列表玻璃透明效果
   @State isShowSingleLineLyric: boolean = false //是否显示播放页返回键
   @State isMemoryLastPlay: boolean = false //是否启用应用退出记忆最后一首的播放进度
   @State isCoverTopBig: boolean = false//顶部大封面部分手机显示会和播放控制页重叠
@@ -595,6 +596,7 @@ export struct LocalMusic {
     this.isCoverTopBig = PreferencesUtil.getBooleanSync(SettingPage.IS_COVER_TOP_BIG, false)
     this.isShowSingleLineLyric = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_SLLYRIC, false)
     this.longPressSpeed = PreferencesUtil.getNumberSync(SettingPage.LONG_PRESS_SPEED, 3)
+    this.isPlayListBgGrass = PreferencesUtil.getBooleanSync(SettingPage.IS_PLAYLIST_BG_GRASS, true)
     this.isShowHeader = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_HEADER, true)
     if (this.isSavePlayMode) {
       this.playType = PreferencesUtil.getNumberSync('musicPlayType', 0)
@@ -4331,7 +4333,7 @@ export struct LocalMusic {
               showClose: true,
               blurStyle: BlurStyle.Thin,
               preferType: this.currentBreakpoint !== BreakpointTypeEnum.SM ? SheetType.CENTER : SheetType.BOTTOM,
-              backgroundColor: Color.Transparent,
+              backgroundColor: this.isPlayListBgGrass?Color.Transparent:$r('app.color.silvery'),
               title: {
                 title: Utility.resourceToString(this.context, $r('app.string.current_play_list'))
                   + `(${this.songList.length}首)`
@@ -6441,7 +6443,7 @@ export struct LocalMusic {
           seekUIStyle: "listItem",// 滑动定位样式(seekLine传统样式,listItem类似抖音汽水音乐样式)
         })
       }
-      .height(48)
+      .height(66)
       .margin({bottom:20})
     }
 
@@ -6664,7 +6666,7 @@ export struct LocalMusic {
             showClose: true,
             preferType: this.currentBreakpoint !== BreakpointTypeEnum.SM ? SheetType.CENTER : SheetType.BOTTOM,
             blurStyle: BlurStyle.Thin,
-            backgroundColor: Color.Transparent,
+            backgroundColor: this.isPlayListBgGrass?Color.Transparent:$r('app.color.silvery'),
             title: {
               title: Utility.resourceToString(this.context, $r('app.string.current_play_list'))
                 + `(${this.songList.length}首)`
@@ -6681,7 +6683,11 @@ export struct LocalMusic {
       .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
       .onClick(() => {
         this.isShowSheetView = !this.isShowSheetView;
-        this.isFrontWhite = true
+        if(this.isPlayListBgGrass){
+          this.isFrontWhite = true
+        }else{
+          this.isFrontWhite = false
+        }
         setTimeout(() => {
           this.playListScroller.scrollToIndex(this.curIndex,true, ScrollAlign.CENTER)
         }, 123)