Bladeren bron

针对List等margin bottom重新调整

onecold 10 maanden geleden
bovenliggende
commit
cd4c0697f0

+ 18 - 0
entry/src/main/ets/dialog/AddSongsToPlaylistDialog.ets

@@ -181,6 +181,24 @@ struct AddSongsToPlaylistDialogContent {
 
           Blank()
 
+          Button(this.selectedSongs.length === this.dataSource.dataArray.length
+            && this.dataSource.dataArray.length > 0 ? '全不选' : '全选')
+            .fontSize(12)
+            .fontColor($r('app.color.text_color'))
+            .backgroundColor(Color.Transparent)
+            .height(30)
+            .padding({ left: 8, right: 8 })
+            .onClick(() => {
+              // 判断是否已经全选
+              if (this.selectedSongs.length === this.dataSource.dataArray.length && this.dataSource.dataArray.length > 0) {
+                // 如果已经全选,则清空选择
+                this.selectedSongs = []
+              } else {
+                // 如果没有全选,则选择当前显示的所有歌曲
+                this.selectedSongs = [...this.dataSource.dataArray]
+              }
+            })
+
           Button('清空')
             .fontSize(12)
             .fontColor($r('app.color.text_color'))

+ 7 - 4
entry/src/main/ets/dialog/PlaylistDialog.ets

@@ -1,6 +1,7 @@
 import { DialogHelper } from '@pura/harmony-dialog';
 import { Playlist } from '../viewmodel/Playlist';
 import { ToastUtil } from '@pura/harmony-utils';
+import { CommonConstants } from '../common/constants/CommonConstants';
 
 /**
  * 歌单对话框内容组件
@@ -10,6 +11,7 @@ struct PlaylistDialogContent {
   @State playlistName: string = ''
   @State playlistDescription: string = ''
   @State isEditMode: boolean = false
+  @StorageProp('themeColor') themeColor: string = CommonConstants.DEFAULT_THEME_COLOR;
   @State originalPlaylist: Playlist | null = null
   
   // 回调函数
@@ -31,6 +33,7 @@ struct PlaylistDialogContent {
         .fontSize(18)
         .fontWeight(FontWeight.Bold)
         .fontColor($r('app.color.text_color'))
+        .visibility(this.isEditMode?Visibility.None:Visibility.Visible)
         .margin({ top: 20 })
 
       // 歌单名称输入框
@@ -79,7 +82,7 @@ struct PlaylistDialogContent {
 
       // 按钮区域
       Row({ space: 12 }) {
-        Button('取消')
+        Button('取消',{ type: ButtonType.Capsule, stateEffect: true })
           .width('45%')
           .height(40)
           .backgroundColor($r('app.color.cancel_button_background'))
@@ -92,10 +95,10 @@ struct PlaylistDialogContent {
             DialogHelper.closeDialog(this.isEditMode ? 'editPlaylistDialog' : 'createPlaylistDialog')
           })
 
-        Button(this.isEditMode ? '保存' : '创建')
+        Button(this.isEditMode ? '保存' : '创建',{ type: ButtonType.Capsule, stateEffect: true })
           .width('45%')
           .height(40)
-          .backgroundColor($r('app.color.theme_color'))
+          .backgroundColor(this.themeColor)
           .borderRadius(8)
           .fontSize(14)
           .fontColor(Color.White)
@@ -107,7 +110,7 @@ struct PlaylistDialogContent {
       .justifyContent(FlexAlign.SpaceBetween)
       .margin({ top: 20, bottom: 20 })
     }
-    .width('90%')
+    .width('100%')
     .backgroundColor($r('app.color.dialog_background'))
     .borderRadius(12)
     .padding({ left: 20, right: 20 })

+ 5 - 14
entry/src/main/ets/pages/NewIndex.ets

@@ -11,14 +11,7 @@ import ScreenUtil from '../common/util/ScreenUtil';
 import { Utility } from '../common/util/Utility';
 import { BusinessError, emitter } from '@kit.BasicServicesKit';
 import { common } from '@kit.AbilityKit';
-// import { AdSlot, AdSlotBuilder,
-//   CSJAdCreator,
-//   CSJAdSdk, CSJNativeExpressAd, NativeExpressAdListener } from '@csj/openadsdk';
-import { PrintBiddingTokenUtils } from '../common/util/PrintBiddintTokenUtils';
-import { ArrayList, JSON, taskpool } from '@kit.ArkTS';
-import { CSJUtil } from '../common/util/CSJUtil';
-import { StreamContent } from '../view/StreamContent';
-import { AvSessionController } from '../controller/AvSessionController';
+
 import { BreakpointSystem, BreakpointTypeEnum } from '../common/util/BreakpointSystem';
 import dataStorage from '@ohos.data.storage';
 import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
@@ -715,6 +708,7 @@ struct NewIndex {
             case MainViewModel.MENU_MUSIC:
               this.mType = 0
               this.modeType = 0
+              this.currentSongListID = ''
               this.doShowDrawer()
               break
             case MainViewModel.MENU_FILE_SCAN:
@@ -729,16 +723,19 @@ struct NewIndex {
             case MainViewModel.MENU_MIEDIA_KU:
               this.modeType = 1
               this.mType = 0
+              this.currentSongListID = ''
               this.doShowDrawer()
               break
             case MainViewModel.MENU_MIEDIA_ARTIST:
               this.modeType = 2
               this.mType = 0
+              this.currentSongListID = ''
               this.doShowDrawer()
               break
             case MainViewModel.MENU_MIEDIA_ALBUM:
               this.modeType = 3
               this.mType = 0
+              this.currentSongListID = ''
               this.doShowDrawer()
               break
             case MainViewModel.MENU_SETTING:
@@ -1252,12 +1249,6 @@ struct NewIndex {
         const playlists = await this.playlistTable.queryAllPlaylists()
         this.playlistList = playlists
         console.info(`onecold 成功加载 ${playlists.length} 个歌单`)
-        // if(ArrayUtil.isNotEmpty(this.playlistList)){
-        //   const playlistSongs = await this.playlistTable.queryPlaylistSongs(this.playlistList[0].id)
-        //   this.currentSongList = await convertPlaylistSongsToVideoItems(this.context,playlistSongs)
-        //   this.currentSongListName= this.playlistList[0].name
-        //   this.currentSongListID = this.playlistList[0].id
-        // }
 
       } else {
         console.warn('onecold 歌单表未初始化')

+ 3 - 4
entry/src/main/ets/pages/PlaylistDetailPage.ets

@@ -548,8 +548,7 @@ export struct PlaylistDetailPage {
                   .width(16)
                   .height(16)
                   .fillColor(Color.White)
-
-                Text('播放全部')
+                Text('播放')
                   .fontSize(14)
                   .fontColor(Color.White)
                   .fontWeight(FontWeight.Medium)
@@ -585,7 +584,7 @@ export struct PlaylistDetailPage {
             })
 
             // 编辑歌单按钮
-            Button() {
+            Button({ type: ButtonType.Capsule, stateEffect: true }) {
               Row({ space: 6 }) {
                 Text('✏️')
                   .fontSize(16)
@@ -625,7 +624,7 @@ export struct PlaylistDetailPage {
             })
 
             // 删除按钮
-            Button() {
+            Button({ type: ButtonType.Capsule, stateEffect: true }) {
               Row({ space: 6 }) {
                 Text('🗑️')
                   .fontSize(16)

+ 51 - 20
entry/src/main/ets/view/LocalMusic.ets

@@ -163,6 +163,7 @@ const ITEM_HEIGHT_BIG: number = 78; // 列表项大高度
 @Preview
 @Component
 export struct LocalMusic {
+  @State offHeight: number = 75
   @State currentSongList: Array<VideoItem> = []//当前歌单
   @Consume currentSongListName:string //当前歌单名称
   @Consume @Watch('onIDChange') currentSongListID:string //当前歌单ID
@@ -219,7 +220,7 @@ export struct LocalMusic {
   @State sortType: number = 4 //默认排序方式
   @State isShowSimi: boolean = false //是否显示私密音频
   @State isShowFAV: boolean = true //是否显示我的收藏
-  @State isShowTitleBar: boolean = true //是否显示分类导航条
+  @State @Watch('onTopBarhange')isShowTitleBar: boolean = true //是否显示分类导航条
   @State isShowAllBar: boolean = true //是否显示播放全部条
   @State isShowSingleLineLyric: boolean = false //是否显示单行歌词
   @State isShowHistory: boolean = true //是否显示最近播放
@@ -250,6 +251,7 @@ export struct LocalMusic {
   @State isFixMessy:boolean = false
   @StorageProp('isLandscape') @Watch('onIsLandscapeChange')  isLandscape: boolean = false;
   @StorageProp('topRectHeight') topRectHeight: number = px2vp(AppUtil.getStatusBarHeight());
+  @StorageProp('bottomRectHeight') bottomRectHeight: number = 0;
   @StorageProp('windowWidth') windowWidth: number = 0;
   @StorageProp('windowHeight') windowHeight: number = 0;
   @StorageProp('isHiCarStatus') isHiCarStatus: boolean = false;
@@ -301,11 +303,29 @@ export struct LocalMusic {
     }
   }
 
+  //bar导航条显示状态变化,不显示的话把topBarHeight=0
+  onTopBarhange(){
+    if(this.isShowTitleBar){
+      console.log('onecold 导航条显示')
+      this.topBarHeight = 50
+      this.offHeight = 75
+    }else{
+      console.log('onecold 导航条隐藏')
+      this.topBarHeight = 0
+      if(this.twoFingerType!=4){
+        this.offHeight = 30
+      }
+
+    }
+
+  }
+
   //点击某个歌单id发生变化的时候回调
   onIDChange(){
     console.log('onecold 歌单id发生变化this.currentSongListID='+this.currentSongListID)
     console.log('onecold 歌单id发生变化this.currentSongListName='+this.currentSongListName)
     if(this.modeType==4){
+      this.isShowTitleBar = false
       this.titleBarModel.setTitleName(this.currentSongListName)
       this.titleBarModel.setLeftIconMainNoAnimate($r('app.media.menu'))
       //获取缓存
@@ -314,7 +334,6 @@ export struct LocalMusic {
       if(StrUtil.isNotEmpty(cacheSongs)){
         this.currentSongList = JSON.parse(cacheSongs) as VideoItem[]
         this.updateListData(this.currentSongList, true)
-        this.isShowTitleBar = false
       }
       this.doSongListTask()//获取歌单信息
     }
@@ -478,6 +497,7 @@ export struct LocalMusic {
     .setLeftIconWidth(26)
     .setLeftIconHeight(26)
     .setTitleName('首页')
+    .setTitleBarMinHeight(55)
     .setTitleFontSize(18)
     .setTitleFontColor(Color.White)
     .setTitleBarBackground(this.isDarkMode ? $r('app.color.title_bar_bg') : this.themeColor)
@@ -2218,6 +2238,7 @@ export struct LocalMusic {
             .id('pup_positon_music')
         }
 
+
         Stack() {
           Column() {
 
@@ -2314,7 +2335,7 @@ export struct LocalMusic {
                   emptyView(this.themeColor)
 
                 }
-                .position({ top: 180 })
+                .position({ top:this.isShowCoverHeader() ? 260 : 180 })
                 .transition(TransitionEffect.asymmetric(TransitionEffect.scale({ x: 1.2, y: 1.2 })
                   .animation({ duration: 500 }),
                   TransitionEffect.scale({ x: 0, y: 0 })))
@@ -2332,7 +2353,6 @@ export struct LocalMusic {
             }
             .layoutWeight(1)
             .height('100%')
-
           }
 
           .layoutWeight(1)
@@ -3140,6 +3160,7 @@ export struct LocalMusic {
         .visibility(this.isCustomizeBg ? Visibility.Hidden : Visibility.Visible)
     }
     .width('100%')
+    .height(this.topBarHeight)
     .visibility(this.isShowTitleBar ? Visibility.Visible : Visibility.None)
   }
 
@@ -3232,6 +3253,7 @@ export struct LocalMusic {
         return true
       }
     }
+
     return (this.modeType == 2 || this.modeType == 3) && this.isCanBack
   }
   @Builder
@@ -3705,7 +3727,8 @@ export struct LocalMusic {
       .width('100%')
       .padding(10)
       .height(50)
-      .visibility(this.modeType === 0 || this.modeType === 1 || this.isCanBack ? Visibility.Visible : Visibility.None)
+      .visibility(this.modeType === 0 || this.modeType === 1||this.modeType === 4
+        || this.isCanBack ? Visibility.Visible : Visibility.None)
       .border({
         width: { bottom: 1 },
         color: this.isCustomizeBg ? Color.Transparent : '#12ec5c87'
@@ -3877,11 +3900,15 @@ export struct LocalMusic {
         .columnsGap(12) // 列间距
         .rowsGap(16) // 行间距
         .cachedCount(6)
-        .margin(
-          this.isHiCar()?{bottom:this.bottomBarHeight+90}:
-          {bottom:this.isShowCoverHeader()? this.topBarHeight+35:
-          this.isCoverOpacity()?this.topBarHeight+this.bottomBarHeight+78
-            :this.topBarHeight+this.bottomBarHeight+108})
+        // .margin(
+        //   this.isHiCar()?{bottom:this.bottomBarHeight+90}:
+        //   {bottom:this.isShowCoverHeader()? this.topBarHeight+35:
+        //   this.isCoverOpacity()?this.topBarHeight+this.bottomBarHeight+78
+        //     :this.topBarHeight+this.bottomBarHeight+108})
+        .margin({
+          bottom:this.isShowCoverHeader() ? this.bottomBarHeight+30
+            :  this.bottomBarHeight+this.topRectHeight+this.topBarHeight+this.offHeight
+        })
         .transition(TransitionEffect.move(TransitionEdge.BOTTOM)
           .animation({ duration: 500, curve: Curve.Ease }))
         .scrollBar(BarState.Off)
@@ -5040,20 +5067,22 @@ export struct LocalMusic {
       .onActionStart(e => {
 
       }))
-    // .divider({ strokeWidth: 1, color: this.isDarkMode? '#333333':'#ffe9f0f0' })
-    .margin(
-      this.isHiCar()&&(this.windowWidth>1800&&this.windowHeight>=1200)?{bottom:this.bottomBarHeight+98}:
-      {
-      bottom: this.isCoverOpacity() ? (this.isShowCoverHeader() ? this.topBarHeight+25 : this.topBarHeight+80)
-        : (this.isShowCoverHeader() ? this.topBarHeight+35 : this.isHiCarSmall()?this.topBarHeight+90:this.topBarHeight+165)
-    })
+    // .margin(
+    //   this.isHiCar()&&(this.windowWidth>1800&&this.windowHeight>=1200)?{bottom:this.bottomBarHeight+98}:
+    //   {
+    //   bottom: this.isCoverOpacity() ? (this.isShowCoverHeader() ? this.topBarHeight+25 : this.topBarHeight+80)
+    //     : (this.isShowCoverHeader() ? this.topBarHeight+35 :
+    //       this.isHiCarSmall()||this.modeType==4?this.topBarHeight+90:this.topBarHeight+165)
+    // })
+    .margin({
+          bottom:this.isShowCoverHeader() ? this.bottomBarHeight+30
+            :  this.bottomBarHeight+this.topRectHeight+this.topBarHeight+this.offHeight
+        })
     .cachedCount(6)
     .reuseId('list_item')
     .borderRadius(20)
     .transition(TransitionEffect.asymmetric(TransitionEffect.scale({ x: 0.8, y: 0.8 }).animation({ duration: 500 }),
       TransitionEffect.scale({ x: 0, y: 0 })))
-    // .transition(TransitionEffect.move(TransitionEdge.BOTTOM)
-    //   .animation({ duration: 500, curve: Curve.Ease }))
     .layoutWeight(1)
     .onScrollIndex((start) => {
       this.selectedIndex = start
@@ -7555,9 +7584,11 @@ export struct LocalMusic {
   @State barBottomOpacity: number = 1
   private hideDone: boolean = false;
   @State currentYOffset: number = 0;
-  @State bottomBarHeight: number = 60;
+  @State bottomBarHeight: number = 55;
   private isHiding: boolean = false;
 
+
+
   //是否是Pura X外屏,或者小屏幕
   isPuraWP() {