|
@@ -6,10 +6,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
+import BFUIKit
|
|
|
import MobileCoreServices
|
|
|
import Photos
|
|
|
import UIKit
|
|
|
-import BFUIKit
|
|
|
|
|
|
let playerHeaderH: CGFloat = cScreenWidth * (250 / 375)
|
|
|
|
|
@@ -135,8 +135,8 @@ open class PQUploadController: BFBaseViewController {
|
|
|
let backBtn = UIButton(type: .custom)
|
|
|
backBtn.frame = CGRect(x: 0, y: cDevice_iPhoneStatusBarHei, width: cDefaultMargin * 4, height: cDefaultMargin * 4)
|
|
|
backBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: -5, right: 0)
|
|
|
-
|
|
|
- backBtn.setImage(UIImage.moduleImage(named: "icon_blanc_back", moduleName: "BFFramework",isAssets: false)?.withRenderingMode(.alwaysTemplate), for: .normal)
|
|
|
+
|
|
|
+ backBtn.setImage(UIImage.moduleImage(named: "icon_blanc_back", moduleName: "BFFramework", isAssets: false)?.withRenderingMode(.alwaysTemplate), for: .normal)
|
|
|
backBtn.addTarget(self, action: #selector(backBtnClick), for: .touchUpInside)
|
|
|
backBtn.imageView?.tintColor = BFConfig.shared.styleTitleColor
|
|
|
return backBtn
|
|
@@ -157,7 +157,7 @@ open class PQUploadController: BFBaseViewController {
|
|
|
emptyData.netDisRefreshBgColor = UIColor.hexColor(hexadecimal: "#FA6400")
|
|
|
emptyData.netDisTitle = "内容加载失败"
|
|
|
emptyData.netDisTitleColor = UIColor.hexColor(hexadecimal: "#333333")
|
|
|
- emptyData.netemptyDisImage = UIImage.init(named: "empty_netDis_icon")
|
|
|
+ emptyData.netemptyDisImage = UIImage(named: "empty_netDis_icon")
|
|
|
emptyData.netDisRefreshTitle = NSMutableAttributedString(string: "重新加载", attributes: [.font: UIFont.systemFont(ofSize: 16, weight: .medium), .foregroundColor: UIColor.white])
|
|
|
return emptyData
|
|
|
}()
|
|
@@ -288,7 +288,7 @@ open class PQUploadController: BFBaseViewController {
|
|
|
return playBtn
|
|
|
}()
|
|
|
|
|
|
- public var playerHeaderView: UIImageView = {
|
|
|
+ public var playerHeaderView: UIImageView = {
|
|
|
let playerHeaderView = UIImageView(frame: CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei, width: cScreenWidth, height: 0))
|
|
|
playerHeaderView.isUserInteractionEnabled = true
|
|
|
playerHeaderView.contentMode = .scaleAspectFit
|
|
@@ -301,9 +301,9 @@ open class PQUploadController: BFBaseViewController {
|
|
|
let selecteBtn = UIButton(frame: CGRect(x: deleteBtn.frame.maxX + cDefaultMargin, y: 0, width: cScreenWidth - nextBtn.frame.width - deleteBtn.frame.maxX - cDefaultMargin * 5, height: cDevice_iPhoneTabBarHei))
|
|
|
selecteBtn.titleLabel?.lineBreakMode = .byTruncatingTail
|
|
|
selecteBtn.setTitle("全部", for: .normal)
|
|
|
-
|
|
|
- selecteBtn.setImage(UIImage.moduleImage(named: "icon_uploadVideo_more", moduleName: "BFFramework",isAssets: false)?.withRenderingMode(.alwaysTemplate), for: .normal)
|
|
|
- selecteBtn.setTitleColor( BFConfig.shared.styleTitleColor, for: .normal)
|
|
|
+
|
|
|
+ selecteBtn.setImage(UIImage.moduleImage(named: "icon_uploadVideo_more", moduleName: "BFFramework", isAssets: false)?.withRenderingMode(.alwaysTemplate), for: .normal)
|
|
|
+ selecteBtn.setTitleColor(BFConfig.shared.styleTitleColor, for: .normal)
|
|
|
selecteBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16, weight: .medium)
|
|
|
selecteBtn.tag = 2
|
|
|
selecteBtn.imagePosition(at: PQButtonImageEdgeInsetsStyle.right, space: cDefaultMargin / 2)
|
|
@@ -314,7 +314,7 @@ open class PQUploadController: BFBaseViewController {
|
|
|
|
|
|
public lazy var deleteBtn: UIButton = {
|
|
|
let deleteBtn = UIButton(frame: CGRect(x: cDefaultMargin, y: 0, width: cDefaultMargin * 4, height: cDevice_iPhoneTabBarHei))
|
|
|
- deleteBtn.setImage(UIImage.moduleImage(named: "icon_blanc_back", moduleName: "BFFramework",isAssets: false)?.withRenderingMode(.alwaysTemplate), for: .normal)
|
|
|
+ deleteBtn.setImage(UIImage.moduleImage(named: "icon_blanc_back", moduleName: "BFFramework", isAssets: false)?.withRenderingMode(.alwaysTemplate), for: .normal)
|
|
|
deleteBtn.tag = 1
|
|
|
deleteBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
|
|
|
deleteBtn.imageView?.tintColor = BFConfig.shared.styleTitleColor
|
|
@@ -346,14 +346,13 @@ open class PQUploadController: BFBaseViewController {
|
|
|
|
|
|
override open func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
-
|
|
|
- view.backgroundColor = BFConfig.shared.editCoverimageSelectedbackgroundColor
|
|
|
- navHeadImageView?.backgroundColor = BFConfig.shared.editCoverimageSelectedbackgroundColor
|
|
|
- lineView?.backgroundColor = BFConfig.shared.editCoverimageSelectedbackgroundColor
|
|
|
+
|
|
|
+ view.backgroundColor = BFConfig.shared.editCoverimageSelectedbackgroundColor
|
|
|
+ navHeadImageView?.backgroundColor = BFConfig.shared.editCoverimageSelectedbackgroundColor
|
|
|
+ lineView?.backgroundColor = BFConfig.shared.editCoverimageSelectedbackgroundColor
|
|
|
addSubViews()
|
|
|
bottomView.backgroundColor = BFConfig.shared.editCoverimageSelectedbackgroundColor
|
|
|
loadLocalData()
|
|
|
-
|
|
|
}
|
|
|
|
|
|
deinit {
|
|
@@ -362,23 +361,42 @@ open class PQUploadController: BFBaseViewController {
|
|
|
|
|
|
override open func viewDidDisappear(_ animated: Bool) {
|
|
|
super.viewDidDisappear(animated)
|
|
|
-
|
|
|
+ if !isAssetImage {
|
|
|
+ avPlayer.pause()
|
|
|
+ playBtn.isHidden = false
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
override open func viewWillAppear(_ animated: Bool) {
|
|
|
super.viewDidAppear(animated)
|
|
|
-
|
|
|
+ if !isAssetImage {
|
|
|
+ if selectedData != nil {
|
|
|
+ playBtn.isHidden = true
|
|
|
+ if playerLayer.superlayer == nil {
|
|
|
+ playerHeaderView.layer.insertSublayer(playerLayer, at: 0)
|
|
|
+ }
|
|
|
+ avPlayer.play()
|
|
|
+ }
|
|
|
+ }
|
|
|
addPlayerItemObserver()
|
|
|
}
|
|
|
+
|
|
|
override open func viewWillDisappear(_ animated: Bool) {
|
|
|
super.viewWillDisappear(animated)
|
|
|
removePlayerItemObserver()
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
open func addSubViews() {
|
|
|
view.addSubview(collectionView)
|
|
|
navHeadImageView?.addSubview(bottomView)
|
|
|
-
|
|
|
+ if !isAssetImage {
|
|
|
+ view.addSubview(playerHeaderView)
|
|
|
+ view.addSubview(sliderView)
|
|
|
+ let ges = UITapGestureRecognizer(target: self, action: #selector(playPreVideo))
|
|
|
+ playerHeaderView.addGestureRecognizer(ges)
|
|
|
+ playerHeaderView.addSubview(playBtn)
|
|
|
+ playerHeaderView.layer.insertSublayer(playerLayer, at: 0)
|
|
|
+ }
|
|
|
PQNotification.addObserver(self, selector: #selector(didBecomeActiveNotification), name: UIApplication.didBecomeActiveNotification, object: nil)
|
|
|
}
|
|
|
|
|
@@ -473,7 +491,10 @@ open class PQUploadController: BFBaseViewController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -499,7 +520,10 @@ open class PQUploadController: BFBaseViewController {
|
|
|
switch sender.tag {
|
|
|
case 1:
|
|
|
navigationController?.popViewController(animated: true)
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
case 2:
|
|
|
showCollects()
|
|
|
case 3:
|
|
@@ -507,13 +531,29 @@ open class PQUploadController: BFBaseViewController {
|
|
|
cShowHUB(superView: nil, msg: isAssetImage ? "请选择图片" : "请选择视频")
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
imageManager.requestImage(for: (selectedData?.asset)!, targetSize: itemSize, contentMode: .aspectFill, options: nil) { [weak self] image, _ in
|
|
|
self?.selectedData?.image = image
|
|
|
let vc = PQImageCropVC(image: (self?.selectedData?.image)!, aspectWidth: self?.videoWidth ?? 0.0, aspectHeight: self?.videoHeight ?? 0.0)
|
|
|
vc.uploadData = self?.selectedData
|
|
|
self?.navigationController?.pushViewController(vc, animated: true)
|
|
|
}
|
|
|
+ case 4:
|
|
|
+ playBtn.isHidden = true
|
|
|
+ if playerLayer.superlayer == nil {
|
|
|
+ playerHeaderView.layer.insertSublayer(playerLayer, at: 0)
|
|
|
+ }
|
|
|
+ avPlayer.play()
|
|
|
default:
|
|
|
break
|
|
|
}
|
|
@@ -558,28 +598,49 @@ open class PQUploadController: BFBaseViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @objc open func playPreVideo() {
|
|
|
+ playBtn.isHidden = !playBtn.isHidden
|
|
|
+ if playBtn.isHidden {
|
|
|
+ if playerLayer.superlayer == nil {
|
|
|
+ playerHeaderView.layer.insertSublayer(playerLayer, at: 0)
|
|
|
+ }
|
|
|
+ avPlayer.play()
|
|
|
+ } else {
|
|
|
+ avPlayer.pause()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@objc func sliderValueDidChanged(sender: UISlider) {
|
|
|
avPlayer.seek(to: CMTime(value: CMTimeValue(sender.value * Float(CMTimeGetSeconds(avPlayer.currentItem?.duration ?? CMTime.zero))), timescale: 1))
|
|
|
}
|
|
|
|
|
|
- @objc func didBecomeActiveNotification() {
|
|
|
+ @objc open func didBecomeActiveNotification() {
|
|
|
if isJumpToAuthorization {
|
|
|
loadLocalData()
|
|
|
isJumpToAuthorization = false
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ open func isPublishEnabled() {
|
|
|
+ if selectedData != nil {
|
|
|
+ nextBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#EE0051")
|
|
|
+ nextBtn.setTitleColor(UIColor.white, for: .normal)
|
|
|
+ } else {
|
|
|
+ nextBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#333333")
|
|
|
+ nextBtn.setTitleColor(UIColor.hexColor(hexadecimal: "#999999"), for: .normal)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
extension PQUploadController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UIScrollViewDelegate {
|
|
|
- public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection _: Int) -> Int {
|
|
|
+ open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection _: Int) -> Int {
|
|
|
if collectionView == self.collectionView {
|
|
|
return allPhotos == nil ? videoData.count : allPhotos.count
|
|
|
}
|
|
|
return categoryData.count
|
|
|
}
|
|
|
|
|
|
- public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
|
+ open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
|
if collectionView == self.collectionView {
|
|
|
let cell = PQSelecteVideoItemCell.selecteVideoItemCell(collectionView: collectionView, indexPath: indexPath)
|
|
|
if videoData.count <= indexPath.item, allPhotos != nil {
|
|
@@ -595,7 +656,7 @@ extension PQUploadController: UICollectionViewDelegate, UICollectionViewDataSour
|
|
|
cell.uploadData = itemData
|
|
|
if itemData.image == nil, itemData.asset != nil {
|
|
|
cell.representedAssetIdentifier = itemData.asset?.localIdentifier
|
|
|
- imageManager.requestImage(for: itemData.asset!, targetSize: itemSize, contentMode: .aspectFill, options: nil) {[weak self, weak cell] image, info in
|
|
|
+ imageManager.requestImage(for: itemData.asset!, targetSize: itemSize, contentMode: .aspectFill, options: nil) { [weak self, weak cell] image, info in
|
|
|
if info?.keys.contains("PHImageResultIsDegradedKey") ?? false, "\(info?["PHImageResultIsDegradedKey"] ?? "0")" == "0", cell?.representedAssetIdentifier == itemData.asset?.localIdentifier {
|
|
|
if image != nil {
|
|
|
itemData.image = image
|
|
@@ -639,13 +700,16 @@ extension PQUploadController: UICollectionViewDelegate, UICollectionViewDataSour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
|
+ open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
|
if collectionView == self.collectionView {
|
|
|
if videoData.count <= indexPath.item {
|
|
|
return
|
|
|
}
|
|
|
let itemData = videoData[indexPath.item]
|
|
|
-
|
|
|
+ if !isAssetImage, (itemData.asset?.duration ?? 0) < 5.0 {
|
|
|
+ cShowHUB(superView: nil, msg: "请选择大于5s的视频")
|
|
|
+ return
|
|
|
+ }
|
|
|
let ratio = Float(itemData.asset?.pixelWidth ?? 0) / Float(itemData.asset?.pixelHeight ?? 1)
|
|
|
if ratio < 0.4 || ratio > 4.2 {
|
|
|
cShowHUB(superView: nil, msg: "暂不支持该比例的素材")
|
|
@@ -660,15 +724,106 @@ extension PQUploadController: UICollectionViewDelegate, UICollectionViewDataSour
|
|
|
if itemData.isSelected {
|
|
|
itemData.isSelected = false
|
|
|
selectedData = nil
|
|
|
-
|
|
|
+ if !isAssetImage {
|
|
|
+ avPlayer.pause()
|
|
|
+ playBtn.isHidden = false
|
|
|
+ sliderView.isHidden = true
|
|
|
+ UIView.animate(withDuration: 0.5, animations: { [weak self] in
|
|
|
+ self?.playerHeaderView.frame = CGRect(x: 0, y: -(self?.preViewSize.height ?? 0) - cDevice_iPhoneNavBarAndStatusBarHei, width: self?.preViewSize.width ?? 0, height: self?.preViewSize.height ?? 0)
|
|
|
+ self?.sliderView.frame.origin.y = self?.playerHeaderView.frame.maxY ?? 0
|
|
|
+ self?.playerHeaderView.center.x = self?.view.center.x ?? 0
|
|
|
+ self?.collectionView.frame = CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei, width: cScreenWidth, height: cScreenHeigth - cDevice_iPhoneNavBarAndStatusBarHei)
|
|
|
+ }) { _ in
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
itemData.isSelected = true
|
|
|
let itemData = videoData[indexPath.item]
|
|
|
-
|
|
|
- selectedData = itemData
|
|
|
-
|
|
|
+ if !isAssetImage {
|
|
|
+ selectedData = nil
|
|
|
+ sliderView.setValue(0, animated: false)
|
|
|
+
|
|
|
+ BFLoadingHUB.shared.showHUB(superView: playerHeaderView)
|
|
|
+ avPlayer.pause()
|
|
|
+ avPlayer.replaceCurrentItem(with: nil)
|
|
|
+ playerLayer.removeFromSuperlayer()
|
|
|
+ PQPHAssetVideoParaseUtil.parasToAVPlayerItem(phAsset: itemData.asset!, isHighQuality: true) { [weak self] playerItem, fileSize, info in
|
|
|
+ if playerItem == nil || fileSize > maxUploadSize {
|
|
|
+ if fileSize > maxUploadSize {
|
|
|
+ cShowHUB(superView: nil, msg: "请选择小于10G的视频")
|
|
|
+ } else {
|
|
|
+ cShowHUB(superView: nil, msg: (info != nil && (info?.keys.contains("PHImageResultIsInCloudKey") ?? false) && "\(info?["PHImageResultIsInCloudKey"] ?? "1")" == "1") ? "暂不支持iCloud中的视频" : "此视频已损坏或已删除无法播放")
|
|
|
+ }
|
|
|
+ self?.videoData[(self?.lastSeletedIndex?.item)!].isSelected = false
|
|
|
+ self?.collectionView.reloadItems(at: [(self?.lastSeletedIndex)!])
|
|
|
+ self?.lastSeletedIndex = nil
|
|
|
+ self?.selectedData = nil
|
|
|
+ DispatchQueue.main.async { [weak self] in
|
|
|
+ self?.sliderView.isHidden = true
|
|
|
+ if (self?.playerHeaderView.frame.minY ?? 0.0) >= 0.0 {
|
|
|
+ UIView.animate(withDuration: 0.5, animations: { [weak self] in
|
|
|
+ self?.playerHeaderView.frame = CGRect(x: 0, y: -(self?.preViewSize.height ?? 0) - cDevice_iPhoneNavBarAndStatusBarHei, width: self?.preViewSize.width ?? 0, height: self?.preViewSize.height ?? 0)
|
|
|
+ self?.sliderView.frame.origin.y = self?.playerHeaderView.frame.maxY ?? 0
|
|
|
+ self?.playerHeaderView.center.x = self?.view.center.x ?? 0
|
|
|
+ self?.collectionView.frame = CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei, width: cScreenWidth, height: cScreenHeigth - cDevice_iPhoneNavBarAndStatusBarHei)
|
|
|
+ }) { _ in
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if self?.playerHeaderView != nil {
|
|
|
+ BFLoadingHUB.shared.dismissHUB(superView: (self?.playerHeaderView)!)
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ DispatchQueue.main.async { [weak self] in
|
|
|
+ self?.selectedData = itemData
|
|
|
+ self?.selectedData?.localPath = (playerItem?.asset as! AVURLAsset).url.absoluteString
|
|
|
+ self?.selectedData?.duration = (playerItem?.asset as! AVURLAsset).duration.seconds
|
|
|
+
|
|
|
+ self?.removePlayerItemObserver()
|
|
|
+ self?.playerItem = playerItem
|
|
|
+
|
|
|
+ self?.addPlayerItemObserver()
|
|
|
+ self?.playBtn.isHidden = true
|
|
|
+ self?.avPlayer.replaceCurrentItem(with: playerItem)
|
|
|
+ if self?.playerLayer.superlayer == nil {
|
|
|
+ self?.playerHeaderView.layer.insertSublayer(self!.playerLayer, at: 0)
|
|
|
+ }
|
|
|
+ self?.avPlayer.play()
|
|
|
+
|
|
|
+
|
|
|
+ let tracks = (playerItem?.asset as? AVURLAsset)?.tracks(withMediaType: .video)
|
|
|
+ if tracks != nil, (tracks?.count ?? 0) > 0 {
|
|
|
+ let videoTrack = tracks?.first
|
|
|
+ let transform = videoTrack?.preferredTransform
|
|
|
+ let width: CGFloat = CGFloat(transform?.a ?? 0.0) * CGFloat(videoTrack?.naturalSize.width ?? 0.0) + CGFloat(transform?.c ?? 0.0) * CGFloat(videoTrack?.naturalSize.height ?? 0.0)
|
|
|
+ let height: CGFloat = CGFloat(transform?.b ?? 0.0) * CGFloat(videoTrack?.naturalSize.width ?? 0.0) + CGFloat(transform?.d ?? 0.0) * CGFloat(videoTrack?.naturalSize.height ?? 0.0)
|
|
|
+ self?.selectedData?.videoWidth = abs(width)
|
|
|
+ self?.selectedData?.videoHeight = abs(height)
|
|
|
+ } else {
|
|
|
+ self?.selectedData?.videoWidth = CGFloat(self?.selectedData?.asset?.pixelWidth ?? 0)
|
|
|
+ self?.selectedData?.videoHeight = CGFloat(self?.selectedData?.asset?.pixelHeight ?? 0)
|
|
|
+ }
|
|
|
+ self?.isPublishEnabled()
|
|
|
+ self?.playerHeaderView.frame = CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei, width: self?.preViewSize.width ?? 0, height: self?.preViewSize.height ?? 0)
|
|
|
+ if self?.playerHeaderView != nil {
|
|
|
+ BFLoadingHUB.shared.showHUB(superView: (self?.playerHeaderView)!)
|
|
|
+ }
|
|
|
+ self?.playerHeaderView.center.x = self?.view.center.x ?? 0
|
|
|
+ self?.sliderView.frame.origin.y = self?.playerHeaderView.frame.maxY ?? 0
|
|
|
+ self?.collectionView.frame = CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei + CGFloat(self?.preViewSize.height ?? 0) + cDefaultMargin * 1.5, width: cScreenWidth, height: cScreenHeigth - cDevice_iPhoneNavBarAndStatusBarHei - CGFloat(self?.preViewSize.height ?? 0) - cDefaultMargin * 1.5)
|
|
|
+ self?.collectionView.scrollToItem(at: indexPath, at: .top, animated: true)
|
|
|
+ self?.sliderView.isHidden = false
|
|
|
+ self?.playBtn.frame.origin = CGPoint(x: (CGFloat(self?.preViewSize.width ?? 0) - CGFloat(cDefaultMargin * 5)) / 2, y: (CGFloat(self?.preViewSize.height ?? 0) - CGFloat(cDefaultMargin * 5)) / 2)
|
|
|
+ self?.playerLayer.frame = self?.playerHeaderView.bounds ?? CGRect.zero
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ selectedData = itemData
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+ isPublishEnabled()
|
|
|
collectionView.reloadItems(at: [indexPath])
|
|
|
} else {
|
|
|
videoData.removeAll()
|
|
@@ -678,9 +833,23 @@ extension PQUploadController: UICollectionViewDelegate, UICollectionViewDataSour
|
|
|
catagerySelectedIndex = indexPath
|
|
|
selecteBtn.setTitle(categoryData[indexPath.item].title, for: .normal)
|
|
|
selecteBtn.imagePosition(at: PQButtonImageEdgeInsetsStyle.right, space: cDefaultMargin / 2)
|
|
|
-
|
|
|
+ if !isAssetImage {
|
|
|
+ playBtn.isHidden = false
|
|
|
+ sliderView.isHidden = true
|
|
|
+ avPlayer.pause()
|
|
|
+ if selectedData != nil {
|
|
|
+ selectedData = nil
|
|
|
+ UIView.animate(withDuration: 0.5, animations: { [weak self] in
|
|
|
+ self?.playerHeaderView.frame = CGRect(x: 0, y: -(self?.preViewSize.height ?? 0) - cDevice_iPhoneNavBarAndStatusBarHei, width: self?.preViewSize.width ?? 0, height: self?.preViewSize.height ?? 0)
|
|
|
+ self?.playerHeaderView.center.x = self?.view.center.x ?? 0
|
|
|
+ self?.sliderView.frame.origin.y = self?.playerHeaderView.frame.maxY ?? 0
|
|
|
+ self?.collectionView.frame = CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei, width: cScreenWidth, height: cScreenHeigth - cDevice_iPhoneNavBarAndStatusBarHei)
|
|
|
+ }) { _ in
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
lastSeletedIndex = nil
|
|
|
-
|
|
|
+ isPublishEnabled()
|
|
|
if allPhotos.count <= 0 {
|
|
|
emptyRemindView.frame = CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei, width: cScreenWidth, height: cScreenHeigth - cDevice_iPhoneNavBarAndStatusBarHei - cDevice_iPhoneTabBarHei)
|
|
|
emptyRemindView.emptyData = emptyData
|
|
@@ -693,29 +862,29 @@ extension PQUploadController: UICollectionViewDelegate, UICollectionViewDataSour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, sizeForItemAt _: IndexPath) -> CGSize {
|
|
|
+ open func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, sizeForItemAt _: IndexPath) -> CGSize {
|
|
|
if collectionView == self.collectionView {
|
|
|
return CGSize(width: (cScreenWidth - cDefaultMargin) / 3, height: (cScreenWidth - cDefaultMargin) / 3)
|
|
|
}
|
|
|
return CGSize(width: collectionView.frame.width, height: cDefaultMargin * 8)
|
|
|
}
|
|
|
|
|
|
- public func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, minimumLineSpacingForSectionAt _: Int) -> CGFloat {
|
|
|
+ open func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, minimumLineSpacingForSectionAt _: Int) -> CGFloat {
|
|
|
if collectionView == self.collectionView {
|
|
|
return cDefaultMargin / 2
|
|
|
}
|
|
|
return 0
|
|
|
}
|
|
|
|
|
|
- public func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, minimumInteritemSpacingForSectionAt _: Int) -> CGFloat {
|
|
|
+ open func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, minimumInteritemSpacingForSectionAt _: Int) -> CGFloat {
|
|
|
if collectionView == self.collectionView {
|
|
|
return cDefaultMargin / 2
|
|
|
}
|
|
|
return 0
|
|
|
}
|
|
|
|
|
|
- public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
|
|
-
|
|
|
+ open func scrollViewDidScroll(_: UIScrollView) {
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -729,20 +898,6 @@ extension PQUploadController: UICollectionViewDelegate, UICollectionViewDataSour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-extension PQUploadController: PHPhotoLibraryChangeObserver {
|
|
|
- public func photoLibraryDidChange(_ changeInstance: PHChange) {
|
|
|
-
|
|
|
-
|
|
|
- DispatchQueue.main.sync { [weak self] in
|
|
|
-
|
|
|
- if allPhotos != nil, changeInstance.changeDetails(for: allPhotos) != nil {
|
|
|
- self?.categoryData.removeAll()
|
|
|
- self?.loadPhotoData()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
extension PQUploadController {
|
|
|
|
|
|
|
|
@@ -780,7 +935,7 @@ extension PQUploadController {
|
|
|
}
|
|
|
|
|
|
private func updateCachedAssets() {
|
|
|
- if allPhotos != nil && allPhotos.count <= 0 {
|
|
|
+ if allPhotos != nil, allPhotos.count <= 0 {
|
|
|
return
|
|
|
}
|
|
|
guard isViewLoaded, view.window != nil else { return }
|
|
@@ -829,4 +984,17 @@ extension PQUploadController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+extension PQUploadController: PHPhotoLibraryChangeObserver {
|
|
|
+ public func photoLibraryDidChange(_ changeInstance: PHChange) {
|
|
|
+
|
|
|
+
|
|
|
+ DispatchQueue.main.sync { [weak self] in
|
|
|
+
|
|
|
+ if allPhotos != nil, changeInstance.changeDetails(for: allPhotos) != nil {
|
|
|
+ self?.categoryData.removeAll()
|
|
|
+ self?.loadPhotoData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|