local TaskCompV1 = class("TaskCompV1", LuaComponent)
local CELL = "app/ui/activity/common/cell/act_task_cell_v1"

function TaskCompV1:init()
	local uiMap = self:getUIMap()
	-- self.banner = uiMap["task_comp.bg.banner"]
	-- self.txTitle = uiMap["task_comp.top.title_tx"]
	-- self.txTime = uiMap["task_comp.top.time_bg.time_tx"]
	self.scrollrect = uiMap["task_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.taskList[index].id)
	end)
end

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

function TaskCompV1: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.taskList = DataManager.ActTaskData:getTaskSortList(actId)
	if self.scrollRect:getTotalCount() == nil or self.scrollRect:getTotalCount() <= 0 then
		self.scrollRect:refillCells(#self.taskList)
	elseif self.scrollRect:getTotalCount() ~= #self.taskList then
		self.scrollRect:clearCells()
		self.scrollRect:refillCells(#self.taskList)
	else
		self.scrollRect:updateAllCell()
	end
end

-- function TaskCompV1:updateTime(actId)
--     self:refresh(actId)

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

return TaskCompV1