Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/ui/cell/CLToastRoot.lua

74 lines
1.8 KiB
Lua
Raw Normal View History

2020-07-09 08:50:24 +08:00
-- xx界面
CLToastRoot = {}
---@type Coolape.CLPanelLua
local csSelf = nil
---@type UnityEngine.Transform
local transform = nil
local uiobjs = {}
local queue = CLLQueue.new()
local index = 0
CLToastRoot.Type = {
normal = 0,
success = 1,
warning = 2,
error = 3
}
-- 初始化,只会调用一次
function CLToastRoot.init(csObj)
csSelf = csObj
transform = csObj.transform
---@type UITable
uiobjs.Table = getCC(transform, "offset", "UITable")
uiobjs.prefab = getCC(uiobjs.Table.transform, "00000", "CLCellLua")
SetActive(uiobjs.prefab.gameObject, false)
end
-- 关闭页面
function CLToastRoot.show()
end
-- 关闭页面
function CLToastRoot.hide()
end
function CLToastRoot.borrow()
local cell
if queue:size() == 0 then
local go = GameObject.Instantiate(uiobjs.prefab.gameObject, uiobjs.Table.transform)
cell = go:GetComponent("CLCellLua")
else
cell = queue:deQueue()
end
2020-07-14 22:04:03 +08:00
cell.name = string.format("%11d", index)
2020-07-09 08:50:24 +08:00
index = index + 1
return cell
end
function CLToastRoot.returnToast(cell)
SetActive(cell.gameObject, false)
queue:enQueue(cell)
end
function CLToastRoot.toast(msg, type, staySec)
2020-07-14 22:04:03 +08:00
if isNilOrEmpty(msg) then
return
end
2020-07-09 08:50:24 +08:00
local cell = CLToastRoot.borrow()
SetActive(cell.gameObject, true)
cell:init({msg = msg, type = type, staySec = staySec}, nil)
uiobjs.Table:Reposition()
end
-- 处理ui上的事件例如点击等
function CLToastRoot.uiEventDelegate(go)
local cell = go:GetComponent("CLCellLua")
if cell then
SetActive(go, false)
csSelf:invoke4Lua(CLToastRoot.returnToast, cell, 0.1)
end
end
--------------------------------------------
return CLToastRoot