瀏覽代碼

1.修改卡点信息

wenweiwei 3 年之前
父節點
當前提交
c9fc62de40

+ 0 - 282
BFFramework/Classes/Base/Controller/PQPhotoAlbumController.swift

@@ -1,282 +0,0 @@
-//
-//  PQPhotoAlbumController.swift
-//  PQSpeed
-//
-//  Created by SanW on 2020/8/31.
-//  Copyright © 2020 BytesFlow. All rights reserved.
-//
-
-import Photos
-import UIKit
-import BFCommonKit
-
-/// 相册集
-open class PQPhotoAlbumController: PQBaseViewController {
-    public  var selectedHandle: ((_ selectedData: PQUploadModel?) -> Void)? // 选中/取消选中的回调
-    public var isTopShow: Bool = false // 是否显示在顶部
-
-    public var categoryH: CGFloat = cDefaultMargin * 26  // 相簿高度
-    public var albaumsData: [PQUploadModel] = Array<PQUploadModel>.init()
-    public let itemSize = CGSize(width: ((cScreenWidth - cDefaultMargin) / 3) * UIScreen.main.scale, height: ((cScreenWidth - cDefaultMargin) / 3) * UIScreen.main.scale)
-    var catagerySelectedIndex: IndexPath = IndexPath(item: 0, section: 0) // 更多图库选择
-    lazy  public var imageManager: PHCachingImageManager = {
-        PHCachingImageManager()
-    }()
-
-    lazy public  var albaumCollectionView: UICollectionView = {
-        let layout = UICollectionViewFlowLayout()
-        layout.sectionInset = UIEdgeInsets.zero
-        layout.itemSize = CGSize(width: view.frame.width, height: cDefaultMargin * 8 )
-        layout.minimumLineSpacing = 0
-        layout.minimumInteritemSpacing = 0
-        let albaumCollectionView = UICollectionView(frame: CGRect(x: 0, y: isTopShow ? 0 : (albaumView.frame.height - categoryH), width: albaumView.frame.width, height: isTopShow ? 0 : categoryH - 300), collectionViewLayout: layout)
-        albaumCollectionView.showsVerticalScrollIndicator = false
-        albaumCollectionView.register(PQAssetCategoryCell.self, forCellWithReuseIdentifier: "PQAssetCategoryCell")
-        albaumCollectionView.delegate = self
-        albaumCollectionView.dataSource = self
-        if #available(iOS 11.0, *) {
-            albaumCollectionView.contentInsetAdjustmentBehavior = .never
-        } else {
-            automaticallyAdjustsScrollViewInsets = false
-        }
-        albaumCollectionView.backgroundColor = UIColor.white
-        return albaumCollectionView
-    }()
-
-    lazy  public var emptyRemindView: PQEmptyRemindView = {
-        let emptyRemindView = PQEmptyRemindView(frame: albaumCollectionView.bounds)
-        emptyRemindView.isHidden = true
-        albaumCollectionView.addSubview(emptyRemindView)
-        emptyRemindView.backgroundColor = PQBFConfig.shared.styleBackGroundColor
-        emptyRemindView.fullRefreshBloc = { [weak self] _, _ in
-            if emptyRemindView.refreshBtn.currentTitle == "授予权限" {
-                openAppSetting()
-            } else if emptyRemindView.refreshBtn.currentTitle == "刷新" {
-                self?.albaumsData.removeAll()
-                self?.loadPhotoData()
-            }
-        }
-        emptyRemindView.remindLab.textColor = UIColor.hexColor(hexadecimal: "#999999")
-        emptyRemindView.refreshBtn.setTitle("授予权限", for: .normal)
-        let anthorEmptyData = PQEmptyModel()
-        anthorEmptyData.title = "挑选相册素材"
-        anthorEmptyData.summary = "要挑选相册素材,请先授予相册使用权限"
-        anthorEmptyData.emptyImage = "icon_authorError"
-        anthorEmptyData.isRefreshHidden = false
-        anthorEmptyData.refreshBgColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)
-        emptyRemindView.emptyData = anthorEmptyData
-        return emptyRemindView
-    }()
-
-    lazy  public var albaumView: UIView = {
-        let albaumView = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height))
-        let ges = UITapGestureRecognizer(target: self, action: #selector(gesTagClick))
-        albaumView.addGestureRecognizer(ges)
-        return albaumView
-    }()
-
-    open override func viewDidLoad() {
-        super.viewDidLoad()
-        
-        // Do any additional setup after loading the view.
-        view.backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.7)
-        hiddenNavigation()
-        loadPhotoData()
-    }
-
-    open override func viewWillAppear(_ animated: Bool) {
-        super.viewWillAppear(animated)
-        PHPhotoLibrary.shared().register(self)
-    }
-
-    open override func viewWillDisappear(_ animated: Bool) {
-        super.viewWillDisappear(animated)
-        PHPhotoLibrary.shared().unregisterChangeObserver(self)
-    }
-}
-
-extension PQPhotoAlbumController {
-    /// 修改view frame
-    /// - Parameter frame: <#frame description#>
-    /// - Returns: <#description#>
-    public func updateViewFrame(frame: CGRect) {
-        view.frame = frame
-        view.isHidden = true
-        view.addSubview(albaumView)
-        view.addSubview(albaumCollectionView)
-    }
-
-    func loadPhotoData() {
-        DispatchQueue.global().async { [weak self] in
-            let allPhotos = PHAsset.fetchAssets(with: creaFetchOptions)
-            if allPhotos.count > 0 {
-                let tempData = PQUploadModel()
-                tempData.title = "全部"
-                tempData.categoryList = allPhotos
-                self?.albaumsData.insert(tempData, at: 0)
-                self?.updateItems(indexPath: IndexPath(item: 0, section: 0))
-            }
-            DispatchQueue.main.async { [weak self] in
-                self?.emptyRemindView.isHidden = allPhotos.count > 0
-            }
-            let smartAlbums = PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .albumRegular, options: nil)
-            smartAlbums.enumerateObjects { [weak self] assCollection, _, _ in
-                if assCollection.localizedTitle != "最近删除" {
-                    self?.convertCollection(collection: assCollection)
-                }
-            }
-            let userCollections = PHCollectionList.fetchTopLevelUserCollections(with: nil)
-            userCollections.enumerateObjects { [weak self] assCollection, index, point in
-                BFLog(message: "userCollections == \(assCollection),index = \(index),point = \(point)")
-                if assCollection is PHAssetCollection {
-                    if assCollection.localizedTitle != "最近删除" {
-                        self?.convertCollection(collection: assCollection as? PHAssetCollection)
-                    }
-                }
-            }
-        }
-    }
-
-    // 转化处理获取到的相簿
-   public func convertCollection(collection: PHAssetCollection?) {
-        if collection == nil {
-            return
-        }
-        DispatchQueue.global().async { [weak self] in
-            var options: PHFetchOptions = creaFetchOptions
-            if collection?.localizedTitle == "最近项目" || collection?.localizedTitle == "最近添加" {
-                options = modiFetchOptions
-            }
-            let assetsFetchResult = PHAsset.fetchAssets(in: collection!, options: options)
-            if assetsFetchResult.count > 0 {
-                let tempData = PQUploadModel()
-                tempData.assetCollection = collection
-                tempData.title = collection?.localizedTitle
-                tempData.categoryList = assetsFetchResult
-                if tempData.categoryList.count > 0 {
-                    if tempData.title == "视频" {
-                        self?.albaumsData.insert(tempData, at: 1)
-                        self?.updateItems(indexPath: IndexPath(item: 1, section: 0))
-                    } else {
-                        self?.albaumsData.append(tempData)
-                        self?.updateItems(indexPath: IndexPath(item: (self?.albaumsData.count ?? 1) - 1, section: 0))
-                    }
-                }
-                BFLog(message: "assetsFetchResult = \(assetsFetchResult)")
-            }
-        }
-    }
-
-    /// 更新数据源
-    /// - Parameter indexPath: <#indexPath description#>
-    /// - Returns: <#description#>
-    public  func updateItems(indexPath _: IndexPath) {
-        DispatchQueue.main.async { [weak self] in
-            self?.albaumCollectionView.reloadData()
-//            UIView.performWithoutAnimation {[weak self] in
-//                self?.albaumCollectionView.performBatchUpdates({
-//                    self?.albaumCollectionView.insertItems(at: [indexPath])
-//                }) {(isSuccess) in
-//
-//                }
-//            }
-        }
-    }
-
-    /// 点击隐藏view
-    /// - Returns: <#description#>
-    @objc  public  func gesTagClick() {
-        if selectedHandle != nil {
-            selectedHandle!(nil)
-        }
-        albaumCollectionView.reloadData()
-        dismissCategoryView()
-    }
-
-    @objc  public func dismissCategoryView() {
-        if isTopShow {
-            UIView.animate(withDuration: 0.3, animations: {
-                self.albaumCollectionView.frame = CGRect(x: 0, y: 0, width: cScreenWidth, height: 0)
-                self.albaumView.alpha = 0
-            }) { _ in
-                self.albaumView.isHidden = true
-                self.view.isHidden = true
-            }
-        } else {
-            albaumCollectionView.dismissViewAnimate { [weak self] _ in
-                self?.view.isHidden = true
-            }
-        }
-    }
-
-    @objc  public func showCategoryView() {
-        if isTopShow {
-            view.isHidden = false
-            albaumView.isHidden = false
-            albaumView.alpha = 0
-//            view.bringSubviewToFront(albaumView)
-            UIView.animate(withDuration: 0.3, animations: {
-                self.albaumCollectionView.frame = CGRect(x: 0, y: 0, width: cScreenWidth, height: self.categoryH)
-                self.albaumView.alpha = 1
-            }) { _ in
-            }
-            albaumCollectionView.reloadData()
-        } else {
-            view.isHidden = false
-            albaumCollectionView.showViewAnimate()
-        }
-    }
-}
-
-extension PQPhotoAlbumController: UICollectionViewDelegate, UICollectionViewDataSource, UIScrollViewDelegate {
-    public func collectionView(_: UICollectionView, numberOfItemsInSection _: Int) -> Int {
-        return albaumsData.count
-    }
-
-    public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
-        let cell = PQAssetCategoryCell.assetCategoryCell(collectionView: collectionView, indexPath: indexPath)
-        let itemData = albaumsData[indexPath.item]
-        let asset = itemData.categoryList.object(at: 0)
-        cell.representedAssetIdentifier = asset.localIdentifier
-        if itemData.image == nil {
-            imageManager.requestImage(for: asset, targetSize: itemSize, contentMode: .aspectFill, options: nil) { image, info in
-                if info?.keys.contains("PHImageResultIsDegradedKey") ?? false, "\(info?["PHImageResultIsDegradedKey"] ?? "0")" == "0", cell.representedAssetIdentifier == asset.localIdentifier {
-                    itemData.image = image
-                    cell.uploadData = itemData
-                }
-            }
-        } else {
-            cell.uploadData = itemData
-        }
-        cell.isSelected = indexPath == catagerySelectedIndex
-        return cell
-    }
-
-    public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
-        if selectedHandle != nil {
-            selectedHandle!(albaumsData[indexPath.item])
-        }
-        catagerySelectedIndex = indexPath
-        collectionView.reloadData()
-        dismissCategoryView()
-    }
-
-    public func scrollViewDidScroll(_ scrollView: UIScrollView) {
-        if (!isTopShow && (scrollView.contentOffset.y < -cDefaultMargin * 7)) || (isTopShow && scrollView.contentOffset.y > ((scrollView.contentSize.height - scrollView.frame.height) + cDefaultMargin * 10)) {
-            if selectedHandle != nil {
-                selectedHandle!(nil)
-            }
-            dismissCategoryView()
-        }
-    }
-}
-
-extension PQPhotoAlbumController: PHPhotoLibraryChangeObserver {
-    public func photoLibraryDidChange(_: PHChange) {
-        DispatchQueue.main.sync {
-            // Check each of the three top-level fetches for changes.
-            albaumsData.removeAll()
-            loadPhotoData()
-        }
-    }
-}

