Ver Fonte

调整一些hicar控制条 hicar状态下控制按钮放左边,歌名放中间 封面右边

onecold há 11 meses atrás
pai
commit
df4c4ae8ed

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

@@ -147,22 +147,15 @@ struct NewIndex {
       const eventData: emitter.EventData = {};
       emitter.emit({ eventId: 888 }, eventData); // 发送音频广播通知更新doSwipBack
     } else {
-      let nowtime = Date.now();
-      if (nowtime - this.backTime < 1000) {
-        const mContext = getContext(this) as common.UIAbilityContext
-        mContext.terminateSelf(); // 关闭应用
-        AvSessionController.getInstance(true).unregisterSessionListener()
+      if (this.isShowDrawer) {
+        // 如果抽屉菜单打开,先关闭抽屉
+        this.getUIContext()?.animateTo({ duration: 555 }, () => {
+          this.isShowDrawer = false
+        })
       } else {
-        if (this.isShowDrawer) {
-          // 如果抽屉菜单打开,先关闭抽屉
-          this.getUIContext()?.animateTo({ duration: 555 }, () => {
-            this.isShowDrawer = false
-          })
-        } else {
-          this.backTime = nowtime;
-          ToastUtil.showToast("再按一次将退出当前应用")
-        }
+        return false
       }
+
     }
     return true;
   }

+ 1 - 1
entry/src/main/ets/pages/SplashIndex.ets

