// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖

using System.Linq;
using Fantasy;
using UnityEngine;
using NBC;

namespace NBF
{
    public partial class ShopDetailsPanel : UIPanel
    {
        protected override void OnShow()
        {
            var config = GetData() as cfg.Goods;
            var first = config.Awards.First();
            var itemConfig = Game.Tables.TbItem.Get(first.Id);
            Model.SetData(itemConfig);
            InputManager.Instance.On(this);
        }

        #region UI输入事件

        [InputInvoke(InputDef.UI.Up, UIInputButtonShowMode.BottomLeft)]
        private void OnUp()
        {
            // ItemList.List.Selector.Up();
            // ChangeListSelected();
        }

        [InputInvoke(InputDef.UI.Down, UIInputButtonShowMode.BottomLeft)]
        private void OnDown()
        {
            // ItemList.List.Selector.Down();
        }

        [InputInvoke(InputDef.UI.Enter, UIInputButtonShowMode.BottomLeft, "购买")]
        private void OnApplySettings()
        {
            // var selectedItem = ItemList.List.Selector.SelectedItem;
            // if (selectedItem != null)
            // {
            //     ItemList.List.InvokeClickItem(selectedItem);
            // }
        }


        [InputInvoke(InputDef.UI.Back, UIInputButtonShowMode.BottomRight)]
        private void OnBack()
        {
            Hide();
        }

        #endregion

        protected override void OnHide()
        {
            InputManager.Instance.Off(this);
        }
    }
}