dateItem.swift 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // dateItem.swift
  3. // ADHTuanCan
  4. //
  5. // Created by 敖德亨 on 2023/9/29.
  6. //
  7. import UIKit
  8. class dateItem: UIView {
  9. @IBOutlet weak var typeView: UIView!
  10. @IBOutlet weak var monthLab: UILabel!
  11. @IBOutlet weak var dayLab: UILabel!
  12. @IBOutlet weak var countLab: UILabel!
  13. var dataSource : HomeTimeItem?
  14. var selectBlock : ((_ model : HomeTimeItem)->Void)?
  15. override func awakeFromNib() {
  16. super.awakeFromNib()
  17. let tap = UITapGestureRecognizer.init(target: self, action:#selector(chooseAction))
  18. self.addGestureRecognizer(tap)
  19. }
  20. func configModel(dateModel : HomeTimeItem){
  21. self.dataSource = dateModel
  22. monthLab.text = "\(dateModel.month ?? "")"
  23. dayLab.text = "\(dateModel.day ?? "")"
  24. countLab.text = "\(dateModel.whichDay ?? "")"
  25. if dateModel.added == "1"{
  26. self.typeView.layer.borderColor = kThemeColor.cgColor
  27. }else{
  28. self.typeView.layer.borderColor = UIColor.color(hex: "#8C94B0").cgColor
  29. }
  30. if dateModel.isSelect{
  31. self.typeView.backgroundColor = kThemeColor
  32. monthLab.textColor = UIColor.white
  33. dayLab.textColor = UIColor.white
  34. countLab.textColor = UIColor.white
  35. }else{
  36. self.typeView.backgroundColor = UIColor.white
  37. monthLab.textColor = UIColor.color(hex: "#6A7585")
  38. dayLab.textColor = UIColor.color(hex: "#1C304F")
  39. countLab.textColor = UIColor.color(hex: "#6A7585")
  40. }
  41. }
  42. @objc func chooseAction(){
  43. if self.dataSource!.isSelect{
  44. return
  45. }
  46. if (self.selectBlock != nil){
  47. self.selectBlock!(self.dataSource!)
  48. }
  49. }
  50. }