Przeglądaj źródła

主题色设置

chendeben 1 rok temu
rodzic
commit
f4172c3a8d

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

@@ -72,20 +72,6 @@ export struct SettingPage {
 
   /** 当前断点类型(如大屏/小屏) */
   @StorageProp('currentBreakpoint') currentBreakpoint: string = BreakpointTypeEnum.MD;
-
-  @State titleBarModel: TitleBar.Model = new TitleBar.Model()
-    .setTitleTextStyle(FontStyle.Normal)
-    .setTitleBarStyle(TitleBar.BarStyle.TRANSPARENT)
-    .setLeftIcon($r('app.media.left_back_white'))
-    .setTitleName('通用设置')
-    .setTitleFontColor(Color.White)
-    .setTitleBarBackground($r('app.color.title_bar_bg'))
-    .setLeftTitleBackground($r('app.color.title_bar_bg'))
-    .setTitleBarBottomLineColor($r('app.color.title_bar_bg'))
-    .setOnLeftClickListener(() => {
-      router.back()
-    })
-    .setTitleBarNormalPadding(0)
   @State verName: string = ''
   @StorageProp('themeColor') themeColor: string = PreferencesUtil.getStringSync('THEME_COLOR', '#FF4081');
 
@@ -311,6 +297,7 @@ export struct SettingPage {
                       this.themeColor = color
                       PreferencesUtil.putSync(SettingPage.THEME_COLOR_KEY, color)
                       AppStorage.setOrCreate('themeColor', color)
+                      this.sendChangeEvent()
                     })
                 })
               }

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

