Browse Source

点击歌单也支持封面在头部的模式

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

+ 6 - 3
entry/src/main/ets/pages/NewIndex.ets

@@ -378,7 +378,7 @@ struct NewIndex {
         Column() {
           Row() {
             Text(this.isLogin ? this.userName : '未登录用户')
-              .fontSize(16)
+              .fontSize(13)
               .fontWeight(FontWeight.Bold)
               .fontColor(this.isDarkMode ? Color.White : Color.Black)
               .textAlign(TextAlign.Start)
@@ -395,12 +395,14 @@ struct NewIndex {
                 .fontSize(13)
                 .fontColor(themeColorWithAlpha(this.themeColor, 0.8, false))
                 .textAlign(TextAlign.Start)
+                .padding({top:5})
               this.TimeTextBuilder()
             } else {
               Text('普通用户')
-                .fontSize(12)
+                .fontSize(13)
                 .fontColor(this.isDarkMode ? Color.White : Color.Grey)
                 .textAlign(TextAlign.Start)
+                .padding({top:5})
               this.TimeTextBuilder()
             }
           } else {
@@ -428,7 +430,8 @@ struct NewIndex {
     .backgroundColor($r('app.color.user_center_card_background'))
     .borderRadius(24)
     .width('86%')
-    .margin({ left: 10, right: 10, top: this.topRectHeight + 10 })
+    .padding(8)
+    .margin({ left: 10, right: 10, top: this.topRectHeight + 10,bottom:10 })
     .shadow({
       radius: 8,
       color: 0x11000000,

+ 5 - 3
entry/src/main/ets/pages/ScanFilePage.ets

@@ -275,7 +275,7 @@ export struct ScanFilePage{
             .margin({ left:25,right: 25 ,top:20,bottom:20 })
 
           }
-          .width(this.currentBreakpoint !== BreakpointTypeEnum.SM?400:300)
+          .width(this.currentBreakpoint !== BreakpointTypeEnum.SM?450:350)
           .backgroundColor($r('app.color.index_background'))
           .margin({ left:25,right: 25,top:20,bottom:20  })
           .borderRadius(20)
@@ -286,8 +286,9 @@ export struct ScanFilePage{
           Column() {
             Button(this.isStart?'正在扫描':$r('app.string.start_scan'), { type: ButtonType.Capsule, stateEffect: false })
 
-              .width(150)
+              .width(180)
               .height(55)
+              .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
               .margin({ top: 20, bottom: 10 })
               .linearGradient({
                 direction: GradientDirection.Right,
@@ -301,8 +302,9 @@ export struct ScanFilePage{
               .alignSelf(ItemAlign.Center)
 
             Button(this.isStartCover?'正在扫描':$r('app.string.onekey_cover'), { type: ButtonType.Capsule, stateEffect: false })
-              .width(150)
+              .width(180)
               .height(55)
+              .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
               .margin({ top: 10, bottom: 20 })
               .linearGradient({
                 direction: GradientDirection.Right,

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

@@ -720,6 +720,7 @@ export struct SettingPage {
                 .selectedColor(this.themeColor)
                 .switchPointColor(Color.White)
                 .margin({ right: 18 })
+                .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
                 .onChange((checked: boolean) => {
                   this.isCoverTop = checked;
                   PreferencesUtil.put(SettingPage.IS_COVER_TOP, this.isCoverTop)

+ 45 - 11
entry/src/main/ets/view/LocalMusic.ets

@@ -834,6 +834,11 @@ export struct LocalMusic {
     if (cachedValue !== undefined) {
       // this.videoLocalList = cachedValue;
       Logger.info('onecold 有缓存 cachedValue = ' + cachedValue)
+      if(this.currentPath !=this.rootPath){//第一个封面赋值给currentTitleCover
+        if(cachedValue[0].pixelMapPath){
+          this.currentTitleCover = cachedValue[0].pixelMapPath
+        }
+      }
       this.updateListData(cachedValue)
     }
 
@@ -904,10 +909,16 @@ export struct LocalMusic {
       this.updateListData(this.videoLocalList)
 
       if (ArrayUtil.isNotEmpty(files)) {
+        if(this.currentPath !=this.rootPath){
+          if(files[0].pixelMapPath){
+            this.currentTitleCover = files[0].pixelMapPath//第一个封面赋值给currentTitleCover
+          }
+        }
         // 缓存结果
         this.addCache(curPath, this.videoLocalList);
         await this.saveCacheToStorage(); // 保存缓存至本地存储
         this.addStringCache(curPath + '_hash', currentHash);
+
       }
 
       console.info(`onecold gengxin 1: ${this.videoLocalList.length}`);
@@ -2641,10 +2652,18 @@ export struct LocalMusic {
     .visibility(this.isShowTitleBar?Visibility.Visible:Visibility.None)
   }
 
-  @State currentTitleName:string = ''
-  @State currentTitleCover:string = ''
+  @State currentTitleName:string = ''//点击歌单,艺术家,专辑进去后的标题
+  @State currentTitleCover:string|ResourceStr = ''//点击歌单,艺术家,专辑进去后的封面
 
   isShowCoverTitle(){
+    if(this.modeType==0){
+      if(this.isHistory||this.isFavMusic){
+        return true
+      }
+      if (this.currentPath != this.rootPath&&!this.isGridMusic ) {
+        return true
+      }
+    }
     return (this.modeType==2||this.modeType==3)&&this.isCanBack&&!this.isGridMusic
   }
 
@@ -2664,6 +2683,7 @@ export struct LocalMusic {
             Image($r('app.media.left_back_white'))
               .width(28)
               .height(28)
+              .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
               .margin({ left: 12, right: 8 })
               .onClick(() => {
                 animateTo({ duration: 555 }, () => {
@@ -2671,7 +2691,17 @@ export struct LocalMusic {
                 })
               })
             Blank().flexGrow(1)
-            Blank().width(32)
+            if(this.modeType==0){
+              Image($r('app.media.add'))
+                .width(25)
+                .height(25)
+                .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
+                .margin({ left: 8, right: 15 })
+                .onClick(() => {
+                  this.showAddDialog()
+                })
+            }
+
           }
           .height(48)
           .width('100%')
@@ -2683,7 +2713,7 @@ export struct LocalMusic {
         Row() {
           Column() {
 
-            Image(StrUtil.isEmpty(this.currentTitleCover) ? this.imageLabel : this.currentTitleCover)
+            Image(this.currentTitleCover)
               .height(100)
               .width(100)
               .alt(this.imageLabel)
@@ -2692,7 +2722,7 @@ export struct LocalMusic {
 
           }
           .alignItems(HorizontalAlign.Start)
-          .margin({left:25,top:10,bottom:10})
+          .margin({left:30,top:10,bottom:15})
 
           Column() {
             Column() {
@@ -2763,12 +2793,8 @@ export struct LocalMusic {
       return ('rgba(255,255,255,0.2)')
     if(this.isDarkMode)
       return $r('app.color.user_center_card_background')
-    if(StrUtil.isEmpty(this.currentTitleCover)){
-      return this.imageLabel
-    }else{
-      return this.currentTitleCover
-    }
 
+      return this.currentTitleCover
   }
 
   @Builder
@@ -3963,9 +3989,12 @@ export struct LocalMusic {
       case CommonConstants.TYPE_IS_DIR:
         if (item.name === LocalMusic.STR_LOCK_VIDEO) {
           this.showVerifyDialog()
+          this.currentTitleName = '私密音频'
+          this.currentTitleCover = $r('app.media.ic_avatar5')
         } else if (item.name === LocalMusic.STR_HISTORY_MUSIC) {
           this.titleBarModel.setTitleName('最近播放')
-
+          this.currentTitleCover = $r('app.media.ic_avatar2')
+          this.currentTitleName = '最近播放'
           //加载动画效果
           this.updateListData(this.historyList,true)
           // this.videoLocalList = this.historyList
@@ -3977,6 +4006,8 @@ export struct LocalMusic {
           this.titleBarModel.setLeftIconMain($r('app.media.left_back_white'))
         } else if(item.name === LocalMusic.STR_FAC_VIDEO){
           this.titleBarModel.setTitleName('我的收藏')
+          this.currentTitleName = '我的收藏'
+          this.currentTitleCover = $r('app.media.ic_avatar1')
           //加载动画效果
           this.updateListData(this.favList)
           if(ArrayUtil.isEmpty(this.favList)){
@@ -3985,9 +4016,12 @@ export struct LocalMusic {
           this.isFavMusic = true
           this.titleBarModel.setLeftIconMain($r('app.media.left_back_white'))
         }else {
+          this.currentTitleName = '歌单:'+item.name
           this.currentPath = item.filePath
+          this.currentTitleCover = $r('app.media.ic_avatar5')
           this.getSortedFiles(this.currentPath)
         }
+
         break;
       case CommonConstants.TYPE_IS_ARTIST:
         // 进入艺术家前安全保存当前滚动偏移量,支持列表和网格