local FullMoonTaskProgCell = class("FullMoonTaskProgCell", BaseCell)

function FullMoonTaskProgCell:init()
    local uiMap = self:getUIMap()
    self.imgProg = uiMap["prog_reward.img_prog"]
    self.txProg = uiMap["prog_reward.img_prog.tx_prog"]
    self.rewardCell = uiMap["prog_reward.reward_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
end

function FullMoonTaskProgCell:refresh(id)
    local canGet = DataManager.FullMoonData:isReachTaskProgressReward(id)
    local isReceived = DataManager.FullMoonData:isReceivedTaskProgressReward(id)

    self.txProg:setText(DataManager.FullMoonData:getTaskProgressTarget(id))
    self.rewardCell:refreshByConfig(DataManager.FullMoonData:getTaskProgressReward(id), isReceived, isReceived)
    if canGet then
        self.imgProg:setSprite(GConst.ATLAS_PATH.ACT_COMMON, "act_common_bg_7")
        if not isReceived then
            self.rewardCell.baseObject:addRedPoint(50, 50, 0.6)
            self.rewardCell:addClickListener(function()
                ModuleManager.FullMoonManager:reqTaskProgressReward(id)
            end)
        else
            self.rewardCell.baseObject:removeRedPoint()
            self.rewardCell:addClickListener(nil)
        end
    else
        self.imgProg:setSprite(GConst.ATLAS_PATH.ACT_COMMON, "act_common_bg_8")
        self.rewardCell.baseObject:removeRedPoint()
        self.rewardCell:addClickListener(nil)
    end
end

return FullMoonTaskProgCell