+ 0 - 566
BFFramework/Classes/Base/Controller/PQPhotoMaterialController.swift

@@ -1,566 +0,0 @@
-//
-//  PQPhotoMaterialController.swift
-//  PQSpeed
-//
-//  Created by SanW on 2021/4/26.
-//  Copyright © 2021 BytesFlow. All rights reserved.
-//
-
-import Photos
-import UIKit
-import BFCommonKit
-
-class PQPhotoMaterialController: PQBaseViewController {
-    // 是否显示素材标识
-    var isShowMediaTag: Bool = true
-    // 是否是已经添加过的素材
-    var isAdded: Bool = false
-    // 默认图片时长
-    var imageDuration: Float64 = 2.0
-    // 已选图片时长
-    var selectedImageDataCount: Int = 0
-    var itemSpacing: CGFloat = cDefaultMargin / 2 // 间隔
-    var itemSize = CGSize(width: (cScreenWidth - cDefaultMargin) / 3, height: (cScreenWidth - cDefaultMargin) / 3) // cell 大小
-    var previousPreheatRect = CGRect.zero
-
-    var allPhotos: PHFetchResult<PHAsset> = PHFetchResult<PHAsset>.init() // 所有的图片
-    var photoData: [PQEditVisionTrackMaterialsModel] = Array<PQEditVisionTrackMaterialsModel>.init() // 相册数据
-    // 选中的相册数据
-    var selectedPhotoData: [PQEditVisionTrackMaterialsModel] = Array<PQEditVisionTrackMaterialsModel>.init()
-    // 选中的总时长
-    var selectedTotalDuration: Float64 = 0
-
-    var selectedMaterialHandle: ((_ currentMaterialData: PQEditVisionTrackMaterialsModel?, _ selectedPhotoData: [PQEditVisionTrackMaterialsModel], _ selectedTotalDuration: Float64, _ imageCount: Int) -> Void)? // 选中/取消选中的回调
-    var detailMaterialHandle: ((_ indexPath: IndexPath, _ currentMaterialData: PQEditVisionTrackMaterialsModel?) -> Void)? // 点击详情
-    /// 滑动的回调
-    var scrollViewDidScroll: ((_ contentOffset: CGPoint) -> Void)?
-    /// 空白页面点击的回调
-    var emptyRefreshHandle: ((_ msgType: material_msgType) -> Void)?
-    var msgType: material_msgType = .all { // 默认类型
-        didSet {
-            photoData.removeAll()
-            allPhotos = PHFetchResult<PHAsset>.init()
-            photoCollectionView.setContentOffset(CGPoint.zero, animated: false)
-            photoCollectionView.reloadData()
-            loadLocalData()
-        }
-    }
-
-    var assetCollection: PHAssetCollection? // 相簿
-    lazy var imageManager: PHCachingImageManager = { // 图库缓存管理
-        (PHCachingImageManager.default() as? PHCachingImageManager) ?? PHCachingImageManager()
-    }()
-
-    lazy var photoFlowLayout: UICollectionViewFlowLayout = {
-        let photoFlowLayout = UICollectionViewFlowLayout()
-        photoFlowLayout.sectionInset = UIEdgeInsets.zero
-        photoFlowLayout.minimumLineSpacing = itemSpacing
-        photoFlowLayout.minimumInteritemSpacing = itemSpacing
-        photoFlowLayout.scrollDirection = .vertical
-        photoFlowLayout.itemSize = itemSize
-        return photoFlowLayout
-    }()
-
-    lazy var photoCollectionView: UICollectionView = {
-        let photoCollectionView = UICollectionView(frame: CGRect(x: itemSpacing, y: 0, width: view.frame.width, height: view.frame.height), collectionViewLayout: photoFlowLayout)
-        photoCollectionView.register(PQChoseMaterialCell.self, forCellWithReuseIdentifier: String(describing: PQChoseMaterialCell.self))
-        photoCollectionView.showsVerticalScrollIndicator = false
-        photoCollectionView.showsHorizontalScrollIndicator = false
-        photoCollectionView.delegate = self
-        photoCollectionView.dataSource = self
-        photoCollectionView.backgroundColor = UIColor.clear
-        if #available(iOS 11.0, *) {
-            photoCollectionView.contentInsetAdjustmentBehavior = .never
-        } else {
-            automaticallyAdjustsScrollViewInsets = false
-        }
-        return photoCollectionView
-    }()
-
-    var anthorEmptyData: PQEmptyModel = {
-        let anthorEmptyData = PQEmptyModel()
-        anthorEmptyData.title = "挑选相册素材"
-        anthorEmptyData.summary = "要挑选相册素材,请先授予相册使用权限"
-        anthorEmptyData.emptyImage = "icon_authorError"
-        anthorEmptyData.isRefreshHidden = false
-        anthorEmptyData.refreshBgColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)
-        return anthorEmptyData
-    }()
-
-    var emptyData: PQEmptyModel = {
-        let emptyData = PQEmptyModel()
-        emptyData.title = "此相册中什么都没有"
-        emptyData.isRefreshHidden = false
-        emptyData.refreshTitle = NSMutableAttributedString(string: "刷新")
-        emptyData.refreshBgColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)
-        emptyData.emptyImage = "material_empty"
-        return emptyData
-    }()
-
-    lazy var emptyRemindView: PQEmptyRemindView = {
-        let emptyRemindView = PQEmptyRemindView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height))
-        emptyRemindView.isHidden = true
-        photoCollectionView.addSubview(emptyRemindView)
-        emptyRemindView.backgroundColor = PQBFConfig.shared.styleBackGroundColor
-        emptyRemindView.fullRefreshBloc = { [weak self] _, _ in
-            if emptyRemindView.refreshBtn.currentTitle == "授予权限" {
-                openAppSetting()
-            } else if emptyRemindView.refreshBtn.currentAttributedTitle == NSMutableAttributedString(string: "刷新") {
-                self?.loadLocalData()
-            } else if self?.emptyRefreshHandle != nil {
-                self?.emptyRefreshHandle!(self?.msgType ?? .all)
-            }
-        }
-        emptyRemindView.remindLab.textColor = UIColor.hexColor(hexadecimal: "#999999")
-        emptyRemindView.refreshBtn.addCorner(corner: 4)
-        return emptyRemindView
-    }()
-
-    override func viewDidLoad() {
-        super.viewDidLoad()
-        view.addSubview(photoCollectionView)
-        hiddenNavigation()
-        view.backgroundColor = PQBFConfig.shared.styleBackGroundColor
-    }
-
-    /// <#Description#>
-    /// - Returns: <#description#>
-    func loadLocalData() {
-        let authStatus = PHPhotoLibrary.authorizationStatus()
-        if authStatus == .notDetermined {
-            // 第一次触发授权 alert
-            PHPhotoLibrary.requestAuthorization { [weak self] (status: PHAuthorizationStatus) -> Void in
-                if status == .authorized {
-                    if (self?.allPhotos == nil) || (self?.allPhotos.count ?? 0) <= 0 {
-                        self?.loadPhotoData()
-                    }
-                }
-                DispatchQueue.main.async { [weak self] in
-                    self?.showEmpthView()
-                }
-            }
-        } else if authStatus == .authorized {
-            BFLog(message: "授权成功,开始请求相册数据-\(allPhotos)")
-//            if allPhotos.count <= 0 {
-            loadPhotoData()
-//            }
-        } else {
-            showEmpthView()
-        }
-        PHPhotoLibrary.shared().register(self)
-    }
-
-    /// 加载图库数据
-    /// - Returns: <#description#>
-    func loadPhotoData() {
-        DispatchQueue.main.async { [weak self] in
-            PQLoadingHUB.shared.showHUB(superView: self!.view, isVerticality: false)
-        }
-        DispatchQueue.global().async { [weak self] in
-            self?.allPhotos = self?.assetCollection != nil ? PHAsset.fetchAssets(in: (self?.assetCollection)!, options: self?.fetchOptions()) : PHAsset.fetchAssets(with: self?.fetchOptions())
-            DispatchQueue.main.async { [weak self] in
-                if self?.view != nil {
-                    PQLoadingHUB.shared.dismissHUB(superView: self!.view)
-                }
-                self?.photoCollectionView.reloadData()
-                self?.showEmpthView()
-//                self?.updateCachedAssets()
-            }
-        }
-    }
-
-    /// 获取option
-    /// - Returns: <#description#>
-    func fetchOptions() -> PHFetchOptions {
-        if msgType != .all {
-            let fetchOptions = PHFetchOptions()
-            fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
-            fetchOptions.predicate = NSPredicate(format: "mediaType = %d", msgType == .video ? PHAssetMediaType.video.rawValue : PHAssetMediaType.image.rawValue)
-            return fetchOptions
-        } else {
-            return creaFetchOptions
-        }
-    }
-
-    /// 展示空页面
-    func showEmpthView() {
-        emptyRemindView.isHidden = allPhotos.count > 0
-        if !emptyRemindView.isHidden {
-            let authStatus = PHPhotoLibrary.authorizationStatus()
-            if authStatus == .denied {
-                emptyRemindView.emptyData = anthorEmptyData
-                emptyRemindView.refreshBtn.setTitle("授予权限", for: .normal)
-            } else {
-                switch msgType {
-                case .video:
-                    emptyData.title = "此相册中没有视频"
-                    emptyData.emptyImage = "stuckPoint_video_empty"
-                    emptyData.refreshTitle = NSMutableAttributedString(string: "去选照片")
-                case .image:
-                    emptyData.title = "此相册中没有照片"
-                    emptyData.emptyImage = "stuckPoint_image_empty"
-                    emptyData.refreshTitle = NSMutableAttributedString(string: "去选视频")
-                default:
-                    emptyData.title = "此相册中什么都没有"
-                    emptyData.emptyImage = "material_empty"
-                    emptyData.refreshTitle = NSMutableAttributedString(string: "刷新")
-                }
-                emptyData.summary = nil
-                emptyRemindView.emptyData = emptyData
-            }
-        }
-    }
-
-    /// 更新frame
-    /// - Parameter newFrame: <#newFrame description#>
-    /// - Returns: <#description#>
-    func updateFrame(newFrame: CGRect, isAnimate: Bool = false, isScroll _: Bool = false) {
-        if isAnimate {
-            UIView.animate(withDuration: 0.5, delay: 0, options: .allowUserInteraction) { [weak self] in
-                // 调整位置
-                self?.view.frame = newFrame
-                self?.photoCollectionView.frame = self?.view.bounds ?? CGRect.zero
-                self?.emptyRemindView.frame = self?.photoCollectionView.bounds ?? CGRect.zero
-            } completion: { _ in
-            }
-        } else {
-            view.frame = newFrame
-            photoCollectionView.frame = view.bounds
-            emptyRemindView.frame = photoCollectionView.bounds
-        }
-    }
-}
-
-extension PQPhotoMaterialController: UICollectionViewDelegate, UICollectionViewDataSource, UIScrollViewDelegate {
-    func collectionView(_: UICollectionView, numberOfItemsInSection _: Int) -> Int {
-        return allPhotos.count
-    }
-
-    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
-        let cell = PQChoseMaterialCell.choseMaterialCell(collectionView: collectionView, indexPath: indexPath)
-        cell.isShowMediaTag = isShowMediaTag
-        cell.isAdded = isAdded
-        if photoData.count <= indexPath.item {
-            let itemData: PQEditVisionTrackMaterialsModel!
-            let asset = allPhotos.object(at: indexPath.item)
-            let selectedItem = selectedPhotoData.first { (item) -> Bool in
-                item.asset == asset
-            }
-            if selectedItem != nil {
-                itemData = selectedItem
-            } else {
-                itemData = PQEditVisionTrackMaterialsModel()
-                itemData.downloadState = .compelte
-                itemData.asset = asset
-                itemData.height = Float(itemData.asset?.pixelHeight ?? 0)
-                itemData.width = Float(itemData.asset?.pixelWidth ?? 0)
-                itemData.type = asset.mediaType == .image ? StickerType.IMAGE.rawValue : StickerType.VIDEO.rawValue
-                itemData.volumeGain = asset.mediaType == .image ? 0 : 100
-                itemData.duration = asset.mediaType == .image ? imageDuration : asset.duration
-                itemData.out = itemData.duration
-            }
-            photoData.append(itemData)
-        }
-        if photoData.count > indexPath.item {
-            let itemData = photoData[indexPath.item]
-            cell.materialData = itemData
-            cell.representedAssetIdentifier = itemData.asset?.localIdentifier
-            if itemData.coverImageUI == nil, itemData.asset != nil {
-                imageManager.requestImage(for: itemData.asset!, targetSize: itemSize, contentMode: .aspectFill, options: nil) { image, info in
-                    if info?.keys.contains("PHImageResultIsDegradedKey") ?? false, "\(info?["PHImageResultIsDegradedKey"] ?? "0")" == "0", cell.representedAssetIdentifier == itemData.asset?.localIdentifier {
-                        if image != nil {
-                            itemData.coverImageUI = image
-                            cell.materialImageView.image = image
-                        } else if image == nil, info?.keys.contains("PHImageResultIsInCloudKey") ?? false {
-                            let option = PHImageRequestOptions()
-                            option.isNetworkAccessAllowed = true
-                            option.resizeMode = .fast
-                            self.imageManager.requestImageData(for: itemData.asset!, options: option) { data, _, _, _ in
-                                if data != nil {
-                                    let image = UIImage(data: data!)
-                                    itemData.coverImageUI = image
-                                    cell.materialImageView.image = image
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        } else {
-            cell.materialData = PQEditVisionTrackMaterialsModel()
-        }
-        cell.materialClicHandle = { [weak self] _, materialData in
-            if (self?.photoData.count ?? 0) > indexPath.item {
-                // 处理相册选择
-                self?.dealWithSelectedMaterial(indexPath: indexPath, materialData: materialData)
-            } else {
-//                collectionView.reloadData()
-            }
-        }
-        return cell
-    }
-
-    func collectionView(_: UICollectionView, didSelectItemAt indexPath: IndexPath) {
-        if photoData.count <= indexPath.item {
-//            collectionView.reloadData()
-            return
-        }
-        if detailMaterialHandle != nil {
-            detailMaterialHandle!(indexPath, photoData[indexPath.item])
-        }
-    }
-
-    func collectionView(_: UICollectionView, willDisplay _: UICollectionViewCell, forItemAt _: IndexPath) {
-        if !isAdded, !isShowMediaTag {
-//            // 卡点音乐素材选择曝光上报
-//            PQEventTrackViewModel.baseReportUpload(businessType: .bt_windowView, objectType: .ot_view_selectSyncedUpMaterial, pageSource: .sp_stuck_selectMaterial, extParams: nil, remindmsg: "卡点音乐素材选择曝光上报")
-        }
-    }
-
-    /// 点击选择的回调
-    /// - Parameter materialData: <#materialData description#>
-    /// - Returns: description
-    func dealWithSelectedMaterial(indexPath: IndexPath?, materialData: PQEditVisionTrackMaterialsModel?) {
-        let ratio = (materialData?.width ?? 0) / (materialData?.height ?? 1)
-        if ratio < 0.4 || ratio > 4.2 {
-            cShowHUB(superView: nil, msg: "暂不支持该比例的素材")
-            return
-        }
-        if materialData != nil, indexPath != nil {
-            materialData?.isSelected = !(materialData?.isSelected ?? false)
-            if materialData?.isSelected ?? false {
-                selectedPhotoData.append(materialData!)
-                if materialData?.type == StickerType.IMAGE.rawValue {
-                    selectedImageDataCount = selectedImageDataCount + 1
-                }
-                materialData?.selectedIndex = selectedPhotoData.count
-                if materialData?.asset != nil && materialData?.asset?.mediaType != .video && (materialData?.coverImageUI == nil || (materialData?.locationPath.count ?? 0) <= 0) {
-                    PQPHAssetVideoParaseUtil.requestAssetOringinImage(asset: (materialData?.asset)!) { [weak self] _, data, image, _ in
-                        if image == nil {
-                            BFLog(message: "图片数据为空!!!!!")
-                        }
-                        // 1,图片,gif的原文件数据,和视频的封面
-                        var newImage: UIImage?
-                        if image != nil {
-                            newImage = UIImage.nx_fixOrientation(image, isFront: false).nx_scaleWithMaxLength(maxLength: 1920)
-                        }
-                        materialData?.coverImageUI = newImage
-                        materialData?.originalData = data
-                        let timeInterval: TimeInterval = Date().timeIntervalSince1970
-                        let imageCacheName = "images_\(timeInterval)"
-                        let imageCachePath = downloadImagesDirectory + imageCacheName
-                        if !directoryIsExists(dicPath: downloadImagesDirectory) {
-                            BFLog(message: "文件夹不存在 \(downloadImagesDirectory)")
-                            createDirectory(path: downloadImagesDirectory)
-                        }
-                        // 创建目录
-                        if newImage != nil {
-                            try? newImage?.pngData()?.write(to: URL(fileURLWithPath: imageCachePath))
-                        } else {
-                            try? data?.write(to: URL(fileURLWithPath: imageCachePath))
-                        }
-                        if materialData?.asset?.mediaType != .video, newImage != nil || data != nil {
-                            materialData?.locationPath = imageCachePath.replacingOccurrences(of: documensDirectory, with: "")
-                        }
-                        materialData?.width = Float(materialData?.asset?.pixelWidth ?? 0)
-                        materialData?.height = Float(materialData?.asset?.pixelHeight ?? 0)
-                        if self?.selectedMaterialHandle != nil {
-                            self?.selectedTotalDuration = (self?.selectedTotalDuration ?? 0) + (materialData?.duration ?? 0.0)
-                            if indexPath != nil {
-                                self?.photoCollectionView.reloadItems(at: [indexPath!])
-                            }
-                            // 处理已选择的数据
-                            self?.dealWithSelectedData(materialData: materialData)
-                        }
-                    }
-                } else {
-                    selectedTotalDuration = selectedTotalDuration + (materialData?.duration ?? 0.0)
-                    if indexPath != nil {
-                        photoCollectionView.reloadItems(at: [indexPath!])
-                    }
-                    // 处理已选择的数据
-                    dealWithSelectedData(materialData: materialData)
-                }
-            } else {
-                // 处理取消选择数据
-                deSeletedMaterialData(materialData: materialData)
-            }
-        }
-    }
-
-    /// 处理取消选择数据
-    /// - Parameter materialData: <#materialData description#>
-    /// - Returns: <#description#>
-    func deSeletedMaterialData(materialData: PQEditVisionTrackMaterialsModel?) {
-        selectedPhotoData.removeAll(where: { (item) -> Bool in
-            item.asset == materialData?.asset
-        })
-        for item in photoData {
-            if item.isSelected, item.selectedIndex > (materialData?.selectedIndex ?? 1) {
-                item.selectedIndex = item.selectedIndex - 1
-            }
-        }
-        if materialData?.type == StickerType.IMAGE.rawValue {
-            selectedImageDataCount = selectedImageDataCount - 1
-        }
-        selectedTotalDuration = selectedTotalDuration - (materialData?.duration ?? 0.0)
-        photoCollectionView.reloadData()
-        // 处理已选择的数据
-        dealWithSelectedData(materialData: materialData)
-    }
-
-    /// 处理已选择的数据
-    /// - Parameters:
-    ///   - indexPath: <#indexPath description#>
-    ///   - materialData: <#materialData description#>
-    /// - Returns: <#description#>
-    func dealWithSelectedData(materialData: PQEditVisionTrackMaterialsModel?) {
-//        if materialData?.asset != nil && materialData?.asset?.mediaType == .video && (materialData?.locationPath == nil || (materialData?.locationPath.count ?? 0) <= 0) {
-//            PQPHAssetVideoParaseUtil.parasToAVAsset(phAsset: (materialData?.asset)!) { [weak self] avAsset, _, _, _ in
-//                if avAsset is AVURLAsset {
-//                    materialData?.locationPath = (avAsset as? AVURLAsset)?.url.absoluteString.replacingOccurrences(of: "file:///", with: "") ?? ""
-//                    if self?.selectedMaterialHandle != nil {
-//                        DispatchQueue.main.async {
-//                            self?.selectedMaterialHandle!(materialData, self?.selectedPhotoData ?? [], self?.selectedTotalDuration ?? 0)
-//                        }
-//                    }
-//                } else if self?.selectedMaterialHandle != nil {
-//                    DispatchQueue.main.async {
-//                        self?.selectedMaterialHandle!(materialData, self?.selectedPhotoData ?? [], self?.selectedTotalDuration ?? 0)
-//                    }
-//                }
-//            }
-//        } else
-        if selectedMaterialHandle != nil {
-            selectedMaterialHandle!(materialData, selectedPhotoData, selectedTotalDuration, selectedImageDataCount)
-        }
-    }
-
-    /// <#Description#>
-    /// - Parameter scrollView: <#scrollView description#>
-    func scrollViewDidScroll(_ scrollView: UIScrollView) {
-        if scrollViewDidScroll != nil {
-            scrollViewDidScroll!(scrollView.contentOffset)
-        }
-    }
-
-    /// 更新数据
-    /// - Parameter isMaterialSelected:
-    /// - Parameter materialData: <#materialData description#>
-    /// - Returns: <#description#>
-    func updateMaterials(isSelected: Bool, materialData: PQEditVisionTrackMaterialsModel?) {
-        let photoIndexPath = selectedPhotoData.firstIndex { (item) -> Bool in
-            materialData?.asset == item.asset
-        }
-        materialData?.isSelected = isSelected
-        if isSelected {
-            if photoIndexPath == nil {
-                selectedPhotoData.append(materialData!)
-            }
-            materialData?.selectedIndex = selectedPhotoData.count
-            selectedTotalDuration = selectedTotalDuration + (materialData?.duration ?? 0.0)
-        } else if photoIndexPath != nil {
-            selectedPhotoData.remove(at: photoIndexPath ?? 0)
-            for item in selectedPhotoData {
-                if item.isSelected, item.selectedIndex > (materialData?.selectedIndex ?? 1) {
-                    item.selectedIndex = item.selectedIndex - 1
-                }
-            }
-            selectedTotalDuration = selectedTotalDuration - (materialData?.duration ?? 0.0)
-        }
-        photoCollectionView.reloadData()
-        if selectedMaterialHandle != nil {
-            selectedMaterialHandle!(materialData, selectedPhotoData, selectedTotalDuration, selectedImageDataCount)
-        }
-    }
-}
-
-extension PQPhotoMaterialController: PHPhotoLibraryChangeObserver {
-    func photoLibraryDidChange(_ changeInstance: PHChange) {
-        DispatchQueue.main.sync {
-            // Check each of the three top-level fetches for changes.
-            guard let collectionChanges = changeInstance.changeDetails(for: allPhotos)
-            else {
-                return
-            }
-            if !collectionChanges.hasIncrementalChanges || collectionChanges.hasMoves {
-                return
-            }
-            // Update the cached fetch result.
-            allPhotos = collectionChanges.fetchResultAfterChanges
-            photoData.removeAll()
-            photoCollectionView.reloadData()
-//            photoCollectionView.setContentOffset(CGPoint.zero, animated: false)
-        }
-    }
-
-    private func resetCachedAssets() {
-        imageManager.stopCachingImagesForAllAssets()
-        previousPreheatRect = .zero
-    }
-
-    private func updateCachedAssets() {
-        if allPhotos.count <= 0 {
-            return
-        }
-        guard isViewLoaded, view.window != nil else { return }
-        let visibleRect = CGRect(origin: photoCollectionView.contentOffset, size: photoCollectionView.bounds.size)
-        let preheatRect = visibleRect.insetBy(dx: 0, dy: -0.5 * visibleRect.height)
-        let delta = abs(preheatRect.midY - previousPreheatRect.midY)
-        guard delta > view.bounds.height / 3 else { return }
-        let (addedRects, removedRects) = differencesBetweenRects(previousPreheatRect, preheatRect)
-        let addedAssets: [PHAsset]? = addedRects
-            .flatMap { rect in photoCollectionView.indexPathsForElements(in: rect) }
-            .map { indexPath in
-                if indexPath.item < allPhotos.count {
-                    return allPhotos.object(at: indexPath.item)
-                } else {
-                    return PHAsset()
-                }
-            }
-        let removedAssets: [PHAsset]? = removedRects
-            .flatMap { rect in photoCollectionView.indexPathsForElements(in: rect) }
-            .map { indexPath in
-                if indexPath.item < allPhotos.count {
-                    return allPhotos.object(at: indexPath.item)
-                } else {
-                    return PHAsset()
-                }
-            }
-        if addedAssets != nil, (addedAssets?.count ?? 0) > 0 {
-            imageManager.startCachingImages(for: addedAssets!,
-                                            targetSize: itemSize, contentMode: .aspectFill, options: nil)
-        }
-        if removedAssets != nil, (removedAssets?.count ?? 0) > 0 {
-            imageManager.stopCachingImages(for: removedAssets!,
-                                           targetSize: itemSize, contentMode: .aspectFill, options: nil)
-        }
-        previousPreheatRect = preheatRect
-    }
-
-    private func differencesBetweenRects(_ old: CGRect, _ new: CGRect) -> (added: [CGRect], removed: [CGRect]) {
-        if old.intersects(new) {
-            var added = [CGRect]()
-            if new.maxY > old.maxY {
-                added += [CGRect(x: new.origin.x, y: old.maxY,
-                                 width: new.width, height: new.maxY - old.maxY)]
-            }
-            if old.minY > new.minY {
-                added += [CGRect(x: new.origin.x, y: new.minY,
-                                 width: new.width, height: old.minY - new.minY)]
-            }
-            var removed = [CGRect]()
-            if new.maxY < old.maxY {
-                removed += [CGRect(x: new.origin.x, y: new.maxY,
-                                   width: new.width, height: old.maxY - new.maxY)]
-            }
-            if old.minY < new.minY {
-                removed += [CGRect(x: new.origin.x, y: old.minY,
-                                   width: new.width, height: new.minY - old.minY)]
-            }
-            return (added, removed)
-        } else {
-            return ([new], [old])
-        }
-    }
-}

+ 0 - 255
BFFramework/Classes/Base/View/PQChoseMaterialCell.swift

@@ -1,255 +0,0 @@
-//
-//  PQPQChoseMaterialCell.swift
-//  PQSpeed
-//
-//  Created by SanW on 2020/8/28.
-//  Copyright © 2020 BytesFlow. All rights reserved.
-//
-
-import Kingfisher
-import UIKit
-import Photos
-import BFCommonKit
-
-public class PQChoseMaterialCell: UICollectionViewCell {
-    // 是否显示素材标识
-    public var isShowMediaTag: Bool = true
-    // 是否是已经添加过的
-    public var isAdded: Bool = false
-    public var representedAssetIdentifier: String!
-    public var materialClicHandle: ((_ sender: UIButton, _ materialData: PQEditVisionTrackMaterialsModel?) -> Void)?
-
-    lazy public var materialImageView: AnimatedImageView = {
-        let materialImageView = AnimatedImageView()
-        materialImageView.contentMode = .scaleAspectFill
-        materialImageView.isUserInteractionEnabled = true
-        materialImageView.clipsToBounds = true
-        return materialImageView
-    }()
-
-    lazy public var borderView: UIView = {
-        let borderView = UIView()
-        borderView.layer.borderColor = UIColor.hexColor(hexadecimal: "#333333").cgColor
-        borderView.layer.borderWidth = 1.5
-        return borderView
-    }()
-
-    lazy public var statusLab: UILabel = {
-        let statusLab = UILabel()
-        statusLab.textColor = UIColor.white
-        statusLab.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.7)
-        statusLab.font = UIFont.systemFont(ofSize: 11)
-        statusLab.text = "GIF"
-        statusLab.addCorner(corner: 3)
-        return statusLab
-    }()
-
-    lazy public var videoStatuImageView: UIImageView = {
-        let videoStatuImageView = UIImageView(image:UIImage.moduleImage(named: "allPreview", moduleName: "BFFramework",isAssets: false))
-        return videoStatuImageView
-    }()
-
-    lazy public var videoLoadingView: AnimatedImageView = {
-        let videoLoadingView = AnimatedImageView()
-        videoLoadingView.kf.setImage(with: URL(fileURLWithPath:  (Bundle.current(moduleName: "BFFramework",isAssets: false)?.path(forResource: "material_loading", ofType: ".gif")!) ?? ""))
-        videoLoadingView.stopAnimating()
-        return videoLoadingView
-    }()
-    
-    lazy public var choseContentView: UIView = {
-        let choseContentView = UIView()
-        let ges = UITapGestureRecognizer(target: self, action: #selector(choseTap(ges:)))
-        choseContentView.addGestureRecognizer(ges)
-//        choseContentView.backgroundColor = UIColor.hexColor(hexadecimal: "#FF0000")
-        return choseContentView
-    }()
-
-    lazy public var choseBtn: UIButton = {
-        let choseBtn = UIButton(type: .custom)
-        choseBtn.setBackgroundImage(UIImage.moduleImage(named: "videomk_chose_nomal", moduleName: "BFFramework",isAssets: false), for: .normal)
-        choseBtn.setBackgroundImage(UIImage.moduleImage(named: "videomk_chose_selected", moduleName: "BFFramework",isAssets: false)?.withRenderingMode(.alwaysTemplate), for: .selected)
-        choseBtn.tintColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)
-        choseBtn.setTitleColor(UIColor.white, for: .normal)
-        choseBtn.titleLabel?.font = UIFont.systemFont(ofSize: 12)
-        choseBtn.tag = 1
-        choseBtn.addCorner(corner: 15)
-        choseBtn.isUserInteractionEnabled = false
-        return choseBtn
-    }()
-
-    /// 删除按钮
-    lazy public var deleteBtn: UIButton = {
-        let deleteBtn = UIButton(type: .custom)
-        deleteBtn.tintColor = PQBFConfig.shared.styleBackGroundColor
-        deleteBtn.setImage(PQBFConfig.shared.materialDeleteImage, for: .normal)
-        deleteBtn.tag = 2
-        deleteBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
-        deleteBtn.isHidden = !isAdded
-        return deleteBtn
-    }()
-
-    @objc class public func choseMaterialCell(collectionView: UICollectionView, indexPath: IndexPath) -> PQChoseMaterialCell {
-        let cell: PQChoseMaterialCell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: PQChoseMaterialCell.self), for: indexPath) as! PQChoseMaterialCell
-        return cell
-    }
-
-    override public init(frame: CGRect) {
-        super.init(frame: frame)
-        contentView.addSubview(borderView)
-        contentView.addSubview(materialImageView)
-        contentView.addSubview(deleteBtn)
-        materialImageView.addSubview(videoStatuImageView)
-        materialImageView.addSubview(choseContentView)
-        choseContentView.addSubview(choseBtn)
-        materialImageView.addSubview(statusLab)
-        materialImageView.addSubview(videoLoadingView)
-    }
-
-    required public  init?(coder _: NSCoder) {
-        fatalError("init(coder:) has not been implemented")
-    }
-
-    public  var materialData: PQEditVisionTrackMaterialsModel? {
-        didSet {
-            addData()
-            addLayout()
-        }
-    }
-
-    public func addData() {
-        if materialData?.coverImageUI != nil {
-            materialImageView.image = materialData?.coverImageUI
-        } else if materialData?.asset != nil{
-//            DispatchQueue.global().async {[weak self] in
-//                (PHCachingImageManager.default() as? PHCachingImageManager)?.requestImage(for: (self?.materialData?.asset)!, targetSize: photoItemSize, contentMode: .aspectFill, options: nil) {[weak self] image, info in
-//                    if info?.keys.contains("PHImageResultIsDegradedKey") ?? false, "\(info?["PHImageResultIsDegradedKey"] ?? "0")" == "0", self?.representedAssetIdentifier == self?.materialData?.asset?.localIdentifier {
-//                        if image != nil {
-//                            self?.materialData?.coverImageUI = image
-//                            DispatchQueue.main.async {[weak self] in
-//                                self?.materialImageView.image = image
-//                            }
-//                        } else if image == nil, info?.keys.contains("PHImageResultIsInCloudKey") ?? false {
-//                            let option = PHImageRequestOptions()
-//                            option.isNetworkAccessAllowed = true
-//                            option.resizeMode = .fast
-//                            (PHCachingImageManager.default() as? PHCachingImageManager)?.requestImageData(for: (self?.materialData?.asset)!, options: option) { data, _, _, _ in
-//                                if data != nil, self?.representedAssetIdentifier == self?.materialData?.asset?.localIdentifier {
-//                                    let image = UIImage(data: data!)
-//                                    self?.materialData?.coverImageUI = image
-//                                    DispatchQueue.main.async {[weak self] in
-//                                        self?.materialImageView.image = image
-//                                    }
-//                                }
-//                            }
-//                        }
-//                    }
-//                }
-//            }
-        }else if(materialData?.netResCoverImageURL != nil){
-            materialImageView.setNetImage(url: materialData?.netResCoverImageURL ?? "")
-        }
-
-        if materialData?.type == StickerType.VIDEO.rawValue {
-            var duration = (materialData?.duration ?? 0.0)
-            if duration < 1 {
-                duration = 1
-            }
-            statusLab.text = "  \(Float64(duration).formatDurationToHMS())  "
-            statusLab.isHidden = false
-        } else if materialData?.type == StickerType.GIF.rawValue {
-            statusLab.text = "  GIF  "
-            statusLab.isHidden = false
-        } else {
-            statusLab.text = nil
-            statusLab.isHidden = true
-        }
-        videoStatuImageView.isHidden = !isShowMediaTag || materialData?.type != StickerType.VIDEO.rawValue
-        choseContentView.isHidden = isAdded
-        deleteBtn.isHidden = !isAdded
-        if !isAdded {
-            choseBtn.isSelected = materialData?.isSelected ?? false
-            if materialData?.isSelected ?? false {
-                choseBtn.setTitle("\(materialData?.selectedIndex ?? 1)", for: .normal)
-            } else {
-                choseBtn.setTitle(nil, for: .normal)
-            }
-        }else{
-            materialImageView.contentMode = .scaleAspectFit
-            materialImageView.backgroundColor = UIColor.hexColor(hexadecimal: "#0F0F14")
-        }
-        videoLoadingView.isHidden = !(!isAdded && materialData?.type == StickerType.VIDEO.rawValue && materialData?.isSelected == true && materialData?.downloadState == .downloading)
-        if videoLoadingView.isHidden {
-            videoLoadingView.stopAnimating()
-        } else {
-            videoLoadingView.startAnimating()
-        }
-        BFLog(message: "导出视频 = \(videoLoadingView.isHidden),asset = \(String(describing: materialData?.asset)),downloadState = \(String(describing: materialData?.downloadState))")
-//        if videoLoadingView.isHidden {
-//            videoLoadingView.stopAnimating()
-//            videoLoadingView.layer.removeAllAnimations()
-//        } else {
-//            videoLoadingView.stopAnimating()
-//            videoLoadingView.layer.removeAllAnimations()
-//            videoLoadingView.showLoadingAnimation()
-//        }
-    }
-
-    public  func addLayout() {
-        if isAdded {
-            borderView.snp.makeConstraints { make in
-                make.size.equalTo(CGSize.zero)
-            }
-            deleteBtn.snp.makeConstraints { make in
-                make.right.equalToSuperview()
-                make.top.equalToSuperview()
-                make.width.height.equalTo(cDefaultMargin * 2)
-            }
-            materialImageView.snp.makeConstraints { make in
-                make.left.equalToSuperview()
-                make.right.equalTo(deleteBtn.snp_centerX)
-                make.top.equalTo(deleteBtn.snp_centerY)
-                make.width.equalTo(materialImageView.snp_height)
-            }
-        } else {
-            borderView.snp.makeConstraints { make in
-                make.size.equalToSuperview()
-            }
-            materialImageView.snp.makeConstraints { make in
-                make.size.equalToSuperview()
-            }
-            choseContentView.snp.makeConstraints { make in
-                make.top.right.equalToSuperview()
-                make.width.height.equalTo(cDefaultMargin * 5)
-            }
-            choseBtn.snp.makeConstraints { make in
-                make.top.right.equalToSuperview()
-                make.width.height.equalTo(cDefaultMargin * 3)
-            }
-        }
-        statusLab.snp.makeConstraints { make in
-            make.bottom.right.equalToSuperview().offset(-4)
-            make.height.equalTo(18)
-        }
-        videoStatuImageView.snp.makeConstraints { make in
-            make.center.equalToSuperview()
-        }
-        videoLoadingView.snp.makeConstraints { make in
-            make.center.equalToSuperview()
-            make.width.height.equalTo(cDefaultMargin * 4)
-        }
-    }
-
-    @objc public func btnClick(sender: UIButton) {
-        if materialClicHandle != nil {
-            materialClicHandle!(sender, materialData)
-        }
-    }
-
-    @objc public func choseTap(ges _: UITapGestureRecognizer) {
-        btnClick(sender: choseBtn)
-    }
-
-    deinit {
-        videoLoadingView.stopAnimating()
-    }
-}

+ 0 - 385
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointMaterialDetailController.swift

@@ -1,385 +0,0 @@
-//
-//  PQStuckPointMaterialDetailController.swift
-//  PQSpeed
-//
-//  Created by SanW on 2021/4/27.
-//  Copyright © 2021 BytesFlow. All rights reserved.
-//
-
-import Kingfisher
-import KingfisherWebP
-import UIKit
-import BFCommonKit
-
-class PQStuckPointMaterialDetailController: PQBaseViewController {
-    var materialData: PQEditVisionTrackMaterialsModel?
-    // 点击的回调
-    var materialDetailClickHandle: ((_ isMaterialSelected: Bool?, _ materialData: PQEditVisionTrackMaterialsModel?) -> Void)?
-    var isMaterialSelected: Bool?
-    var margin: CGFloat = 35 // 左右间距
-    // 最大的宽度
-    var maxWidth: CGFloat = cScreenWidth
-    // 最大的高度
-    var maxHeight: CGFloat = cScreenHeigth - cDevice_iPhoneNavBarAndStatusBarHei - cDevice_iPhoneStatusBarHei
-    // 预览区域宽度
-    var preViewWidth: CGFloat = cScreenWidth
-    // 预览区域高度
-    var preViewHeight: CGFloat = cScreenHeigth - cDevice_iPhoneNavBarAndStatusBarHei - cDevice_iPhoneStatusBarHei
-    lazy var preImageView: UIImageView = {
-        let preImageView = UIImageView(frame: CGRect(x: (maxWidth - preViewWidth) / 2, y: cDevice_iPhoneNavBarAndStatusBarHei + (maxHeight - preViewHeight) / 2, width: preViewWidth, height: preViewHeight))
-        preImageView.center.x = view.center.x
-        preImageView.backgroundColor = PQBFConfig.shared.styleBackGroundColor
-        preImageView.contentMode = .scaleAspectFit
-        preImageView.isUserInteractionEnabled = true
-        preImageView.clipsToBounds = true
-        // preImageView.image = UIImage.init(named: "cut_place")
-        return preImageView
-    }()
-
-    lazy var choseTitleBtn: UIButton = {
-        let choseTitleBtn = UIButton(type: .custom)
-        choseTitleBtn.frame = CGRect(x: cScreenWidth - cDefaultMargin * 6, y: 0, width: cDefaultMargin * 5, height: cDefaultMargin * 3)
-        choseTitleBtn.setTitleColor(UIColor.white, for: .normal)
-        choseTitleBtn.titleLabel?.font = UIFont.systemFont(ofSize: 17, weight: .medium)
-        choseTitleBtn.setTitle("取消", for: .selected)
-        choseTitleBtn.setTitle("选择", for: .normal)
-        choseTitleBtn.tag = 2
-        choseTitleBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
-        return choseTitleBtn
-    }()
-
-    lazy var choseBtn: UIButton = {
-        let choseBtn = UIButton(type: .custom)
-        choseBtn.frame = CGRect(x: choseTitleBtn.frame.minX - cDefaultMargin * 3, y: 0, width: cDefaultMargin * 3, height: cDefaultMargin * 3)
-        choseBtn.setBackgroundImage(UIImage.moduleImage(named: "videomk_chose_nomal", moduleName: "BFFramework",isAssets: false), for: .normal)
-        choseBtn.setTitleColor(UIColor.white, for: .normal)
-        choseBtn.titleLabel?.font = UIFont.systemFont(ofSize: 12)
-        choseBtn.tag = 1
-        choseBtn.addCorner(corner: 15)
-        choseBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
-        return choseBtn
-    }()
-
-    lazy var changeModeBtn: UIButton = {
-        let changeModeBtn = UIButton(type: .custom)
-        changeModeBtn.setImage(UIImage.moduleImage(named: "videomk_changeMode", moduleName: "BFFramework",isAssets: false), for: .normal)
-        changeModeBtn.frame = CGRect(x: 15, y: preImageView.frame.height - cDefaultMargin * 4 - 15, width: cDefaultMargin * 4, height: cDefaultMargin * 4)
-        changeModeBtn.tag = 3
-        changeModeBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
-        return changeModeBtn
-    }()
-
-    lazy var gifRemindLab: UILabel = {
-        let gifRemindLab = UILabel(frame: CGRect(x: (preImageView.frame.width - cDefaultMargin * 4) / 2, y: preImageView.frame.height - cDefaultMargin * 3 - 15, width: cDefaultMargin * 4, height: cDefaultMargin * 3))
-        gifRemindLab.textAlignment = .center
-        gifRemindLab.font = UIFont.systemFont(ofSize: 18)
-        gifRemindLab.textColor = UIColor.white
-        gifRemindLab.text = "GIF"
-        return gifRemindLab
-    }()
-
-    lazy var playBtn: UIButton = {
-        let playBtn = UIButton(type: .custom)
-        playBtn.frame = CGRect(x: (preImageView.frame.width - cDefaultMargin * 5) / 2, y: (preImageView.frame.height - cDefaultMargin * 5) / 2, width: cDefaultMargin * 5, height: cDefaultMargin * 5)
-        playBtn.setImage(UIImage.moduleImage(named: "icon_video_play", moduleName: "BFFramework",isAssets: false), for: .normal)
-        playBtn.isUserInteractionEnabled = false
-        playBtn.isHidden = true
-        // playBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
-        return playBtn
-    }()
-
-    lazy var avPlayer: AVPlayer = {
-        let avPlayer = AVPlayer()
-        NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: avPlayer.currentItem, queue: .main) { [weak self] notify in
-            BFLog(message: "AVPlayerItemDidPlayToEndTime = \(notify)")
-            avPlayer.seek(to: CMTime(value: CMTimeValue((self?.materialData?.model_in ?? 0) * playerTimescale), timescale: CMTimeScale(playerTimescale)))
-            self?.playBtn.isHidden = false
-        }
-        NotificationCenter.default.addObserver(forName: .AVPlayerItemNewErrorLogEntry, object: avPlayer.currentItem, queue: .main) { notify in
-            BFLog(message: "AVPlayerItemNewErrorLogEntry = \(notify)")
-        }
-        NotificationCenter.default.addObserver(forName: .AVPlayerItemFailedToPlayToEndTime, object: avPlayer.currentItem, queue: .main) { notify in
-            BFLog(message: "AVPlayerItemFailedToPlayToEndTime = \(notify)")
-        }
-        NotificationCenter.default.addObserver(forName: .AVPlayerItemPlaybackStalled, object: avPlayer.currentItem, queue: .main) { notify in
-            BFLog(message: "AVPlayerItemPlaybackStalled = \(notify)")
-        }
-        avPlayer.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: CMTimeScale(playerTimescale)), queue: .main) { [weak self] cmTime in
-            // let progress = CMTimeGetSeconds(avPlayer.currentItem?.currentTime() ?? CMTime.zero) / CMTimeGetSeconds(avPlayer.currentItem?.duration ?? CMTime.zero)
-            let delta = CMTimeGetSeconds(cmTime)
-            let start = CGFloat(delta - (self?.materialData?.model_in ?? 0.0))
-            var endTime: Float64 = self?.materialData?.out ?? 0
-            if endTime <= 0 {
-                endTime = self?.materialData?.duration ?? 0
-            }
-            let total = CGFloat(endTime - (self?.materialData?.model_in ?? 0.0))
-            let progress = start / total
-            if progress >= 1 {
-                self?.playBtn.isHidden = false
-            }
-            BFLog(message: "progress = \(progress)")
-        }
-        return avPlayer
-    }()
-
-    lazy var playerLayer: AVPlayerLayer = {
-        let playerLayer = AVPlayerLayer(player: avPlayer)
-        playerLayer.frame = CGRect(origin: CGPoint.zero, size: preImageView.frame.size)
-        return playerLayer
-    }()
-
-    override func viewDidLoad() {
-        super.viewDidLoad()
-        leftButton(image: UIImage.init(named: "icon_detail_back"), tintColor: PQBFConfig.shared.styleTitleColor)
-        navHeadImageView?.backgroundColor = UIColor.clear
-        let width = CGFloat(materialData?.width ?? Float(preViewWidth))
-        let height = CGFloat(materialData?.height ?? Float(preViewHeight))
-        if width >= height {
-            preViewWidth = maxWidth
-            preViewHeight = preViewWidth * height / width
-        } else {
-            preViewHeight = maxHeight
-            preViewWidth = preViewHeight * width / height
-        }
-        lineView?.removeFromSuperview()
-        view.addSubview(preImageView)
-//        preImageView.addSubview(changeModeBtn)
-        if materialData?.type == StickerType.GIF.rawValue {
-            preImageView.addSubview(gifRemindLab)
-            setImageToPreImageView()
-        } else if materialData?.type == StickerType.IMAGE.rawValue {
-            setImageToPreImageView()
-        } else if materialData?.type == StickerType.VIDEO.rawValue {
-            preImageView.addSubview(playBtn)
-            preImageView.layer.insertSublayer(playerLayer, at: 0)
-            let ges = UITapGestureRecognizer(target: self, action: #selector(playPreVideo))
-            preImageView.addGestureRecognizer(ges)
-            // 设置播放内容
-            setPlayerItem()
-        }
-//        updateSelectedState()
-        isMaterialSelected = materialData?.isSelected
-    }
-
-    deinit {
-        if materialData?.type == StickerType.VIDEO.rawValue {
-            avPlayer.replaceCurrentItem(with: nil)
-            PQNotification.removeObserver(self)
-        }
-    }
-
-    /// 设置图片
-    /// - Returns: <#description#>
-    func setImageToPreImageView() {
-        if materialData?.asset != nil {
-            if materialData?.originalData == nil {
-                PQPHAssetVideoParaseUtil.requestAssetOringinImage(asset: (materialData?.asset)!) { [weak self] _, data, image, _ in
-                    if image == nil {
-                        BFLog(message: "图片数据为空!!!!!")
-                    }
-                    // 1,图片,gif的原文件数据,和视频的封面
-                    var newImage: UIImage?
-                    if image != nil {
-                        newImage = UIImage.nx_fixOrientation(image, isFront: false).nx_scaleWithMaxLength(maxLength: 1920)
-                    }
-                    self?.materialData?.coverImageUI = newImage
-                    self?.materialData?.originalData = data
-//                    if isGIF {
-//                        self?.materialData?.type = StickerType.GIF.rawValue
-//                        if self?.gifRemindLab.superview == nil {
-//                            self?.preImageView.addSubview(self!.gifRemindLab)
-//                        }
-//                        self?.preImageView.displayGIF(data: data)
-//                    } else {
-                    self?.preImageView.image = newImage
-//                    }
-                }
-            } else {
-                setNomarlImageToPreImageView()
-            }
-        } else {
-            setNomarlImageToPreImageView()
-        }
-    }
-
-    func setNomarlImageToPreImageView() {
-        if materialData?.type == StickerType.VIDEO.rawValue {
-            return
-        }
-        if materialData?.type == StickerType.GIF.rawValue && materialData?.originalData != nil {
-            preImageView.displayGIF(data: materialData?.originalData)
-        } else if preImageView.image != nil {
-            preImageView.image = preImageView.image
-        } else if preImageView.image == nil && materialData?.coverImageUI != nil {
-            if materialData?.type == StickerType.GIF.rawValue {
-                preImageView.displayGIF(data: kf_imageCacheData(originUrl: materialData?.netResCoverImageURL ?? ""))
-            } else {
-                preImageView.image = materialData?.coverImageUI
-            }
-        } else if materialData?.coverImageUI != nil {
-            preImageView.image = materialData?.coverImageUI
-        } else if materialData?.locationPath.count ?? 0 > 0 {
-            if materialData?.type == StickerType.GIF.rawValue {
-                let fileData: Data = try! Data(contentsOf: URL(fileURLWithPath: documensDirectory + (materialData?.locationPath)!))
-                materialData?.originalData = fileData
-                preImageView.displayGIF(data: materialData?.originalData)
-            } else {
-                var coverImage = UIImage(contentsOfFile: documensDirectory + (materialData?.locationPath)!)
-                if coverImage == nil {
-                    // 有可能是 WEBP
-                    let fileData: Data = try! Data(contentsOf: URL(fileURLWithPath: documensDirectory + (materialData?.locationPath)!))
-                    if fileData.count != 0, fileData.isWebPFormat {
-                        coverImage = WebPProcessor.default.process(item: ImageProcessItem.data(fileData), options: KingfisherParsedOptionsInfo([.onlyLoadFirstFrame, .scaleFactor(1)]))
-                    }
-                }
-                preImageView.image = coverImage
-                materialData?.coverImageUI = coverImage
-            }
-
-        } else if (materialData?.netResCoverImageURL != nil && ((materialData?.netResCoverImageURL?.count ?? 0) > 0)) || (materialData?.materialUrl != nil && ((materialData?.materialUrl.count ?? 0) > 0)) {
-            var url = materialData?.materialUrl
-            if url == nil || (url?.count ?? 0) <= 0 {
-                url = materialData?.netResCoverImageURL
-            }
-            ImageDownloader.default.downloadImage(with: URL(string: url ?? "")!, options: nil) { [weak self] result in
-                switch result {
-                case let .success(imageLoading):
-                    self?.materialData?.originalData = imageLoading.originalData
-                    self?.materialData?.coverImageUI = imageLoading.image
-                    if self?.materialData?.type == StickerType.GIF.rawValue {
-                        self?.preImageView.displayGIF(data: imageLoading.originalData)
-                    } else {
-                        self?.preImageView.image = imageLoading.image
-                    }
-                    let imageOrientation = UIImage.nx_fixOrientation(imageLoading.image, isFront: false).nx_scaleWithMaxLength(maxLength: 1024)
-                    // 下载器的原地址
-                    let diskCachePath = ImageCache.default.cachePath(forKey: url!)
-                    let imageCacheName = url!.md5
-                    let imageCachePath = downloadImagesDirectory + imageCacheName
-                    if !directoryIsExists(dicPath: downloadImagesDirectory) {
-                        BFLog(message: "文件夹不存在 \(downloadImagesDirectory)")
-                        createDirectory(path: downloadImagesDirectory)
-                    }
-                    if self?.materialData?.type != StickerType.GIF.rawValue {
-                        try! imageOrientation.pngData()?.write(to: URL(fileURLWithPath: imageCachePath))
-                    } else {
-                        try! imageLoading.originalData.write(to: URL(fileURLWithPath: imageCachePath))
-                    }
-                    if !FileManager.default.fileExists(atPath: imageCachePath) {
-                        try! FileManager.default.copyItem(atPath: diskCachePath, toPath: downloadImagesDirectory + imageCacheName)
-                    }
-                    if self?.materialData?.type != StickerType.VIDEO.rawValue {
-                        self?.materialData?.locationPath = imageCachePath.replacingOccurrences(of: documensDirectory, with: "")
-                    }
-                case let .failure(error):
-                    BFLog(message: "下载图片失败:\(error.localizedDescription)")
-                }
-            }
-        }
-    }
-
-    /// 预览视频
-    @objc func playPreVideo() {
-        playBtn.isHidden = !playBtn.isHidden
-        if avPlayer.currentItem == nil {
-            setPlayerItem()
-        }
-        if playBtn.isHidden {
-            if playerLayer.superlayer == nil {
-                preImageView.layer.insertSublayer(playerLayer, at: 0)
-            }
-            avPlayer.play()
-        } else {
-            avPlayer.pause()
-        }
-    }
-
-    /// 设置播放item
-    /// - Returns: <#description#>
-    func setPlayerItem() {
-        if materialData?.locationPath.count ?? 0 > 0 {
-            if materialData?.locationPath.contains("mobile/Media/DCIM") ?? false {
-                addPlayItem(playerItem: AVPlayerItem(url: URL(fileURLWithPath: materialData!.locationPath)))
-            } else {
-                addPlayItem(playerItem: AVPlayerItem(url: URL(fileURLWithPath: documensDirectory + materialData!.locationPath)))
-            }
-        } else if materialData?.locationPath.count == 0 && materialData?.asset != nil {
-            PQLoadingHUB.shared.showHUB()
-            PQPHAssetVideoParaseUtil.parasToAVPlayerItem(phAsset: (materialData?.asset)!) { [weak self] playerItem, _, _ in
-                PQLoadingHUB.shared.dismissHUB()
-//                self?.materialData?.locationPath = (playerItem?.asset as? AVURLAsset)?.url.absoluteString.replacingOccurrences(of: "file:///", with: "") ?? ""
-                self?.addPlayItem(playerItem: playerItem)
-            }
-        } else if isValidURL(url: materialData?.netResUrl) {
-            addPlayItem(playerItem: AVPlayerItem(url: URL(string: materialData?.netResUrl ?? "")!))
-        }
-    }
-
-    /// 添加播放
-    /// - Parameter playerItem: <#playerItem description#>
-    func addPlayItem(playerItem: AVPlayerItem?) {
-        avPlayer.replaceCurrentItem(with: playerItem)
-        avPlayer.play()
-        let startTime = materialData?.model_in ?? 0
-        var endTime = materialData?.out ?? 0
-        if endTime <= 0 {
-            endTime = Float64(materialData?.duration ?? 0.0)
-        }
-        avPlayer.seek(to: CMTime(value: CMTimeValue(startTime * playerTimescale), timescale: CMTimeScale(playerTimescale)))
-        avPlayer.currentItem?.forwardPlaybackEndTime = CMTime(value: CMTimeValue(endTime * playerTimescale), timescale: CMTimeScale(playerTimescale))
-    }
-
-    /// 按钮点击事件
-    /// - Parameter sender: <#sender description#>
-    @objc func btnClick(sender: UIButton) {
-        switch sender.tag {
-        case 1, 2:
-            let ratio = (materialData?.width ?? 0) / (materialData?.height ?? 1)
-            if ratio < 0.4 || ratio > 4.2 {
-                cShowHUB(superView: nil, msg: "暂不支持该比例的素材")
-                return
-            }
-            materialData?.isSelected = !(materialData?.isSelected ?? false)
-//            updateSelectedState()
-        default:
-            break
-        }
-    }
-
-    /// 更新选中状态
-    func updateSelectedState() {
-        if materialData?.isSelected ?? false {
-            choseBtn.setBackgroundImage(nil, for: .normal)
-            choseBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#EE0051")
-            if materialData?.selectedIndex == 0 {
-                choseBtn.setTitle("1", for: .normal)
-            } else {
-                choseBtn.setTitle("\(materialData?.selectedIndex ?? 1)", for: .normal)
-            }
-            choseTitleBtn.isSelected = true
-        } else {
-            choseBtn.setBackgroundImage(UIImage.moduleImage(named: "videomk_chose_nomal", moduleName: "BFFramework",isAssets: false), for: .normal)
-            choseBtn.backgroundColor = UIColor.clear
-            choseBtn.setTitle(nil, for: .normal)
-            choseTitleBtn.isSelected = false
-        }
-
-        if materialData?.originalData == nil {
-            materialData?.originalData = kf_imageCacheData(originUrl: materialData?.netResCoverImageURL ?? "")
-            if materialData?.originalData != nil {
-                if materialData?.type == StickerType.GIF.rawValue && materialData?.originalData != nil && (materialData?.duration ?? 0.0) <= 0 {
-                    PQPHAssetVideoParaseUtil.parasGIFImage(data: (materialData?.originalData)!) { [weak self] _, _, duration in
-                        self?.materialData?.duration = duration ?? 0.0
-                    }
-                }
-            }
-        }
-    }
-
-    override func backBtnClick() {
-        if materialDetailClickHandle != nil {
-            materialDetailClickHandle!(isMaterialSelected, materialData)
-        }
-        super.backBtnClick()
-    }
-}

