123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- //
- // MVSettingController.swift
- // MusicVideoPlus
- //
- // Created by ak on 2021/6/2.
- //
- import UIKit
- import BFFramework
- class MVSettingController: MVBaseController{
- //tips 1
- lazy var tipsA: UILabel = {
- let tipsA = UILabel()
- tipsA.font = UIFont.systemFont(ofSize: 26, weight: .medium)
- tipsA.textColor = UIColor.hexColor(hexadecimal: "#929292")
- let infoDictionary = Bundle.main.infoDictionary
-
- let majorVersion :String = infoDictionary! ["CFBundleShortVersionString"] as! String//主程序版本号
- let buildVersion :String = infoDictionary! ["CFBundleVersion"] as! String//主程序版本号
- tipsA.text = "APP版本号\nV\(majorVersion)\n\(buildVersion)"
- tipsA.lineBreakMode = .byWordWrapping
- tipsA.textAlignment = .center
- tipsA.numberOfLines = 0
- return tipsA
- }()
- //显示协议
- lazy var protocolLab: TYAttributedLabel = {
- let protocolLab = TYAttributedLabel()
- protocolLab.highlightedLinkBackgroundColor = UIColor.clear
- protocolLab.backgroundColor = UIColor.clear
- protocolLab.delegate = self
- protocolLab.numberOfLines = 0
- protocolLab.font = UIFont.systemFont(ofSize: 14)
- protocolLab.text = ""
- protocolLab.textColor = UIColor.hexColor(hexadecimal: "#999999")
- protocolLab.appendLink(withText: "《用户协议》", linkFont: UIFont.systemFont(ofSize: 14), linkColor: UIColor.hexColor(hexadecimal: "#6783AC"), underLineStyle: CTUnderlineStyle.init(), linkData: cUserProtocol)
- protocolLab.appendLink(withText: "《隐私协议》", linkFont: UIFont.systemFont(ofSize: 14), linkColor: UIColor.hexColor(hexadecimal: "#6783AC"), underLineStyle: CTUnderlineStyle.init(), linkData: cPrivacy)
- protocolLab.textAlignment = CTTextAlignment.center
- return protocolLab
- }()
-
- // 卡点视频 btn
- lazy var logoutBtn: UIButton = {
- let logoutBtn = UIButton(type: .custom)
- logoutBtn.addTarget(self, action: #selector(btnClick), for: .touchUpInside)
- logoutBtn.setImage(UIImage(named: "logoutBtn"), for: .normal)
- logoutBtn.adjustsImageWhenHighlighted = false
- return logoutBtn
- }()
-
- override func viewWillAppear(_: Bool) {
- super.viewWillAppear(true)
- showNavigation()
-
- leftButton(image: "back_black")
-
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
- view.backgroundColor = UIColor.hexColor(hexadecimal: "#F2F2F2")
- navHeadImageView?.backgroundColor = UIColor.hexColor(hexadecimal: "#F2F2F2")
- view.addSubview(tipsA)
- view.addSubview(protocolLab)
- view.addSubview(logoutBtn)
- addLayout()
-
-
- logoutBtn.isHidden = !BFLoginUserInfo.shared.isLogin()
-
- }
-
- @objc func btnClick() {
- BFLog(message: "logout ")
- let remindData:PQBaseModel = PQBaseModel()
- remindData.title = "退出?"
-
- let remindView = PQRemindView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
- UIApplication.shared.keyWindow?.addSubview(remindView)
- remindView.remindData = remindData
- remindView.remindBlock = { [weak self] sender, _ in
- if sender.tag == 2 {
- PQMineViewModel.quitLogin { [weak self] _, _ in
- postNotification(name: cQuitSuccesssNotiKey)
- self?.logoutBtn.isHidden = true
- self?.navigationController?.popViewController(animated: true)
- }
- }
- }
- }
-
-
- func addLayout() {
-
- tipsA.snp.remakeConstraints { make in
- make.width.equalTo(182)
- make.height.equalTo(160)
- make.centerX.equalToSuperview()
- make.top.equalToSuperview().offset(113)
- }
-
- protocolLab.snp.makeConstraints { make in
- make.bottom.equalTo(view).offset(-cDefaultMargin * 5)
- make.left.equalTo(view).offset(cDefaultMargin * 2)
- make.right.equalTo(view).offset(-cDefaultMargin * 2)
- make.height.equalTo(cScreenHeigth <= 568 ? cDefaultMargin * 4 : cDefaultMargin * 6)
- }
-
- logoutBtn.snp.makeConstraints { make in
- make.bottom.equalTo(protocolLab.snp.top).offset(-30)
- make.centerX.equalToSuperview()
- make.height.equalTo(50)
- make.width.equalTo(335)
- }
- }
- }
- extension MVSettingController: TYAttributedLabelDelegate {
- func attributedLabel(_: TYAttributedLabel!, textStorageClicked textStorage: TYTextStorageProtocol!, at _: CGPoint) {
- var link: String? = (textStorage as? TYLinkTextStorage)?.linkData as? String ?? ""
- if link == nil || (link?.count ?? 0) <= 0 {
- let range = (textStorage as? TYLinkTextStorage)?.range
- if range?.length == 0 {
- link = cUserProtocol
- } else if range?.length == 6 {
- link = cPrivacy
- }
- }
- let detail = PQBaseWebViewController()
- detail.baseUrl = link
- navigationController?.pushViewController(detail, animated: true)
- }
- }
|