Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/ui/panel/CLLPPopTime.lua
2020-07-24 22:12:55 +08:00

173 lines
5.7 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 CLLPPopTime = {}
---@type Coolape.CLPanelLua
local csSelf = nil
---@type UnityEngine.Transform
local transform = nil
local uiobjs = {}
local defaultTime
local callback
local hours = {}
local minutes = {}
local seconds = {}
local hh, mm, ss
local firstCell
-- 初始化,只会调用一次
function CLLPPopTime.init(csObj)
csSelf = csObj
transform = csObj.transform
table.insert(hours, joinStr(NumEx.nStrForLen(23, 2), ""))
for i = 0, 22 do
table.insert(hours, joinStr(NumEx.nStrForLen(i, 2), ""))
end
table.insert(minutes, joinStr(NumEx.nStrForLen(59, 2), ""))
table.insert(seconds, joinStr(NumEx.nStrForLen(59, 2), ""))
for i = 0, 58 do
table.insert(minutes, joinStr(NumEx.nStrForLen(i, 2), ""))
table.insert(seconds, joinStr(NumEx.nStrForLen(i, 2), ""))
end
---@type UISprite
uiobjs.SpriteBg = getCC(transform, "Bottom/offset/SpriteBg", "UISprite")
local offset = getChild(transform, "Bottom/offset")
---@type Coolape.CLUILoopGrid
uiobjs.listGridHH = getCC(offset, "ListHH/Content/Grid", "CLUILoopGrid")
uiobjs.centerOnChildHH = uiobjs.listGridHH:GetComponent("UICenterOnChild")
---@type Coolape.CLUILoopGrid
uiobjs.listGridMM = getCC(offset, "ListMM/Content/Grid", "CLUILoopGrid")
uiobjs.centerOnChildMM = uiobjs.listGridMM:GetComponent("UICenterOnChild")
---@type Coolape.CLUILoopGrid
uiobjs.listGridSS = getCC(offset, "ListSS/Content/Grid", "CLUILoopGrid")
uiobjs.centerOnChildSS = uiobjs.listGridSS:GetComponent("UICenterOnChild")
end
-- 设置数据
function CLLPPopTime.setData(paras)
callback = MapEx.getObject(paras, "callback")
defaultTime = MapEx.getString(paras, "time")
defaultTime = isNilOrEmpty(defaultTime) and DateEx.toHHMMSS(DateEx.nowMS) or defaultTime
local strs = strSplit(defaultTime, ":")
hh = strs[1]
mm = strs[2]
ss = strs[3]
end
--当有通用背板显示时的回调
function CLLPPopTime.onShowFrame()
end
-- 显示在c#中。show为调用refreshshow和refresh的区别在于当页面已经显示了的情况当页面再次出现在最上层时只会调用refresh
function CLLPPopTime.show()
firstCell = nil
uiobjs.listGridHH:setList(hours, CLLPPopTime.initCellHour, CLLPPopTime.onHeadHour, CLLPPopTime.onEndHour)
uiobjs.centerOnChildHH:Recenter()
-- uiobjs.centerOnChildHH:CenterOn(firstCell.transform)
firstCell = nil
uiobjs.listGridMM:setList(minutes, CLLPPopTime.initCellMinute, CLLPPopTime.onHeadMinute, CLLPPopTime.onEndMinute)
uiobjs.centerOnChildMM:Recenter()
-- uiobjs.centerOnChildMM:CenterOn(firstCell.transform)
firstCell = nil
uiobjs.listGridSS:setList(seconds, CLLPPopTime.initCellSec, CLLPPopTime.onHeadSec, CLLPPopTime.onEndSec)
uiobjs.centerOnChildSS:Recenter()
-- uiobjs.centerOnChildSS:CenterOn(firstCell.transform)
end
function CLLPPopTime.initCellHour(cell, data)
cell:init(data, nil)
cell.luaTable.setCenterObj(uiobjs.centerOnChildHH)
if firstCell == nil then
firstCell = cell
end
end
function CLLPPopTime.onHeadHour(head)
uiobjs.listGridHH:insertList(hours)
end
function CLLPPopTime.onEndHour(tail)
uiobjs.listGridHH:appendList(hours)
end
function CLLPPopTime.initCellMinute(cell, data)
cell:init(data, nil)
cell.luaTable.setCenterObj(uiobjs.centerOnChildMM)
if firstCell == nil then
firstCell = cell
end
end
function CLLPPopTime.onHeadMinute(head)
uiobjs.listGridMM:insertList(minutes)
end
function CLLPPopTime.onEndMinute(tail)
uiobjs.listGridMM:appendList(minutes)
end
function CLLPPopTime.initCellSec(cell, data)
cell:init(data, nil)
cell.luaTable.setCenterObj(uiobjs.centerOnChildSS)
if firstCell == nil then
firstCell = cell
end
end
function CLLPPopTime.onHeadSec(head)
uiobjs.listGridSS:insertList(seconds)
end
function CLLPPopTime.onEndSec(tail)
uiobjs.listGridSS:appendList(seconds)
end
function CLLPPopTime.onStartCenterOnChild(scrollview)
end
function CLLPPopTime.onCenterChild(center, scrollview)
---@type Coolape.CLUILoopGrid
local grid = getCC(scrollview.transform, "Grid", "CLUILoopGrid")
grid:refreshContentOnly()
end
function CLLPPopTime.onFinishCenterChild(scrollview)
end
-- 刷新
function CLLPPopTime.refresh()
end
-- 关闭页面
function CLLPPopTime.hide()
end
-- 网络请求的回调cmd指命succ成功失败msg消息paras服务器下行数据
function CLLPPopTime.procNetwork(cmd, succ, msg, paras)
end
-- 处理ui上的事件例如点击等
function CLLPPopTime.uiEventDelegate(go)
local goName = go.name
if goName == "ButtonClose" then
hideTopPanel(csSelf)
elseif goName == "ButtonOkay" then
local cell = uiobjs.centerOnChildHH.centeredObject:GetComponent("CLCellLua")
local hh = cell.luaTable.getData()
hh = string.gsub(hh, "", "")
cell = uiobjs.centerOnChildMM.centeredObject:GetComponent("CLCellLua")
local mm = cell.luaTable.getData()
mm = string.gsub(mm, "", "")
cell = uiobjs.centerOnChildSS.centeredObject:GetComponent("CLCellLua")
local ss = cell.luaTable.getData()
ss = string.gsub(ss, "", "")
hideTopPanel(csSelf)
Utl.doCallback(callback, joinStr(hh, ":", mm, ":", ss))
end
end
-- 当顶层页面发生变化时回调
function CLLPPopTime.onTopPanelChange(topPanel)
end
-- 当按了返回键时关闭自己返值为true时关闭
function CLLPPopTime.hideSelfOnKeyBack()
return true
end
--------------------------------------------
return CLLPPopTime