Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/ui/cell/CLCellToast.lua
2020-07-09 09:23:09 +08:00

53 lines
1.5 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单元
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 = "public_tips_2"
colorIcon = Color.green
elseif mData.type == CLToastRoot.Type.warning then
spriteName = "public_tips_3"
colorIcon = Color.yellow
elseif mData.type == CLToastRoot.Type.error then
spriteName = "public_tips_4"
colorIcon = Color.red
else
spriteName = "public_tips_1"
colorIcon = Color.white
end
uiobjs.SpriteIcon.color = colorIcon
CLUIUtl.setSpriteFit(uiobjs.SpriteIcon, spriteName)
uiobjs.tweenAlpha.delay = mData.staySec or 1
uiobjs.tweenAlpha:ResetToBeginning()
uiobjs.tweenAlpha:Play(true)
end
-- 取得数据
function _cell.getData()
return mData
end
--------------------------------------------
return _cell