Browse Source

1.修改卡点信息

wenweiwei 3 years ago
parent
commit
006f7c1a36

+ 2 - 3
BFFramework.podspec

@@ -48,10 +48,9 @@ TODO: Add long description of the pod here.
    s.frameworks = 'UIKit', 'AVFoundation','OpenGLES', 'CoreMedia', 'QuartzCore'
     # 排除非 ios 平台的文件
     # s.ios.exclude_files = 'framework/Source/Mac', 'framework/Source/Linux', 'framework/Source/Operations/Shaders/ConvertedShaders_GL.swift'
-
-    s.dependency 'BFNetRequestKit'
     s.dependency 'BFCommonKit'
-#    s.dependency 'BFCommonKit', :path => '/Users/sanw/Desktop/BytesFlow/Person/Projects/BFCommonKit/'
+    s.dependency 'BFNetRequestKit'
+    s.dependency 'BFMaterialKit'
     s.dependency 'ObjectMapper','4.2.0' # json转model库
     s.dependency 'AliyunOSSiOS','2.10.8' # 阿里云组件
     s.dependency 'WechatOpenSDK-Swift','1.8.7.1' # 微信组件

+ 33 - 5
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointEditerController.swift

@@ -17,6 +17,7 @@ import ObjectMapper
 import RealmSwift
 import UIKit
 import BFCommonKit
