using System.Collections.Generic;

namespace ET.Client
{
    public class CommonUtil : Singleton<CommonUtil>
    {

        public async ETTask OpenCommonServerMsgPanel(string content)
        {
            if (string.IsNullOrEmpty(content))
            {
                Log.Error("content == null");
                return;
            }
            var ui = UIHelper.Get(GameUtil.Instance.GetSceneComponent(), UIType.UICommonServerMsg);
            if (ui != null && ui.GameObject.activeInHierarchy)
            {
                var com = ui.GetComponent<UICommonServerMsgComponent>();
                com.PushTask(content);
            }
            else
            {
                Dictionary<string, object> dic = new Dictionary<string, object>()
                    {
                        { "content",content},
                    };
                await UIHelper.Create(GameUtil.Instance.GetSceneComponent(), UIType.UICommonServerMsg, UILayer.High, dic);
            }
        }
    }
}