MVSettingController.swift 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //
  2. // MVSettingController.swift
  3. // MusicVideoPlus
  4. //
  5. // Created by ak on 2021/6/2.
  6. //
  7. import UIKit
  8. import BFFramework
  9. class MVSettingController: MVBaseController{
  10. //tips 1
  11. lazy var tipsA: UILabel = {
  12. let tipsA = UILabel()
  13. tipsA.font = UIFont.systemFont(ofSize: 26, weight: .medium)
  14. tipsA.textColor = UIColor.hexColor(hexadecimal: "#929292")
  15. let infoDictionary = Bundle.main.infoDictionary
  16. let majorVersion :String = infoDictionary! ["CFBundleShortVersionString"] as! String//主程序版本号
  17. let buildVersion :String = infoDictionary! ["CFBundleVersion"] as! String//主程序版本号
  18. tipsA.text = "APP版本号\nV\(majorVersion)\n\(buildVersion)"
  19. tipsA.lineBreakMode = .byWordWrapping
  20. tipsA.textAlignment = .center
  21. tipsA.numberOfLines = 0
  22. return tipsA
  23. }()
  24. //显示协议
  25. lazy var protocolLab: TYAttributedLabel = {
  26. let protocolLab = TYAttributedLabel()
  27. protocolLab.highlightedLinkBackgroundColor = UIColor.clear
  28. protocolLab.backgroundColor = UIColor.clear
  29. protocolLab.delegate = self
  30. protocolLab.numberOfLines = 0
  31. protocolLab.font = UIFont.systemFont(ofSize: 14)
  32. protocolLab.text = ""
  33. protocolLab.textColor = UIColor.hexColor(hexadecimal: "#999999")
  34. protocolLab.appendLink(withText: "《用户协议》", linkFont: UIFont.systemFont(ofSize: 14), linkColor: UIColor.hexColor(hexadecimal: "#6783AC"), underLineStyle: CTUnderlineStyle.init(), linkData: cUserProtocol)
  35. protocolLab.appendLink(withText: "《隐私协议》", linkFont: UIFont.systemFont(ofSize: 14), linkColor: UIColor.hexColor(hexadecimal: "#6783AC"), underLineStyle: CTUnderlineStyle.init(), linkData: cPrivacy)
  36. protocolLab.textAlignment = CTTextAlignment.center
  37. return protocolLab
  38. }()
  39. // 卡点视频 btn
  40. lazy var logoutBtn: UIButton = {
  41. let logoutBtn = UIButton(type: .custom)
  42. logoutBtn.addTarget(self, action: #selector(btnClick), for: .touchUpInside)
  43. logoutBtn.setImage(UIImage(named: "logoutBtn"), for: .normal)
  44. logoutBtn.adjustsImageWhenHighlighted = false
  45. return logoutBtn
  46. }()
  47. override func viewWillAppear(_: Bool) {
  48. super.viewWillAppear(true)
  49. showNavigation()
  50. leftButton(image: "back_black")
  51. }
  52. override func viewDidLoad() {
  53. super.viewDidLoad()
  54. view.backgroundColor = UIColor.hexColor(hexadecimal: "#F2F2F2")
  55. navHeadImageView?.backgroundColor = UIColor.hexColor(hexadecimal: "#F2F2F2")
  56. view.addSubview(tipsA)
  57. view.addSubview(protocolLab)
  58. view.addSubview(logoutBtn)
  59. addLayout()
  60. logoutBtn.isHidden = !BFLoginUserInfo.shared.isLogin()
  61. }
  62. @objc func btnClick() {
  63. BFLog(message: "logout ")
  64. let remindData:PQBaseModel = PQBaseModel()
  65. remindData.title = "退出?"
  66. let remindView = PQRemindView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
  67. UIApplication.shared.keyWindow?.addSubview(remindView)
  68. remindView.remindData = remindData
  69. remindView.remindBlock = { [weak self] sender, _ in
  70. if sender.tag == 2 {
  71. PQMineViewModel.quitLogin { [weak self] _, _ in
  72. postNotification(name: cQuitSuccesssNotiKey)
  73. self?.logoutBtn.isHidden = true
  74. self?.navigationController?.popViewController(animated: true)
  75. }
  76. }
  77. }
  78. }
  79. func addLayout() {
  80. tipsA.snp.remakeConstraints { make in
  81. make.width.equalTo(182)
  82. make.height.equalTo(160)
  83. make.centerX.equalToSuperview()
  84. make.top.equalToSuperview().offset(113)
  85. }
  86. protocolLab.snp.makeConstraints { make in
  87. make.bottom.equalTo(view).offset(-cDefaultMargin * 5)
  88. make.left.equalTo(view).offset(cDefaultMargin * 2)
  89. make.right.equalTo(view).offset(-cDefaultMargin * 2)
  90. make.height.equalTo(cScreenHeigth <= 568 ? cDefaultMargin * 4 : cDefaultMargin * 6)
  91. }
  92. logoutBtn.snp.makeConstraints { make in
  93. make.bottom.equalTo(protocolLab.snp.top).offset(-30)
  94. make.centerX.equalToSuperview()
  95. make.height.equalTo(50)
  96. make.width.equalTo(335)
  97. }
  98. }
  99. }
  100. extension MVSettingController: TYAttributedLabelDelegate {
  101. func attributedLabel(_: TYAttributedLabel!, textStorageClicked textStorage: TYTextStorageProtocol!, at _: CGPoint) {
  102. var link: String? = (textStorage as? TYLinkTextStorage)?.linkData as? String ?? ""
  103. if link == nil || (link?.count ?? 0) <= 0 {
  104. let range = (textStorage as? TYLinkTextStorage)?.range
  105. if range?.length == 0 {
  106. link = cUserProtocol
  107. } else if range?.length == 6 {
  108. link = cPrivacy
  109. }
  110. }
  111. let detail = PQBaseWebViewController()
  112. detail.baseUrl = link
  113. navigationController?.pushViewController(detail, animated: true)
  114. }
  115. }