+import Photos
 
 class PQStuckPointEditerController: PQBaseViewController {
     // 是否导出视频成功
@@ -34,7 +35,34 @@ class PQStuckPointEditerController: PQBaseViewController {
     // 选择的图片总数
     var selectedImageDataCount: Int = 0
     // 选中的素材数据
-    var selectedPhotoData: [PQEditVisionTrackMaterialsModel]?
+    var selectedPhotoData: [PHAsset]? {
+        didSet {
+            if selectedPhotoData != nil, (selectedPhotoData?.count ?? 0) > 0 {
+                selectedMetarialData = Array<PQEditVisionTrackMaterialsModel>.init()
+                selectedPhotoData?.forEach { phAsset in
+                    let metarialData = PQEditVisionTrackMaterialsModel()
+                    metarialData.asset = phAsset
+                    metarialData.width = Float(phAsset.pixelWidth)
+                    metarialData.itemWidth = Float(phAsset.pixelWidth)
+                    metarialData.height = Float(phAsset.pixelHeight)
+                    metarialData.itemHeight = Float(phAsset.pixelHeight)
+                    if phAsset.mediaType == .image {
+                        metarialData.type = "image"
+                    } else if phAsset.mediaType == .video {
+                        metarialData.type = "video"
+                        metarialData.duration = Float64(phAsset.duration)
+                    }
+                    metarialData.canvasFillType = phAsset.canvasFillType ?? ""
+                    metarialData.locationPath = phAsset.localPath ?? ""
+                    metarialData.selectedIndex = phAsset.selectedIndex ?? 1
+                    metarialData.originalData = phAsset.originalData
+                    metarialData.coverImageUI = phAsset.image
+                    selectedMetarialData?.append(metarialData)
+                }
+            }
+        }
+    }
+    var selectedMetarialData: [PQEditVisionTrackMaterialsModel]?
     // 选中的音乐数据
     var stuckPointMusicData: PQVoiceModel?
     // 保存所有段的所有贴纸,音频信息,用于播放器的渲染使用
@@ -316,7 +344,7 @@ class PQStuckPointEditerController: PQBaseViewController {
     func createPorjectData() {
         // 1,添加选择的视觉素材
         let section: PQEditSectionModel = PQEditSectionModel()
-        selectedPhotoData?.forEach { model in
+        selectedMetarialData?.forEach { model in
 
             let json = model.toJSONString(prettyPrint: false)
             if json == nil {
@@ -894,13 +922,13 @@ extension PQStuckPointEditerController {
             exportSession.cancelExport()
         }
         var isHaveVideo: Bool = false
-        if selectedPhotoData != nil, (selectedPhotoData?.count ?? 0) > 0 {
+        if selectedMetarialData != nil, (selectedMetarialData?.count ?? 0) > 0 {
             if synchroMarskView.superview == nil {
                 UIApplication.shared.keyWindow?.addSubview(synchroMarskView)
             }
             let dispatchGroup = DispatchGroup()
 
-            for photo in selectedPhotoData! {
+            for photo in selectedMetarialData! {
                 if photo.asset != nil, photo.asset?.mediaType == .video {
                     if !isHaveVideo {
                         isHaveVideo = true
@@ -914,7 +942,7 @@ extension PQStuckPointEditerController {
                             let fileName = (avAsset as! AVURLAsset).url.absoluteString
 
                             BFLog(message: "video  fileName is\(fileName)")
-                            let tempPhoto = self.selectedPhotoData?.first(where: { material in
+                            let tempPhoto = self.selectedMetarialData?.first(where: { material in
                                 material.asset == photo.asset
                             })
 

+ 23 - 20
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointMaterialController.swift

@@ -7,7 +7,9 @@
 //
 
 import UIKit
+import Photos
 import BFCommonKit
+import BFMaterialKit
 
 public class PQStuckPointMaterialController: PQBaseViewController {
     // 按钮高
@@ -41,8 +43,8 @@ public class PQStuckPointMaterialController: PQBaseViewController {
         return changeCollecBtn
     }()
 
-    lazy var albumController: PQPhotoAlbumController = {
-        let albumController = PQPhotoAlbumController()
+    lazy var albumController: BFPhotoAlbumController = {
+        let albumController = BFPhotoAlbumController()
         albumController.isTopShow = true
         albumController.categoryH = cDefaultMargin * 40
         addChild(albumController)
@@ -138,14 +140,14 @@ public class PQStuckPointMaterialController: PQBaseViewController {
     }()
 
     /// 已选素材列表
-    lazy var materialListView: PQSelectedMaterialListView = {
-        let materialListView = PQSelectedMaterialListView(frame: CGRect(x: 0, y: cScreenHeigth, width: cScreenWidth, height: 88))
+    lazy var materialListView: BFSelectedMaterialListView = {
+        let materialListView = BFSelectedMaterialListView(frame: CGRect(x: 0, y: cScreenHeigth, width: cScreenWidth, height: 88))
         materialListView.deletedMaterialHandle = { [weak self] materialData, isDissmiss in
             /// 处理已经选择的数据
             self?.dealWithSelectedMaterials(isDissmiss: isDissmiss, isChose: false, materialData: materialData)
         }
         materialListView.detailMaterialHandle = { [weak self] _, materialData in
-            let detailVc: PQStuckPointMaterialDetailController = PQStuckPointMaterialDetailController()
+            let detailVc: BFMaterialDetailController = BFMaterialDetailController()
             detailVc.materialDetailClickHandle = { [weak self] isMaterialSelected, materialData in
                 if isMaterialSelected != materialData?.isSelected {
                     self?.photoMaterialVc.updateMaterials(isSelected:!(isMaterialSelected ?? false), materialData: materialData)
@@ -154,6 +156,7 @@ public class PQStuckPointMaterialController: PQBaseViewController {
             if !(materialData?.isSelected ?? false) {
                 materialData?.selectedIndex = (self?.selectedDataCount ?? 0) + 1
             }
+            detailVc.isStuckPoint = true
             detailVc.materialData = materialData
             self?.navigationController?.pushViewController(detailVc, animated: true)
         }
@@ -161,13 +164,12 @@ public class PQStuckPointMaterialController: PQBaseViewController {
     }()
 
     /// 图片加载视图
-    lazy var photoMaterialVc: PQPhotoMaterialController = {
-        let photoMaterialVc = PQPhotoMaterialController()
+    lazy var photoMaterialVc: BFPhotosMaterialController = {
+        let photoMaterialVc = BFPhotosMaterialController()
         photoMaterialVc.isShowMediaTag = false
         photoMaterialVc.imageDuration = 1
         addChild(photoMaterialVc)
         view.insertSubview(photoMaterialVc.view, belowSubview: bottomRemindView)
-//        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)))
         photoMaterialVc.updateFrame(newFrame: CGRect(x: 0, y: (navHeadImageView?.frame.maxY ?? cDevice_iPhoneNavBarAndStatusBarHei) + margin / 2, width: view.frame.width, height: view.frame.height - ((navHeadImageView?.frame.maxY ?? cDevice_iPhoneNavBarAndStatusBarHei) + margin + bottomRemindView.frame.height)))
         photoMaterialVc.selectedMaterialHandle = { [weak self] currentMaterialData, selectedPhotoData, selectedTotalDuration, imageCount in
             self?.dealWithSelectedMaterial(materialData: currentMaterialData, selectedDatas: selectedPhotoData, totalDuration: selectedTotalDuration, imageCount: imageCount)
@@ -175,7 +177,8 @@ public class PQStuckPointMaterialController: PQBaseViewController {
             self?.dealWithSelectedMaterials(isDissmiss: selectedPhotoData.count <= 0, isChose: true, materialData: currentMaterialData)
         }
         photoMaterialVc.detailMaterialHandle = { [weak self] _, currentMaterialData in
-            let detailVc: PQStuckPointMaterialDetailController = PQStuckPointMaterialDetailController()
+            let detailVc: BFMaterialDetailController = BFMaterialDetailController()
+            detailVc.isStuckPoint = true
             detailVc.materialDetailClickHandle = { [weak self] isMaterialSelected, materialData in
                 if isMaterialSelected != materialData?.isSelected {
                     self?.photoMaterialVc.updateMaterials(isSelected:!(isMaterialSelected ?? false), materialData: materialData)
@@ -229,7 +232,6 @@ public class PQStuckPointMaterialController: PQBaseViewController {
             if sender?.isSelected ?? false {
                 albumController.showCategoryView()
             } else {
-                albumController.albaumCollectionView.reloadData()
                 albumController.dismissCategoryView()
             }
         case 10, 11, 12: // 筛选全部图库
@@ -290,28 +292,29 @@ public class PQStuckPointMaterialController: PQBaseViewController {
     /// 图库选择的回调
     /// - Parameter seletedData: <#seletedData description#>
     /// - Returns: <#description#>
-    func albumSelectedHandle(seletedData: PQUploadModel?) {
-        changeCollecBtn.isSelected = false
-        if seletedData == nil {
-            return
-        }
+    func albumSelectedHandle(seletedData: PHAsset?) {
         changeCollecBtn.setTitle(seletedData?.title ?? "全部", for: .normal)
+        changeCollecBtn.isSelected = false
         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
     }
 
     /// 点击选择的回调
     /// - Parameter materialData: <#materialData description#>
     /// - Returns: <#description#>
-    func dealWithSelectedMaterial(materialData _: PQEditVisionTrackMaterialsModel?, selectedDatas: [PQEditVisionTrackMaterialsModel]?, totalDuration: Float64, imageCount: Int) {
+    func dealWithSelectedMaterial(materialData _: PHAsset?, selectedDatas: [PHAsset]?, totalDuration: Float64, imageCount: Int) {
         selectedDataCount = selectedDatas?.count ?? 0
         selectedImageDataCount = imageCount
         confirmBtn.isSelected = (selectedDataCount > 0 && (imageCount >= 2 || selectedDataCount > imageCount))
         if confirmBtn.isSelected {
-            confirmBtn.backgroundColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)
+            confirmBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#EE0051")
         } else {
-            confirmBtn.backgroundColor = PQBFConfig.shared.otherTintColor
+            confirmBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#333333")
         }
         if selectedDataCount <= 0 {
             bottomRemindLab.attributedText = NSAttributedString(string: "至少选择 1 个视频或 2 张照片")
@@ -320,7 +323,7 @@ public class PQStuckPointMaterialController: PQBaseViewController {
             bottomRemindLab.attributedText = att
         } else {
             let att = NSMutableAttributedString(string: "素材总时长 \(totalDuration.formatDurationToHMS())")
-            att.setAttributes([.foregroundColor: UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)], range: NSRange(location: 6, length: "\(totalDuration.formatDurationToHMS())".count))
+            att.setAttributes([.foregroundColor: UIColor.hexColor(hexadecimal: "#EE0051")], range: NSRange(location: 6, length: "\(totalDuration.formatDurationToHMS())".count))
             bottomRemindLab.attributedText = att
         }
         confirmBtn.setTitle(selectedDataCount > 0 ? "确定(\(selectedDataCount))" : "确定", for: .normal)
@@ -328,7 +331,7 @@ public class PQStuckPointMaterialController: PQBaseViewController {
 
     /// 处理已经选择的数据
     /// - Returns: <#description#>
-    func dealWithSelectedMaterials(isDissmiss: Bool, isChose: Bool, materialData: PQEditVisionTrackMaterialsModel?) {
+    func dealWithSelectedMaterials(isDissmiss: Bool, isChose: Bool, materialData: PHAsset?) {
         // 添加当前素材
         if materialData != nil {
             if isChose {

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

@@ -9,6 +9,7 @@
 import AVFoundation
 import UIKit
 import BFCommonKit
+import Photos
 
 class PQStuckPointMusicController: PQBaseViewController {
     // 选中的总时长
@@ -18,7 +19,7 @@ class PQStuckPointMusicController: PQBaseViewController {
     // 选择的图片总数
     var selectedImageDataCount: Int = 0
     // 选中的素材数据
-    var selectedPhotoData: [PQEditVisionTrackMaterialsModel]?
+    var selectedPhotoData: [PHAsset]?
     // 选中的音乐数据
     var selectedMusicData: PQVoiceModel?
     /// 缓存数据