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

namespace SimplifyXR
{


    public class BasePanelFeatures : MonoBehaviour
    {

        [Header("Base Panel Features")]
        [Tooltip("Toggle to customize any of the base features of the Standard Panel.")]
        public bool customizeBaseFeatures = false;
        [Conditional("customizeBaseFeatures", true, ComparisonType.Equals),
            Tooltip("Enable or disable the default behavior of the Standard Panel close button.")]
        public bool autoCloseButton = true;


        public TextMeshProUGUI titleText => baseRoot.GetElementAsType<TextMeshProUGUI>("Panel Title");
        public Button closeButton => baseRoot.GetElementAsType<Button>("Close Button");


        [HideInInspector]
        public ElementRoot baseRoot;

        #region Panel Base Features     


        public void ClosePanel()
        {
            this.gameObject.SetActive(false);
        } 


        public void Awake()
        {
            baseRoot = this.GetComponentInChildren<ElementRoot>();
            if (autoCloseButton) baseRoot.closeButton.onClick.AddListener(ClosePanel);
        }

        public void OnDestroy()
        {           
            if (autoCloseButton) baseRoot.closeButton.onClick.RemoveAllListeners();
        }
        #endregion

    }

}