local this = class("cellSatietyItem", G_UIModuleBase)
local foodTpl = L_GameTpl:getFoodTpl()
local _commonItemTpl = L_GameTpl:getCommonItemTpl()

function this.bind()
  return {
    itemIcon = "",
    img_iconFilter = "",
    satiety = "",
    itemNum = 0,
    qulaityColor = C_Color.white
  }
end

function this.methods()
  return {
    onClick_item = function(self)
      self:emit("onClick_item", self)
    end
  }
end

function this:refresh()
  if not self.isBind then
    return
  end
  self.bind.itemNum = self.bind.itemnum
  local fTpl = foodTpl:getTplById(self.bind.itemid)
  self.bind.satiety = string.format("+%d", foodTpl:getSatietyScore(fTpl))
  local conf = L_ItemTplManager:getItemConfig(L_Const.resType.commonItem, self.bind.itemid)
  local commonItemTpl = _commonItemTpl:getTplById(self.bind.itemid)
  self.bind.img_iconFilter = commonItemTpl and _commonItemTpl:getFilterIcon(commonItemTpl) or ""
  self.bind.itemIcon = conf.icon
  if conf.quality then
    local _, color = C_ColorUtility.TryParseHtmlString(L_RarityTpl:getColorCircle(L_RarityTpl:getTplById(conf.quality)))
    self.bind.qulaityColor = color
  end
end

function this:getCellRect()
  if not self.isBind then
    return nil
  end
  if not self.bindComponents then
    return nil
  end
  return self.bindComponents.cellRect
end

return this
