Browse Source

Merge branch 'master' of https://git.yishihui.com/iOS/BFFramework
合并代码

jsonwang 3 years ago
parent
commit
616c2a76db

BIN
BFFramework/Assets/base/icon_detail_back@2x.png


BIN
BFFramework/Assets/base/icon_detail_back@3x.png


+ 17 - 1
BFFramework/Classes/Base/Controller/PQBaseViewController.swift

@@ -25,6 +25,18 @@ public class PQBaseViewController: UIViewController, UIGestureRecognizerDelegate
         }
     }
 
+    /// <#Description#>
+    public var isPresent: Bool {
+        var isPresent = true
+        let viewcontrollers = navigationController?.viewControllers
+        if (viewcontrollers?.count ?? 0) > 1 {
+            if viewcontrollers?[(viewcontrollers?.count ?? 1) - 1] == self {
+                isPresent = false
+            }
+        }
+        return isPresent
+    }
+
     public lazy var manager: NetworkReachabilityManager? = {
         let manager = NetworkReachabilityManager(host: "www.baidu.com")
         manager?.listener = { status in
@@ -121,7 +133,11 @@ public class PQBaseViewController: UIViewController, UIGestureRecognizerDelegate
     @objc func rightBtnClick(sender _: UIButton) {}
 
     @objc func backBtnClick() {
-        navigationController?.popViewController(animated: true)
+        if isPresent {
+            dismiss(animated: true, completion: nil)
+        } else {
+            navigationController?.popViewController(animated: true)
+        }
     }
 
     override public func viewDidAppear(_ animated: Bool) {

+ 18 - 46
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointMaterialController.swift

@@ -214,6 +214,8 @@ public class PQStuckPointMaterialController: PQBaseViewController {
         view.insertSubview(materialListView, belowSubview: bottomRemindView)
         // 卡点音乐素材选择曝光上报
         PQEventTrackViewModel.baseReportUpload(businessType: .bt_windowView, objectType: .ot_view_selectSyncedUpMaterial, pageSource: .sp_stuck_selectMaterial, extParams: nil, remindmsg: "卡点视频数据上报-(曝光上报:卡点视频素材选择页)")
+        // 注册通知
+        addNotification(self, selector: #selector(dismissVc), name: cFinishedPublishedNotiKey, object: nil)
     }
 
     /// 按钮点击事件
@@ -263,10 +265,26 @@ public class PQStuckPointMaterialController: PQBaseViewController {
 
     override func backBtnClick() {
         super.backBtnClick()
+        if isPresent {
+            postNotification(name: cFinishedPublishedNotiKey)
+        }
         // 卡点视频返回按钮点击上报
         PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_back, pageSource: .sp_stuck_selectMaterial, extParams: nil, remindmsg: "卡点视频数据上报-(点击上报:返回按钮)")
     }
 
+    // 返回
+    @objc func dismissVc() {
+        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.2) { [weak self] in
+            if self?.isPresent ?? false {
+                self?.dismiss(animated: true, completion: nil)
+            }
+        }
+    }
+
+    deinit {
+        PQNotification.removeObserver(self)
+    }
+
     /// 图库选择的回调
     /// - Parameter seletedData: <#seletedData description#>
     /// - Returns: <#description#>
@@ -279,10 +297,6 @@ public class PQStuckPointMaterialController: PQBaseViewController {
         changeCollecBtn.imagePosition(at: .right, space: cDefaultMargin / 2)
         photoMaterialVc.assetCollection = seletedData?.assetCollection
         photoMaterialVc.msgType = photoMaterialVc.msgType
-//        photoMaterialVc.msgType = .video
-//        choseLocalAllBtn.isSelected = false
-//        choseLocalVideoBtn.isSelected = true
-//        choseLocalImageBtn.isSelected = false
     }
 
     /// 点击选择的回调
@@ -294,29 +308,13 @@ public class PQStuckPointMaterialController: PQBaseViewController {
         confirmBtn.isSelected = (selectedDataCount > 0 && (imageCount >= 2 || selectedDataCount > imageCount))
         if confirmBtn.isSelected {
             confirmBtn.backgroundColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)
-//            if !materialHeadView.isHidden {
-//                UIView.animate(withDuration: 0.5, delay: 0, options: .allowUserInteraction) { [weak self] in
-//                    // 调整位置
-//                    self?.adjustPhotoMaterialFrame()
-//                } completion: { [weak self] _ in
-//                    self?.materialHeadView.isHidden = true
-//                }
-//            }
         } else {
             confirmBtn.backgroundColor = PQBFConfig.shared.otherTintColor
-//            if materialHeadView.isHidden {
-//                UIView.animate(withDuration: 0.5, delay: 0, options: .allowUserInteraction) { [weak self] in
-//                    // 调整位置
-//                    self?.adjustPhotoMaterialFrame(isHidden: false)
-//                } completion: { _ in
-//                }
-//            }
         }
         if selectedDataCount <= 0 {
             bottomRemindLab.attributedText = NSAttributedString(string: "至少选择 1 个视频或 2 张照片")
         } else if selectedImageDataCount == 1, selectedDataCount == selectedImageDataCount {
             let att = NSMutableAttributedString(string: "至少选择 1 个视频或 2 张照片")
-//            att.setAttributes([.foregroundColor: UIColor.hexColor(hexadecimal: "#EE0051")], range: NSRange(location: 5, length: 1))
             bottomRemindLab.attributedText = att
         } else {
             let att = NSMutableAttributedString(string: "素材总时长 \(totalDuration.formatDurationToHMS())")
@@ -326,32 +324,6 @@ public class PQStuckPointMaterialController: PQBaseViewController {
         confirmBtn.setTitle(selectedDataCount > 0 ? "确定(\(selectedDataCount))" : "确定", for: .normal)
     }
 
-    /// 调整位置
-    /// - Parameter isHidden: <#isHidden description#>
-    /// - Returns: <#description#>
-    func adjustPhotoMaterialFrame(isHidden _: Bool = true) {
-//        if isHidden {
-//            materialHeadView.alpha = 0
-//            materialHeadView.frame = CGRect(x: 0, y: 0, width: materialHeadView.frame.width, height: 0)
-//            photoMaterialVc.updateFrame(newFrame: CGRect(x: 0, y: choseLocalAllBtn.frame.maxY + margin, width: view.frame.width, height: view.frame.height - (choseLocalAllBtn.frame.maxY + margin + bottomRemindView.frame.height) - (selectedDataCount > 0 ? materialListView.frame.height : 0)), isAnimate: true)
-//        } else {
-//            materialHeadView.isHidden = false
-//            materialHeadView.alpha = 1
-//            materialHeadView.frame = CGRect(x: margin / 2, y: choseLocalAllBtn.frame.maxY + margin, width: view.frame.width - margin, height: topImageH)
-//            photoMaterialVc.updateFrame(newFrame: CGRect(x: 0, y: (choseLocalAllBtn.frame.maxY + margin + topImageH) + margin / 2, width: view.frame.width, height: view.frame.height - ((choseLocalAllBtn.frame.maxY + margin + topImageH) + margin + bottomRemindView.frame.height) - (selectedDataCount > 0 ? materialListView.frame.height : 0)), isAnimate: true)
-//        }
-    }
-
-    /// 更新frame
-    /// - Parameter contentOffset: <#contentOffset description#>
-    func updateMaterialHeadFrame(contentOffset _: CGPoint) {
-//        BFLog(message: "===\((navHeadImageView?.frame.maxY ?? cDevice_iPhoneNavBarAndStatusBarHei) + topImageH),\(contentOffset.y)")
-//        if !materialHeadView.isHidden, contentOffset.y <= ((navHeadImageView?.frame.maxY ?? cDevice_iPhoneNavBarAndStatusBarHei) + topImageH), contentOffset.y >= 0 {
-//            materialHeadView.frame.origin.y = (navHeadImageView?.frame.maxY ?? cDevice_iPhoneNavBarAndStatusBarHei) - contentOffset.y
-//            photoMaterialVc.updateFrame(newFrame: CGRect(x: 0, y: materialHeadView.frame.maxY + margin / 2, width: view.frame.width, height: view.frame.height - (materialHeadView.frame.maxY + margin + bottomRemindView.frame.height) - (selectedDataCount > 0 ? materialListView.frame.height : 0)))
-//        }
-    }
-
     /// 处理已经选择的数据
     /// - Returns: <#description#>
     func dealWithSelectedMaterials(isDissmiss: Bool, isChose: Bool, materialData: PQEditVisionTrackMaterialsModel?) {

+ 2 - 0
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointMusicController.swift

@@ -113,6 +113,8 @@ class PQStuckPointMusicController: PQBaseViewController {
         // 一级分类点击
         topCategoryController.didSelectedHandle = { [weak self] _, _, _, itemData in
             if itemData is PQStuckPointMusicTagsModel {
+                self?.musicPageController.updateCurrentPlayMusic(isPlaying: false, isClearCurrentMusic: true)
+                self?.searchController.updateCurrentPlayMusic(isPlaying: false, isClearCurrentMusic: true)
                 self?.tagData = itemData as? PQStuckPointMusicTagsModel
                 self?.dealWithCategorySelectedData(itemData: itemData as? PQStuckPointMusicTagsModel)
                 // 更新当前标签

+ 2 - 0
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointPublicController.swift

@@ -913,6 +913,8 @@ extension PQStuckPointPublicController {
                 // 点击上报:完成
                 PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_finished, pageSource: .sp_stuck_publishSyncedUp, extParams: ["videoId": videoData?.uniqueId ?? ""], remindmsg: "卡点视频数据上报-(点击上报:完成)")
                 navigationController?.popToRootViewController(animated: true)
+                // 发送通知
+                postNotification(name: cFinishedPublishedNotiKey)
             }
         default:
             break

+ 3 - 0
BFFramework/Classes/Stuckpoint/Model/PQVoiceModel.swift

@@ -281,6 +281,9 @@ public class PQVoiceModel: NSObject, NSCopying {
         let V2: Float64 = Float64(imageCount)
         // 视频总时长
         let V1T: Float64 = totalDuration - V2
+        if endTime <= startTime {
+            endTime = startTime + MaxM
+        }
         // 推荐音乐时长
         var M: Float64 = endTime - startTime
         // 音频段数

+ 2 - 1
BFFramework/Classes/Stuckpoint/View/PQStuckPointLoadingView.swift

@@ -37,9 +37,10 @@ class PQStuckPointLoadingView: UIView {
 
     override init(frame: CGRect) {
         super.init(frame: frame)
+        backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.5)
         addSubViews()
         addLayout()
-        backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.8)
+        
     }
 
     required init?(coder _: NSCoder) {

+ 4 - 0
BFFramework/Classes/Stuckpoint/ViewModel/PQStuckPointViewModel.swift

@@ -89,6 +89,10 @@ public class PQStuckPointViewModel: NSObject {
                     let tempMusic = PQVoiceModel(jsonDict: dict)
                     if tempMusic.rhythmSdata.count > 0 && (videoCount > 0 || imageCount > 0 ||  totalDuration > 0)  {
                         tempMusic.endTime = tempMusic.startTime + tempMusic.stuckPointCuttingTime(videoCount: videoCount, imageCount: imageCount, totalDuration: totalDuration)
+                        BFLog(message: "music:\(tempMusic.musicName ?? ""),\(tempMusic.startTime),\(tempMusic.endTime)")
+                    }
+                    if tempMusic.endTime <= tempMusic.startTime {
+                        tempMusic.endTime = tempMusic.startTime + 40
                     }
                     musicPageList.append(tempMusic)
                 }

+ 2 - 1
BFFramework/Classes/Utils/PQConstant.swift

@@ -242,6 +242,8 @@ public let cAudioTransferSubTitleSuccessKey: String = "audioTransferSubTitleSucc
 public let cLostNet: String = "lostNet\(cPrimarykey)"
 // 取消视频发布引导弹框
 public let cDismissVideoMakeGuideKey: String = "dismissVideoMakeGuide\(cPrimarykey)"
+// 点击完成或发布完成跳转
+public let cFinishedPublishedNotiKey: String = "finishedPublishedNotiKey\(cPrimarykey)"
 
 // oss 上传文件进度 add by ak
 public let cOSSUploadFileProgress: String = "OSSUploadFileProgress\(cPrimarykey)"
@@ -265,4 +267,3 @@ public let cAliFeedbackAppSecret: String = "3b831b2068aef36607886a3912ef4fbb"
 public let cBMKLocationAppkey: String = "buprQzBBojKbvDvED8Xix7xHA91ShAnL"
 // 分享小程序ID
 public let cShareWeappRawId: String = "gh_ecd1ea0b84cf"
-

+ 4 - 1
Example/BFFramework/ViewController.swift

@@ -31,7 +31,10 @@ class ViewController: UIViewController {
         print("打开界面")
         BFLog(message: "ssssss")
 //        PQBFConfig.shared.styleColor = .green
-        navigationController?.pushViewController(PQStuckPointMaterialController(), animated: true)
+//        navigationController?.pushViewController(PQStuckPointMaterialController(), animated: true)
+        let nav = UINavigationController(rootViewController: PQStuckPointMaterialController())
+        nav.modalPresentationStyle = .overFullScreen
+        present(nav, animated: true, completion: nil)
         return "111"
     }
 }