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(UIShareComponent))]
	public static class UIShareComponentSystem
    {
		[ObjectSystem]
		public class UIShareComponentAwakeSystem : AwakeSystem<UIShareComponent>
		{
			protected override void Awake(UIShareComponent self, params object[] param)
			{
                ReferenceCollector rc = self.GetParent<UI>().GameObject.GetComponent<ReferenceCollector>();
                self.friendShareBtn = rc.Get<GameObject>("friendShareBtn");
                self.friendShareBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnFriendShareBtn(); });
                self.wechatShareBtn = rc.Get<GameObject>("wechatShareBtn");
                self.wechatShareBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnWeixinBtn(); });
                self.clickBtn = rc.Get<GameObject>("clickBtn");
                self.clickBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnCloseBtn(); });
                self.Init();
            }
        }

        private static void Init(this UIShareComponent self)
        {
            
        }

        public static async void OnFriendShareBtn(this UIShareComponent self)
        {
            await SoundManager.Instance.PlaySound("clickbtnsound");
        }

        public static async void OnWeixinBtn(this UIShareComponent self)
        {
            await SoundManager.Instance.PlaySound("clickbtnsound");
        }

        public static void OnCloseBtn(this UIShareComponent self)
        {
            self.OnCloseAsync();
        }

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