using UnityEngine; 
 | 
using UnityEngine.UI; 
 | 
using System.Collections.Generic; 
 | 
  
 | 
namespace vnxbqy.UI 
 | 
{ 
 | 
    public class ContactType : MonoBehaviour 
 | 
    { 
 | 
        [SerializeField] GameObject unSelectImg; 
 | 
        [SerializeField] GameObject selectImg; 
 | 
        [SerializeField] Text titleText; 
 | 
        [SerializeField] Text numText; 
 | 
        [SerializeField] Transform arrowIcon; 
 | 
        [SerializeField] RedpointBehaviour behaviour; 
 | 
  
 | 
        FriendsModel _friendsModel; 
 | 
        FriendsModel friendsModel 
 | 
        { 
 | 
            get 
 | 
            { 
 | 
                return _friendsModel ?? (_friendsModel = ModelCenter.Instance.GetModel<FriendsModel>()); 
 | 
            } 
 | 
        } 
 | 
  
 | 
        GroupType localType = GroupType.None; 
 | 
  
 | 
        public void Init(GroupType type,GroupType selectType = GroupType.None) 
 | 
        { 
 | 
            localType = type; 
 | 
            behaviour.redpointId = friendsModel.GetGroupRedPointId(type); 
 | 
            RefreshContactNum(type); 
 | 
            switch (type) 
 | 
            { 
 | 
                case GroupType.RecentContact: 
 | 
                    titleText.text = Language.Get("ChatPanel_RecentContactName_1"); 
 | 
                    break; 
 | 
                case GroupType.Friend: 
 | 
                    titleText.text = Language.Get("ChatPanel_FriendName_1"); 
 | 
                    break; 
 | 
                case GroupType.Enemy: 
 | 
                    titleText.text = Language.Get("ChatPanel_EnemyName_1"); 
 | 
                    break; 
 | 
                case GroupType.Balcklist: 
 | 
                    titleText.text = Language.Get("ChatPanel_BlacklistName_1"); 
 | 
                    break; 
 | 
            } 
 | 
  
 | 
            if (selectType != GroupType.None && selectType == localType) 
 | 
            { 
 | 
                unSelectImg.SetActive(false); 
 | 
                selectImg.SetActive(true); 
 | 
                RefreshArrowIconUIBySelect(true); 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                unSelectImg.SetActive(true); 
 | 
                selectImg.SetActive(false); 
 | 
                RefreshArrowIconUIBySelect(false); 
 | 
            } 
 | 
        } 
 | 
  
 | 
        private void RefreshContactNum(GroupType type) 
 | 
        { 
 | 
            if (type != localType) return; 
 | 
  
 | 
            Dictionary<uint, FriendPlayer> friendPlayerDict = friendsModel.GetFriendDictByType((byte)type); 
 | 
            if(friendPlayerDict != null) 
 | 
            { 
 | 
                numText.text = StringUtility.Contact(friendPlayerDict.Count, "/", friendsModel.contactTypeNumDict[type]); 
 | 
                RefreshArrowIconUIByNum(friendPlayerDict.Count); 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                numText.text = StringUtility.Contact(0, "/", friendsModel.contactTypeNumDict[type]); 
 | 
                RefreshArrowIconUIByNum(0); 
 | 
            } 
 | 
        } 
 | 
  
 | 
        private void RefreshArrowIconUIByNum(int num) 
 | 
        { 
 | 
            if(num > 0) 
 | 
            { 
 | 
                arrowIcon.SetActive(true); 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                arrowIcon.SetActive(false); 
 | 
            } 
 | 
        } 
 | 
  
 | 
        private void RefreshArrowIconUIBySelect(bool isChoose) 
 | 
        { 
 | 
            if (isChoose) 
 | 
            { 
 | 
                arrowIcon.localRotation = Quaternion.Euler(0, 0, -90); 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                arrowIcon.localRotation = Quaternion.Euler(0, 0, 0); 
 | 
            } 
 | 
  
 | 
        } 
 | 
    } 
 | 
} 
 |