//
//  AV_WaterSettingVC.swift
//  anniversary_Project
//
//  Created by 忆海16 on 2024/7/9.
//

import UIKit

class AV_WaterSettingVC: AV_RootVC {
    
    @IBOutlet weak var sersionV: UIView!
    
    
    @IBOutlet weak var waterprogressView: UIView!
    
    
    @IBOutlet weak var waterbgView: UIView!
    
    
    @IBOutlet weak var clockView: UIView!
    
    @IBOutlet weak var aboutView: UIView!
    
    @IBOutlet weak var privaCyView: UIView!
    
    
    @IBOutlet weak var userView: UIView!
    
    
    @IBOutlet weak var targetLabel: UILabel!
    
    @IBOutlet weak var drinkLabel: UILabel!
    
    let circularProgressBarView = CircularProgressBarView()
    
    
    var tapCount = 0
    var timer: Timer?
    override func viewDidLoad() {
        super.viewDidLoad()
//        [LuxADManager configureSecureClick:self.view];
        LuxADManager.configureSecureClick(self.view)
        sersionV.layer.cornerRadius = 28
       
        waterbgView.layer.cornerRadius = 28
        clockView.layer.cornerRadius = 28
        aboutView.layer.cornerRadius = 28
        privaCyView.layer.cornerRadius = 28
        userView.layer.cornerRadius = 28
      
        // 设置 circularProgressBarView 的 frame 或者使用 Auto Layout
        circularProgressBarView.frame = waterprogressView.bounds
        waterprogressView.addSubview(circularProgressBarView)

             // 设置进度条颜色和轨道颜色
             circularProgressBarView.progressColor = .hexSting(color: "#62BFFF", alpha: 1)
             circularProgressBarView.trackColor = .hexSting(color: "#FFFFFF", alpha: 1)

            
        
        
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.navigationBar.isHidden = true
        let defaults = UserDefaults.standard
        let drink = Int(defaults.integer(forKey: "waveView"))
        drinkLabel.text = "\(drink)"
        let target = defaults.integer(forKey: "waterml")
        
        targetLabel.text = "Target:\(target)ml"
        
        let percentage = ( Double(drink)  / Double(target) ) * 100
        // 设置进度值
        circularProgressBarView.progress = percentage / 100 // 75% progress
        
    }
    
    
    @IBAction func about(_ sender: Any) {
        let vc = AV_AboutVC()
        navigationController?.pushViewController(vc, animated: true)
        
    }
    
    
    @IBAction func privacy(_ sender: Any) {
        let vc = AV_PivacyVC()
        vc.type = 1
        self.present(vc, animated: true,completion: nil)
    }
    
    @IBAction func editBTn(_ sender: Any) {
       let vc =  AV_pagesAllVC()
        navigationController?.pushViewController(vc, animated: true)
    }
    
    @IBAction func back(_ sender: Any) {
        navigationController?.popViewController(animated: true)
    }
    

    @IBAction func user(_ sender: Any) {
        let vc = AV_PivacyVC()
        vc.type = 0
        self.present(vc, animated: true,completion: nil)
    }
    
    
    @IBAction func version(_ sender: Any) {
      
    }

}