@@ -136,6 +136,7 @@ const ITEM_HEIGHT: number = 58; // 列表项高度
 @Preview
 @Component
 export struct LocalMusic {
+  @StorageProp('themeColor') themeColor: string = PreferencesUtil.getStringSync('THEME_COLOR', '#FF4081');
   themeMode: number=0;
   @State titleName: string = '首页'
   @State textStr: string = ''
@@ -332,9 +333,9 @@ export struct LocalMusic {
     .setTitleName('首页')
     .setTitleFontSize(18)
     .setTitleFontColor(Color.White)
-    .setTitleBarBackground($r('app.color.title_bar_bg'))
-    .setTitleBarBottomLineColor($r('app.color.title_bar_bg'))
-    .setLeftTitleStateNormalStyleColor($r('app.color.title_bar_bg'))
+    .setTitleBarBackground(this.themeColor)
+    .setTitleBarBottomLineColor(this.themeColor)
+    .setLeftTitleStateNormalStyleColor(this.themeColor)
     .setRightIcon($r('app.media.add'))
     .setOnRightClickListener(() => {
       this.showSheelDialog()
@@ -453,7 +454,9 @@ export struct LocalMusic {
     // 读取 themeMode 并同步 currentColorMode
     this.themeMode = PreferencesUtil.getNumberSync(SettingPage.THEME_MODE, 0)
     this.applyThemeMode(this.themeMode)
-
+    let themeColor = PreferencesUtil.getStringSync('THEME_COLOR', '#FF4081');
+    AppStorage.setOrCreate('themeColor', themeColor);
+    this.themeColor = themeColor;
     this.windowClass.on('windowSizeChange', (size) => {
       LogUtil.info('onecold  windowSizeChange')
       if(!this.isPhoneLan()){
@@ -511,10 +514,10 @@ export struct LocalMusic {
       this.titleBarModel.setTitleBarBottomLineColor(Color.Transparent)
       this.titleBarModel.setLeftTitleStateNormalStyleColor(Color.Transparent)
     }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'))
+      this.titleBarModel.setTitleBarBackground(this.themeColor)
+      this.titleBarModel .setTitleBarBottomLineColor(this.themeColor)
+      this.titleBarModel.setRightTitleStateNormalStyleColor(this.themeColor)
+      this.titleBarModel.setLeftTitleStateNormalStyleColor(this.themeColor)
     }
   }
 
@@ -1276,8 +1279,8 @@ export struct LocalMusic {
       progress: this.progress,
       backCancel: false,
       autoCancel: false,
-      loadColor: $r('app.color.title_bar_bg'),
-      fontColor: $r('app.color.title_bar_bg')
+      loadColor: this.themeColor,
+      fontColor: this.themeColor
     });
     // 计算所有文件的总大小
     let totalSize = 0;
@@ -1743,7 +1746,7 @@ export struct LocalMusic {
           Line().width('100%').height('100%')
         }
         .height(this.isPhoneLan()?0:px2vp(AppUtil.getStatusBarHeight()))
-        .backgroundColor(this.isCustomizeBg?Color.Transparent:$r('app.color.title_bar_bg'))
+        .backgroundColor(this.isCustomizeBg?Color.Transparent:this.themeColor)
         .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP])
         TitleBar({ model: $titleBarModel })
           .id('pup_positon_music')
@@ -1871,7 +1874,7 @@ export struct LocalMusic {
           //     .width('50%')
           //     .height(55)
           //     .margin({ top: 50, bottom: 40 })
-          //     .backgroundColor($r('app.color.title_bar_bg'))
+          //     .backgroundColor(this.themeColor)
           //
           //     .onClick(() => {
           //       this.showSheelDialog()
@@ -2165,7 +2168,7 @@ export struct LocalMusic {
       SymbolGlyph($r('sys.symbol.identify_song'))
         .height(33)
         .width(33)
-        .fontColor([$r('app.color.img_color')])
+        .fontColor([this.themeColor])
         .fontSize(33)
         // .alt($r('app.media.music_group'))
         .borderRadius('100%')
@@ -2254,6 +2257,7 @@ export struct LocalMusic {
       Stack() {
 
         Image(StrUtil.isEmpty(item.pixelMapPath) ? $r('app.media.music_red') : item.pixelMapPath)
+          .fillColor(this.themeColor)
           .height(33)
           .width(33)
           .alt($r('app.media.music_red'))
@@ -2354,7 +2358,7 @@ export struct LocalMusic {
           ForEach(this.tabs, (i: string, index) => {
             Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) {
               Flex()
-                .backgroundColor($r('app.color.tab_item_bg'))
+                .backgroundColor(this.themeColor)
                 .borderRadius(20)
                 .padding(10)
                 .margin(6)
@@ -2479,7 +2483,7 @@ export struct LocalMusic {
             duration: 666,
             curve: 'ease-in-out' // 可选动画曲线
           })// .opacity(this.opacityItem)
-          .fillColor($r('app.color.img_color'))
+          .fillColor(this.themeColor)
           .clickEffect({ level: ClickEffectLevel.MIDDLE })
           .onClick(() => {
             this.isSearchMode = true
@@ -2496,7 +2500,7 @@ export struct LocalMusic {
           })
 
         SymbolGlyph(this.isGridMusic?$r('sys.symbol.list_bullet'):$r('sys.symbol.square_grid_2x2'))
-        .fontColor([$r('app.color.img_color')])
+        .fontColor([this.themeColor])
           .width(25)
           .animation({
             duration: 666,
@@ -2522,10 +2526,10 @@ export struct LocalMusic {
       Row({ space: 8 }) {
         Row({ space: 8 }) {
           // Image($r("app.media.hm_play"))
-          IBestIcon({name:'play-circle-o',iconSize:25,color:$r('app.color.img_color')})
+          IBestIcon({name:'play-circle-o',iconSize:25,color:this.themeColor})
             .width(25)
             .margin({ left: 8 })
-            // .fillColor($r('app.color.img_color'))
+            // .fillColor(this.themeColor)
           Text(`播放全部`)
             .fontColor($r('app.color.text_color'))
             .fontSize(14)
@@ -2601,7 +2605,7 @@ export struct LocalMusic {
             duration: 666,
             curve: 'ease-in-out' // 可选动画曲线
           })// .opacity(this.opacityItem)
-          .fillColor($r('app.color.img_color'))
+          .fillColor(this.themeColor)
           .clickEffect({ level: ClickEffectLevel.MIDDLE })
           .onClick(() => {
             this.isSearchMode = true
@@ -2612,20 +2616,20 @@ export struct LocalMusic {
             duration: 666,
             curve: 'ease-in-out' // 可选动画曲线
           })
-          .fillColor($r('app.color.img_color'))
+          .fillColor(this.themeColor)
           .clickEffect({ level: ClickEffectLevel.MIDDLE })
           .onClick(() => {
             this.isGridMusic = !this.isGridMusic
           })
         // Image($r("app.media.refresh"))
-        IBestIcon({ name: 'replay',iconSize:25,color:$r('app.color.img_color') })
+        IBestIcon({ name: 'replay',iconSize:25,color:this.themeColor })
           // .width(25)
           .visibility(this.isHistory || this.isCanBack || this.isSearchMode ? Visibility.None : Visibility.Visible)
           .animation({
             duration: 666,
             curve: 'ease-in-out' // 可选动画曲线
           })// .opacity(this.opacityItem)
-          // .fillColor($r('app.color.img_color'))
+          // .fillColor(this.themeColor)
           .clickEffect({ level: ClickEffectLevel.MIDDLE })
           .onClick(() => {
             if(this.isFavMusic){
@@ -2644,7 +2648,7 @@ export struct LocalMusic {
             duration: 666,
             curve: 'ease-in-out' // 可选动画曲线
           })
-          .fillColor($r('app.color.img_color'))
+          .fillColor(this.themeColor)
           .clickEffect({ level: ClickEffectLevel.MIDDLE })
           .onClick(() => {
             this.showRankDialog()
@@ -2660,7 +2664,7 @@ export struct LocalMusic {
             duration: 666,
             curve: 'ease-in-out' // 可选动画曲线
           })
-          .fillColor($r('app.color.img_color'))
+          .fillColor(this.themeColor)
           .clickEffect({ level: ClickEffectLevel.MIDDLE })
           .onClick(() => {
             this.isMultiSelect = !this.isMultiSelect
@@ -2668,7 +2672,7 @@ export struct LocalMusic {
         Image($r("app.media.uninstall_green"))
           .width(24)
           .margin({ right: 10 })
-          .fillColor($r('app.color.img_color'))
+          .fillColor(this.themeColor)
           .visibility(this.isHistory ? Visibility.Visible : Visibility.None)
           .animation({
             duration: 666,
@@ -3613,7 +3617,7 @@ export struct LocalMusic {
             .height(24)
             .width(24)
             .margin({ left: 8, right: 16 })
-            .fillColor($r('app.color.img_color'))
+            .fillColor(this.themeColor)
             .displayPriority(2)
             .onClick(() => {
               if (ArrayUtil.isNotEmpty(this.songList)) {
@@ -3631,7 +3635,7 @@ export struct LocalMusic {
               type: ProgressType.Ring,
 
             })
-              .color($r('app.color.title_bar_bg'))// 进度条前景色为灰色
+              .color(this.themeColor)// 进度条前景色为灰色
               .backgroundColor(Color.Pink)
               .height(36)
               .aspectRatio(CommonConstants.ASPECT_RATIO)
@@ -3639,7 +3643,7 @@ export struct LocalMusic {
               .height(32)
               .width(32)
               .displayPriority(3)
-              .fillColor($r('app.color.img_color'))
+              .fillColor(this.themeColor)
               .onClick(() => {
                 if (ArrayUtil.isNotEmpty(this.songList)) {
                   this.playOrPause()
@@ -3657,7 +3661,7 @@ export struct LocalMusic {
               right: 16,
               left: 16
             })
-            .fillColor($r('app.color.img_color'))
+            .fillColor(this.themeColor)
             .displayPriority(2)
             .onClick(() => {
               if (ArrayUtil.isNotEmpty(this.songList)) {
@@ -3672,7 +3676,7 @@ export struct LocalMusic {
             .height(24)
             .width(24)
             .displayPriority(1)
-            .fillColor($r('app.color.img_color'))
+            .fillColor(this.themeColor)
             .bindSheet($$this.isShowSheet, this.PlayListSheet(), {
               height: '95%',
               dragBar: true,
@@ -3837,6 +3841,7 @@ export struct LocalMusic {
 
             Image(StrUtil.isEmpty(item.pixelMapPath) ? $r('app.media.music_red') :
             item.pixelMapPath)
+              .fillColor(this.themeColor)
               .height(33)
               .width(33)
               .borderRadius('100%')
@@ -3857,7 +3862,7 @@ export struct LocalMusic {
                   curve: 'Linear',
                 })
 
-                .fontColor($r('app.color.title_bar_bg'))
+                .fontColor(this.themeColor)
                 .margin({ left: 10 })
               Row() {
                 Text(item.artist)
@@ -3865,7 +3870,7 @@ export struct LocalMusic {
                   .maxLines(1)
                   .textOverflow({ overflow: TextOverflow.MARQUEE })//超长滚动
                   .padding({ top: 8 })
-                  .fontColor($r('app.color.title_bar_bg'))
+                  .fontColor(this.themeColor)
                   .margin({ left: 10 })
 
               }
@@ -3882,7 +3887,7 @@ export struct LocalMusic {
               .fontSize(12)
               .height(38)
               .width(88)
-              .backgroundColor($r('app.color.title_bar_bg'))
+              .backgroundColor(this.themeColor)
               .stateEffect(true)
               .margin({ right: 5, left: 12 })
               .onClick(async () => {
@@ -3896,7 +3901,7 @@ export struct LocalMusic {
               .fontSize(12)
               .height(38)
               .width(88)
-              .backgroundColor($r('app.color.title_bar_bg'))
+              .backgroundColor(this.themeColor)
               .stateEffect(true)
               .margin({ right: 12, left: 5 })
               .onClick(async () => {
@@ -4004,7 +4009,7 @@ export struct LocalMusic {
             .layoutWeight(1)
             .height(50)
             .width(100)
-            .backgroundColor($r('app.color.title_bar_bg'))
+            .backgroundColor(this.themeColor)
             .stateEffect(true)
             .margin({ right: 20, bottom: 20 })
             .onClick(async () => {
@@ -4017,7 +4022,7 @@ export struct LocalMusic {
             .layoutWeight(1)
             .height(50)
             .width(100)
-            .backgroundColor($r('app.color.title_bar_bg'))
+            .backgroundColor(this.themeColor)
             .stateEffect(true)
             .margin({ left: 20, bottom: 20 })
             .onClick(async () => {
@@ -4059,6 +4064,7 @@ export struct LocalMusic {
 
             Image(StrUtil.isEmpty(this.currentSong.pixelMapPath) ? $r('app.media.music_red') :
             this.currentSong.pixelMapPath)
+              .fillColor(this.themeColor)
               .height(33)
               .width(33)
               .borderRadius('100%')
@@ -4305,7 +4311,7 @@ export struct LocalMusic {
             // 文字描述区域
             Text(this.getDisplayText(minutes))
               .fontSize(15)
-              .fontColor(minutes === this.selectedMinutes ? $r('app.color.title_bar_bg') :
+              .fontColor(minutes === this.selectedMinutes ? this.themeColor :
               $r('app.color.text_color'))// 选中态颜色变化
               .textAlign(TextAlign.Start)
               .layoutWeight(1); // 占据剩余空间
@@ -4313,7 +4319,7 @@ export struct LocalMusic {
             // 复选框区域
             Checkbox()
               .select(minutes === this.selectedMinutes ? true : minutes === -1 ? this.isCustomSuccess : false)// 绑定选中状态
-              .selectedColor($r('app.color.title_bar_bg'))// 主题色
+              .selectedColor(this.themeColor)// 主题色
               .shape(CheckBoxShape.CIRCLE)
               .size({ width: 24, height: 24 })
               .margin({ left: 20 })
@@ -4463,7 +4469,7 @@ export struct LocalMusic {
       .width(40)
       .height(40)
       .type(ButtonType.Circle)
-      .backgroundColor($r('app.color.title_bar_bg'))
+      .backgroundColor(this.themeColor)
       .margin(5)
       .onClick(() => {
         this.addToNextPlay(item);
@@ -4477,7 +4483,7 @@ export struct LocalMusic {
       .width(40)
       .height(40)
       .type(ButtonType.Circle)
-      .backgroundColor($r('app.color.title_bar_bg'))
+      .backgroundColor(this.themeColor)
       .margin(5)
       .onClick(() => {
         this.songList.splice(Number(index), 1)
@@ -4492,7 +4498,7 @@ export struct LocalMusic {
       .width(40)
       .height(40)
       .type(ButtonType.Circle)
-      .backgroundColor($r('app.color.title_bar_bg'))
+      .backgroundColor(this.themeColor)
       .margin(5)
       .onClick(() => {
         Utility.doShareMusic(item, getContext(this) as common.UIAbilityContext)
@@ -4638,6 +4644,7 @@ export struct LocalMusic {
           .height(33)
           .width(33)
           .alt($r('app.media.music_red'))
+          .fillColor(this.themeColor)
           .borderRadius('100%')
           .clip(true)
           .margin({ left: 20 })
@@ -6012,7 +6019,7 @@ export struct LocalMusic {
               .height(28)
               .fontSize(12)
               .fontColor('#FFFFFF')
-              .backgroundColor(this.currentLyricAlignMode === index ? $r('app.color.title_bar_bg') :Color.Transparent)
+              .backgroundColor(this.currentLyricAlignMode === index ? this.themeColor :Color.Transparent)
               .border({
                 color: this.currentLyricAlignMode === index ? '#007DFF' : '#DDDDDD',
                 width: 1.8
@@ -6571,7 +6578,7 @@ export struct LocalMusic {
       Row() {
         Button('取消')
           .fontColor(Color.White)
-          .backgroundColor($r('app.color.title_bar_bg'))//.linearGradient( { direction: GradientDirection.Right, colors:[['#ff37a0fc',0.0],['#67e667',0.5],['#f5856e',1.0]]})
+          .backgroundColor(this.themeColor)//.linearGradient( { direction: GradientDirection.Right, colors:[['#ff37a0fc',0.0],['#67e667',0.5],['#f5856e',1.0]]})
           .height(50)
           .layoutWeight(1)
           .stateEffect(true)
@@ -6583,7 +6590,7 @@ export struct LocalMusic {
           .fontColor(Color.White)//.linearGradient( { direction: GradientDirection.Right, colors:[['#ff37a0fc',0.0],['#67e667',0.5],['#f5856e',1.0]]})
           .layoutWeight(1)
           .height(50)
-          .backgroundColor($r('app.color.title_bar_bg'))
+          .backgroundColor(this.themeColor)
           .stateEffect(true)
           .margin({ left: 6 })
           .onClick(() => {
@@ -6805,7 +6812,7 @@ export struct LocalMusic {
                   .layoutWeight(1)
                 Blank()
                 Toggle({ type: ToggleType.Switch, isOn: this.isMusicMemoryPlay })
-                  .selectedColor($r('app.color.title_bar_bg'))
+                  .selectedColor(this.themeColor)
                   .switchPointColor(Color.White)
                   .margin({ right: 15 })
                   .visibility(more.id == 6 ? Visibility.Visible : Visibility.None)
@@ -6824,7 +6831,7 @@ export struct LocalMusic {
                   .width(48)
                   .height(24);
                 Toggle({ type: ToggleType.Switch, isOn: this.isMusicBGCover })
-                  .selectedColor($r('app.color.title_bar_bg'))
+                  .selectedColor(this.themeColor)
                   .switchPointColor(Color.White)
                   .margin({ right: 15 })
                   .visibility(more.id == 7 ? Visibility.Visible : Visibility.None)
@@ -6844,7 +6851,7 @@ export struct LocalMusic {
                   .width(48)
                   .height(24);
                 Toggle({ type: ToggleType.Switch, isOn: this.isSavePlayMode })
-                  .selectedColor($r('app.color.title_bar_bg'))
+                  .selectedColor(this.themeColor)
                   .switchPointColor(Color.White)
                   .margin({ right: 15 })
                   .visibility(more.id == 8 ? Visibility.Visible : Visibility.None)
@@ -6864,7 +6871,7 @@ export struct LocalMusic {
                   .height(24);
 
                 Toggle({ type: ToggleType.Switch, isOn: this.isCoverRectangle })
-                  .selectedColor($r('app.color.title_bar_bg'))
+                  .selectedColor(this.themeColor)
                   .switchPointColor(Color.White)
                   .margin({ right: 15 })
                   .visibility(more.id == 13 ? Visibility.Visible : Visibility.None)
@@ -7138,7 +7145,7 @@ export struct LocalMusic {
               .layoutWeight(1)
               .height(40)
               .width(80)
-              .backgroundColor($r('app.color.title_bar_bg'))
+              .backgroundColor(this.themeColor)
               .stateEffect(true)
               .margin({ left: 0, bottom: 20 })
               .onClick(async () => {
@@ -8579,7 +8586,7 @@ export struct LocalMusic {
       .width(40)
       .height(40)
       .type(ButtonType.Circle)
-      .backgroundColor($r('app.color.title_bar_bg'))
+      .backgroundColor(this.themeColor)
       .margin(5)
       .visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
       .onClick(() => {
@@ -8597,7 +8604,7 @@ export struct LocalMusic {
       .width(40)
       .height(40)
       .type(ButtonType.Circle)
-      .backgroundColor($r('app.color.title_bar_bg'))
+      .backgroundColor(this.themeColor)
       .margin(5)
 
       .visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
@@ -8614,7 +8621,7 @@ export struct LocalMusic {
       .width(40)
       .height(40)
       .type(ButtonType.Circle)
-      .backgroundColor($r('app.color.title_bar_bg'))
+      .backgroundColor(this.themeColor)
       .margin(5)
       .id(filePath + 'copy')
       .visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
@@ -8631,7 +8638,7 @@ export struct LocalMusic {
       .width(40)
       .height(40)
       .type(ButtonType.Circle)
-      .backgroundColor($r('app.color.title_bar_bg'))
+      .backgroundColor(this.themeColor)
       .margin(5)
       .id(filePath)
       .visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
@@ -8647,7 +8654,7 @@ export struct LocalMusic {
       .width(40)
       .height(40)
       .type(ButtonType.Circle)
-      .backgroundColor($r('app.color.title_bar_bg'))
+      .backgroundColor(this.themeColor)
       .margin(5)
       .id(filePath + 'current')
       .visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None :
@@ -8665,7 +8672,7 @@ export struct LocalMusic {
       .width(40)
       .height(40)
       .type(ButtonType.Circle)
-      .backgroundColor($r('app.color.title_bar_bg'))
+      .backgroundColor(this.themeColor)
       .visibility(item.type === CommonConstants.TYPE_IS_DIR ?
         (item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
           item.name === LocalMusic.STR_HISTORY_MUSIC ? Visibility.None : Visibility.Visible) : Visibility.Visible)
@@ -8683,7 +8690,7 @@ export struct LocalMusic {
       .width(40)
       .height(40)
       .type(ButtonType.Circle)
-      .backgroundColor($r('app.color.title_bar_bg'))
+      .backgroundColor(this.themeColor)
       .visibility(item.type === CommonConstants.TYPE_IS_DIR ?
         (item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
           item.name === LocalMusic.STR_HISTORY_MUSIC ? Visibility.None : Visibility.Visible) : Visibility.Visible)
@@ -8700,7 +8707,7 @@ export struct LocalMusic {
       .width(40)
       .height(40)
       .type(ButtonType.Circle)
-      .backgroundColor($r('app.color.title_bar_bg'))
+      .backgroundColor(this.themeColor)
       .margin(5)
       .visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
       .onClick(() => {

+ 7 - 2
entry/src/main/ets/view/RotatingCover.ets

@@ -14,7 +14,7 @@
  */
 
 import { displaySync } from '@kit.ArkGraphics2D';
-import { StrUtil } from '@pura/harmony-utils';
+import { PreferencesUtil, StrUtil } from '@pura/harmony-utils';
 
 @Component
 export struct RotatingCover {
@@ -22,6 +22,8 @@ export struct RotatingCover {
   @Prop songLabel: string;
   @State timer: number = 0
   @State rotateAngle: number = 0
+  @StorageProp('themeColor') themeColor: string = '#FF4081';
+
 
 
   //封面旋转动画
@@ -37,7 +39,9 @@ export struct RotatingCover {
 
   aboutToAppear() {
 
-
+    let themeColor = PreferencesUtil.getStringSync('THEME_COLOR', '#FF4081');
+    AppStorage.setOrCreate('themeColor', themeColor);
+    this.themeColor=themeColor
   }
 
   aboutToDisappear(): void {
@@ -50,6 +54,7 @@ export struct RotatingCover {
         .height(32)
         .width(32)
         .alt( $r('app.media.music_red'))
+        .fillColor(this.themeColor)
         .borderRadius(16)
         .margin({ right: 12 })
         .rotate({

+ 13 - 13
entry/src/main/ets/view/TitleBar.ets

@@ -509,7 +509,7 @@ export namespace TitleBar {
 
     setTitleBarBackground(value: ResourceColor): Model {
       this.titleBarBackground = value;
-      console.log('Heanup: TitleBar背景色:'+JSON.stringify(value))
+      console.log('Heanup: TitleBar背景色:'+(value.toString()))
       return this;
     }
 
@@ -835,18 +835,18 @@ export namespace TitleBar {
      */
     private barStyleTransform(value: BarStyle) {
 
-        this.setTitleBarBackground($r('app.color.title_bar_bg'));
-        this.setTitleFontColor($r('app.color.title_text'));
-        this.setTitleBarBottomLineColor($r('app.color.title_bar_bottom_line'));
-
-        this.setLeftTitleStateNormalStyleColor($r('app.color.title_bar_bg'));
-        this.setLeftTitleStatePressedStyleColor($r('app.color.title_bar_pressed'));
-        this.setLeftIcon($r('app.media.left_back_black'));
-        this.setLeftTitleFontColor($r('app.color.title_left_text'));
-
-        this.setRightTitleStateNormalStyleColor($r('app.color.title_bar_bg'));
-        this.setRightTitleStatePressedStyleColor($r('app.color.title_bar_pressed'));
-        this.setRightTitleFontColor($r('app.color.title_right_text'));
+        // this.setTitleBarBackground($r('app.color.title_bar_bg'));
+        // this.setTitleFontColor($r('app.color.title_text'));
+        // this.setTitleBarBottomLineColor($r('app.color.title_bar_bottom_line'));
+        //
+        // this.setLeftTitleStateNormalStyleColor($r('app.color.title_bar_bg'));
+        // this.setLeftTitleStatePressedStyleColor($r('app.color.title_bar_pressed'));
+        // this.setLeftIcon($r('app.media.left_back_black'));
+        // this.setLeftTitleFontColor($r('app.color.title_left_text'));
+        //
+        // this.setRightTitleStateNormalStyleColor($r('app.color.title_bar_bg'));
+        // this.setRightTitleStatePressedStyleColor($r('app.color.title_bar_pressed'));
+        // this.setRightTitleFontColor($r('app.color.title_right_text'));
 
     }
   }

BIN
entry/src/main/resources/base/media/music_red.png


+ 1 - 0
entry/src/main/resources/base/media/music_red.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1749976802589" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1517" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M150.588235 542.117647a30.117647 30.117647 0 1 1 60.235294 0 271.058824 271.058824 0 0 0 271.058824 271.058824 30.117647 30.117647 0 1 1 0 60.235294C298.917647 873.411765 150.588235 725.082353 150.588235 542.117647z m722.82353-60.235294a30.117647 30.117647 0 1 1-60.235294 0 271.058824 271.058824 0 0 0-271.058824-271.058824 30.117647 30.117647 0 1 1 0-60.235294c182.964706 0 331.294118 148.329412 331.294118 331.294118zM512 1024C229.225412 1024 0 794.774588 0 512S229.225412 0 512 0s512 229.225412 512 512-229.225412 512-512 512z m0-60.235294c249.494588 0 451.764706-202.270118 451.764706-451.764706 0-249.494588-202.270118-451.764706-451.764706-451.764706C262.505412 60.235294 60.235294 262.505412 60.235294 512c0 249.494588 202.270118 451.764706 451.764706 451.764706z m0-331.294118a120.470588 120.470588 0 1 1 0-240.941176 120.470588 120.470588 0 0 1 0 240.941176z m0-60.235294a60.235294 60.235294 0 1 0 0-120.470588 60.235294 60.235294 0 0 0 0 120.470588z" fill="#dd2d1e" p-id="1518"></path></svg>