Bläddra i källkod

添加沉浸式开关

onecold 7 månader sedan
förälder
incheckning
8aaf8e91c9
1 ändrade filer med 28 tillägg och 41 borttagningar
  1. 28 41
      entry/src/main/ets/view/LocalMusic.ets

+ 28 - 41
entry/src/main/ets/view/LocalMusic.ets

@@ -299,6 +299,7 @@ const ITEM_HEIGHT_BIG: number = 78; // 列表项大高度
 @Preview
 @Component
 export struct LocalMusic {
+  @State showSimple: boolean = true//开启沉浸模式
   @State isPaging: boolean = true;//是否分页加载机制
   @State isCoverRectangle: boolean = true;
   @State showZMIndex: boolean = false //是否右侧显示字母索引
@@ -1070,6 +1071,7 @@ export struct LocalMusic {
     context.getApplicationContext().setColorMode(colorMode)
   }
   initSetting() {
+    this.showSimple = PreferencesUtil.getBooleanSync('showSimple', true)
     this.showZMIndex = PreferencesUtil.getBooleanSync('showZMIndex', false)
     this.autoHideTitle = PreferencesUtil.getBooleanSync('autoHideTitle', true)
     this.isShowPrecious = PreferencesUtil.getBooleanSync('isShowPrecious', false)
@@ -6431,7 +6433,7 @@ export struct LocalMusic {
       this.hideAlphabetIndexAfterDelay(1500)
     })
     .onReachEnd(() => {
-      if(this.modeType === 4 )
+      if(this.modeType === 4 )//歌单不能加载下一页
         return;
       // 触底加载下一页
       Logger.info('heanup LocalMusic', `onReachEnd: hasMore=${this.hasMoreData}, isLoading=${this.isLoadingPage}`);
@@ -10622,11 +10624,9 @@ export struct LocalMusic {
       })
 
 
-      if(this.curDisplayIsHiCar){
-        this.playModeButton()
-      }else{
-        this.fullButton()
-      }
+
+      this.playModeButton()
+
 
 
     }
@@ -10780,7 +10780,7 @@ export struct LocalMusic {
   BottomView(){
     Row() {
 
-      this.playModeButton()
+      this.fullButton()
 
       if(this.currentSong){
         Button({type:ButtonType.Circle,stateEffect:true}){
@@ -10870,6 +10870,7 @@ export struct LocalMusic {
     }
     .width(this.isLandscape?'88%':'95%')
     .justifyContent(FlexAlign.SpaceAround)
+    .visibility(this.showSimple?Visibility.None:Visibility.Visible)
     .height(30)
     .animation({
       duration: 666,
@@ -10905,40 +10906,8 @@ export struct LocalMusic {
   @Builder
   playProgressView() {
     Row() {
-      Button({ type: ButtonType.Circle, stateEffect: true }) {
-        Column() {
-          if (this.playType === 0) {
-            Image($r('app.media.loop'))
-              .width($r('app.float.control_image_width'))
-              .aspectRatio(CommonConstants.ASPECT_RATIO)
-          } else if (this.playType === 1) {
-            Image($r('app.media.single'))
-              .width($r('app.float.control_image_width'))
-              .aspectRatio(CommonConstants.ASPECT_RATIO)
-          } else if (this.playType === 2) {
-            Image($r('app.media.normal_play'))
-              .width($r('app.float.control_image_width'))
-              .aspectRatio(CommonConstants.ASPECT_RATIO)
-          } else if (this.playType === 3) {
-            Image($r('app.media.random'))
-              .width($r('app.float.control_image_width'))
-              .aspectRatio(CommonConstants.ASPECT_RATIO)
-          }
-        }
-      }
-      .visibility(this.is_auto_hide_progress ? Visibility.None : Visibility.Visible)
-      .animation({
-        duration: 666,
-        curve: 'ease-in-out' // 可选动画曲线
-      })
-      .backgroundColor(Color.Transparent)
-      .margin({  right: 10 })
-      .clickEffect({ level: ClickEffectLevel.LIGHT, scale: 0.5 })
-      .onClick(async () => {
-        this.setLoopMode()
-
-      })
 
+      this.fullButton()
 
       Text(this.currentTime)
         .fontSize($r('app.float.slider_font_size'))
@@ -12613,6 +12582,22 @@ export struct LocalMusic {
                   .width(48)
                   .height(24);
 
+                Toggle({ type: ToggleType.Switch, isOn: this.showSimple })
+                  .selectedColor(this.themeColor)
+                  .switchPointColor(Color.White)
+                  .clickEffect({ level: ClickEffectLevel.LIGHT, scale: 0.5 })
+                  .margin({ right: 15 })
+                  .visibility(more.id == 22 ? Visibility.Visible : Visibility.None)
+                  .onChange((checked: boolean) => { // 选择开关状态变化时触发事件
+                    if (more.id == 22) {
+                      this.showSimple = checked;
+                      PreferencesUtil.put('showSimple', this.showSimple)
+                    }
+
+                  })
+                  .width(48)
+                  .height(24);
+
                 Toggle({ type: ToggleType.Switch, isOn: this.isShowBgLiuGUANG })
                   .selectedColor(this.themeColor)
                   .switchPointColor(Color.White)
@@ -12706,7 +12691,9 @@ export struct LocalMusic {
 
     { id: 13, image: $r('app.media.rectangle'), title: '封面方形' },
 
-    { id : 21, image: $r('app.media.kp_music'), title: '开启背景流光' },
+    {id : 22, image: $r('app.media.skip'), title: '沉浸式' },
+
+    { id : 21, image: $r('app.media.kp_music'), title: '背景双边流光' },
 
     { id: 8, image: $r('app.media.cut_current'), title: '保存播放模式' },