ChangeMealCollectItem.swift 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // ChangeMealCollectItem.swift
  3. // ADHTuanCan
  4. //
  5. // Created by 敖德亨 on 2023/10/27.
  6. //
  7. import UIKit
  8. class ChangeMealCollectItem: UICollectionViewCell {
  9. @IBOutlet weak var replaceBtn: UIButton!
  10. @IBOutlet weak var foodImg: UIImageView!
  11. @IBOutlet weak var nameLab: UILabel!
  12. var changeFoodBlock : ((_ model : MealFoodMsgModel)->Void)?
  13. var dataSource : MealFoodMsgModel?
  14. //固定套餐列表
  15. let reMarkView = Bundle.main.loadNibNamed("AddRemarkView", owner: nil, options: nil)?.last as? AddRemarkView
  16. override func awakeFromNib() {
  17. super.awakeFromNib()
  18. }
  19. func configDataSouce(model : MealFoodMsgModel){
  20. self.dataSource = model
  21. self.foodImg.sd_setImage(url: URL.init(string: model.link ?? "") ,placeHolderImage: UIImage.init(named: "placeHolderImage"))
  22. self.nameLab.text = "\(model.name ?? "")"
  23. if model.replacePoolId != nil{
  24. self.replaceBtn.isHidden = false
  25. }else{
  26. self.replaceBtn.isHidden = true
  27. }
  28. }
  29. @IBAction func changeAction(_ sender: UIButton) {
  30. if self.changeFoodBlock != nil{
  31. self.changeFoodBlock!(self.dataSource!)
  32. }
  33. }
  34. @IBAction func reMarkAction(_ sender: UIButton) {
  35. self.reMarkView?.showWithString(model: self.dataSource)
  36. }
  37. }