local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarActivityCell = class("SideBarActivityCell", SideBarBaseCellComp)

function SideBarActivityCell:getModuleKey()
    return ModuleManager.MODULE_KEY.ACTIVITY
end

function SideBarActivityCell:getIsOpen()
    return DataManager.ActivityData:isOpen() and DataManager.ActivityData:isActive()
end

function SideBarActivityCell:getSpineName()
    return "ui_main_btn_act_summer"
end

function SideBarActivityCell:onClick()
    ModuleManager.ActivityManager:showActivityUI()
end

function SideBarActivityCell:getIsShowRedPoint()
    return DataManager.ActivityData:hasEntryRedPoint()
end

function SideBarActivityCell:onRefresh()
    self.timeBg:setVisible(true)
    self:_refreshTime()
end

function SideBarActivityCell:updateTime()
    if self:getIsOpen() then
        self:_refreshTime()
    else
        self:closeBtn()
    end
end

function SideBarActivityCell:_refreshTime()
    local remainTime = DataManager.ActivityData:getEndRemainTime()
    if remainTime >= 0 then
        self.timeTx:setText(GFunc.getTimeStr(remainTime))
    else
        self.timeTx:setText("00:00:00")
    end
end

return SideBarActivityCell