local TournWaveGiftComp = class("TournWaveGiftComp", LuaComponent)

function TournWaveGiftComp:init()
    local uiMap = self:getUIMap()
    self.scrollrectComp = uiMap["gift_panel.scrollrect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)

    self.scrollrectComp:addInitCallback(function()
		return "app/ui/activity/tourn_wave/cell/tourn_wave_gift_cell"
	end)
	self.scrollrectComp:addRefreshCallback(function(index, cell)
		cell:refresh(self.giftList[index].id)
	end)

    self:bind(DataManager.TournWaveData, "isDirty", function()
        self:refresh()
	end)
    self:bind(DataManager.ShopData, "isDirty", function()
        self:refresh()
	end)
end

function TournWaveGiftComp:refresh()
    self.giftList = DataManager.TournWaveData:getGiftIdsSort()
    self.scrollrectComp:clearCells()
	self.scrollrectComp:refillCells(#self.giftList)
end

return TournWaveGiftComp