Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/ui/cell/CSCellBottomBtn.lua
2020-08-05 20:46:00 +08:00

82 lines
2.4 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.

---@class CellBottomBtn
local _cell = {}
local csSelf = nil
local transform = nil
local mData = nil
local uiobjs = {}
-- 初始化,只调用一次
function _cell.init(csObj)
csSelf = csObj
transform = csSelf.transform
--[[
上的组件getChild(transform, "offset", "Progress BarHong"):GetComponent("UISlider");
--]]
---@type UIToggle
uiobjs.toggle = csSelf:GetComponent("UIToggle")
uiobjs.Label = getCC(transform, "Label", "UILabel")
-- uiobjs.LabelCheck = getCC(transform, "LabelCheck", "UILabel")
uiobjs.boxCollider = csSelf:GetComponent("BoxCollider")
uiobjs.Background = getCC(transform, "Background", "UISprite")
uiobjs.Checkmark = getCC(transform, "Checkmark", "UISprite")
uiobjs.LabelReddotNum = getCC(transform, "LabelReddotNum", "UILabel")
end
-- 显示,
-- 注意c#侧不会在调用show时调用refresh
function _cell.show(go, data)
mData = data
uiobjs.Label.text = mData.name
-- uiobjs.LabelCheck.text = mData.name
uiobjs.boxCollider.center = Vector3.zero
uiobjs.boxCollider.size = Vector3(mData.width, 150, 0)
uiobjs.Background.spriteName = mData.Background
uiobjs.Checkmark.spriteName = mData.Checkmark
if mData.id == 1 then
local unreadNum = DBMessage.getUnreadNum(DBMessage.MsgType.Sys)
_cell.setReddotNum(unreadNum)
else
_cell.setReddotNum(0)
end
end
function _cell.setReddotNum(num)
if num and num > 0 then
SetActive(uiobjs.LabelReddotNum.gameObject, true)
if num > 9 then
uiobjs.LabelReddotNum.text = ""
else
uiobjs.LabelReddotNum.text = tostring(num)
end
else
SetActive(uiobjs.LabelReddotNum.gameObject, false)
end
end
-- 注意c#侧不会在调用show时调用refresh
function _cell.setSelected(val)
uiobjs.toggle:Set(val)
end
function _cell.refreshState()
if uiobjs.toggle.value then
uiobjs.Background.color = Color.white
uiobjs.Label.color = ColorEx.getColor(0xff2990dc)
else
uiobjs.Background.color = ColorEx.getColor(153, 153, 153)
uiobjs.Label.color = ColorEx.getColor(153, 153, 153)
end
end
-- 取得数据
function _cell.getData()
return mData
end
function _cell.uiEventDelegate(go)
_cell.refreshState()
end
--------------------------------------------
return _cell