//
//  SpeakEleLoginGuideCtr.swift
//  SpeakEasyLearnEnglish
//
//  Created by edy on 2025/7/10.
//

import UIKit


class SpeakEleLoginGuideCtr: SpeakEleBaseViewCtr {

    @IBOutlet weak var SpeakDescLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        setDescription()
    }
    
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
    }
    
    @IBAction func SpeakLogin(_ sender: Any) {
        let login = SpeakEleLoginViewCtr()
        self.navigationController?.pushViewController(login, animated: true)
    }
    
    @IBAction func SpeakSkip(_ sender: Any) {
        let guide = SpeakEleGuideViewCtr()
        self.navigationController?.pushViewController(guide, animated: true)
    }
    
    private func TermsOfService() -> Void {
        let web = SpeakEleWebViewCtr()
        web.LoadWithUrl(url: SpeakTerms)
        self.navigationController?.pushViewController(web, animated: true)
    }
    
    private func PrivacyPolicy() -> Void {
        let web = SpeakEleWebViewCtr()
        web.LoadWithUrl(url: SpeakPrivacy)
        self.navigationController?.pushViewController(web, animated: true)
    }
    
    private func setDescription() -> Void {
        SpeakDescLabel.AddTextTap(["Privacy Policy","Terms of Service."])
        let privacy = "Privacy Policy".attributed().font(UIFont.montserrat(.medium,size: 10)).underline(.single).paragraphStyle(.center,lineSpacing: 4).build()
        let terms = "Terms of Service.".attributed().font(UIFont.montserrat(.medium,size: 10)).underline(.single).paragraphStyle(.center,lineSpacing: 4).build()
        let att = "Proceeding further indicates your agreement to our ".attributed().paragraphStyle(.center,lineSpacing: 4).build().combined(with: [privacy," and ", terms])
        SpeakDescLabel.attributedText = att
        SpeakDescLabel.callblack = { [weak self] text in
            guard let v:String = text as? String else { return }
            if v == "Privacy Policy" {
                self?.PrivacyPolicy()
            }else{
                self?.TermsOfService()
            }
        }

    }
}
