local ArenaGradingCell = class("ArenaGradingCell", BaseCell)

function ArenaGradingCell:init()
    local uiMap = self:getUIMap()

    -- self.imgGrading = uiMap["arena_grading_cell.img_grading"]
    -- self.imgIdx = uiMap["arena_grading_cell.img_idx"]
    self.txGrading = uiMap["arena_grading_cell.tx_grading"]
    self.spineRoot = uiMap["arena_grading_cell.spine_root"]
end

function ArenaGradingCell:onClose()
	if self.spineGrading then
		self.spineGrading:destroy()
		self.spineGrading = nil
	end
end

function ArenaGradingCell:refresh(id)
    if id == nil then
        return
    end

    local gradingIconName = DataManager.ArenaData:getGradingIconName(id)
    local gradingNumName = DataManager.ArenaData:getGradingNumName(id)
    self.txGrading:setText(DataManager.ArenaData:getGradingName(id))
    -- self.imgIdx:setSprite(GConst.ATLAS_PATH.ARENA, DataManager.ArenaData:getGradingNumName(id))
    -- self.imgGrading:setSprite(GConst.ATLAS_PATH.ARENA, DataManager.ArenaData:getGradingIconName(id))

    self.spineRoot:removeAllChildren()
	SpineManager:loadUISpineWidgetAsync(gradingIconName.."_spine", self.spineRoot, function(spineObject)
	    self.spineGrading = spineObject
	    self.spineGrading:setSkin(gradingNumName)
	    self.spineGrading:playAnim("idle", true)
	end)
end

return ArenaGradingCell