| | 1 | | using System; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.UI; |
| | 4 | |
|
| | 5 | | namespace DCL.Social.Chat |
| | 6 | | { |
| | 7 | | public class LeaveChannelConfirmationWindowComponentView : BaseComponentView, ILeaveChannelConfirmationWindowCompone |
| | 8 | | { |
| | 9 | | [Header("Prefab References")] |
| | 10 | | [SerializeField] internal Button backgroundButton; |
| | 11 | | [SerializeField] internal Button closeButton; |
| | 12 | | [SerializeField] internal ButtonComponentView cancelButton; |
| | 13 | | [SerializeField] internal ButtonComponentView confirmButton; |
| | 14 | |
|
| | 15 | | [Header("Configuration")] |
| | 16 | | [SerializeField] internal LeaveChannelConfirmationWindowComponentModel model; |
| | 17 | |
|
| 0 | 18 | | public RectTransform Transform => (RectTransform)transform; |
| | 19 | |
|
| | 20 | | public event Action OnCancelLeave; |
| | 21 | | public event Action<string> OnConfirmLeave; |
| | 22 | |
|
| | 23 | | public override void Awake() |
| | 24 | | { |
| 3 | 25 | | base.Awake(); |
| | 26 | |
|
| 3 | 27 | | backgroundButton.onClick.AddListener(() => OnCancelLeave?.Invoke()); |
| 3 | 28 | | closeButton.onClick.AddListener(() => OnCancelLeave?.Invoke()); |
| 3 | 29 | | cancelButton.onClick.AddListener(() => OnCancelLeave?.Invoke()); |
| 3 | 30 | | confirmButton.onClick.AddListener(() => OnConfirmLeave?.Invoke(model.channelId)); |
| 3 | 31 | | } |
| | 32 | |
|
| | 33 | | public override void Dispose() |
| | 34 | | { |
| 5 | 35 | | backgroundButton.onClick.RemoveAllListeners(); |
| 5 | 36 | | closeButton.onClick.RemoveAllListeners(); |
| 5 | 37 | | cancelButton.onClick.RemoveAllListeners(); |
| 5 | 38 | | confirmButton.onClick.RemoveAllListeners(); |
| | 39 | |
|
| 5 | 40 | | base.Dispose(); |
| 5 | 41 | | } |
| | 42 | |
|
| | 43 | | public void Configure(LeaveChannelConfirmationWindowComponentModel newModel) |
| | 44 | | { |
| 1 | 45 | | model = newModel; |
| 1 | 46 | | RefreshControl(); |
| 1 | 47 | | } |
| | 48 | |
|
| | 49 | | public override void RefreshControl() |
| | 50 | | { |
| 1 | 51 | | if (model == null) |
| 0 | 52 | | return; |
| | 53 | |
|
| 1 | 54 | | SetChannel(model.channelId); |
| 1 | 55 | | } |
| | 56 | |
|
| 2 | 57 | | public void SetChannel(string channelId) => model.channelId = channelId; |
| | 58 | |
|
| 1 | 59 | | public override void Show(bool instant = false) => gameObject.SetActive(true); |
| | 60 | |
|
| 1 | 61 | | public override void Hide(bool instant = false) => gameObject.SetActive(false); |
| | 62 | | } |
| | 63 | | } |