INIntroduceController.swift 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //
  2. // INIntrocudeController.swift
  3. // Introduce
  4. //
  5. // Created by 胡志强 on 2021/11/29.
  6. //
  7. import BFCommonKit
  8. import BFRecordScreenKit
  9. import BFUIKit
  10. import Foundation
  11. import Photos
  12. import UIKit
  13. class INIntroduceController: BFBaseViewController {
  14. var stripSwithView: BFStripSwithView?
  15. let exportBtn = UIButton()
  16. var assets: [PHAsset]? {
  17. didSet {
  18. if let ass = assets {
  19. recordScreenVC.assets = ass
  20. }
  21. }
  22. }
  23. let recordScreenVC = BFRecordScreenController()
  24. override func viewWillAppear(_ animated: Bool) {
  25. super.viewWillAppear(animated)
  26. showNavigation()
  27. PQNotification.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
  28. PQNotification.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
  29. }
  30. override func viewWillDisappear(_ animated: Bool) {
  31. super.viewWillDisappear(animated)
  32. PQNotification.removeObserver(self)
  33. }
  34. @objc internal func keyboardWillHide(_: Notification?) {
  35. navHeadImageView?.isHidden = false
  36. }
  37. @objc internal func keyboardWillShow(_: Notification?) {
  38. navHeadImageView?.isHidden = true
  39. }
  40. override func viewDidLoad() {
  41. super.viewDidLoad()
  42. navHeadImageView?.backgroundColor = .clear
  43. leftButton(image: nil, imageName: nil, tintColor: .white)
  44. exportBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#28BE67")
  45. exportBtn.setTitle("导出", for: .normal)
  46. exportBtn.addCorner(corner: 4)
  47. exportBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16)
  48. exportBtn.addTarget(self, action: #selector(exportAction), for: .touchUpInside)
  49. navHeadImageView?.addSubview(exportBtn)
  50. exportBtn.frame = CGRect(x: (navHeadImageView?.frame.width ?? 0) - 12 - 60, y: 0, width: 60, height: 36)
  51. exportBtn.center.y = backButton?.center.y ?? 0
  52. addChild(recordScreenVC)
  53. recordScreenVC.view.frame = view.frame
  54. view.addSubview(recordScreenVC.view)
  55. recordScreenVC.changeItemHandle = { [weak self] index in
  56. self?.stripSwithView?.changeSwitchStatus(index: index)
  57. }
  58. if assets != nil, (assets?.count ?? 0) > 1 {
  59. 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)
  60. stripSwithView?.center.y = backButton?.center.y ?? 0
  61. stripSwithView?.itemClickHandle = { [weak self] _, index in
  62. self?.recordScreenVC.updateContentOffset(index: index)
  63. }
  64. navHeadImageView?.addSubview(stripSwithView!)
  65. }
  66. }
  67. override func backBtnClick() {
  68. let alertController = UIAlertController(title: "退出将不会保存当前操作",
  69. message: "", preferredStyle: .alert)
  70. let cancelAction = UIAlertAction(title: "不退出", style: .default, handler: nil)
  71. let okAction = UIAlertAction(title: "确认退出", style: .cancel, handler: {[weak self]
  72. action in
  73. print("点击了确定")
  74. self?.recordScreenVC.backBtnClick()
  75. self?.super_back()
  76. })
  77. okAction.setValue(UIColor.red, forKey:"titleTextColor")
  78. alertController.addAction(okAction)
  79. alertController.addAction(cancelAction)
  80. self.present(alertController, animated: true, completion: nil)
  81. }
  82. private func super_back() {
  83. super.backBtnClick()
  84. }
  85. @objc func exportAction() {
  86. recordScreenVC.backBtnClick()
  87. let controller = INVideoExportController()
  88. controller.export.data = recordScreenVC.itemModels
  89. controller.export.originSoundVolumn = recordScreenVC.noSpeakVolume
  90. controller.export.originSoundInRecordVolumn = recordScreenVC.haveSpeakVolume
  91. navigationController?.pushViewController(controller, animated: true)
  92. }
  93. }