using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;

namespace Assets.Scripts.UI.Control
{
    public class PFUIInputField: PFUIComponentBase
    {
        [SerializeField]
        private InputField mInnerInputField;

        public string Text
        {
            get
            {
                return this.mInnerInputField.text;
            }
            set
            {
                this.mInnerInputField.text = value;
            }
        }

        public void OnSelect(BaseEventData eventData)
        {
            //throw new NotImplementedException();
            this.mInnerInputField.OnSelect(eventData);
            var image = this.transform.GetComponent<Image>();
            var png = Resources.Load<Sprite>("Images/input-bg2");
            image.sprite = png;
        }

        public void OnDeselect(BaseEventData eventData)
        {
            this.mInnerInputField.OnDeselect(eventData);
            var image = this.transform.GetComponent<Image>();
            var png1 = Resources.Load<Sprite>("Images/input-bg1");
            image.sprite = png1;
        }

        void Awake()
        {
            UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.PointerClick, new UnityAction<BaseEventData>(this.OnSelect));
            UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.Select, new UnityAction<BaseEventData>(this.OnSelect));
            UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.Deselect, new UnityAction<BaseEventData>(this.OnDeselect));
        }
    }
}
