Browse Source

主题色设置

chendeben 1 năm trước cách đây
mục cha
commit
7e3cd0a730

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

@@ -272,6 +272,7 @@ export struct SettingPage {
                     showMode: promptAction.ToastShowMode.TOP_MOST,
                     bottom: 85
                   })
+                  this.sendChangeEvent()
                 })
             }
             .height(55)

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

@@ -333,9 +333,9 @@ export struct LocalMusic {
     .setTitleName('首页')
     .setTitleFontSize(18)
     .setTitleFontColor(Color.White)
-    .setTitleBarBackground(this.themeColor)
-    .setTitleBarBottomLineColor(this.themeColor)
-    .setLeftTitleStateNormalStyleColor(this.themeColor)
+    .setTitleBarBackground(this.isDarkMode?$r('app.color.title_bar_bg'):this.themeColor)
+    .setTitleBarBottomLineColor(this.isDarkMode?$r('app.color.title_bar_bg'):this.themeColor)
+    .setLeftTitleStateNormalStyleColor(this.isDarkMode?$r('app.color.title_bar_bg'):this.themeColor)
     .setRightIcon($r('app.media.add'))
     .setOnRightClickListener(() => {
       this.showSheelDialog()
@@ -457,6 +457,7 @@ export struct LocalMusic {
     let themeColor = PreferencesUtil.getStringSync('THEME_COLOR', '#FF4081');
     AppStorage.setOrCreate('themeColor', themeColor);
     this.themeColor = themeColor;
+    this.doChangeSetting()
     this.windowClass.on('windowSizeChange', (size) => {
       LogUtil.info('onecold  windowSizeChange')
       if(!this.isPhoneLan()){
@@ -514,10 +515,18 @@ export struct LocalMusic {
       this.titleBarModel.setTitleBarBottomLineColor(Color.Transparent)
       this.titleBarModel.setLeftTitleStateNormalStyleColor(Color.Transparent)
     }else{
-      this.titleBarModel.setTitleBarBackground(this.themeColor)
-      this.titleBarModel .setTitleBarBottomLineColor(this.themeColor)
-      this.titleBarModel.setRightTitleStateNormalStyleColor(this.themeColor)
-      this.titleBarModel.setLeftTitleStateNormalStyleColor(this.themeColor)
+      if (!this.isDarkMode) {
+        this.titleBarModel.setTitleBarBackground(this.themeColor)
+        this.titleBarModel .setTitleBarBottomLineColor(this.themeColor)
+        this.titleBarModel.setRightTitleStateNormalStyleColor(this.themeColor)
+        this.titleBarModel.setLeftTitleStateNormalStyleColor(this.themeColor)
+      }else {
+        this.titleBarModel.setTitleBarBackground($r('app.color.title_bar_bg'))
+        this.titleBarModel .setTitleBarBottomLineColor($r('app.color.title_bar_bg'))
+        this.titleBarModel.setRightTitleStateNormalStyleColor($r('app.color.title_bar_bg'))
+        this.titleBarModel.setLeftTitleStateNormalStyleColor($r('app.color.title_bar_bg'))
+      }
+
     }
   }
 
@@ -1746,7 +1755,7 @@ export struct LocalMusic {
           Line().width('100%').height('100%')
         }
         .height(this.isPhoneLan()?0:px2vp(AppUtil.getStatusBarHeight()))
-        .backgroundColor(this.isCustomizeBg?Color.Transparent:this.themeColor)
+        .backgroundColor(this.isCustomizeBg?Color.Transparent:(this.isDarkMode?$r('app.color.title_bar_bg'):this.themeColor))
         .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP])
         TitleBar({ model: $titleBarModel })
           .id('pup_positon_music')