local ZUIPanelDialogOK = {}

local function OnClickButtonOk()
    print("ZUIPanelDialogOK.OnClickButtonOK")
    require("Base/UIHelper.lua"):CloseUI("UI/Public/ZUIPanelDialogOK.lua")
end

function ZUIPanelDialogOK.SetInfo(tipsInfo, confirmFunction)
    local rootPanel = ZUIPanelDialogOK.rootPanel

    local textTips = rootPanel.transform:Find("Text_Tips").gameObject
    textTips:GetComponent("Text").text = tipsInfo

	local buttonConfirm = rootPanel.transform:Find("Button_OK").gameObject
    buttonConfirm:GetComponent("Button").onClick:AddListener(function()
        print("ZUIDialogConfirmPanel.OnClickConfirm")
        if confirmFunction ~= nil then confirmFunction() end
        require("Base/UIHelper.lua"):CloseUI("UI/Public/ZUIPanelDialogOK.lua")
    end)
end

local function MeetingClosedNotify()
    require("Base/UIHelper.lua"):CloseUI("UI/Public/ZUIPanelDialogOK.lua")
end

local function RegisterEvent()
    local eventManager = require("Base/ZEventDispatchCenter.lua")

    eventManager:RegisterEvent(eventManager.EventType.CLOSE_ALL_PAGE, MeetingClosedNotify)
end

local function UnregisterEvent()
    local eventManager = require("Base/ZEventDispatchCenter.lua")

    eventManager:RegisterEvent(eventManager.EventType.CLOSE_ALL_PAGE, MeetingClosedNotify)
end

function ZUIPanelDialogOK.Awake(luaRoot)
	ZUIPanelDialogOK.luaRoot = luaRoot

	local canvas = CS.UnityEngine.GameObject.Find("Canvas")
	ZUIPanelDialogOK._rootCanvas = canvas

	local prefabPanel = LoadResource("Prefabs/UI/Public/ZUIDialogOKPanel.prefab")
	local rootPanel = CS.UnityEngine.GameObject.Instantiate(prefabPanel, ZUIPanelDialogOK._rootCanvas.transform)
    rootPanel.name = "ZUIDialogOKPanel"
    ZUIPanelDialogOK.rootPanel = rootPanel
end

function ZUIPanelDialogOK.Start(luaRoot)
	local rootPanel = ZUIPanelDialogOK.rootPanel

	local buttonLogin = rootPanel.transform:Find("Button_OK").gameObject
	buttonLogin:GetComponent("Button").onClick:AddListener(OnClickButtonOk)

    RegisterEvent()
end

function ZUIPanelDialogOK.OnDestroy()
    UnregisterEvent()
	CS.UnityEngine.GameObject.Destroy(ZUIPanelDialogOK.rootPanel)
    print("ZUIPanelDialogOK.OnDestroy ... ...")
end

return ZUIPanelDialogOK