//
//  INRecorderSetting.swift
//  Introduce
//
//  Created by ak on 2022/1/24.
//  Copyright © 2022 BytesFlow. All rights reserved.
//  功能：设置界面

import Foundation
import BFUIKit
import BFCommonKit

class INRecorderSetting:BFBaseViewController{
    var cUserProtocol:String = "https://weapppiccdn.yishihui.com/resources/agreements/shishuo/videoservice_\( BFLocalizedUtil.currentLanguage()).html"
    var cPrivacy:String = "https://weapppiccdn.yishihui.com/resources/agreements/shishuo/videoagreement_\( BFLocalizedUtil.currentLanguage()).html"
    
    lazy var tipsA: UILabel = {
        let tipsA = UILabel()
        tipsA.font = UIFont.systemFont(ofSize: 40, 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 = "v\(majorVersion)"
        tipsA.lineBreakMode = .byWordWrapping
        tipsA.textAlignment = .center
        tipsA.numberOfLines = 0
        return tipsA
    }()
    
    lazy var bottomView:UIView = {
        let bottomView = UIView(frame:CGRect.init(x: 0, y: view.frame.height - cSafeAreaHeight - 20 - 30, width: view.frame.width, height: 30))
        let userProBtn = UIButton.init(type: .custom)
        userProBtn.setTitle("hone_privacy".BFLocale, for: .normal)
        userProBtn.tag = 1
        userProBtn.titleLabel?.font = UIFont.systemFont(ofSize: 13)
        userProBtn.setTitleColor(UIColor.hexColor(hexadecimal: "6E7F9A"), for: .normal)
        userProBtn.addTarget(self, action: #selector(protocolClick(sender:)), for: .touchUpInside)
        
        let lineLab = UILabel()
        lineLab.text = "   |   "
        lineLab.font = UIFont.systemFont(ofSize: 13)
        lineLab.textColor = UIColor.hexColor(hexadecimal: "6E7F9A")
        
        let priProBtn = UIButton.init(type: .custom)
        priProBtn.setTitle("hone_service".BFLocale, for: .normal)
        priProBtn.tag = 2
        priProBtn.titleLabel?.font = UIFont.systemFont(ofSize: 13)
        priProBtn.setTitleColor(UIColor.hexColor(hexadecimal: "6E7F9A"), for: .normal)
        priProBtn.addTarget(self, action: #selector(protocolClick(sender:)), for: .touchUpInside)
        
        bottomView.addSubview(userProBtn)
        bottomView.addSubview(lineLab)
        bottomView.addSubview(priProBtn)
        lineLab.snp.makeConstraints { make in
            make.center.equalToSuperview()
        }
        userProBtn.snp.makeConstraints { make in
            make.right.equalTo(lineLab.snp.left)
            make.centerY.equalToSuperview()
        }
        priProBtn.snp.makeConstraints { make in
            make.left.equalTo(lineLab.snp.right)
            make.centerY.equalToSuperview()
        }
        return bottomView
    }()
    
    override func viewWillAppear(_: Bool) {
        super.viewWillAppear(true)
        
        navigationController?.isNavigationBarHidden = true
 
 
 
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor.hexColor(hexadecimal: "#F2F2F2")
        view.addSubview(bottomView)
        
        view.addSubview(tipsA)
   
        tipsA.snp.remakeConstraints { make in
            make.width.equalTo(182)
            make.height.equalTo(160)
            make.centerX.equalToSuperview()
            make.top.equalToSuperview().offset(357 - (navHeadImageView?.height ?? 0))
        }
        leftButton(image: nil, imageName: nil, tintColor: UIColor.black)
        backButton?.isHidden = false
        showNavigation()
        
        navHeadImageView?.isHidden = false
        lineView?.isHidden = true
        navHeadImageView?.backgroundColor = .clear
 

    }
    
    @objc func protocolClick(sender:UIButton) {
        var link: String?
        if sender.tag == 1 {
            link = cUserProtocol
        } else {
            link = cPrivacy
        }
        if link != nil, (link?.count ?? 0) > 0 {
            let detail = BFBaseWebViewController()
            detail.baseUrl = link
            self.navigationController?.pushViewController(detail, animated: true)
        }
    }

}
