Pārlūkot izejas kodu

优化hicar布局

onecold 8 mēneši atpakaļ
vecāks
revīzija
7bb6366eeb

+ 36 - 33
entry/src/main/ets/pages/NewIndex.ets

@@ -326,7 +326,7 @@ struct NewIndex {
     });
 
     this.logHiCar('info', `getHiCarStatus isHiCarStatus=${this.isHiCarStatus}`)
-    if(this.isHiCarStatus||this.isBigScreen()){
+    if(this.curDisplayIsHiCar||this.isBigScreen()){
       this.getUIContext()?.animateTo({ duration: 555 }, () => {
         this.isShowDrawer = true
         this.offsetX = 0
@@ -554,22 +554,19 @@ struct NewIndex {
   @Builder
   PlayController() {
     Row() {
-      if(this.isHiCar()){
+      this.playConLeft(!this.curDisplayIsHiCar)
+      if(!this.curDisplayIsHiCar){
         this.playConRigth()
+      }
+      if(this.curDisplayIsHiCar){
         Column(){
           this.centerName()
-        }.layoutWeight(1)
+        }
+        .layoutWeight(1)
         .onClick(()=>{
           this.setShowPlayTrue()
         })
-        this.playConLeft(false)
-
-      }else{
-        this.playConLeft()
-        this.playConRigth()
       }
-
-
     }
     .width('100%')
     .height(this.bottomBarHeight)
@@ -599,32 +596,38 @@ struct NewIndex {
           color: 'on_primary'
         })
         .geometryTransition('cover', { follow: true }) // 绑定标识符
-      Column() {
-        Text(this.currentSong?.name)
-          .fontSize(16)
-          .textOverflow({ overflow: TextOverflow.MARQUEE }) //超长滚动
-          .maxLines(1)
-          .fontColor(Color.White)
-          .fontWeight(FontWeight.Bolder);
-        Row() {
-          Text(this.currentSong?.artist)
-            .margin({ top: 2 })
-            .fontSize(13)
-            .textAlign(TextAlign.Start)
-            .maxLines(1)
-            .fontWeight(FontWeight.Bold)
+      if(!this.curDisplayIsHiCar){
+        Column() {
+          Text(this.currentSong?.name)
+            .fontSize(16)
             .textOverflow({ overflow: TextOverflow.MARQUEE }) //超长滚动
+            .maxLines(1)
             .fontColor(Color.White)
+            .fontWeight(FontWeight.Bolder);
+          Row() {
+            Text(this.currentSong?.artist)
+              .margin({ top: 2 })
+              .fontSize(13)
+              .textAlign(TextAlign.Start)
+              .maxLines(1)
+              .fontWeight(FontWeight.Bold)
+              .textOverflow({ overflow: TextOverflow.MARQUEE }) //超长滚动
+              .fontColor(Color.White)
+          }
+          .visibility(this.currentSong?.artist? Visibility.Visible:Visibility.None)
         }
-        .visibility(this.currentSong?.artist? Visibility.Visible:Visibility.None)
+        .padding({left:8})
+        .alignItems(isLeft?HorizontalAlign.Start:HorizontalAlign.End)
+        .margin({ right: isLeft?22:10 })
+      }else{
+        this.playConRigth()
       }
-      .padding({left:8})
-      .alignItems(isLeft?HorizontalAlign.Start:HorizontalAlign.End)
-      .margin({ right: isLeft?22:10 })
-      .visibility(isLeft? Visibility.Visible:Visibility.None)
+
     }
     .padding({ right: 18 })
-    .layoutWeight(isLeft?1:0)
+    .layoutWeight(1)
+    .alignItems(VerticalAlign.Center)
+    .justifyContent(FlexAlign.Start)
     .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.8 })
     .onClick(() => {
       this.setShowPlayTrue()
@@ -693,6 +696,8 @@ struct NewIndex {
           this.getUIContext().getHostContext()!.eventHub.emit('openPlayList');
         })
     }
+    .margin({left:this.curDisplayIsHiCar?20:5})
+    .justifyContent(this.curDisplayIsHiCar?FlexAlign.Start:FlexAlign.End)
   }
 
 
@@ -700,9 +705,7 @@ struct NewIndex {
   //是不是hicar的屏幕分辨率
   isHiCar() {
 
-    return this.isHiCarStatus&&this.curDisplayIsHiCar;
-
-    return false;
+    return this.curDisplayIsHiCar;
   }
 
   //是不是正常的手机竖屏

+ 50 - 37
entry/src/main/ets/view/LocalMusic.ets

@@ -10435,8 +10435,11 @@ export struct LocalMusic {
       this.TopPlayProgressView()
       //播放 暂停,下一首,上一首
       this.playCenterView()
-      //播放进度条
-      this.BottomView()
+      if(!this.curDisplayIsHiCar){
+        //播放进度条
+        this.BottomView()
+      }
+
     }
     .position({ bottom: this.isHiCarSmall()?50:(this.isCoverOpacity() ? 55 : 70) }) // 将  固定在底部
 
@@ -10512,7 +10515,13 @@ export struct LocalMusic {
         await this.playNext();
       })
 
-      this.fullButton()
+
+      if(this.curDisplayIsHiCar){
+        this.playModeButton()
+      }else{
+        this.fullButton()
+      }
+
 
     }
     .width('95%')
@@ -10614,44 +10623,48 @@ export struct LocalMusic {
 
   }
 
-
+  @Builder
+  playModeButton(){
+    Button({type:ButtonType.Circle,stateEffect:true}){
+      Column() {
+        if (this.playType === 0) {
+          Image($r('app.media.loop'))
+            .width(27)
+            .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
+            .aspectRatio(CommonConstants.ASPECT_RATIO)
+        } else if (this.playType === 1) {
+          Image($r('app.media.single'))
+            .width(27)
+            .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
+            .aspectRatio(CommonConstants.ASPECT_RATIO)
+        } else if (this.playType === 2) {
+          Image($r('app.media.normal_play'))
+            .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
+            .width(27)
+            .aspectRatio(CommonConstants.ASPECT_RATIO)
+        } else if (this.playType === 3) {
+          Image($r('app.media.random'))
+            .width(27)
+            .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
+            .aspectRatio(CommonConstants.ASPECT_RATIO)
+        }
+      }
+    }
+    .layoutWeight(1)
+    .margin({ left: 5 })
+    .height(45)
+    .width(45)
+    .backgroundColor(Color.Transparent)
+    .onClick(async () => {
+      this.setLoopMode()
+    })
+  }
   //播放进度条
   @Builder
   BottomView(){
     Row() {
-      Button({type:ButtonType.Circle,stateEffect:true}){
-        Column() {
-          if (this.playType === 0) {
-            Image($r('app.media.loop'))
-              .width(27)
-              .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
-              .aspectRatio(CommonConstants.ASPECT_RATIO)
-          } else if (this.playType === 1) {
-            Image($r('app.media.single'))
-              .width(27)
-              .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
-              .aspectRatio(CommonConstants.ASPECT_RATIO)
-          } else if (this.playType === 2) {
-            Image($r('app.media.normal_play'))
-              .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
-              .width(27)
-              .aspectRatio(CommonConstants.ASPECT_RATIO)
-          } else if (this.playType === 3) {
-            Image($r('app.media.random'))
-              .width(27)
-              .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
-              .aspectRatio(CommonConstants.ASPECT_RATIO)
-          }
-        }
-      }
-      .layoutWeight(1)
-      .margin({ left: 5 })
-      .height(45)
-      .width(45)
-      .backgroundColor(Color.Transparent)
-      .onClick(async () => {
-        this.setLoopMode()
-      })
+
+      this.playModeButton()
 
       if(this.currentSong){
         Button({type:ButtonType.Circle,stateEffect:true}){