Quellcode durchsuchen

listItem的左滑开关可以设置
list的item可以长按,长按菜单增加详情

onecold vor 1 Jahr
Ursprung
Commit
55ff8267d4

+ 10 - 8
entry/src/main/ets/pages/NewIndex.ets

@@ -171,14 +171,7 @@ struct NewIndex {
 
 
   onPageShow() {
-    console.log('getHiCarStatus isHiCarStatus:' + this.isHiCarStatus)
-    if(this.isHiCarStatus||this.isBigScreen()){
-      this.getUIContext()?.animateTo({ duration: 555 }, () => {
-        this.isShowDrawer = true
-        this.offsetX = 0
-      })
-      this.isShowTitleBar = false
-    }
+
 
   }
   /**
@@ -235,6 +228,15 @@ struct NewIndex {
 
     });
 
+    console.log('getHiCarStatus isHiCarStatus:' + this.isHiCarStatus)
+    if(this.isHiCarStatus||this.isBigScreen()){
+      this.getUIContext()?.animateTo({ duration: 555 }, () => {
+        this.isShowDrawer = true
+        this.offsetX = 0
+      })
+      this.isShowTitleBar = false
+    }
+
   }
 
   /**

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

@@ -54,6 +54,7 @@ export struct SettingPage {
   public static TWO_FINGER_TYPE: string = 'twoFingerType';
   public static LONG_PRESS_SPEED: string = 'longPressSpeed';
   public static IS_PLAYLIST_BG_GRASS: string = 'isPlayListBgGrass';
+  static readonly IS_SWIPE: string = 'isSwipe'
 
   public static THEME_COLOR_LIST: Array<ThemeColorItem> = [
     { name: '玫瑰粉', color: '#FF4081', isVip: false },
@@ -109,6 +110,7 @@ export struct SettingPage {
   @State isSavePlayMode: boolean = true
   @State isCoverTop: boolean = true
   @State isCoverTopBig: boolean = false//顶部大封面部分手机显示会和播放控制页重叠
+  @State isSwipe: boolean = false //listItem的左滑开关
   @State isPlayListBgGrass: boolean = true//是否播放列表玻璃透明效果
 
 
@@ -229,6 +231,7 @@ export struct SettingPage {
     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)
+    this.isSwipe = PreferencesUtil.getBooleanSync(SettingPage.IS_SWIPE, true)
     // 只用 themeMode 控制主题
     this.themeMode = PreferencesUtil.getNumberSync(SettingPage.THEME_MODE, 0)
     this.applyThemeMode(this.themeMode)
@@ -915,6 +918,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.isSwipe })
+                .selectedColor(this.themeColor)
+                .switchPointColor(Color.White)
+                .margin({ right: 18 })
+                .onChange((checked: boolean) => {
+                  this.isSwipe = checked;
+                  PreferencesUtil.put(SettingPage.IS_SWIPE, this.isSwipe)
+                  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'))
             // 记住播放进度
             Row() {

+ 97 - 23
entry/src/main/ets/view/LocalMusic.ets

@@ -190,6 +190,7 @@ export struct LocalMusic {
   @State isShowSingleLineLyric: boolean = false //是否显示播放页返回键
   @State isMemoryLastPlay: boolean = false //是否启用应用退出记忆最后一首的播放进度
   @State isCoverTopBig: boolean = false //顶部大封面部分手机显示会和播放控制页重叠
+  @State isSwipe: boolean = false //listItem的左滑开关
   @State customizeBgPath: string | undefined = '';
   @State isDarkMode: boolean = false
   @State lyricTextWeight: number = 400
@@ -604,6 +605,7 @@ export struct LocalMusic {
     this.isPlayListBgGrass = PreferencesUtil.getBooleanSync(SettingPage.IS_PLAYLIST_BG_GRASS, true)
     this.isShowHeader = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_HEADER, true)
     this.volume = PreferencesUtil.getNumberSync('DefalutVolume', this.volume)
+    this.isSwipe = PreferencesUtil.getBooleanSync(SettingPage.IS_SWIPE, true)
     //如果是hicar连接状态,这些都是false
     if(this.isHiCarStatus){
       this.isShowTitleBar = false//不显示导航栏
@@ -2557,6 +2559,40 @@ export struct LocalMusic {
               .fontColor(this.currentSong?.filePath === item.filePath ? this.themeColor :
               $r('app.color.text_color'))
               .margin({ left: this.twoFingerType == 3 ? 6 : 8 })
+              .bindPopup(this.longItemFilePath === item.filePath, {
+                builder: this.MenuBuilder(item,index,item.filePath),
+                placement: Placement.Top,
+                // autoCancel: true,
+                mask: {color:'#33000000'},
+                // popupColor: Color.Yellow,
+                enableArrow: false,//是否显示箭头
+                showInSubWindow: false,
+                onStateChange: (e) => {
+                  if (!e.isVisible) {
+                    this.longItemFilePath = ''
+                    this.tempLyricContent = ''
+                  }
+                }
+              })
+
+              .gesture(LongPressGesture()
+                .onAction(async () => {
+                  //如果是专辑和艺术家的首页,不能长按
+                  if((this.modeType===2||this.modeType==3)&&!this.isCanBack)
+                    return
+                  //如果是我的收藏 最近播放等也不能长按
+                  if(item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
+                    item.name === LocalMusic.STR_HISTORY_MUSIC
+                  )
+                    return
+                  this.longItemFilePath = item.filePath
+                  this.tempLyricContent = await this.getLyricContent(item)
+                  LogUtil.info('长按this.tempLyricContent = '+this.tempLyricContent)
+                })
+                .onActionEnd((event: GestureEvent) => {
+
+                })
+              )
             Row() {
               Text(StrUtil.isEmpty(item.artist) ? item.cTime : item.artist + '  ' + item?.album)
                 .fontSize(this.twoFingerType == 1 ? 11 : this.twoFingerType == 2 ? 12 : 14)
@@ -2573,6 +2609,24 @@ export struct LocalMusic {
                 $r('app.color.text_color'))
                 .margin({ left: 10 })
             }
+            .gesture(LongPressGesture()
+              .onAction(async () => {
+                //如果是专辑和艺术家的首页,不能长按
+                if((this.modeType===2||this.modeType==3)&&!this.isCanBack)
+                  return
+                //如果是我的收藏 最近播放等也不能长按
+                if(item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
+                  item.name === LocalMusic.STR_HISTORY_MUSIC
+                )
+                  return
+                this.longItemFilePath = item.filePath
+                this.tempLyricContent = await this.getLyricContent(item)
+                LogUtil.info('长按this.tempLyricContent = '+this.tempLyricContent)
+              })
+              .onActionEnd((event: GestureEvent) => {
+
+              })
+            )
 
           }
           .height('100%')
@@ -3693,7 +3747,7 @@ export struct LocalMusic {
     }
     return wightG
   }
-
+  @State isShowDetail:boolean = false
   @Builder
   MenuBuilder(item: VideoItem, index: number, filePath: string) {
     Scroll() {
@@ -3761,6 +3815,25 @@ export struct LocalMusic {
               this.showWarnIsDeleteFile(item, index + '', filePath)
               this.longItemFilePath = ''
             })
+
+          MenuItem({
+            symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.info_circle')),
+            content: $r('app.string.detail')
+          })
+            .bindSheet($$this.isShowDetail, this.detailSheet(item), {
+              height:this.isCoverOpacity()?'95%': '66%',
+              dragBar: true,
+              showClose: true,
+              blurStyle:BlurStyle.Thin,
+              preferType: this.currentBreakpoint !== BreakpointTypeEnum.SM ? SheetType.CENTER : SheetType.BOTTOM,
+              backgroundColor:Color.Transparent,
+              title: { title: '详情信息' }
+            })
+            .visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
+            .onClick(() => {
+              this.isShowDetail = !this.isShowDetail
+            })
+
           MenuItem({
             symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.share')),
             content: $r('app.string.share')
@@ -3845,7 +3918,7 @@ export struct LocalMusic {
             TransitionEffect.scale({ x: 0, y: 0 })))
           .clickEffect({ level: ClickEffectLevel.LIGHT })
           .swipeAction((
-            (this.modeType == 0 || this.modeType == 1 || ((this.modeType == 3 || this.modeType == 2) && this.isCanBack))
+            (this.isSwipe&&this.modeType == 0 || this.modeType == 1 || ((this.modeType == 3 || this.modeType == 2) && this.isCanBack))
               && item.type !== CommonConstants.TYPE_IS_CSJAD &&
               !this.isHistory) ? { end: this.DeleteButton(item, index, item.filePath) } : {}) //左滑
           .onClick(() => {
@@ -4820,10 +4893,10 @@ export struct LocalMusic {
   }
 
   @Builder
-  detailSheet() {
+  detailSheet(item:VideoItem) {
     Scroll() {
       Column() {
-        this.songDetail()
+        this.songDetail(item)
       }
     }
     .width('100%')
@@ -4831,14 +4904,14 @@ export struct LocalMusic {
   }
 
   @Builder
-  songDetail() {
+  songDetail(currentItem:VideoItem) {
     Column() {
-      if (this.currentSong) {
+      if (currentItem) {
         Row() {
           Stack() {
 
-            Image(StrUtil.isEmpty(this.currentSong.pixelMapPath) ? $r('app.media.music_red') :
-            this.currentSong.pixelMapPath)
+            Image(StrUtil.isEmpty(currentItem.pixelMapPath) ? $r('app.media.music_red') :
+            currentItem.pixelMapPath)
               .fillColor(this.themeColor)
               .height(33)
               .width(33)
@@ -4851,7 +4924,7 @@ export struct LocalMusic {
 
           Column() {
             Column() {
-              Text(this.currentSong.name)
+              Text(currentItem.name)
                 .fontSize(14)
                 .maxLines(1)
                 .animation({
@@ -4862,8 +4935,8 @@ export struct LocalMusic {
                 .fontColor($r('app.color.text_color'))
                 .margin({ left: 10 })
               Row() {
-                Text(StrUtil.isEmpty(this.currentSong.artist) ? this.currentSong.cTime :
-                  this.currentSong.artist + '  ' + this.currentSong?.album)
+                Text(StrUtil.isEmpty(currentItem.artist) ? currentItem.cTime :
+                  currentItem.artist + '  ' + currentItem?.album)
                   .fontSize(11)
                   .padding({ top: 8 })
                   .fontColor($r('app.color.text_color'))
@@ -4891,7 +4964,7 @@ export struct LocalMusic {
             .fontSize(14)
             .fontColor(Color.White)
             .margin({ left: 22 })
-          Text(this.currentSong?.artist ? this.currentSong.artist : '未知歌手')
+          Text(currentItem?.artist ? currentItem.artist : '未知歌手')
             .fontSize(14)
             .fontColor(Color.White)
             .margin({ left: 10 })
@@ -4908,7 +4981,7 @@ export struct LocalMusic {
             .fontSize(14)
             .fontColor(Color.White)
             .margin({ left: 22 })
-          Text(this.currentSong?.album ? this.currentSong.album : '未知专辑')
+          Text(currentItem?.album ?currentItem.album : '未知专辑')
             .fontSize(14)
             .margin({ left: 10 })
             .fontColor(Color.White)
@@ -4923,7 +4996,8 @@ export struct LocalMusic {
             .fontSize(14)
             .fontColor(Color.White)
             .margin({ left: 22 })
-          Text(this.totalTime)
+          Text(StrUtil.isEmpty(currentItem.duration)?
+            (this.isShowDetailMore?this.totalTime:'未知'):currentItem.duration)
             .fontSize(14)
             .margin({ left: 10 })
             .fontColor(Color.White)
@@ -4938,7 +5012,7 @@ export struct LocalMusic {
             .fontSize(14)
             .fontColor(Color.White)
             .margin({ left: 22 })
-          Text(Utility.convertToKHz(this.currentSong.sampleRate))
+          Text(Utility.convertToKHz(currentItem.sampleRate))
             .fontSize(14)
             .margin({ left: 10 })
             .fontColor(Color.White)
@@ -4953,7 +5027,7 @@ export struct LocalMusic {
             .fontSize(14)
             .fontColor(Color.White)
             .margin({ left: 22 })
-          Text(this.currentSong.trackCount)
+          Text(StrUtil.isEmpty(currentItem.trackCount)?'1':currentItem.trackCount)
             .fontSize(14)
             .margin({ left: 10 })
             .fontColor(Color.White)
@@ -4968,7 +5042,7 @@ export struct LocalMusic {
             .fontSize(14)
             .fontColor(Color.White)
             .margin({ left: 22 })
-          Text(Utility.formatMimeType(this.currentSong.mimeType))
+          Text(Utility.formatMimeType(currentItem.mimeType))
             .fontSize(14)
             .margin({ left: 10 })
             .fontColor(Color.White)
@@ -4983,7 +5057,7 @@ export struct LocalMusic {
             .fontSize(14)
             .fontColor(Color.White)
             .margin({ left: 22 })
-          Text(this.currentSong.size)
+          Text(currentItem.size)
             .fontSize(14)
             .margin({ left: 10 })
             .fontColor(Color.White)
@@ -4998,7 +5072,7 @@ export struct LocalMusic {
             .fontSize(14)
             .fontColor(Color.White)
             .margin({ left: 22 })
-          Text(this.currentSong.fileName)
+          Text(currentItem.fileName)
             .fontSize(14)
             .margin({ left: 10 })
             .fontColor(Color.White)
@@ -5013,7 +5087,7 @@ export struct LocalMusic {
             .fontSize(14)
             .fontColor(Color.White)
             .margin({ left: 22 })
-          Text(this.currentSong.cTime)
+          Text(currentItem.cTime)
             .fontSize(14)
             .margin({ left: 10 })
             .fontColor(Color.White)
@@ -5028,7 +5102,7 @@ export struct LocalMusic {
             .fontSize(14)
             .fontColor(Color.White)
             .margin({ left: 22 })
-          Text(this.currentSong.filePath)
+          Text(currentItem.filePath)
             .fontSize(12)
             .margin({ left: 10 })
             .fontColor(Color.White)
@@ -8174,7 +8248,7 @@ export struct LocalMusic {
         ForEach(this.moreItems, (more: MoreItem, index: number) => {
           Button({ type: ButtonType.Capsule, stateEffect: true }) {
             Row() {
-              if (more.id === 3) {
+              if (more.id === 3&&this.currentSong) {
                 Image(more.image)
                   .width(24)
                   .height(24)
@@ -8182,7 +8256,7 @@ export struct LocalMusic {
                 Text(more.title)
                   .fontSize(16)
                   .fontColor(Color.White)
-                  .bindSheet($$this.isShowDetailMore, this.detailSheet(), {
+                  .bindSheet($$this.isShowDetailMore, this.detailSheet(this.currentSong), {
                     height: this.isCoverOpacity() ? '95%' : '75%',
                     dragBar: true,
                     preferType: this.currentBreakpoint !== BreakpointTypeEnum.SM ? SheetType.CENTER : SheetType.BOTTOM,

+ 4 - 0
entry/src/main/resources/base/element/string.json

@@ -435,6 +435,10 @@
     {
       "name": "onekey_cover",
       "value": "一键获取封面"
+    },
+    {
+      "name": "detail",
+      "value": "详情"
     }
   ]
 }