local ActivityTaskComp = class("ActivityTaskComp", LuaComponent)

function ActivityTaskComp:init()
    local uiMap = self:getUIMap()
    self.txScore = uiMap["task_panel.bounty.tx_score"]
    self.imgProg = uiMap["task_panel.bounty.prog.img_prog"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
    self.txProg = uiMap["task_panel.bounty.prog.tx_prog"]
    self.txLv = uiMap["task_panel.bounty.tx_lv"]
    self.txLvNum = uiMap["task_panel.bounty.tx_lv_num"]
    self.scrollrectComp = uiMap["task_panel.list_task"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
end

function ActivityTaskComp:refresh()
    -- 战令积分显示
    local total = DataManager.ActivityData:getBountyUpgradeScore()
    local cur = DataManager.ActivityData:getBountyLevelScore()
    self.imgProg.value = cur / total
    self.txScore:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_DESC_1))
    self.txProg:setText(cur .. "/" .. total)
    self.txLv:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_DESC_12))
    self.txLvNum:setText(DataManager.ActivityData:getBountyLevel())

    -- 任务列表
    local tasks = DataManager.ActivityData:getTaskListSort()
	self.scrollrectComp:addInitCallback(function()
		return "app/ui/activity/cell/activity_task_cell"
	end)
	self.scrollrectComp:addRefreshCallback(function(index, cell)
		cell:refresh(tasks[index])
	end)
	self.scrollrectComp:clearCells()
	self.scrollrectComp:refillCells(#tasks)
end

return ActivityTaskComp