using FairyGUI;

namespace NBF
{
    public abstract class HomePageBase : GComponent
    {
        public int Page;

        public HomePanel Panel;

        public void Show(HomePanel panel)
        {
            Panel = panel;
            ShowAnimation();
            OnShow();
        }

        public void Hide()
        {
            if (visible)
            {
                HideAnimation();
                OnHide();
            }
        }

        #region Anim

        private void ShowAnimation()
        {
            visible = true;
            alpha = 0;
            GTween.Kill(this);
            TweenFade(1, 0.5f);
        }

        private void HideAnimation()
        {
            GTween.Kill(this);
            TweenFade(0, 0.2f).OnComplete(() => { visible = false; });
        }

        #endregion

        protected abstract void OnShow();
        protected abstract void OnHide();
    }
}