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

function SideBarFourteenDayCell:getIsOpen()
    return DataManager.FourteenDayData:isOpen() and DataManager.FourteenDayData:isActiveTime()
end

function SideBarFourteenDayCell:getSpineName()
    return "ui_act_fourteen_mainbtn"
end

function SideBarFourteenDayCell:onClick()
    ModuleManager.FourteenDayManager:showFourteenDayUI()
end

function SideBarFourteenDayCell:getIsShowRedPoint()
    return DataManager.FourteenDayData:hasRedPoint()
end

function SideBarFourteenDayCell:onRefresh()
    self:_refreshTime()
end

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

function SideBarFourteenDayCell:_refreshTime()
    local remainTime = DataManager.FourteenDayData:getEndRemainTime()
    if remainTime >= 0 then
        self.timeBg:setVisible(true)
        self.timeTx:setText(GFunc.getTimeStr(remainTime))
    else
        self.timeBg:setVisible(false)
        self.timeTx:setText("00:00:00")
    end
end

return SideBarFourteenDayCell