using System.Collections.Generic;
using Excel2Json;
using UnityEngine;
using UnityEngine.UI;

namespace Mono
{
    [UIBinding(prefab = "CSGPanel")]
    public class CSGPanel : UIPanel
    {
        public Button Btn_DQ;
        public Button Btn_SR;
        public Button Btn_Return;
        
        public Button Btn_OnClick;
        public Button Btn_OnClick01;

        public RectTransform RegionScrollView;
        public RectTransform PoetScrollView;
        public RectTransform PoetContent;
        public RectTransform RegionContent;
        
        public RectTransform DQ;
        public RectTransform SR;

        public override void GetUIData()
        {
            Btn_DQ = UIData.Get<Button>("Btn_DQ");
            Btn_SR = UIData.Get<Button>("Btn_SR");
            Btn_Return = UIData.Get<Button>("Btn_Return");
            
            Btn_OnClick = UIData.Get<Button>("Btn_OnClick");
            Btn_OnClick01 = UIData.Get<Button>("Btn_OnClick01");
            
            RegionScrollView = UIData.Get<RectTransform>("RegionScrollView");
            PoetScrollView = UIData.Get<RectTransform>("PoetScrollView");
            PoetContent = UIData.Get<RectTransform>("PoetContent");
            RegionContent = UIData.Get<RectTransform>("RegionContent");
            
            DQ = UIData.Get<RectTransform>("DQ");
            SR = UIData.Get<RectTransform>("SR");
            
        }

        public override void AddButtonEvent()
        {
            Btn_DQ.onClick.AddListener(() =>
            {
                DQ.gameObject.SetActive(true);
                SR.gameObject.SetActive(false);
            });
            Btn_SR.onClick.AddListener(() =>
            {
                DQ.gameObject.SetActive(false);
                SR.gameObject.SetActive(true);
            });
            Btn_Return.onClick.AddListener(() =>
            {
                UIManager.Instance.HideUIPanel<CSGPanel>();
                UIManager.Instance.LoadAndOpenPanel<MainScenePanel>(UIManager.UILayer.Middle);
            });
            
            Btn_OnClick.onClick.AddListener(()=>{
                
                });
            Btn_OnClick01.onClick.AddListener(()=>{
                
            });
            
        }

        public override void Show()
        {
            base.Show();

            //CustomInit();
        }


        public List<RegionItem> RegionItems = new List<RegionItem>();

        public void CustomInit()
        {
            for (var i = 0; i < RegionItems.Count; i++)
            {
                UIManager.Instance.RecUICom(this, RegionItems[i]);
            }

            RegionItems.Clear();
            RegionConfig[] regionConfigs = ConfigComponent.Instance.GetAll<RegionConfig>();
            for (var i = 0; i < regionConfigs.Length; i++)
            {
                RegionItem regionItem = UIManager.Instance.CreatUICom<RegionItem>(this, RegionContent);
                regionItem.CustomInit(regionConfigs[i]);
                RegionItems.Add(regionItem);
            }

            // RegionItem regionItem = UIManager.Instance.CreatUICom<RegionItem>(this, RegionContent);
            // regionItem.CustomInit("江津");
            //
            // RegionItem regionItem1 = UIManager.Instance.CreatUICom<RegionItem>(this, RegionContent);
            // regionItem1.CustomInit("北碚");
            //
            // RegionItem regionItem2 = UIManager.Instance.CreatUICom<RegionItem>(this, RegionContent);
            // regionItem2.CustomInit("合川");
        }
    }
}