c1_lua/lua/app/ui/collection/collection_reward_ui.lua
2023-07-14 17:07:03 +08:00

59 lines
1.5 KiB
Lua

local CollectionRewardUI = class("CollectionRewardUI", BaseUI)
function CollectionRewardUI:isFullScreen()
return true
end
function CollectionRewardUI:showCommonBG()
return false
end
function CollectionRewardUI:getPrefabPath()
return "assets/prefabs/ui/collection/collection_reward_ui.prefab"
end
function CollectionRewardUI:onPressBackspace()
self:closeUI()
end
function CollectionRewardUI:ctor(params)
self.collectType = params
end
function CollectionRewardUI:onCover()
end
function CollectionRewardUI:onReshow()
end
function CollectionRewardUI:onClose()
end
function CollectionRewardUI:onLoadRootComplete()
local uiMap = self.root:genAllChildren()
self.scrollrectComp = uiMap["collect_reward_ui.scrollrect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
uiMap["collect_reward_ui.banner.btn_close"]:addClickListener(function()
self:closeUI()
end)
end
function CollectionRewardUI:onRefresh()
local datas = DataManager.CollectionData:getRewardList(self.collectType)
self.scrollrectComp:addInitCallback(function()
return "app/ui/collection/cell/collection_reward_cell"
end)
self.scrollrectComp:addRefreshCallback(function(index, cell)
cell:refresh(self.collectType, #datas - index + 1)
end)
self.scrollrectComp:clearCells()
self.scrollrectComp:refillCells(#datas)
local selectIdx = DataManager.CollectionData:getCurTargetId(self.collectType)
selectIdx = #datas - selectIdx + 1
if selectIdx - 2 >= 0 then
selectIdx = selectIdx - 2
end
self.scrollrectComp:moveToIndex(selectIdx)
end
return CollectionRewardUI