123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using TMPro;
- using UnityEngine.UI;
- public class InviteDlgUserItem : MonoBehaviour
- {
- public TMP_Text itemName;
- public TMP_Text level;
- public Image stateImage;
- public TMP_Text stateText;
- public Image headImage;
- private InviteUserConfig inviteUserConfig;
- public Toggle toggle;
- private void Start()
- {
- toggle = transform.GetComponent<Toggle>();
- toggle.onValueChanged.AddListener((state) =>
- {
- OnValueChange(state);
- });
- }
- public void SetData(Sprite headImage, string level , InviteUserConfig userConfig)
- {
- if (headImage != null)
- this.headImage.sprite = headImage;
-
- itemName.text = userConfig.NickName;
- this.level.text = level;
- this.inviteUserConfig = userConfig;
- switch (userConfig.Online)
- {
- case "1":
- stateImage.color = Color.green;
- stateText.text = "在线";
- toggle.interactable = true;
- break;
- case "2":
- stateImage.color = Color.blue;
- stateText.text = "通话中";
- toggle.interactable = false;
- break;
- case "0":
- stateImage.color = Color.red;
- stateText.text = "离线";
- toggle.interactable = false;
- break;
- default:
- break;
- }
- }
- public void ResetData()
- {
- itemName.text = "韩风";
- this.level.text = "组长";
- stateImage.color = Color.red;
- stateText.text = "离线";
- inviteUserConfig = null;
- }
- private void OnValueChange(bool isOn)
- {
- if (InviteDlg.Instance && inviteUserConfig != null)
- {
- if (isOn)
- {
- InviteDlg.Instance.InviteUnionIdList.Add(inviteUserConfig);
- if (InviteDlg.Instance.InviteUnionIdList.Count > 0)
- {
- InviteDlg.Instance.RecoverInviteBtn();
- }
- }
- else
- {
- if (InviteDlg.Instance.InviteUnionIdList.Contains(inviteUserConfig))
- {
- InviteDlg.Instance.InviteUnionIdList.Remove(inviteUserConfig);
- }
- if (InviteDlg.Instance.InviteUnionIdList.Count <= 0)
- {
- InviteDlg.Instance.InitInviteBtn();
- }
- }
- }
- }
- }
|