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

function SideBarSevenDaysCell:getModuleKey()
    return ModuleManager.MODULE_KEY.SEVEN_DAY
end

function SideBarSevenDaysCell:getHasPurchase()
    return false
end

function SideBarSevenDaysCell:getIsOpen()
    return DataManager.SevenDayData:getIsOpen()
end

function SideBarSevenDaysCell:getSpineName()
    return "ui_main_btn_sevenday"
end

function SideBarSevenDaysCell:onClick()
    ModuleManager.SevenDayManager:showUI()
end

function SideBarSevenDaysCell:getIsShowRedPoint()
    return DataManager.SevenDayData:showRedPoint()
end

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

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

function SideBarSevenDaysCell:_refreshTime()
    local remainTime = DataManager.SevenDayData:getEndTime() - Time:getServerTime()
    if remainTime >= 0 then
        self.timeTx:setText(GFunc.getTimeStr(remainTime))
    else
        self.timeTx:setText("00:00:00")
    end
end

return SideBarSevenDaysCell