// // dateItem.swift // ADHTuanCan // // Created by 敖德亨 on 2023/9/29. // import UIKit class dateItem: UIView { @IBOutlet weak var typeView: UIView! @IBOutlet weak var monthLab: UILabel! @IBOutlet weak var dayLab: UILabel! @IBOutlet weak var countLab: UILabel! var dataSource : HomeTimeItem? var selectBlock : ((_ model : HomeTimeItem)->Void)? override func awakeFromNib() { super.awakeFromNib() let tap = UITapGestureRecognizer.init(target: self, action:#selector(chooseAction)) self.addGestureRecognizer(tap) } func configModel(dateModel : HomeTimeItem){ self.dataSource = dateModel monthLab.text = "\(dateModel.month ?? "")" dayLab.text = "\(dateModel.day ?? "")" countLab.text = "\(dateModel.whichDay ?? "")" if dateModel.added == "1"{ self.typeView.layer.borderColor = kThemeColor.cgColor }else{ self.typeView.layer.borderColor = UIColor.color(hex: "#8C94B0").cgColor } if dateModel.isSelect{ self.typeView.backgroundColor = kThemeColor monthLab.textColor = UIColor.white dayLab.textColor = UIColor.white countLab.textColor = UIColor.white }else{ self.typeView.backgroundColor = UIColor.white monthLab.textColor = UIColor.color(hex: "#6A7585") dayLab.textColor = UIColor.color(hex: "#1C304F") countLab.textColor = UIColor.color(hex: "#6A7585") } } @objc func chooseAction(){ if self.dataSource!.isSelect{ return } if (self.selectBlock != nil){ self.selectBlock!(self.dataSource!) } } }