+ 0 - 89
BFFramework/Classes/Stuckpoint/View/PQSelectedMaterialListView.swift

@@ -1,89 +0,0 @@
-//
-//  PQSelectedMaterialListView.swift
-//  PQSpeed
-//
-//  Created by SanW on 2021/5/16.
-//  Copyright © 2021 BytesFlow. All rights reserved.
-//
-
-import UIKit
-import BFCommonKit
-
-class PQSelectedMaterialListView: UIView {
-    var photoData: [PQEditVisionTrackMaterialsModel] = Array<PQEditVisionTrackMaterialsModel>.init() // 相册数据
-    var deletedMaterialHandle: ((_ materialData: PQEditVisionTrackMaterialsModel?, _ isDissmiss: Bool) -> Void)? // 删除已选素材回调
-    var detailMaterialHandle: ((_ indexPath: IndexPath, _ currentMaterialData: PQEditVisionTrackMaterialsModel?) -> Void)? // 点击详情
-    lazy var photoCollectionView: UICollectionView = {
-        let photoFlowLayout = UICollectionViewFlowLayout()
-        photoFlowLayout.itemSize = CGSize(width: 74, height: 74)
-        photoFlowLayout.minimumLineSpacing = cDefaultMargin
-        photoFlowLayout.minimumInteritemSpacing = 0
-        photoFlowLayout.scrollDirection = .horizontal
-        let photoCollectionView = UICollectionView(frame: bounds, collectionViewLayout: photoFlowLayout)
-        photoCollectionView.register(PQChoseMaterialCell.self, forCellWithReuseIdentifier: String(describing: PQChoseMaterialCell.self))
-        photoCollectionView.showsVerticalScrollIndicator = false
-        photoCollectionView.showsHorizontalScrollIndicator = false
-        photoCollectionView.delegate = self
-        photoCollectionView.dataSource = self
-        photoCollectionView.backgroundColor = UIColor.clear
-        if #available(iOS 11.0, *) {
-            photoCollectionView.contentInsetAdjustmentBehavior = .never
-        } else {}
-        return photoCollectionView
-    }()
-
-    override init(frame: CGRect) {
-        super.init(frame: frame)
-        backgroundColor = PQBFConfig.shared.styleBackGroundColor
-        addSubview(photoCollectionView)
-    }
-
-    required init?(coder _: NSCoder) {
-        fatalError("init(coder:) has not been implemented")
-    }
-
-    /// 添加新素材
-    /// - Parameter itemData: <#itemData description#>
-    /// - Returns: <#description#>
-    func addMaterialData(materialData: PQEditVisionTrackMaterialsModel) {
-        let temp = photoData.firstIndex { item in
-            item.asset == materialData.asset
-        }
-        if temp == nil, materialData.isSelected {
-            photoData.append(materialData)
-            photoCollectionView.reloadData()
-            photoCollectionView.scrollToItem(at: IndexPath(item: photoData.count - 1, section: 0), at: .right, animated: true)
-        } else if temp != nil, !materialData.isSelected {
-            photoData.remove(at: temp ?? 0)
-            photoCollectionView.reloadData()
-        }
-    }
-}
-
-extension PQSelectedMaterialListView: UICollectionViewDelegate, UICollectionViewDataSource, UIScrollViewDelegate {
-    func collectionView(_: UICollectionView, numberOfItemsInSection _: Int) -> Int {
-        return photoData.count
-    }
-
-    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
-        let cell = PQChoseMaterialCell.choseMaterialCell(collectionView: collectionView, indexPath: indexPath)
-        cell.isShowMediaTag = false
-        cell.isAdded = true
-        cell.materialData = photoData[indexPath.item]
-        cell.materialClicHandle = { [weak self] _, _ in
-            if self?.deletedMaterialHandle != nil {
-                self?.deletedMaterialHandle!(self?.photoData[indexPath.item], (self?.photoData.count ?? 0) <= 1)
-            }
-            self?.photoData[indexPath.item].isSelected = false
-            self?.photoData.remove(at: indexPath.item)
-            collectionView.reloadData()
-        }
-        return cell
-    }
-
-    func collectionView(_: UICollectionView, didSelectItemAt indexPath: IndexPath) {
-        if detailMaterialHandle != nil {
-            detailMaterialHandle!(indexPath, photoData[indexPath.item])
-        }
-    }
-}