@@ -353,7 +353,7 @@ struct  SplashIndex{
 
 
   junpToMain(){
-    router.pushUrl({
+    router.replace({
       url: 'pages/NewIndex',
       params: {
         videoList: this.videoLocalList

+ 180 - 133
entry/src/main/ets/view/LocalMusic.ets

@@ -394,6 +394,7 @@ export struct LocalMusic {
     })
 
   doSwipBack() {
+    this.isZero = false
     if (this.modeType !== 0 && this.isCanBack) {
       this.onModeChange()
       this.isCanBack = false
@@ -4522,142 +4523,19 @@ export struct LocalMusic {
 
 
       Row() {
-        Row() {
-          RotatingCover({ songLabel: this.currentSong?.pixelMapPath })
+        if(this.isHiCar()){
+          this.playConRigth()
+          Column(){
+            this.centerName()
+          }.layoutWeight(1)
+          this.playConLeft(false)
 
-          Column() {
-            Text(this.currentSong?.name)
-              .fontSize(16)
-              .textOverflow({ overflow: TextOverflow.MARQUEE })//超长滚动
-              .maxLines(1)
-              .fontColor($r('app.color.text_color'))
-              .fontWeight(500)
-            Row() {
-              Text(this.currentSong?.artist)
-                .margin({ top: 2 })
-                .fontSize(13)
-                .maxLines(1)
-                .textOverflow({ overflow: TextOverflow.MARQUEE })//超长滚动
-                .fontColor($r('app.color.text_color'))
-            }
-          }
-          .alignItems(HorizontalAlign.Start)
-          .margin({ right: 22 })
+        }else{
+          this.playConLeft()
+          this.playConRigth()
         }
-        .padding({ right: 18 })
-        .layoutWeight(1)
-        .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
-        .onClick(() => {
-
-          if (ArrayUtil.isNotEmpty(this.songList)) {
-            this.isShowPlay = true;
-            let lyricPath = this.videoUrl.substring(0, this.videoUrl.lastIndexOf('.')) + '.lrc'
-            this.initLyric(lyricPath);
-            this.startAutoHide()
 
 
-          } else {
-            ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
-          }
-        })
-
-        Row() {
-          Image($r('app.media.hm_previous'))
-            .height(28)
-            .width(28)
-            .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
-            .margin({ left: 8, right: 16 })
-            .fillColor(this.themeColor)
-            .displayPriority(2)
-            .onClick(() => {
-              if (ArrayUtil.isNotEmpty(this.songList)) {
-                this.playPrevious()
-              } else {
-                ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
-              }
-
-
-            })
-          //播放进度条
-          Stack() {
-            Progress({
-              value: Math.floor(this.progressValue),
-              type: ProgressType.Ring,
-
-            })
-              .color(this.themeColor)// 进度条前景色为灰色
-              .backgroundColor($r('app.color.index_background'))
-              .height(40)
-              .aspectRatio(CommonConstants.ASPECT_RATIO)
-            Image(this.CONTROL_PlayStatus === PlayStatus.PLAY ? $r('app.media.hm_pause') : $r('app.media.hm_play2'))
-              .height(38)
-              .width(38)
-              .displayPriority(3)
-              .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
-              .fillColor(this.themeColor)
-              .onClick(() => {
-                if (ArrayUtil.isNotEmpty(this.songList)) {
-                  console.info('onecold playOrPause 4642')
-                  this.playOrPause()
-                } else {
-                  ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
-                }
-              })
-          }
-
-
-          Image($r('app.media.hm_next'))
-            .height(28)
-            .width(28)
-            .margin({
-              right: 16,
-              left: 16
-            })
-            .fillColor(this.themeColor)
-            .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
-            .displayPriority(2)
-            .onClick(() => {
-              if (ArrayUtil.isNotEmpty(this.songList)) {
-                this.playNext()
-              } else {
-                ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
-              }
-
-            })
-
-          Image($r('app.media.hm_playlist'))
-            .height(28)
-            .width(28)
-            .displayPriority(1)
-            .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
-            .fillColor(this.themeColor)
-            .bindSheet($$this.isShowSheet, this.PlayListSheet(), {
-              height: '95%',
-              dragBar: true,
-              showClose: true,
-              blurStyle: BlurStyle.Thin,
-              preferType: this.currentBreakpoint !== BreakpointTypeEnum.SM ? SheetType.CENTER : SheetType.BOTTOM,
-              backgroundColor: this.isPlayListBgGrass ? Color.Transparent : $r('app.color.silvery'),
-              title: {
-                title: Utility.resourceToString(this.context, $r('app.string.current_play_list'))
-                  + `(${this.songList.length}首)`
-              }
-            })
-            .onClick(() => {
-              if (ArrayUtil.isNotEmpty(this.songList)) {
-                this.isShowSheet = !this.isShowSheet;
-                this.isFrontWhite = false
-                LogUtil.info('onecold scrollToIndex = ' + this.curIndex)
-
-                this.scrollIndex()
-
-              } else {
-                ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
-              }
-
-
-            })
-        }
       }
       .width('100%')
       .height(this.bottomBarHeight)
@@ -4685,6 +4563,174 @@ export struct LocalMusic {
 
   @State isFrontWhite: boolean = false
 
+  @Builder
+  centerName() {
+    Column() {
+      Text(this.currentSong?.name)
+        .fontSize(16)
+        .textOverflow({ overflow: TextOverflow.MARQUEE }) //超长滚动
+        .maxLines(1)
+        .fontColor($r('app.color.text_color'))
+        .fontWeight(500);
+      Row() {
+        Text(this.currentSong?.artist)
+          .margin({ top: 2 })
+          .fontSize(13)
+          .textAlign(TextAlign.Start)
+          .maxLines(1)
+          .textOverflow({ overflow: TextOverflow.MARQUEE }) //超长滚动
+          .fontColor($r('app.color.text_color'));
+      }
+      .visibility(this.currentSong?.artist? Visibility.Visible:Visibility.None)
+    }
+    .alignItems(HorizontalAlign.Center)
+  }
+  @Builder
+  playConLeft(isLeft: boolean = true) {
+    Row() {
+      RotatingCover({ songLabel: this.currentSong?.pixelMapPath });
+
+      Column() {
+        Text(this.currentSong?.name)
+          .fontSize(16)
+          .textOverflow({ overflow: TextOverflow.MARQUEE }) //超长滚动
+          .maxLines(1)
+          .fontColor($r('app.color.text_color'))
+          .fontWeight(500);
+        Row() {
+          Text(this.currentSong?.artist)
+            .margin({ top: 2 })
+            .fontSize(13)
+            .textAlign(TextAlign.Start)
+            .maxLines(1)
+            .textOverflow({ overflow: TextOverflow.MARQUEE }) //超长滚动
+            .fontColor($r('app.color.text_color'));
+        }
+        .visibility(this.currentSong?.artist? Visibility.Visible:Visibility.None)
+      }
+      .alignItems(isLeft?HorizontalAlign.Start:HorizontalAlign.End)
+      .margin({ right: isLeft?22:10 })
+      .visibility(isLeft? Visibility.Visible:Visibility.None)
+    }
+    .padding({ right: 18 })
+    .layoutWeight(isLeft?1:0)
+    .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
+    .onClick(() => {
+
+      if (ArrayUtil.isNotEmpty(this.songList)) {
+        this.isShowPlay = true;
+        let lyricPath = this.videoUrl.substring(0, this.videoUrl.lastIndexOf('.')) + '.lrc';
+        this.initLyric(lyricPath);
+        this.startAutoHide();
+
+
+      } else {
+        ToastUtil.showToast('当前播放列表为空,请先导入音乐。');
+      }
+    })
+  }
+
+  @Builder
+  playConRigth() {
+    Row() {
+      Image($r('app.media.hm_previous'))
+        .height(28)
+        .width(28)
+        .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
+        .margin({ left: 8, right: 16 })
+        .fillColor(this.themeColor)
+        .displayPriority(2)
+        .onClick(() => {
+          if (ArrayUtil.isNotEmpty(this.songList)) {
+            this.playPrevious()
+          } else {
+            ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
+          }
+
+
+        })
+      //播放进度条
+      Stack() {
+        Progress({
+          value: Math.floor(this.progressValue),
+          type: ProgressType.Ring,
+
+        })
+          .color(this.themeColor)// 进度条前景色为灰色
+          .backgroundColor($r('app.color.index_background'))
+          .height(40)
+          .aspectRatio(CommonConstants.ASPECT_RATIO)
+        Image(this.CONTROL_PlayStatus === PlayStatus.PLAY ? $r('app.media.hm_pause') : $r('app.media.hm_play2'))
+          .height(38)
+          .width(38)
+          .displayPriority(3)
+          .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
+          .fillColor(this.themeColor)
+          .onClick(() => {
+            if (ArrayUtil.isNotEmpty(this.songList)) {
+              console.info('onecold playOrPause 4642')
+              this.playOrPause()
+            } else {
+              ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
+            }
+          })
+      }
+
+
+      Image($r('app.media.hm_next'))
+        .height(28)
+        .width(28)
+        .margin({
+          right: 16,
+          left: 16
+        })
+        .fillColor(this.themeColor)
+        .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
+        .displayPriority(2)
+        .onClick(() => {
+          if (ArrayUtil.isNotEmpty(this.songList)) {
+            this.playNext()
+          } else {
+            ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
+          }
+
+        })
+
+      Image($r('app.media.hm_playlist'))
+        .height(28)
+        .width(28)
+        .displayPriority(1)
+        .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
+        .fillColor(this.themeColor)
+        .bindSheet($$this.isShowSheet, this.PlayListSheet(), {
+          height: '95%',
+          dragBar: true,
+          showClose: true,
+          blurStyle: BlurStyle.Thin,
+          preferType: this.currentBreakpoint !== BreakpointTypeEnum.SM ? SheetType.CENTER : SheetType.BOTTOM,
+          backgroundColor: this.isPlayListBgGrass ? Color.Transparent : $r('app.color.silvery'),
+          title: {
+            title: Utility.resourceToString(this.context, $r('app.string.current_play_list'))
+              + `(${this.songList.length}首)`
+          }
+        })
+        .onClick(() => {
+          if (ArrayUtil.isNotEmpty(this.songList)) {
+            this.isShowSheet = !this.isShowSheet;
+            this.isFrontWhite = false
+            LogUtil.info('onecold scrollToIndex = ' + this.curIndex)
+
+            this.scrollIndex()
+
+          } else {
+            ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
+          }
+
+
+        })
+    }
+  }
+
   scrollIndex(){
     if(this.curIndex>500)//条数太大的时候 滚动非常卡 导致闪退,先改为不滚
      return
@@ -8073,7 +8119,8 @@ export struct LocalMusic {
             this.musicNameInfo(false)
           } else {
             Image(StrUtil.isEmpty(this.cover) ? this.imageLabel : this.cover)
-              .height(this.isHiCarSmall()?(this.isHiCarKuanBianPing()?140:px2vp(this.windowHeight)*0.38):(this.isCoverOpacity() ? 250 : this.isCoverRectangle ? 320 : 162))
+              .height(this.isHiCarSmall()?(this.isHiCarKuanBianPing()?140:px2vp(this.windowHeight)*0.38):
+                (this.isCoverOpacity() ? (px2vp(this.windowHeight)*0.62) : this.isCoverRectangle ? 320 : 162))
               .objectFit(this.isCoverRectangle ? ImageFit.Contain : ImageFit.Auto)
               .alt(this.imageLabel)
               .margin({ right: 20, left: 20 })