Forráskód Böngészése

分类导航开关如果不显示,左边抽屉就显示分类导航的菜单的完善

onecold 1 éve
szülő
commit
53d467e731

+ 42 - 65
entry/src/main/ets/pages/NewIndex.ets

@@ -168,6 +168,14 @@ struct NewIndex {
     this.hasActiveSubscription = PreferencesUtil.getBooleanSync('hasActiveSubscription', false);
   }
 
+  onPageShow() {
+
+    if(this.isHiCar()||this.isBigScreen()){
+      this.isShowDrawer = true
+      this.isShowTitleBar = false
+    }
+
+  }
   /**
    * 页面显示生命周期钩子
    * - 注册断点系统
@@ -179,9 +187,7 @@ struct NewIndex {
 
   async aboutToAppear() {
     this.isShowTitleBar = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_TITLTBAR, true)
-    if(this.isHiCar()){
-      this.isShowTitleBar = false
-    }
+
     Utility.enableFullScreen()
     this.topRectHeight = px2vp(AppUtil.getStatusBarHeight());
     Utility.getAppName(getContext(this)).then((appName: string) => {
@@ -540,7 +546,7 @@ struct NewIndex {
               Text(item.title)
                 .margin({ left: 10, right: 20 })
                 .fontSize(15)
-                .fontColor(this.mType == index ? this.themeColor : $r('app.color.index_tab_font_color'))
+                .fontColor(this.isTextSelected(index) ? this.themeColor : $r('app.color.index_tab_font_color'))
                 .fontWeight(480)
               Blank()
               // 右侧箭头
@@ -561,19 +567,11 @@ struct NewIndex {
               case MainViewModel.MENU_MUSIC:
                 this.mType = 0
                 this.modeType = 0
-                if (!this.isBigScreen()) {
-                  this.getUIContext()?.animateTo({ duration: 555 }, () => {
-                    this.isShowDrawer = false
-                  })
-                }
+                this.doShowDrawer()
                 break
               case MainViewModel.MENU_FILE_SCAN:
                 this.mType = 2
-                if (!this.isBigScreen()) {
-                  this.getUIContext()?.animateTo({ duration: 555 }, () => {
-                    this.isShowDrawer = false
-                  })
-                }
+                this.doShowDrawer()
                 break
             // case MainViewModel.MENU_HOME:
             //   this.mType = 0
@@ -585,34 +583,22 @@ struct NewIndex {
               case MainViewModel.MENU_MIEDIA_KU:
                 this.modeType = 1
                 this.mType = 0
-                this.getUIContext()?.animateTo({ duration: 555 }, () => {
-                  this.isShowDrawer = false
-                })
+                this.doShowDrawer()
                 break
               case MainViewModel.MENU_MIEDIA_ARTIST:
                 this.modeType = 2
                 this.mType = 0
-                this.getUIContext()?.animateTo({ duration: 555 }, () => {
-                  this.isShowDrawer = false
-                })
+                this.doShowDrawer()
                 break
               case MainViewModel.MENU_MIEDIA_ALBUM:
                 this.modeType = 3
                 this.mType = 0
-                this.getUIContext()?.animateTo({ duration: 555 }, () => {
-                  this.isShowDrawer = false
-                })
+                this.doShowDrawer()
                 break
               case MainViewModel.MENU_SETTING:
                 this.mType = 3
-                if (!this.isBigScreen()) {
-                  this.getUIContext()?.animateTo({ duration: 555 }, () => {
-                    this.isShowDrawer = false
-                  })
-                }
-                // router.pushUrl({
-                //   url: 'pages/SettingPage'
-                // }, router.RouterMode.Single);
+                this.doShowDrawer()
+
                 break
               case MainViewModel.MENU_VIP:
                 router.pushUrl({
@@ -621,31 +607,18 @@ struct NewIndex {
                 break
               case MainViewModel.MENU_USER:
                 this.mType = 1
-                if (!this.isBigScreen()) {
-                  this.getUIContext()?.animateTo({ duration: 555 }, () => {
-                    this.isShowDrawer = false
-                  })
-                }
-                // router.pushUrl({
-                //   url: 'pages/UserCenter'
-                // }, router.RouterMode.Single);
+                this.doShowDrawer()
                 break
               case MainViewModel.MENU_NET_CONNECT:
                 this.mType = 1
-                this.getUIContext()?.animateTo({ duration: 555 }, () => {
-                  this.isShowDrawer = false
-                })
+                this.doShowDrawer()
                 break
               case MainViewModel.MENU_SIMI:
                 router.pushUrl({
                   url: 'pages/VerifyPage'
                 });
                 break
-              case MainViewModel.MENU_LIKE:
-                router.pushUrl({
-                  url: 'pages/LikeVideoPage'
-                });
-                break
+
               case MainViewModel.MENU_DUTY:
                 router.pushUrl({
                   url: 'pages/WebIndex',
@@ -655,26 +628,10 @@ struct NewIndex {
               case MainViewModel.MENU_HAOPING:
                 Utility.gotoMarket(getContext(this) as common.UIAbilityContext, this.bundleName)
                 break
-              case MainViewModel.MENU_TEST_SPEED:
-                router.pushUrl({
-                  url: 'pages/SpeedIndex'
-                });
-                break
-              case MainViewModel.MENU_OPTIMIZE:
-                router.pushUrl({
-                  url: 'pages/AddSpeedPage'
-                });
-                break
+
               case MainViewModel.MENU_ABOUT:
                 this.mType = 4
-                if (!this.isBigScreen()) {
-                  this.getUIContext()?.animateTo({ duration: 555 }, () => {
-                    this.isShowDrawer = false
-                  })
-                }
-                // router.pushUrl({
-                //   url: 'pages/AboutPage'
-                // }, router.RouterMode.Single);
+                this.doShowDrawer()
                 break
               case MainViewModel.MENU_UPDATE:
                 AlertDialog.show({
@@ -726,6 +683,26 @@ struct NewIndex {
     .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
   }
 
+  isTextSelected(index:number):boolean{
+    if(this.isShowTitleBar&&!this.isHiCar()){
+        return this.mType ==index
+    }else{
+      if(this.mType == 0){
+        return this.modeType == index
+      }
+      return this.mType+3 == index
+    }
+    return false
+  }
+
+  doShowDrawer(){
+    if (!this.isBigScreen()) {
+      this.getUIContext()?.animateTo({ duration: 555 }, () => {
+        this.isShowDrawer = false
+      })
+    }
+  }
+
   gotoShare() {
     let shareData: systemShare.SharedData = new systemShare.SharedData({
       utd: uniformTypeDescriptor.UniformDataType.TEXT,

+ 3 - 3
entry/src/main/ets/viewmodel/MainViewModel.ets

@@ -51,13 +51,13 @@ export  class  MainViewModel{
       new ItemData($r('app.string.media_ku'), $r('app.media.hm_playlist'),MainViewModel.MENU_MIEDIA_KU,false),
       new ItemData($r('app.string.artist'), $r('app.media.kp_music'),MainViewModel.MENU_MIEDIA_ARTIST,false),
       new ItemData($r('app.string.album'), $r('app.media.llq'),MainViewModel.MENU_MIEDIA_ALBUM,false),
-
+      new ItemData($r('app.string.user_center'), { type: 'symbol', value: $r('sys.symbol.person') }, MainViewModel.MENU_USER, false),
       new ItemData($r('app.string.file_scan'), { type: 'symbol', value: $r('sys.symbol.doc_text_badge_magnifyingglass') },MainViewModel.MENU_FILE_SCAN,false),
+      new ItemData($r('app.string.setting'),  { type: 'symbol', value: $r('sys.symbol.gearshape') },MainViewModel.MENU_SETTING,false),
+      new ItemData($r('app.string.about_me'), { type: 'symbol', value: $r('sys.symbol.info_shield') },MainViewModel.MENU_ABOUT,false),
       new ItemData($r('app.string.haoping'), { type: 'symbol', value: $r('sys.symbol.flower') },MainViewModel.MENU_HAOPING,false),
       new ItemData($r('app.string.persion_duty'),{ type: 'symbol', value: $r('sys.symbol.doc_plaintext') },MainViewModel.MENU_DUTY,false),
       new ItemData($r('app.string.yszc'), { type: 'symbol', value: $r('sys.symbol.lock') },MainViewModel.MENU_YSZC,false),
-      new ItemData($r('app.string.about_me'), { type: 'symbol', value: $r('sys.symbol.info_shield') },MainViewModel.MENU_ABOUT,false),
-      new ItemData($r('app.string.setting'),  { type: 'symbol', value: $r('sys.symbol.gearshape') },MainViewModel.MENU_SETTING,false),
       new ItemData($r('app.string.share_tt'),  { type: 'symbol', value: $r('sys.symbol.share') },MainViewModel.MENU_SHARE,false),
       // new ItemData($r('app.string.nor_setting'), $r('app.media.hm_gps'),MainViewModel.MENU_SETTING,false),
     ];