MVSettingController.swift 5.0 KB

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