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

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

function SideBarTournArenaCell:getIsOpen()
    return DataManager.TournArenaData:isOpen() and DataManager.TournArenaData:isActiveTime()
end

function SideBarTournArenaCell:getSpineName()
    return "ui_act_tournarena_main_btn"
end

function SideBarTournArenaCell:onClick()
    ModuleManager.TournArenaManager:showActMainUI()
end

function SideBarTournArenaCell:getIsShowRedPoint()
    return DataManager.TournArenaData:hasEntryRedPoint()
end

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

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

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

return SideBarTournArenaCell