local BottomBtnCell = class("BottomBtnCell", BaseCell)

function BottomBtnCell:refresh(index, selected, showAni)
    self.selected = selected
    local uiMap = self:getUIMap()
    local icon = uiMap["bottom_btn_cell.icon"]
    local descObj = uiMap["bottom_btn_cell.desc"]
    local iconScale = 1
    local descContent = selected and I18N:getGlobalText("MAIN_BTN_" .. index) or GConst.EMPTY_STRING
    descObj:setText(descContent)
    local pos = -66
    if index == GConst.MainCityConst.BOTTOM_PAGE.HERO then
        -- 英雄页图标下移6像素特殊处理
        icon:setLocalPositionY(pos - 6)
    else
        icon:setLocalPositionY(pos)
    end
    if selected then
        if showAni then
            GFunc.goTargetElasticityY(icon,nil, 21,0.6)
        else
            GFunc.goTargetElasticityY(icon, true)
            icon:setLocalPositionY(pos + 21*2)
            icon:setLocalScale(iconScale, iconScale, iconScale)
        end
    else
        icon:setLocalScale(iconScale, iconScale, iconScale)
    end
end

function BottomBtnCell:addClickListener(func)
    self:getBaseObject():addClickListener(function()
        local audioPath = AudioManager.CLICK_ID[GConst.CLICK_SOUND.NORMAL]
        if audioPath then
            AudioManager:playEffect(audioPath)
        end
        func()
    end, GConst.CLICK_SOUND.NONE)
end

function BottomBtnCell:getCurLocalPosX()
    local obj = self.baseObject
    return obj:getAnchoredPositionX()
end


return BottomBtnCell