Ver código fonte

修复hicar模式下 左滑的抽屉菜单不好拉下来

onecold 1 ano atrás
pai
commit
bf3fb0ab49
1 arquivos alterados com 150 adições e 145 exclusões
  1. 150 145
      entry/src/main/ets/pages/NewIndex.ets

+ 150 - 145
entry/src/main/ets/pages/NewIndex.ets

@@ -1,6 +1,6 @@
 import { AppUtil, DeviceUtil, DisplayUtil, LogUtil, PreferencesUtil, ToastUtil } from '@pura/harmony-utils';
 import TitleBar from '../view/TitleBar';
-import { router } from '@kit.ArkUI';
+import { curves, router } from '@kit.ArkUI';
 import mainViewModel, { MainViewModel } from '../viewmodel/MainViewModel';
 import ItemData from '../viewmodel/ItemData';
 import type { sysResource } from '../viewmodel/ItemData';
@@ -282,7 +282,7 @@ struct NewIndex {
       Column() {
         this.getLeftView()
       }
-
+      .backgroundColor(Color.Transparent)
       Column() {
         Stack() {
           // 本地音乐内容区
@@ -303,7 +303,10 @@ struct NewIndex {
             Column()
               .width('100%')
               .height('100%')
-              .backgroundColor(Color.Transparent)
+              .backgroundBlurStyle(BlurStyle.BACKGROUND_THIN)
+              .transition(TransitionEffect.OPACITY.animation({
+                curve: curves.springMotion(0, 1)
+              }))
               .onClick(() => {
                 // 点击遮罩层关闭抽屉
                 this.getUIContext()?.animateTo({ duration: 555 }, () => {
@@ -395,8 +398,6 @@ struct NewIndex {
     Column() {
       Column() {
 
-        this.buildUserInfoCard()
-
         this.getDrawerView()
       }
       .width('100%')
@@ -566,152 +567,156 @@ struct NewIndex {
    */
   @Builder
   getDrawerView() {
+
     List({ space: 0, scroller: this.scroller }) {
-      ForEach(this.isHiCar()||!this.isShowTitleBar?mainViewModel.getDrawerData():mainViewModel.getDrawerData2(), (item: ItemData, index: number) => {
-        ListItem() {
-          Button({ type: ButtonType.Capsule, stateEffect: true }) {
-            Row() {
-              // 菜单图标
-              if (typeof item.img === 'object' && item.img !== null && (item.img as sysResource).type === 'symbol') {
-                SymbolGlyph((item.img as sysResource).value as Resource)// .size({ width: 22, height: 22 })
-                  .fontSize(22)
-                  .fontColor([this.themeColor])
-                  .alignSelf(ItemAlign.Center)
-                  .margin({ left: 25 })
-              } else {
-                Image(item.img as Resource)
+      ListItemGroup({ header: this.buildUserInfoCard() }) {
+        ForEach(this.isHiCar()||!this.isShowTitleBar?mainViewModel.getDrawerData():mainViewModel.getDrawerData2(), (item: ItemData, index: number) => {
+          ListItem() {
+            Button({ type: ButtonType.Capsule, stateEffect: true }) {
+              Row() {
+                // 菜单图标
+                if (typeof item.img === 'object' && item.img !== null && (item.img as sysResource).type === 'symbol') {
+                  SymbolGlyph((item.img as sysResource).value as Resource)// .size({ width: 22, height: 22 })
+                    .fontSize(22)
+                    .fontColor([this.themeColor])
+                    .alignSelf(ItemAlign.Center)
+                    .margin({ left: 25 })
+                } else {
+                  Image(item.img as Resource)
+                    .height(22)
+                    .alignSelf(ItemAlign.Center)
+                    .fillColor(this.themeColor)
+                    .margin({ left: 25 })
+                }
+
+                // 菜单标题
+                Text(item.title)
+                  .margin({ left: 10, right: 20 })
+                  .fontSize(15)
+                  .fontColor(this.isTextSelected(index) ? this.themeColor : $r('app.color.index_tab_font_color'))
+                  .fontWeight(480)
+                Blank()
+                // 右侧箭头
+                Image($r('app.media.arrow_right'))
+                  .width(22)
                   .height(22)
-                  .alignSelf(ItemAlign.Center)
-                  .fillColor(this.themeColor)
-                  .margin({ left: 25 })
+                  .margin({ left: 20, right: 0 })
+                  .align(Alignment.Center)
               }
-
-              // 菜单标题
-              Text(item.title)
-                .margin({ left: 10, right: 20 })
-                .fontSize(15)
-                .fontColor(this.isTextSelected(index) ? this.themeColor : $r('app.color.index_tab_font_color'))
-                .fontWeight(480)
-              Blank()
-              // 右侧箭头
-              Image($r('app.media.arrow_right'))
-                .width(22)
-                .height(22)
-                .margin({ left: 20, right: 0 })
-                .align(Alignment.Center)
+              .width('100%')
+              .height(55)
             }
-            .width('100%')
-            .height(55)
-          }
-          .backgroundColor(Color.Transparent)
-          .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
-          .onClick(async () => {
-            // 根据 item.id 跳转或切换功能
-            switch (item.id) {
-              case MainViewModel.MENU_MUSIC:
-                this.mType = 0
-                this.modeType = 0
-                this.doShowDrawer()
-                break
-              case MainViewModel.MENU_FILE_SCAN:
-                this.mType = 2
-                this.doShowDrawer()
-                break
-            // case MainViewModel.MENU_HOME:
-            //   this.mType = 0
-            //   this.modeType = 0
-            //   this.getUIContext()?.animateTo({ duration: 555 }, () => {
-            //     this.isShowDrawer = false
-            //   })
-            //   break
-              case MainViewModel.MENU_MIEDIA_KU:
-                this.modeType = 1
-                this.mType = 0
-                this.doShowDrawer()
-                break
-              case MainViewModel.MENU_MIEDIA_ARTIST:
-                this.modeType = 2
-                this.mType = 0
-                this.doShowDrawer()
-                break
-              case MainViewModel.MENU_MIEDIA_ALBUM:
-                this.modeType = 3
-                this.mType = 0
-                this.doShowDrawer()
-                break
-              case MainViewModel.MENU_SETTING:
-                this.mType = 3
-                this.doShowDrawer()
-
-                break
-              case MainViewModel.MENU_VIP:
-                router.pushUrl({
-                  url: 'pages/VipPage'
-                }, router.RouterMode.Single);
-                break
-              case MainViewModel.MENU_USER:
-                this.mType = 1
-                this.doShowDrawer()
-                break
-              case MainViewModel.MENU_NET_CONNECT:
-                this.mType = 1
-                this.doShowDrawer()
-                break
-              case MainViewModel.MENU_SIMI:
-                router.pushUrl({
-                  url: 'pages/VerifyPage'
-                });
-                break
-
-              case MainViewModel.MENU_DUTY:
-                router.pushUrl({
-                  url: 'pages/WebIndex',
-                  params: { titleName: '用户协议', webUrl: CommonConstants.NEW_DUTY }
-                });
-                break
-              case MainViewModel.MENU_HAOPING:
-                Utility.gotoMarket(getContext(this) as common.UIAbilityContext, this.bundleName)
-                break
-
-              case MainViewModel.MENU_ABOUT:
-                this.mType = 4
-                this.doShowDrawer()
-                break
-              case MainViewModel.MENU_UPDATE:
-                AlertDialog.show({
-                  title: '版本更新',
-                  message: '当前版本为最新版本:' + this.versionName,
-                  autoCancel: true,
-                  alignment: DialogAlignment.Center,
-                  offset: { dx: 0, dy: -20 }, //在Y轴方向上的编译量
-                  confirm: {
-                    value: '确定',
-                    fontColor: Color.White,
-                    backgroundColor: $r('app.color.title_bar_bg'),
-                    action: () => {
+            .backgroundColor(Color.Transparent)
+            .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
+            .onClick(async () => {
+              // 根据 item.id 跳转或切换功能
+              switch (item.id) {
+                case MainViewModel.MENU_MUSIC:
+                  this.mType = 0
+                  this.modeType = 0
+                  this.doShowDrawer()
+                  break
+                case MainViewModel.MENU_FILE_SCAN:
+                  this.mType = 2
+                  this.doShowDrawer()
+                  break
+                // case MainViewModel.MENU_HOME:
+                //   this.mType = 0
+                //   this.modeType = 0
+                //   this.getUIContext()?.animateTo({ duration: 555 }, () => {
+                //     this.isShowDrawer = false
+                //   })
+                //   break
+                case MainViewModel.MENU_MIEDIA_KU:
+                  this.modeType = 1
+                  this.mType = 0
+                  this.doShowDrawer()
+                  break
+                case MainViewModel.MENU_MIEDIA_ARTIST:
+                  this.modeType = 2
+                  this.mType = 0
+                  this.doShowDrawer()
+                  break
+                case MainViewModel.MENU_MIEDIA_ALBUM:
+                  this.modeType = 3
+                  this.mType = 0
+                  this.doShowDrawer()
+                  break
+                case MainViewModel.MENU_SETTING:
+                  this.mType = 3
+                  this.doShowDrawer()
+
+                  break
+                case MainViewModel.MENU_VIP:
+                  router.pushUrl({
+                    url: 'pages/VipPage'
+                  }, router.RouterMode.Single);
+                  break
+                case MainViewModel.MENU_USER:
+                  this.mType = 1
+                  this.doShowDrawer()
+                  break
+                case MainViewModel.MENU_NET_CONNECT:
+                  this.mType = 1
+                  this.doShowDrawer()
+                  break
+                case MainViewModel.MENU_SIMI:
+                  router.pushUrl({
+                    url: 'pages/VerifyPage'
+                  });
+                  break
+
+                case MainViewModel.MENU_DUTY:
+                  router.pushUrl({
+                    url: 'pages/WebIndex',
+                    params: { titleName: '用户协议', webUrl: CommonConstants.NEW_DUTY }
+                  });
+                  break
+                case MainViewModel.MENU_HAOPING:
+                  Utility.gotoMarket(getContext(this) as common.UIAbilityContext, this.bundleName)
+                  break
+
+                case MainViewModel.MENU_ABOUT:
+                  this.mType = 4
+                  this.doShowDrawer()
+                  break
+                case MainViewModel.MENU_UPDATE:
+                  AlertDialog.show({
+                    title: '版本更新',
+                    message: '当前版本为最新版本:' + this.versionName,
+                    autoCancel: true,
+                    alignment: DialogAlignment.Center,
+                    offset: { dx: 0, dy: -20 }, //在Y轴方向上的编译量
+                    confirm: {
+                      value: '确定',
+                      fontColor: Color.White,
+                      backgroundColor: $r('app.color.title_bar_bg'),
+                      action: () => {
+                      }
                     }
-                  }
-                })
-                break
-              case MainViewModel.MENU_YSZC:
-                router.pushUrl({
-                  url: 'pages/WebIndex',
-                  params: { titleName: '隐私政策', webUrl: CommonConstants.NEW_YS_HW }
-                });
-                break
-
-              case MainViewModel.MENU_SHARE:
-                this.gotoShare()
-                break
-            }
-          })
-        }
-        .transition(TransitionEffect.move(TransitionEdge.BOTTOM)
-          .animation({ duration: 600, curve: Curve.Ease, delay: 60 * index }))
-        .width('90%')
-        .height(55)
+                  })
+                  break
+                case MainViewModel.MENU_YSZC:
+                  router.pushUrl({
+                    url: 'pages/WebIndex',
+                    params: { titleName: '隐私政策', webUrl: CommonConstants.NEW_YS_HW }
+                  });
+                  break
+
+                case MainViewModel.MENU_SHARE:
+                  this.gotoShare()
+                  break
+              }
+            })
+          }
+          .transition(TransitionEffect.move(TransitionEdge.BOTTOM)
+            .animation({ duration: 600, curve: Curve.Ease, delay: 60 * index }))
+          .width('90%')
+          .height(55)
+
+        })
+      }
 
-      })
     }
     .width('86%')
     .borderRadius(20)