|
@@ -14,15 +14,16 @@ import UIKit
|
|
import BFAnalyzeKit
|
|
import BFAnalyzeKit
|
|
|
|
|
|
class INIntroduceController: BFBaseViewController {
|
|
class INIntroduceController: BFBaseViewController {
|
|
- var stripSwithView: BFStripSwithView?
|
|
|
|
- let exportBtn = UIButton()
|
|
|
|
- var assets: [PHAsset]? {
|
|
|
|
- didSet {
|
|
|
|
- if let ass = assets {
|
|
|
|
- recordScreenVC.assets = ass
|
|
|
|
- }
|
|
|
|
|
|
+ lazy var stripSwithView : BFStripSwithView = {
|
|
|
|
+ let v = BFStripSwithView(frame: .zero, items: 0, space: 4)
|
|
|
|
+ v.itemClickHandle = { [weak self] _, index in
|
|
|
|
+ guard let wself = self else { return }
|
|
|
|
+ wself.recordScreenVC.updateContentOffset(index: index)
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ return v
|
|
|
|
+ }()
|
|
|
|
+ let exportBtn = UIButton()
|
|
|
|
+ var assets: [PHAsset]?
|
|
|
|
|
|
let recordScreenVC = BFRecordScreenController()
|
|
let recordScreenVC = BFRecordScreenController()
|
|
|
|
|
|
@@ -62,10 +63,6 @@ class INIntroduceController: BFBaseViewController {
|
|
navHeadImageView?.image = UIImage(named: "top_shadow")
|
|
navHeadImageView?.image = UIImage(named: "top_shadow")
|
|
navHeadImageView?.contentMode = .scaleToFill
|
|
navHeadImageView?.contentMode = .scaleToFill
|
|
leftButton(image: nil, imageName: nil, tintColor: .white)
|
|
leftButton(image: nil, imageName: nil, tintColor: .white)
|
|
-
|
|
|
|
-
|
|
|
|
- addMaterialBtn.frame = CGRect(x: backButton?.rightX ?? 0, y: backButton?.y ?? 0, width: 30, height: backButton?.height ?? 0)
|
|
|
|
- navHeadImageView?.addSubview(addMaterialBtn)
|
|
|
|
|
|
|
|
exportBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#389AFF")
|
|
exportBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#389AFF")
|
|
exportBtn.setTitle("导出", for: .normal)
|
|
exportBtn.setTitle("导出", for: .normal)
|
|
@@ -79,8 +76,20 @@ class INIntroduceController: BFBaseViewController {
|
|
addChild(recordScreenVC)
|
|
addChild(recordScreenVC)
|
|
recordScreenVC.view.frame = view.frame
|
|
recordScreenVC.view.frame = view.frame
|
|
view.addSubview(recordScreenVC.view)
|
|
view.addSubview(recordScreenVC.view)
|
|
|
|
+ if let ass = assets {
|
|
|
|
+ recordScreenVC.fetchMaterial(ass)
|
|
|
|
+ }
|
|
recordScreenVC.changeItemHandle = { [weak self] index in
|
|
recordScreenVC.changeItemHandle = { [weak self] index in
|
|
- self?.stripSwithView?.changeSwitchStatus(index: index)
|
|
|
|
|
|
+
|
|
|
|
+ guard let wself = self else { return }
|
|
|
|
+
|
|
|
|
+ // 删除了一条
|
|
|
|
+ if index == -3 {
|
|
|
|
+ wself.resetStripSwithView(wself.recordScreenVC.itemModels.count)
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ wself.stripSwithView.changeSwitchStatus(index: index)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
recordScreenVC.recordEndHandle = {model in
|
|
recordScreenVC.recordEndHandle = {model in
|
|
// 录音完成时上报
|
|
// 录音完成时上报
|
|
@@ -90,17 +99,27 @@ class INIntroduceController: BFBaseViewController {
|
|
// 点击字幕按钮上报
|
|
// 点击字幕按钮上报
|
|
BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_captionsButton, pageSource: .sp_speekPage,extParams: ["isSubtitlesClose":isOn],commonParams: commonParams())
|
|
BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_captionsButton, pageSource: .sp_speekPage,extParams: ["isSubtitlesClose":isOn],commonParams: commonParams())
|
|
}
|
|
}
|
|
- if assets != nil, (assets?.count ?? 0) > 1 {
|
|
|
|
- stripSwithView = BFStripSwithView(frame: CGRect(x: (backButton?.frame.maxX ?? 0), y: 0, width: exportBtn.frame.minX - (backButton?.frame.maxX ?? 0) - 10, height: cDevice_iPhoneNavBarHei), items: assets?.count ?? 1,space: 4)
|
|
|
|
- stripSwithView?.center.y = backButton?.center.y ?? 0
|
|
|
|
- stripSwithView?.itemClickHandle = { [weak self] _, index in
|
|
|
|
- self?.recordScreenVC.updateContentOffset(index: index)
|
|
|
|
-// if (self?.assets?.count ?? 0) > index {
|
|
|
|
-// // 曝光上报
|
|
|
|
-// BFEventTrackAdaptor.baseReportUpload(businessType: .bt_pageView, objectType: self?.assets?[index].mediaType == .video ? .ot_video: .ot_image, pageSource: .sp_speekPage, commonParams: commonParams())
|
|
|
|
-// }
|
|
|
|
|
|
+
|
|
|
|
+ navHeadImageView?.addSubview(stripSwithView)
|
|
|
|
+ navHeadImageView?.addSubview(addMaterialBtn)
|
|
|
|
+ stripSwithView.snp.makeConstraints { make in
|
|
|
|
+ make.left.equalTo(backButton!.snp.right).offset(5)
|
|
|
|
+ make.top.height.equalTo(backButton!)
|
|
|
|
+ if assets!.count > 1 {
|
|
|
|
+ make.width.equalTo(cScreenWidth).priority(.high)
|
|
|
|
+ }else{
|
|
|
|
+ make.width.equalTo(0).priority(.high)
|
|
}
|
|
}
|
|
- navHeadImageView?.addSubview(stripSwithView!)
|
|
|
|
|
|
+ }
|
|
|
|
+ addMaterialBtn.snp.makeConstraints { make in
|
|
|
|
+ make.left.equalTo(stripSwithView.snp.right).offset(-2)
|
|
|
|
+ make.top.height.equalTo(backButton!)
|
|
|
|
+ make.width.equalTo(addMaterialBtn.snp.height)
|
|
|
|
+ make.right.lessThanOrEqualTo(exportBtn.snp.left).offset(-15)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if assets != nil, (assets?.count ?? 0) > 1 {
|
|
|
|
+ stripSwithView.resetView(count: assets?.count ?? 0)
|
|
} else if assets != nil,(assets?.count ?? 0) > 0 {
|
|
} else if assets != nil,(assets?.count ?? 0) > 0 {
|
|
// 曝光上报
|
|
// 曝光上报
|
|
BFEventTrackAdaptor.baseReportUpload(businessType: .bt_pageView, objectType: assets?.first?.mediaType == .video ? .ot_video: .ot_image, pageSource: .sp_speekPage, commonParams: commonParams())
|
|
BFEventTrackAdaptor.baseReportUpload(businessType: .bt_pageView, objectType: assets?.first?.mediaType == .video ? .ot_video: .ot_image, pageSource: .sp_speekPage, commonParams: commonParams())
|
|
@@ -117,13 +136,67 @@ class INIntroduceController: BFBaseViewController {
|
|
}
|
|
}
|
|
|
|
|
|
// MARK: - Button action
|
|
// MARK: - Button action
|
|
|
|
+ func updateAsset(_ phAssets:[PHAsset]) {
|
|
|
|
+ recordScreenVC.fetchMaterial(phAssets)
|
|
|
|
+ resetStripSwithView(recordScreenVC.itemModels.count)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func resetStripSwithView(_ count: Int){
|
|
|
|
+ stripSwithView.resetView(count: count)
|
|
|
|
+ DispatchQueue.main.async {[weak self] in
|
|
|
|
+ guard let wself = self else { return }
|
|
|
|
+ wself.stripSwithView.snp.updateConstraints { make in
|
|
|
|
+ if count > 1 {
|
|
|
|
+ make.width.equalTo(cScreenWidth).priority(.high)
|
|
|
|
+ }else{
|
|
|
|
+ make.width.equalTo(0).priority(.high)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ wself.stripSwithView.setNeedsLayout()
|
|
|
|
+ wself.stripSwithView.layoutIfNeeded()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@objc func addmaterial(){
|
|
@objc func addmaterial(){
|
|
- let vc = INPhotoVideosController()
|
|
|
|
-
|
|
|
|
|
|
+ if recordScreenVC.itemModels.count >= 20{
|
|
|
|
+ cShowHUB(superView: nil, msg: "已经选择了20个素材了!!")
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if recordScreenVC.isNormalPlaying {
|
|
|
|
+ recordScreenVC.pause()
|
|
|
|
+// recordScreenVC.playVideo(btn: recordScreenVC.playBtn)
|
|
|
|
+ }
|
|
|
|
+ let alertv = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
|
|
|
+ if recordScreenVC.itemModels.count > 0 && recordScreenVC.itemModels.last!.mediaType != .Camera {
|
|
|
|
+ let action = UIAlertAction(title: "拍摄录制", style: .default) {[weak self] action in
|
|
|
|
+ guard let wself = self else { return }
|
|
|
|
+
|
|
|
|
+ let phAsset = PHAsset()
|
|
|
|
+ phAsset.title = "record.camera"
|
|
|
|
+ wself.updateAsset([phAsset])
|
|
|
|
+ }
|
|
|
|
+ alertv.addAction(action)
|
|
|
|
+ }
|
|
|
|
|
|
- navigationController?.present(vc, animated: true, completion: {
|
|
|
|
|
|
+ let action1 = UIAlertAction(title: "从相册选择", style: .destructive) {[weak self] action in
|
|
|
|
+ guard let wself = self else { return }
|
|
|
|
+ let vc = INPhotoVideosController()
|
|
|
|
+ vc.maxMaterialNum = 20 - wself.recordScreenVC.itemModels.count
|
|
|
|
+ vc.modalPresentationStyle = .fullScreen
|
|
|
|
+ vc.nextBtnCallBack = {[weak self] phAssets in
|
|
|
|
+ guard let wself = self else { return }
|
|
|
|
+
|
|
|
|
+ wself.updateAsset(phAssets)
|
|
|
|
+ }
|
|
|
|
|
|
- })
|
|
|
|
|
|
+ wself.navigationController?.present(vc, animated: true, completion: nil)
|
|
|
|
+ }
|
|
|
|
+ alertv.addAction(action1)
|
|
|
|
+
|
|
|
|
+ let action2 = UIAlertAction(title: "取消", style: .cancel, handler: nil)
|
|
|
|
+ alertv.addAction(action2)
|
|
|
|
+
|
|
|
|
+ self.present(alertv, animated: true, completion: nil)
|
|
}
|
|
}
|
|
|
|
|
|
override func backBtnClick() {
|
|
override func backBtnClick() {
|