local GiftCompV1 = class("GiftCompV1", LuaComponent)
local CELL = "app/ui/activity/common/cell/act_gift_cell_v1"

function GiftCompV1:init()
	local uiMap = self:getUIMap()
	-- self.banner = uiMap["gift_comp.bg.banner"]
	-- self.txTitle = uiMap["gift_comp.top.title_tx"]
	-- self.txTime = uiMap["gift_comp.top.time_bg.time_tx"]
	self.scrollrect = uiMap["gift_comp.scrollrect"]
	self.scrollRect = self.scrollrect:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
	self.scrollRect:addInitCallback(function()
		return CELL
	end)
	self.scrollRect:addRefreshCallback(function(index, cell)
		cell:refresh(self.data:getActId(), self.giftList[index])
	end)
end

function GiftCompV1:setParentUI(parentUI, dataKey)
	self.parentUI = parentUI
	self.dataKey = dataKey
	self.data = DataManager[dataKey]
end

function GiftCompV1:refresh()
	local actId = self.data:getActId()
	-- self.txTitle:setText(I18N:getGlobalText(GConst.ActSprintConst.ACT_LIST_NAME[actId]))
	-- self.banner:setTexture(GConst.ActSprintConst.ACT_MAIN_BANNER[actId])
	self.giftList = DataManager.ActGiftData:getGiftIdsSort(actId)
	if self.scrollRect:getTotalCount() == nil or self.scrollRect:getTotalCount() <= 0 then
		self.scrollRect:refillCells(#self.giftList)
	elseif self.scrollRect:getTotalCount() ~= #self.giftList then
		self.scrollRect:clearCells()
		self.scrollRect:refillCells(#self.giftList)
	else
		self.scrollRect:updateAllCell()
	end
end

-- function GiftCompV1:updateTime()
--     self.txTime:setText(Time:formatNumTimeStr(DataManager.ActSprintSummonDataAll:getRemainTime()))
-- end

return GiftCompV1