using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using static System.Net.Mime.MediaTypeNames;

namespace ET.Client
{
	[FriendOf(typeof(UICustomerServiceComponent))]
	public static class UICustomerServiceComponentSystem
    {
		[ObjectSystem]
		public class UICustomerServiceComponentAwakeSystem : AwakeSystem<UICustomerServiceComponent>
		{
			protected override void Awake(UICustomerServiceComponent self, params object[] param)
			{
                ReferenceCollector rc = self.GetParent<UI>().GameObject.GetComponent<ReferenceCollector>();
                self.sureBtn = rc.Get<GameObject>("sureBtn");
                self.sureBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnCloseBtn(); });
                self.Init();
            }
        }

        private static void Init(this UICustomerServiceComponent self)
        {
            
        }

        public static async void OnCloseBtn(this UICustomerServiceComponent self)
        {
            await SoundManager.Instance.PlaySound("clickbtnsound");
            self.OnCloseAsync();
        }

        public static async void OnCloseAsync(this UICustomerServiceComponent self)
        {
            await UIHelper.Remove(self.ClientScene(),UIType.UICustomerService);
        }
    }
}