Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/ui/cell/CLToastRoot.lua
2020-07-14 22:04:03 +08:00

74 lines
1.8 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 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
cell.name = string.format("%11d", index)
index = index + 1
return cell
end
function CLToastRoot.returnToast(cell)
SetActive(cell.gameObject, false)
queue:enQueue(cell)
end
function CLToastRoot.toast(msg, type, staySec)
if isNilOrEmpty(msg) then
return
end
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