Kaynağa Gözat

处理网盘的返回手势问题

onecold 7 ay önce
ebeveyn
işleme
76a652eabd

+ 3 - 2
entry/src/main/ets/common/constants/EventConstants.ets

@@ -28,8 +28,9 @@ export class EventConstants {
    * UI交互事件
    */
   // SwipeBack状态更新事件
-  static readonly EVENT_SWIPE_BACK_UPDATE: number = 888;
-
+  static readonly EVENT_SWIPE_BACK_UPDATE: number = 888;//本地音乐的手势返回通知
+  static readonly EVENT_SWIPE_BACK_NAVID: number = 889;//Navidrome的手势返回通知
+  static readonly EVENT_SWIPE_BACK_DISK: number = 890;//网盘的手势返回通知
   /**
    * 用户相关事件
    */

+ 23 - 9
entry/src/main/ets/pages/NewIndex.ets

@@ -70,7 +70,7 @@ const TAG = 'NewIndex'; // 日志标签
 @Entry
 @Component
 struct NewIndex {
-
+  @State isDetailView: boolean = false; // 是否在艺术家/专辑详情视图
   @Provide isShowPlay: boolean = false;
   @Provide CONTROL_PlayStatus: number = PlayStatus.INIT;
   @Provide progressValue: number = 0;
@@ -207,12 +207,23 @@ struct NewIndex {
    * - 如果是根目录,双击返回键退出应用,否则提示
    */
   onBackPress(): boolean | void {
+    console.info('onecold onBackPress isDetailView = '+ this.isDetailView);
+    console.info('onecold onBackPress mType = '+  this.mType);
     if (this.currentPath !== this.rootPath || this.isHistory || this.isFavMusic ||
       (this.modeType !== 0 && this.isCanBack)) {
       console.info('onecold 返回键处理逻辑:发送音频广播通知更新列表');
       const eventData: emitter.EventData = {};
       emitter.emit({ eventId: EventConstants.EVENT_SWIPE_BACK_UPDATE }, eventData); // 发送音频广播通知更新doSwipBack
-    }else if(this.mType > 0){
+    } else if(this.mType === 7&&this.isDetailView) {
+      // NavidromePage/Jellyfin/Emby 页面,发送手势返回事件
+      console.info('onecold NavidromePage 返回键处理:发送手势返回事件');
+      const eventData: emitter.EventData = {};
+      emitter.emit({ eventId: EventConstants.EVENT_SWIPE_BACK_NAVID}, eventData);
+    } else if(this.mType === 6) {
+      console.info('onecold 网盘 返回键处理:发送手势返回事件');
+      const eventData: emitter.EventData = {};
+      emitter.emit({ eventId: EventConstants.EVENT_SWIPE_BACK_DISK }, eventData);
+    }  else if(this.mType > 0){
       this.getUIContext()?.animateTo({ duration: 555 }, () => {
         // 动画闭包内控制Image组件的出现和消失
         // this.isShowDrawer = !this.isShowDrawer
@@ -417,17 +428,20 @@ struct NewIndex {
         .visibility(this.mType === 4 ? Visibility.Visible : Visibility.None)
       AboutPage()
         .visibility(this.mType === 5 ? Visibility.Visible : Visibility.None)
+      if(this.mType === 6){
+        WebDavMainPage({
+          offsetX:this.offsetX,
+          isShowDrawer:this.isShowDrawer,
+          mType:this.mType,
+          selectedAccount:this.selectedAccount
+        })
+          .visibility(this.mType === 6 ? Visibility.Visible : Visibility.None)
+      }
 
-      WebDavMainPage({
-        offsetX:this.offsetX,
-        isShowDrawer:this.isShowDrawer,
-        mType:this.mType,
-        selectedAccount:this.selectedAccount
-      })
-        .visibility(this.mType === 6 ? Visibility.Visible : Visibility.None)
       if(this.mType === 7){
         NavidromePage({
           offsetX:this.offsetX,
+          isDetailView:this.isDetailView,
           isShowDrawer:this.isShowDrawer,
           mType:this.mType,
           selectedAccount:this.selectedAccount

+ 16 - 2
entry/src/main/ets/pages/WebDavMainPage.ets

@@ -384,6 +384,15 @@ export struct WebDavMainPage {
     // 订阅WebDAV状态变化
     this.webdavManager.subscribe(this.eventHandler);
     this.subscribeWebDavMetadataUpdates();
+
+
+    // 监听手势返回事件
+    let eventBackSwipeBack: emitter.InnerEvent = { eventId: EventConstants.EVENT_SWIPE_BACK_DISK }
+    emitter.on(eventBackSwipeBack, (eventData: emitter.EventData) => {
+      console.info('onecold', ' 收到 EVENT_SWIPE_BACK_DISK 事件');
+      // 如果在详情视图模式,退出详情视图
+      this.goBack()
+    });
   }
 
 
@@ -621,8 +630,15 @@ export struct WebDavMainPage {
           this.isLoading = false;
         });
       this.breadcrumbs = this.webdavManager.getBreadcrumbs();
+    }else{
+      this.getUIContext().animateTo({ duration: 555 }, () => {
+        // 动画闭包内控制Image组件的出现和消失
+        this.isShowDrawer = !this.isShowDrawer
+        this.offsetX = 0
+      })
     }
 
+
   }
 
   // 切换账户
@@ -1346,10 +1362,8 @@ export struct WebDavMainPage {
             const currentOffsetY = this.listScroller.currentOffset().yOffset;
             // 判断滚动方向
             if (currentOffsetY > this.prevOffsetY) {
-              console.log("onecold 向上滚动");
               this.isShowTitleBar = false
             } else if (currentOffsetY < this.prevOffsetY) {
-              console.log("onecold 向下滚动");
               this.isShowTitleBar = true
             }
             // 更新前一次偏移量

+ 1 - 1
entry/src/main/ets/view/LocalMusic.ets

@@ -1281,7 +1281,7 @@ export struct LocalMusic {
 
     //侧滑广播接收时间
     let eventUpdateSwipeBack: emitter.InnerEvent = { eventId: EventConstants.EVENT_SWIPE_BACK_UPDATE }
-    // 监听广播事件(打开其他应用处理)
+    // 监听广播事件(手势返回处理)
     emitter.on(eventUpdateSwipeBack, (eventData: emitter.EventData) => {
 
       animateTo({ duration: 555 }, () => {

+ 14 - 1
entry/src/main/ets/view/NavidromePage.ets

@@ -90,7 +90,7 @@ export struct NavidromePage {
   @State isPlaylistPageLoading: boolean = false;
 
   // 新增:详情视图状态
-  @State isDetailView: boolean = false; // 是否在艺术家/专辑详情视图
+  @Link isDetailView: boolean; // 是否在艺术家/专辑详情视图
   @State previousTab: number = 0; // 进入详情视图前的标签页索引
   @StorageProp('isDarkMode') isDarkMode: boolean = false;
   @StorageLink('currentSong') currentSong: VideoItem | undefined = undefined;
@@ -229,6 +229,19 @@ export struct NavidromePage {
       this.initSetting()
     });
 
+    // 监听手势返回事件
+    let eventBackSwipeBack: emitter.InnerEvent = { eventId: EventConstants.EVENT_SWIPE_BACK_NAVID }
+    emitter.on(eventBackSwipeBack, (eventData: emitter.EventData) => {
+      console.info('heanup', 'NavidromePage 收到 EVENT_SWIPE_BACK_NAVID 事件');
+      // 如果在详情视图模式,退出详情视图
+      if (this.isDetailView) {
+        this.getUIContext().animateTo({ duration: 555 }, () => {
+          this.isDetailView = false;
+          this.clearFilter();
+        })
+      }
+    });
+
     this.refreshNavidromeData();
   }
 

+ 0 - 1
lib/src/main/ets/view/LyricView2.ets

@@ -381,7 +381,6 @@ export struct LyricView2 {
 
         value = Math.max(0, Math.min(1, value))
 
-
         return [[this.textHighlightColor, 0.0],
             [this.textHighlightColor, value],
             [this.textColor, value],