up
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
-- xx单元
|
||||
local _cell = {}
|
||||
---@type Coolape.CLCellLua
|
||||
local csSelf = nil
|
||||
local transform = nil
|
||||
local mData = nil
|
||||
local uiobjs = {}
|
||||
|
||||
-- 初始化,只调用一次
|
||||
function _cell.init(csObj)
|
||||
csSelf = csObj
|
||||
transform = csSelf.transform
|
||||
---@type TweenAlpha
|
||||
uiobjs.tweenAlpha = csSelf:GetComponent("TweenAlpha")
|
||||
uiobjs.Label = getCC(transform, "Label", "UILabel")
|
||||
uiobjs.SpriteIcon = getCC(transform, "SpriteIcon", "UISprite")
|
||||
end
|
||||
|
||||
-- 显示,
|
||||
-- 注意,c#侧不会在调用show时,调用refresh
|
||||
function _cell.show(go, data)
|
||||
mData = data
|
||||
uiobjs.Label.text = trim(data.msg)
|
||||
local spriteName = ""
|
||||
local colorIcon
|
||||
if mData.type == CLToastRoot.Type.success then
|
||||
spriteName = "cust_suc"
|
||||
colorIcon = Color.green
|
||||
elseif mData.type == CLToastRoot.Type.warning then
|
||||
spriteName = "cust_suc"
|
||||
colorIcon = Color.yellow
|
||||
elseif mData.type == CLToastRoot.Type.error then
|
||||
spriteName = "cust_suc"
|
||||
colorIcon = Color.red
|
||||
else
|
||||
spriteName = "cust_suc"
|
||||
colorIcon = Color.white
|
||||
end
|
||||
uiobjs.SpriteIcon.color = colorIcon
|
||||
uiobjs.SpriteIcon.spriteName = spriteName
|
||||
uiobjs.tweenAlpha.delay = mData.staySec or 1
|
||||
uiobjs.tweenAlpha:ResetToBeginning()
|
||||
uiobjs.tweenAlpha:Play(true)
|
||||
end
|
||||
|
||||
-- 取得数据
|
||||
function _cell.getData()
|
||||
return mData
|
||||
end
|
||||
|
||||
--------------------------------------------
|
||||
return _cell
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13a784d9c776d449d9fc58f903e96c2d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,70 @@
|
||||
-- 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 = tostring(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)
|
||||
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
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33067a79b0a6e4f0eac1d039bb110f55
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -31,7 +31,7 @@ function _cell.show(go, data)
|
||||
local optionInfor = DBCust.getFilter4Popup(DBCust.FilterGroup.dealFlagList)
|
||||
uiobjs.LabelStatus:refreshItems(optionInfor.options, optionInfor.values)
|
||||
uiobjs.formRoot:setValue(mData)
|
||||
if tostring(mData.dealflag) == "0" then
|
||||
if tostring(mData.dealFlag) == "0" then
|
||||
SetActive(uiobjs.SpriteStatus.gameObject, true)
|
||||
else
|
||||
SetActive(uiobjs.SpriteStatus.gameObject, false)
|
||||
|
||||
Reference in New Issue
Block a user