浏览代码

1.改变跳转方式

wenweiwei 4 年之前
父节点
当前提交
06f4be6b59
共有 1 个文件被更改,包括 51 次插入65 次删除
  1. 51 65
      MusicVideoPlus/MusicVideoPlus/Classes/Modules/Home/Controllers/MVHomeController.swift

+ 51 - 65
MusicVideoPlus/MusicVideoPlus/Classes/Modules/Home/Controllers/MVHomeController.swift

@@ -7,7 +7,7 @@
 
 import BFFramework
 class MVHomeController: MVBaseController {
-    //视频播放列表
+    // 视频播放列表
     private var viewListView: MVBanner = {
         let videoListView = MVBanner(frame: .zero, margin: 30, lineSpacing: 12, minScale: MVBanner.Scale(scale: 1))
         videoListView.backgroundColor = UIColor.white
@@ -53,7 +53,7 @@ class MVHomeController: MVBaseController {
     // 标签分类
     lazy var categoryCollectionView: UICollectionView = {
         let flowLayout = UICollectionViewFlowLayout()
-        flowLayout.sectionInset = UIEdgeInsets.init(top: 0, left: 11, bottom: 0, right: 11)
+        flowLayout.sectionInset = UIEdgeInsets(top: 0, left: 11, bottom: 0, right: 11)
         flowLayout.minimumLineSpacing = 0
         flowLayout.minimumInteritemSpacing = 10
         flowLayout.scrollDirection = .horizontal
@@ -79,26 +79,24 @@ class MVHomeController: MVBaseController {
     var mAllVideos: Array = Array<PQVideoListModel>.init()
 
     var lastBnnerSelectIndex: IndexPath = IndexPath()
-    
-    //是否点击的再创作
-    var isCreateVideo:Bool = false
- 
+
+    // 是否点击的再创作
+    var isCreateVideo: Bool = false
+
     deinit {
         PQNotification.removeObserver(self)
     }
-    //登录成功后自动跳转到系统相册
-    @objc func loginSuccesss() {
 
-        if(isCreateVideo){
+    // 登录成功后自动跳转到系统相册
+    @objc func loginSuccesss() {
+        if isCreateVideo {
             isCreateVideo = false
             createVideo(indexPath: lastBnnerSelectIndex)
-        }else{
+        } else {
             navigationController?.pushViewController(PQStuckPointMaterialController(), animated: true)
         }
-       
-    
-
     }
+
     override func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
 
@@ -107,14 +105,13 @@ class MVHomeController: MVBaseController {
         cell?.pauseView.isHidden = false
         PQSingletoVideoPlayer.shared.stopPlayer(isRemove: false)
     }
-    
-    func getData(){
-        
-        if(mVideos.count > 0){
+
+    func getData() {
+        if mVideos.count > 0 {
             BFLog(message: "已经请求过数据")
             return
         }
-        MVHomeViewModel.getHomeHotVideos {[weak self] hotVideos, _ in
+        MVHomeViewModel.getHomeHotVideos { [weak self] hotVideos, _ in
             BFLog(message: "hotVideos count is :\(hotVideos.count)")
 
             self?.mVideos = hotVideos
@@ -131,20 +128,19 @@ class MVHomeController: MVBaseController {
             }
 
             self?.viewListView.reloadData()
-            
-            //自动播放第一个视频 确保 reloaddata 完成
-      
-                self?.playVideo(page: 0)
-           
+
+            // 自动播放第一个视频 确保 reloaddata 完成
+
+            self?.playVideo(page: 0)
         }
     }
 
     override func viewDidLoad() {
         super.viewDidLoad()
-        
+
         addNotification(self, selector: #selector(loginSuccesss), name: cLoginSuccesssNotiKey, object: nil)
         addNotification(self, selector: #selector(loginSuccesss), name: cBandingPhoneSuccessKey, object: nil)
-        
+
 //        view.addSubview(mineBtn)
         view.addSubview(stuckPointBtn)
         view.addSubview(settingBtn)
@@ -156,12 +152,12 @@ class MVHomeController: MVBaseController {
         viewListView.reloadData()
 
         addLayout()
-                
+
         manager?.startListening()
         manager?.listener = { [weak self] status in
-            
+
             if status == .reachable(.wwan) || status == .reachable(.ethernetOrWiFi) {
-               BFLog(message: "来网了")
+                BFLog(message: "来网了")
                 self?.getData()
             }
         }
@@ -237,28 +233,26 @@ class MVHomeController: MVBaseController {
     }
 
     @objc func btnClick(sender: UIButton) {
-        
-
         switch sender.tag {
         case 1000:
-            if(enableLogin()){
+            if enableLogin() {
                 navigationController?.pushViewController(MVMineController(), animated: true)
             }
         case 2000:
-            if(enableLogin()){
-                navigationController?.pushViewController(PQStuckPointMaterialController(), animated: true)
+            if enableLogin() {
+                let nav = UINavigationController(rootViewController: PQStuckPointMaterialController())
+                nav.modalPresentationStyle = .overFullScreen
+                present(nav, animated: true, completion: nil)
             }
-
         case 3000:
             navigationController?.pushViewController(MVSettingController(), animated: true)
-
         default:
             break
         }
     }
-    
-    //判断是否可登录
-    func enableLogin() -> Bool{
+
+    // 判断是否可登录
+    func enableLogin() -> Bool {
         // 无网
         if !isNetConnected() {
             let remindData: PQBaseModel = PQBaseModel()
@@ -281,47 +275,42 @@ class MVHomeController: MVBaseController {
             present(vc, animated: true, completion: nil)
             return false
         }
-        
+
         // 用户被封禁
         BFLog(message: "userStatus is \(BFLoginUserInfo.shared.userStatus)")
         if BFLoginUserInfo.shared.userStatus == "3" {
-            
-            PQBandingPhoneRemindView.accountBlockRemindView(remindTitle:"无法上传视频")
+            PQBandingPhoneRemindView.accountBlockRemindView(remindTitle: "无法上传视频")
             return false
         }
-        
+
         // 未绑定手机号
         BFLog(message: "phoneNumber is \(BFLoginUserInfo.shared.phoneNumber)")
         if BFLoginUserInfo.shared.phoneNumber.count <= 0 || BFLoginUserInfo.shared.phoneNumber == "<null>" {
-
             let remindView = PQBandingPhoneRemindView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
             remindView.tag = cBandinPhoneTag
             remindView.bandingPhoneRemindHandle = { [weak self] sender in
                 if sender.tag == 2 {
-
                     addNotification(self!, selector: #selector(self?.loginSuccesss), name: cBandingPhoneSuccessKey, object: nil)
                     self?.navigationController?.pushViewController(PQBandingPhoneController(), animated: true)
                 }
             }
-                remindView.remindBlock = { [weak self] sender, webUrl in
-                    let detail = PQBaseWebViewController()
-                  
-                    detail.baseUrl = webUrl
-                    self?.navigationController?.pushViewController(detail, animated: true)
-                
-                }
-            self.view.addSubview(remindView)
+            remindView.remindBlock = { [weak self] _, webUrl in
+                let detail = PQBaseWebViewController()
 
-            return  false
+                detail.baseUrl = webUrl
+                self?.navigationController?.pushViewController(detail, animated: true)
+            }
+            view.addSubview(remindView)
+
+            return false
         }
-        
+
         return true
-        
     }
 
     // 再创作视频
     func createVideo(indexPath: IndexPath) {
-        if(enableLogin()){
+        if enableLogin() {
             PQStuckPointViewModel.stuckPointProjectMusicInfo(projectId: mAllVideos[indexPath.row].reCreateVideoData?.projectId ?? "") { musicData, _ in
                 if musicData != nil {
                     let vc = PQStuckPointMaterialController()
@@ -379,7 +368,6 @@ extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
     }
 
     func playVideo(page: Int) {
-        
         DispatchQueue.main.async {
             let cell: MVBannerCell? = self.viewListView.collectionView.cellForItem(at: IndexPath(row: page, section: 0)) as? MVBannerCell
             let showProtocal: String? = getUserDefaults(key: cShowProtocal) as? String
@@ -390,30 +378,28 @@ extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
                 let hotVideoIndex = self.mVideos.firstIndex(where: { (items) -> Bool in
                     items.categoryName == self.mAllVideos[page].categoryName
                 })
-                
+
                 BFLog(message: "播放的视频分类为:\(String(describing: self.mVideos[hotVideoIndex ?? 0].categoryName)) page is :\(page)")
-                //设置选中状态
+                // 设置选中状态
                 for hot in self.mVideos {
                     hot.isSelected = false
                 }
                 self.mVideos[hotVideoIndex ?? 0].isSelected = true
 
                 self.categoryCollectionView.reloadData()
-                self.categoryCollectionView.scrollToItem(at: IndexPath(row: hotVideoIndex ?? 0, section: 0), at:  .centeredHorizontally, animated: true)
+                self.categoryCollectionView.scrollToItem(at: IndexPath(row: hotVideoIndex ?? 0, section: 0), at: .centeredHorizontally, animated: true)
 
                 self.lastBnnerSelectIndex = IndexPath(row: page, section: 0)
- 
-                
-            }else{
+
+            } else {
                 BFLog(message: "播放不成功: cell:\(String(describing: cell)) mVideos:\(self.mVideos.count) showProtocal: is \(String(describing: showProtocal))")
             }
         }
     }
-    
+
     func pageControl(currentPage page: Int) {
         BFLog(message: "page is \(page)")
         playVideo(page: page)
-
     }
 }