MenuHeadView.swift 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // MenuHeadView.swift
  3. // ADHTuanCan
  4. //
  5. // Created by 敖德亨 on 2023/10/4.
  6. //
  7. import UIKit
  8. class MenuHeadView: UIView {
  9. @IBOutlet weak var backImageView: UIImageView!
  10. @IBOutlet weak var topHeight: NSLayoutConstraint!
  11. var HeadTimeRangeAction : (()->Void)?
  12. var backBlock : (()->Void)?
  13. var deletActionBlock : (()->Void)?
  14. var selectBlock : ((_ model : HomeTimeItem)->Void)?
  15. let dateView = Bundle.main.loadNibNamed("HomeDateView", owner: nil, options: nil)?.last as? HomeDateView
  16. override func awakeFromNib() {
  17. super.awakeFromNib()
  18. self.addSubview(dateView!)
  19. topHeight.constant = kStatuBarHeight + 25
  20. self.dateView!.mas_remakeConstraints { make in
  21. make?.left.right().bottom().mas_equalTo()(self)
  22. make?.height.offset()(160)
  23. }
  24. self.dateView?.timeRangeAction = {[weak self] in
  25. if (self?.HeadTimeRangeAction != nil)
  26. {
  27. self?.HeadTimeRangeAction!()
  28. }
  29. }
  30. self.dateView?.selectBlock = {[weak self] model in
  31. if (self?.selectBlock != nil){
  32. self?.selectBlock!(model)
  33. }
  34. }
  35. self.dateView?.deletActionBlock = {[weak self] in
  36. if (self?.deletActionBlock != nil){
  37. self?.deletActionBlock!()
  38. }
  39. }
  40. }
  41. @IBAction func backAction(_ sender: UIButton) {
  42. if (self.backBlock != nil){
  43. self.backBlock!()
  44. }
  45. }
  46. func configModel(dateModel : HomeTimeRangModel ){
  47. self.dateView?.configModel(dateModel: dateModel)
  48. self.dateView?.timeBtn.isHidden = true
  49. self.dateView?.deletBtn.isHidden = false
  50. self.dateView?.titleLab.text = LanguagesUtil.createTextBy(Ctext: "已选菜品", Etext: "selected foods")
  51. }
  52. }