/// #pkgName FGUI包名
/// #panelName UIPanel名字
/// #UIName = $"{#pkgName}{#panelName}" UIKey名字
/// 该脚本由模板创建
/// created by cb 2024

using FairyGUI;
using FL.Battle.Buffs;
using System.Collections.Generic;
using XGame.Framework.UI;

namespace FL.FGUI
{
    /// <summary>
    /// UI逻辑处理类
    /// </summary>
    /// <typeparam name=""></typeparam>
    public partial class MainBuffPreviewPanelCtrl : UIController<MainBuffPreviewPanelVM>
    {
        protected override void OnEnable(object intent)
        {
            AddUIListenres();
            RefreshList(intent as List<BuffPreviewDto>);
        }
        protected override void OnDisable()
        {
            RemoveUIListenres();
        }
        #region UI事件
        private void AddUIListenres()
        {
            VM.CloseBtn.onClick.Add(OnClickCloseBtn);

        }
        private void RemoveUIListenres()
        {
            VM.CloseBtn.onClick.Remove(OnClickCloseBtn);

        }
        private void OnClickCloseBtn(EventContext context)
        {
            Context.ClosePanel();
        }

        #endregion

        private void RefreshList(List<BuffPreviewDto> dtos)
        {
            VM.BuffInfoList.ListType = EGListType.Virtual;
            VM.BuffInfoList.BindDatas(dtos);
        }
    }
}