local module = class("cellPetCatalogBox", G_UIModuleBase)

function module.bind()
  return {
    listPet = {
      moduleName = "pages/petCatalogue/cellCatalogPet"
    },
    cellSize = C_Vector2(2080, 1021)
  }
end

function module.methods()
  return {}
end

function module:refresh()
  self.bindComponents.boxListGrid.constraintCount = self.bind.objPerRow
  local temp = {}
  for i = 1, #self.bind.petList do
    table.insert(temp, {
      petId = self.bind.petList[i].petId,
      onClickCb = function(cell)
        self.bind.onClickCb(cell)
      end,
      catalogId = self.bind.pageIdxBase + i
    })
  end
  self.bind.listPet:clear()
  self.bind.listPet:insert_array(temp)
  self:setAttrView(self._isAttr or false)
  if C_ResolutionUtility.CheckSuperWidthScreen() then
    self.bind.cellSize = C_Vector2(2740, 1021)
  end
end

function module:setAttrView(isAttr)
  self._isAttr = isAttr
  if self.modules.listPet then
    for _, cell in pairs(self.modules.listPet) do
      cell:setAttrView(isAttr)
    end
  end
end

function module:refreshRedDot()
  if self.modules.listPet then
    for _, cell in pairs(self.modules.listPet) do
      cell:refreshRedDot()
    end
  end
end

return module
