INRecorderController.swift 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. //
  2. // INRecorderController.swift
  3. // Introduce
  4. //
  5. // Created by 胡志强 on 2021/11/29.
  6. // 首页
  7. import BFMaterialKit
  8. import BFRecordScreenKit
  9. import BFUIKit
  10. import Foundation
  11. import UIKit
  12. import TYAttributedLabel
  13. import BFCommonKit
  14. import BFAnalyzeKit
  15. public let cUserProtocol = "https://weapppiccdn.yishihui.com/resources/agreements/shishuo/videoservice.html?type=20"
  16. /** 隐私政策 */
  17. public let cPrivacy = "https://weapppiccdn.yishihui.com/resources/agreements/shishuo/videoagreement.html?type=20"
  18. class INRecorderController: BFBaseViewController {
  19. lazy var addVideoBtn: UIButton = {
  20. let btn = UIButton(type: .custom)
  21. // btn.setTitle("Add", for: .normal)
  22. btn.setImage(UIImage(named: "add"), for: .normal)
  23. btn.addTarget(self, action: #selector(addVideo), for: .touchUpInside)
  24. return btn
  25. }()
  26. lazy var bgView:UIImageView = {
  27. let bgView = UIImageView.init(frame: CGRect.init(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
  28. bgView.contentMode = .scaleAspectFill
  29. bgView.image = UIImage(named: "homebg")
  30. return bgView
  31. }()
  32. //欢迎界面
  33. lazy var centerView:UIView = {
  34. let view = UIView.init()
  35. return view
  36. }()
  37. //欢迎界面
  38. lazy var welcomeView:UIView = {
  39. let view = UIView.init()
  40. view.backgroundColor = .white
  41. view.addCorner(corner:17)
  42. return view
  43. }()
  44. //欢迎界面背景
  45. lazy var welcomeBackView:UIView = {
  46. let view = UIView.init(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
  47. view.backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.6)
  48. return view
  49. }()
  50. lazy var welcomeTitle:UILabel = {
  51. let l = UILabel()
  52. l.text = "home_agreement_tittle".BFLocale
  53. l.textColor = .black
  54. l.font = UIFont.boldSystemFont(ofSize: 22)
  55. l.textAlignment = .center
  56. view.addSubview(l)
  57. return l
  58. }()
  59. //显示编译时间
  60. lazy var buildTimeLabel:UILabel = {
  61. let l = UILabel.init(frame: CGRect.init(x: 0, y: 120, width: cScreenWidth, height: 20))
  62. l.text = "打包时间:" + PQENVUtil.shared.ENBuildTime
  63. l.textColor = .white
  64. l.font = UIFont.boldSystemFont(ofSize: 18)
  65. l.textAlignment = .left
  66. return l
  67. }()
  68. lazy var protocolLab: TYAttributedLabel = {
  69. let protocolLab = TYAttributedLabel()
  70. protocolLab.highlightedLinkBackgroundColor = UIColor.clear
  71. protocolLab.backgroundColor = UIColor.clear
  72. protocolLab.numberOfLines = 0
  73. protocolLab.delegate = self
  74. protocolLab.font = UIFont.systemFont(ofSize: 14)
  75. protocolLab.text = "home_agreement_begin".BFLocale
  76. protocolLab.textColor = UIColor(red: 0.262, green: 0.262, blue: 0.262, alpha: 1)
  77. protocolLab.appendLink(withText: "home_agreement_service".BFLocale, linkFont: UIFont.systemFont(ofSize: 14), linkColor: UIColor.hexColor(hexadecimal: "#90a9d2"), underLineStyle:CTUnderlineStyle(), linkData: cUserProtocol)
  78. protocolLab.appendLink(withText: "home_agreement_privacy".BFLocale, linkFont: UIFont.systemFont(ofSize: 14), linkColor: UIColor.hexColor(hexadecimal: "#90a9d2"), underLineStyle:CTUnderlineStyle(), linkData: cPrivacy)
  79. protocolLab.appendLink(withText: "\("home_agreement_remarks".BFLocale)\n\n", linkFont: UIFont.systemFont(ofSize: 14), linkColor: UIColor.hexColor(hexadecimal: "#434343"), underLineStyle: CTUnderlineStyle(), linkData: nil)
  80. protocolLab.appendLink(withText: "home_agreement_prompt".BFLocale, linkFont: UIFont.systemFont(ofSize: 14), linkColor: UIColor(red: 0.262, green: 0.262, blue: 0.262, alpha: 1), underLineStyle: CTUnderlineStyle(), linkData: nil)
  81. protocolLab.textAlignment = CTTextAlignment.left
  82. return protocolLab
  83. }()
  84. lazy var doneBtn:UIButton = {
  85. let doneBtn = UIButton()
  86. doneBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#389AFF")
  87. doneBtn.setTitle("option_accept".BFLocale, for: .normal)
  88. doneBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16)
  89. doneBtn.addTarget(self, action: #selector(doneAction), for: .touchUpInside)
  90. doneBtn.addCorner(corner: 4)
  91. return doneBtn
  92. }()
  93. lazy var cancleBtn:UIButton = {
  94. let cancleBtn = UIButton()
  95. cancleBtn.backgroundColor = UIColor.clear
  96. cancleBtn.setTitle("option_refuse".BFLocale, for: .normal)
  97. cancleBtn.setTitleColor( UIColor(red: 0.262, green: 0.262, blue: 0.262, alpha: 1), for: .normal)
  98. cancleBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14)
  99. cancleBtn.addTarget(self, action: #selector(cancleAction), for: .touchUpInside)
  100. cancleBtn.addCorner(corner: 4)
  101. return cancleBtn
  102. }()
  103. override func viewWillAppear(_ animated: Bool) {
  104. super.viewWillAppear(animated)
  105. hiddenNavigation()
  106. // 曝光上报
  107. BFEventTrackAdaptor.baseReportUpload(businessType: .bt_pageView, objectType: nil, pageSource: .sp_homePage, commonParams: commonParams())
  108. }
  109. lazy var bottomView:UIView = {
  110. let bottomView = UIView(frame:CGRect.init(x: 0, y: view.frame.height - cSafeAreaHeight - 20 - 30, width: view.frame.width, height: 30))
  111. let userProBtn = UIButton.init(type: .custom)
  112. userProBtn.setTitle("hone_privacy".BFLocale, for: .normal)
  113. userProBtn.tag = 1
  114. userProBtn.titleLabel?.font = UIFont.systemFont(ofSize: 13)
  115. userProBtn.setTitleColor(UIColor.hexColor(hexadecimal: "6E7F9A"), for: .normal)
  116. userProBtn.addTarget(self, action: #selector(protocolClick(sender:)), for: .touchUpInside)
  117. let lineLab = UILabel()
  118. lineLab.text = " | "
  119. lineLab.font = UIFont.systemFont(ofSize: 13)
  120. lineLab.textColor = UIColor.hexColor(hexadecimal: "6E7F9A")
  121. let priProBtn = UIButton.init(type: .custom)
  122. priProBtn.setTitle("hone_service".BFLocale, for: .normal)
  123. priProBtn.tag = 2
  124. priProBtn.titleLabel?.font = UIFont.systemFont(ofSize: 13)
  125. priProBtn.setTitleColor(UIColor.hexColor(hexadecimal: "6E7F9A"), for: .normal)
  126. priProBtn.addTarget(self, action: #selector(protocolClick(sender:)), for: .touchUpInside)
  127. bottomView.addSubview(userProBtn)
  128. bottomView.addSubview(lineLab)
  129. bottomView.addSubview(priProBtn)
  130. lineLab.snp.makeConstraints { make in
  131. make.center.equalToSuperview()
  132. }
  133. userProBtn.snp.makeConstraints { make in
  134. make.right.equalTo(lineLab.snp.left)
  135. make.centerY.equalToSuperview()
  136. }
  137. priProBtn.snp.makeConstraints { make in
  138. make.left.equalTo(lineLab.snp.right)
  139. make.centerY.equalToSuperview()
  140. }
  141. return bottomView
  142. }()
  143. override func viewDidLoad() {
  144. super.viewDidLoad()
  145. view.backgroundColor = .black
  146. view.addSubview(bgView)
  147. if(PQENVUtil.shared.channel == "Development"){
  148. view.addSubview(buildTimeLabel)
  149. }
  150. view.addSubview(centerView)
  151. view.addSubview(bottomView)
  152. centerView.snp.makeConstraints { make in
  153. make.width.equalTo(140)
  154. make.height.equalTo(209)
  155. make.center.equalToSuperview()
  156. }
  157. centerView.addSubview(addVideoBtn)
  158. addVideoBtn.snp.makeConstraints { make in
  159. make.top.equalToSuperview().offset(5)
  160. make.left.equalToSuperview().offset(5)
  161. make.width.height.equalTo(130)
  162. }
  163. let l = UILabel()
  164. l.text = "hone_star".BFLocale
  165. l.textColor = UIColor.hexColor(hexadecimal: "#8C9399")
  166. l.font = UIFont.systemFont(ofSize: 17)
  167. centerView.addSubview(l)
  168. let text = l.text
  169. let attributedString = NSMutableAttributedString.init(string: text!)
  170. let paragraphStyle = NSMutableParagraphStyle()
  171. paragraphStyle.lineSpacing = 7
  172. paragraphStyle.alignment = .center
  173. attributedString.addAttribute(.paragraphStyle, value: paragraphStyle, range: .init(location: 0, length: l.text?.count ?? 0))
  174. l.attributedText = attributedString
  175. l.sizeToFit()
  176. l.numberOfLines = 2
  177. l.snp.makeConstraints { make in
  178. make.top.equalTo(addVideoBtn.snp.bottom).offset(19)
  179. make.centerX.equalToSuperview()
  180. make.width.equalTo(200)
  181. make.height.equalTo(60)
  182. }
  183. //欢迎界面
  184. if(getUserDefaults(key: "welcomeViewisshow") == nil){
  185. view.addSubview(welcomeBackView)
  186. welcomeBackView.addSubview(welcomeView)
  187. welcomeView.addSubview(protocolLab)
  188. welcomeView.addSubview(welcomeTitle)
  189. welcomeView.addSubview(doneBtn)
  190. welcomeView.addSubview(cancleBtn)
  191. welcomeView.snp.makeConstraints{ make in
  192. make.center.equalToSuperview()
  193. make.width.equalTo(280)
  194. make.height.equalTo(350)
  195. }
  196. welcomeTitle.snp.makeConstraints{ make in
  197. make.centerX.equalToSuperview()
  198. make.width.equalToSuperview()
  199. make.top.equalToSuperview().offset(30)
  200. make.height.equalTo(31)
  201. }
  202. protocolLab.snp.makeConstraints{ make in
  203. make.centerX.equalToSuperview()
  204. make.width.equalTo(230)
  205. make.top.equalTo(welcomeTitle.snp.bottom).offset(16)
  206. make.height.equalTo(140)
  207. }
  208. doneBtn.snp.makeConstraints { make in
  209. make.centerX.equalToSuperview()
  210. make.width.equalTo(230)
  211. make.height.equalTo(47)
  212. make.top.equalTo(protocolLab.snp.bottom).offset(30)
  213. }
  214. cancleBtn.snp.makeConstraints { make in
  215. make.centerX.equalToSuperview()
  216. make.width.equalTo(230)
  217. make.height.equalTo(20)
  218. make.top.equalTo(doneBtn.snp.bottom).offset(17)
  219. }
  220. }
  221. // add by ak 取 nsl token
  222. BFRecordScreenViewModel.getNlsAccessToken { [weak self] token, appkey in
  223. BFLog(message: "提前取一次nls appkey is \(appkey), token is \(token)")
  224. }
  225. }
  226. @objc func doneAction() {
  227. welcomeBackView.isHidden = true
  228. saveUserDefaults(key: "welcomeViewisshow", value: "true")
  229. }
  230. @objc func cancleAction() {
  231. welcomeBackView.isHidden = true
  232. exit(-1)
  233. }
  234. override func didReceiveMemoryWarning() {
  235. super.didReceiveMemoryWarning()
  236. // Dispose of any resources that can be recreated.
  237. }
  238. @objc func addVideo() {
  239. if (getUserDefaults(key: "welcomeViewisshow") == nil) {
  240. welcomeBackView.isHidden = false
  241. }else{
  242. let vc = INPhotoVideosController()
  243. vc.hidesBottomBarWhenPushed = true
  244. navigationController?.pushViewController(vc, animated: true)
  245. // 按钮点击
  246. BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_addVideo, pageSource: .sp_homePage, commonParams: commonParams())
  247. }
  248. }
  249. @objc func protocolClick(sender:UIButton) {
  250. var link: String?
  251. if sender.tag == 1 {
  252. link = cUserProtocol
  253. } else {
  254. link = cPrivacy
  255. }
  256. if link != nil, (link?.count ?? 0) > 0 {
  257. let detail = BFBaseWebViewController()
  258. detail.baseUrl = link
  259. self.navigationController?.pushViewController(detail, animated: true)
  260. }
  261. }
  262. }
  263. //点击超链接回调
  264. extension INRecorderController: TYAttributedLabelDelegate {
  265. func attributedLabel(_: TYAttributedLabel!, textStorageClicked textStorage: TYTextStorageProtocol!, at _: CGPoint) {
  266. let link: String? = (textStorage as? TYLinkTextStorage)?.linkData as? String ?? ""
  267. if link != nil, (link?.count ?? 0) > 0 {
  268. let detail = BFBaseWebViewController()
  269. detail.baseUrl = link
  270. self.navigationController?.pushViewController(detail, animated: true)
  271. }
  272. }
  273. }