using FGUI.Toast_23;

namespace ChillConnect
{
    // using FGUI.SC001_Tips;

    public class JoastUI : BaseUI
    {
        private JoastUICtrl ctrl;
        private JoastModel model;
        private com_tips ui;

        public JoastUI(JoastUICtrl ctrl) : base(ctrl)
        {
            uiName = UIConst.JoastUI;
            this.ctrl = ctrl;
        }

        protected override void SetUIInfo(UIInfo uiInfo)
        {
            uiInfo.packageName = "Toast_23";
            uiInfo.assetName = "com_tips";
            uiInfo.layerType = UILayerType.Tips;
            uiInfo.isNeedOpenAnim = false;
            uiInfo.isNeedCloseAnim = false;
            uiInfo.isNeedUIMask = false;
        }

        #region 生命周期

        protected override void OnInit()
        {
        }

        protected override void OnClose()
        {
            CommonHelper.FadeOut(ui);
        }

        protected override void OnBind()
        {
            ui = baseUI as com_tips;
        }

        protected override void OnOpenBefore(object args)
        {
            JoastData joastData = args as JoastData;
            if (joastData != default)
            {
                ui.node_tips.text_tips.text = joastData.ValueStr;
                ui.t0.Play(() =>
                {
                    uiCtrlDispatcher.Dispatch(UICtrlMsg.SCTipsUI_Close, joastData);
                });
            }
            else
            {
                CtrlCloseUI();
            }
        }

        protected override void OnOpen(object args)
        {
            // CommonHelper.FadeIn(ui);
        }

        #endregion
    }
}