+ 4 - 2
Example/BFFramework.xcodeproj/project.pbxproj

@@ -233,11 +233,13 @@
 			);
 			inputPaths = (
 				"${PODS_ROOT}/Target Support Files/Pods-BFFramework_Example/Pods-BFFramework_Example-resources.sh",
-				"${PODS_CONFIGURATION_BUILD_DIR}/BFFramework/BFFramework.bundle",
+				"${PODS_CONFIGURATION_BUILD_DIR}/BFFramework/BFFramework_Resources.bundle",
+				"${PODS_CONFIGURATION_BUILD_DIR}/BFMaterialKit/BFMaterialKit_Resources.bundle",
 			);
 			name = "[CP] Copy Pods Resources";
 			outputPaths = (
-				"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/BFFramework.bundle",
+				"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/BFFramework_Resources.bundle",
+				"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/BFMaterialKit_Resources.bundle",
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/sh;

+ 6 - 1
Example/Podfile.lock

@@ -33,6 +33,7 @@ PODS:
   - BFFramework (1.0.0):
     - AliyunOSSiOS (= 2.10.8)
     - BFCommonKit
+    - BFMaterialKit
     - BFNetRequestKit
     - Bugly (= 2.5.90)
     - LMJHorizontalScrollText (= 2.0.2)
@@ -40,6 +41,8 @@ PODS:
     - ObjectMapper (= 4.2.0)
     - TXLiteAVSDK_Player (= 8.7.10102)
     - WechatOpenSDK-Swift (= 1.8.7.1)
+  - BFMaterialKit (0.0.6):
+    - BFCommonKit
   - BFNetRequestKit (0.1.4):
     - Alamofire (= 5.4.3)
   - Bugly (2.5.90)
@@ -77,6 +80,7 @@ DEPENDENCIES:
 SPEC REPOS:
   https://git.yishihui.com/wenweiwei/BFSpecs.git:
     - BFCommonKit
+    - BFMaterialKit
     - BFNetRequestKit
   https://github.com/CocoaPods/Specs.git:
     - Alamofire
@@ -105,7 +109,8 @@ SPEC CHECKSUMS:
   Alamofire: e447a2774a40c996748296fa2c55112fdbbc42f9
   AliyunOSSiOS: 8db92936545593b9e5c66d680ef2ac0738946651
   BFCommonKit: d7e5b2b13f34cf578e0f2dc6896618c0970fbae9
-  BFFramework: ad60184334d37fed96f4d9d0dd694bd933c4cab7
+  BFFramework: ec7dc882ecb587d52cdbd78fc0c60f403a84dd14
+  BFMaterialKit: 417988162e65a368b211847c08fba9ed9b4dfa50
   BFNetRequestKit: bec1d28012c7206cdf775fb31e394139d245d376
   Bugly: 88bc32c0acc6fef7b74d610f0319ee7560d6b9fe
   FDFullscreenPopGesture: a8a620179e3d9c40e8e00256dcee1c1a27c6d0f0