| | 1 | | using System; |
| | 2 | | using TMPro; |
| | 3 | | using UnityEngine; |
| | 4 | | using UnityEngine.EventSystems; |
| | 5 | | using UnityEngine.UI; |
| | 6 | |
|
| | 7 | | public class PublicChatWindowComponentView : BaseComponentView, IPublicChatWindowView, IComponentModelConfig<PublicChatM |
| | 8 | | { |
| | 9 | | [SerializeField] internal Button closeButton; |
| | 10 | | [SerializeField] internal Button backButton; |
| | 11 | | [SerializeField] internal TMP_Text nameLabel; |
| | 12 | | [SerializeField] internal ChatHUDView chatView; |
| | 13 | | [SerializeField] internal PublicChatModel model; |
| | 14 | | [SerializeField] internal ToggleComponentView muteToggle; |
| | 15 | |
|
| | 16 | | private Coroutine alphaRoutine; |
| | 17 | |
|
| | 18 | | public event Action OnClose; |
| | 19 | | public event Action OnBack; |
| | 20 | | public event Action<bool> OnFocused |
| | 21 | | { |
| 2 | 22 | | add => onFocused += value; |
| 0 | 23 | | remove => onFocused -= value; |
| | 24 | | } |
| | 25 | | public event Action OnClickOverWindow; |
| | 26 | | public event Action<bool> OnMuteChanged; |
| | 27 | |
|
| 0 | 28 | | public bool IsActive => gameObject.activeInHierarchy; |
| 1 | 29 | | public IChatHUDComponentView ChatHUD => chatView; |
| 0 | 30 | | public RectTransform Transform => (RectTransform) transform; |
| | 31 | |
|
| | 32 | | public static PublicChatWindowComponentView Create() |
| | 33 | | { |
| 10 | 34 | | return Instantiate(Resources.Load<PublicChatWindowComponentView>("SocialBarV1/NearbyChatChannelHUD")); |
| | 35 | | } |
| | 36 | |
|
| | 37 | | public override void Awake() |
| | 38 | | { |
| 10 | 39 | | base.Awake(); |
| 11 | 40 | | backButton.onClick.AddListener(() => OnBack?.Invoke()); |
| 11 | 41 | | closeButton.onClick.AddListener(() => OnClose?.Invoke()); |
| 10 | 42 | | muteToggle.OnSelectedChanged += (b, s, arg3) => OnMuteChanged?.Invoke(b); |
| 10 | 43 | | } |
| | 44 | |
|
| | 45 | | public override void RefreshControl() |
| | 46 | | { |
| 3 | 47 | | nameLabel.text = $"~{model.name}"; |
| 3 | 48 | | muteToggle.SetIsOnWithoutNotify(model.muted); |
| 3 | 49 | | } |
| | 50 | |
|
| 2 | 51 | | public void Hide() => gameObject.SetActive(false); |
| | 52 | |
|
| 2 | 53 | | public void Show() => gameObject.SetActive(true); |
| | 54 | |
|
| | 55 | | public void Configure(PublicChatModel model) |
| | 56 | | { |
| 3 | 57 | | this.model = model; |
| 3 | 58 | | RefreshControl(); |
| 3 | 59 | | } |
| | 60 | |
|
| 1 | 61 | | public void OnPointerDown(PointerEventData eventData) => OnClickOverWindow?.Invoke(); |
| | 62 | |
|
| | 63 | | } |