Bladeren bron

优化发现页搜索记录

onecold 4 maanden geleden
bovenliggende
commit
ea43255719
1 gewijzigde bestanden met toevoegingen van 83 en 15 verwijderingen
  1. 83 15
      entry/src/main/ets/view/FindView.ets

+ 83 - 15
entry/src/main/ets/view/FindView.ets

@@ -13,6 +13,7 @@ import { PointLightActionButton } from './PointLight/PointLightActionButton'
 import { PointLightContentButton } from './PointLight/PointLightContentButton'
 import { SettingPage } from '../pages/SettingPage'
 import { FindAlbumDetail } from './FindAlbumDetail'
+import { PlayingIndicator } from './PlayingIndicator'
 import { setFindPlaylist } from '../common/util/FindPlaylistStore'
 
 @Builder
@@ -158,6 +159,8 @@ export struct FindView {
   @StorageProp('bottomSafeHeight') bottomSafeHeight: number = 0
   @StorageProp('isDarkMode') isDarkMode: boolean = false
   @StorageProp('themeColor') themeColor: string = CommonConstants.DEFAULT_THEME_COLOR
+  @StorageLink('currentSong') currentSong: VideoItem | undefined = undefined
+  @StorageLink('isPlaying') isPlaying: boolean = false
 
   private mediaTable?: MediaTable
   private localSongsPool: VideoItem[] = []
@@ -1265,6 +1268,27 @@ export struct FindView {
     return StrUtil.isNotEmpty(item.pixelMapPath) ? item.pixelMapPath as string : $r('app.media.alt')
   }
 
+  private getSongQualityText(item: VideoItem): string {
+    if (StrUtil.isNotEmpty(item.md5Str)) {
+      const quality = item.md5Str as string
+      return quality.includes('Lossless') ? '无损' : quality
+    }
+
+    const sampleRate = Number(item.sampleRate ?? '0')
+    const bitDepth = Number(item.bits_per_raw_sample ?? '0')
+    if (sampleRate >= 88200 || bitDepth >= 24) {
+      return 'Hi-Res'
+    }
+
+    const mimeType = (item.mimeType ?? '').toLowerCase()
+    const fileName = (item.fileName ?? item.name ?? '').toLowerCase()
+    const isLosslessFormat = mimeType.includes('flac') || mimeType.includes('wav') || mimeType.includes('ape') ||
+      mimeType.includes('alac') || mimeType.includes('dsf') || mimeType.includes('dff') ||
+      fileName.endsWith('.flac') || fileName.endsWith('.wav') || fileName.endsWith('.ape') ||
+      fileName.endsWith('.alac') || fileName.endsWith('.dsf') || fileName.endsWith('.dff')
+    return isLosslessFormat ? '无损' : ''
+  }
+
   private getAlbumCover(coverPath: string): string | Resource {
     return StrUtil.isNotEmpty(coverPath) ? coverPath : $r('app.media.alt')
   }
@@ -1334,6 +1358,14 @@ export struct FindView {
     return $r('app.color.find_card_background')
   }
 
+  private getSongQualityBadgeTextColor(): ResourceColor {
+    return $r('app.color.album_detail_song_quality_text')
+  }
+
+  private getSongQualityBadgeBackgroundColor(): ResourceColor {
+    return $r('app.color.album_detail_song_quality_background')
+  }
+
   @Builder
   private buildLoadingState() {
     Column({ space: 14 }) {
@@ -1537,11 +1569,14 @@ export struct FindView {
 
       Flex({ wrap: FlexWrap.Wrap }) {
         ForEach(this.searchHistoryItems, (keyword: string) => {
-          Button(keyword)
-            .fontSize(12)
-            .fontColor($r('app.color.text_color'))
-            .backgroundColor($r('app.color.find_history_background'))
-            .borderRadius(16)
+          PointLightContentButton({
+            pointColor: this.themeColor,
+            buttonColor: $r('app.color.find_history_background'),
+            pointLightHeight: 40,
+            builder: () => {
+              this.buildSearchHistoryChipContent(keyword)
+            }
+          })
             .margin({ right: 8, bottom: 8 })
             .padding({ left: 12, right: 12, top: 8, bottom: 8 })
             .onClick(() => {
@@ -1555,6 +1590,14 @@ export struct FindView {
     .width('100%')
   }
 
+  @Builder
+  private buildSearchHistoryChipContent(keyword: string) {
+    Text(keyword)
+      .fontSize(12)
+      .fontColor($r('app.color.text_color'))
+      .padding({ left: 5, right: 5, top: 3, bottom: 3 })
+  }
+
   @Builder
   private buildSearchResultCardContent(item: VideoItem) {
     Row({ space: 12 }) {
@@ -1562,7 +1605,7 @@ export struct FindView {
         Image(this.getSongCover(item))
           .width(58)
           .height(58)
-          .borderRadius(14)
+          .borderRadius(8)
           .objectFit(ImageFit.Cover)
 
         Row() {
@@ -1580,6 +1623,7 @@ export struct FindView {
       .height(58)
 
       Column({ space: 4 }) {
+
         Text(this.getSongTitle(item))
           .fontSize(14)
           .fontWeight(FontWeight.Bold)
@@ -1588,16 +1632,40 @@ export struct FindView {
           .textOverflow({ overflow: TextOverflow.Ellipsis })
           .width('100%')
 
-        Text(this.getSongSubtitle(item))
-          .fontSize(11)
-          .lineHeight(14)
-          .fontColor(this.getSecondaryTextColor())
-          .maxLines(1)
-          .textOverflow({ overflow: TextOverflow.Ellipsis })
-          .width('100%')
+
+        Row (){
+          if (StrUtil.isNotEmpty(this.getSongQualityText(item))) {
+            Text(this.getSongQualityText(item))
+              .fontSize(10)
+              .fontWeight(FontWeight.Medium)
+              .fontColor(this.getSongQualityBadgeTextColor())
+              .padding({ left: 6, right: 6, top: 2, bottom: 2 })
+              .backgroundColor(this.getSongQualityBadgeBackgroundColor())
+              .borderRadius(4)
+          }
+          Text(this.getSongSubtitle(item))
+            .fontSize(11)
+            .lineHeight(14)
+            .fontColor(this.getSecondaryTextColor())
+            .maxLines(1)
+            .textOverflow({ overflow: TextOverflow.Ellipsis })
+            .width('100%')
+        }
+
       }
       .layoutWeight(1)
       .alignItems(HorizontalAlign.Start)
+
+      Column({ space: 8 }) {
+        PlayingIndicator({
+          isActive: this.isPlaying && this.currentSong?.filePath === item.filePath,
+          indicatorSize: 18,
+          marginRight: 20,
+          marginTop: 8,
+          marginBottom: 8
+        })
+      }
+      .alignItems(HorizontalAlign.End)
     }
     .width('100%')
     .padding(10)
@@ -2446,7 +2514,7 @@ export struct FindView {
       Column() {
         this.buildTopErrorBanner()
         this.buildSwiperSection()
-        Column({ space: 14 }) {
+        Column({ space: 6 }) {
           this.buildActionButtons()
           this.buildLocalRandomSection()
           this.buildFavoriteSection()
@@ -2563,6 +2631,6 @@ export struct FindView {
     }
     .width('100%')
     .height('100%')
-    .backgroundColor(this.isCustomizeBg ? Color.Transparent : $r('app.color.index_background'))
+    .backgroundColor(this.isCustomizeBg ? Color.Transparent : $r('app.color.start_window_background'))
   }
 }