| | 1 | | using System; |
| | 2 | | using TMPro; |
| | 3 | | using UnityEngine; |
| | 4 | | using UnityEngine.UI; |
| | 5 | |
|
| | 6 | | namespace DCL.Chat.HUD |
| | 7 | | { |
| | 8 | | public class ChannelContextualMenu : BaseComponentView |
| | 9 | | { |
| | 10 | | [Flags] |
| | 11 | | internal enum Options |
| | 12 | | { |
| | 13 | | Leave = 1 << 0 |
| | 14 | | } |
| | 15 | |
|
| | 16 | | [SerializeField] internal Options options; |
| | 17 | | [SerializeField] internal TMP_Text headerTiler; |
| | 18 | | [SerializeField] internal Button leaveButton; |
| | 19 | | [SerializeField] internal Button closeButton; |
| | 20 | |
|
| | 21 | | public event Action OnLeave; |
| | 22 | |
|
| | 23 | | public override void Awake() |
| | 24 | | { |
| 6 | 25 | | base.Awake(); |
| | 26 | |
|
| 6 | 27 | | leaveButton.onClick.AddListener(() => |
| | 28 | | { |
| 3 | 29 | | OnLeave?.Invoke(); |
| 3 | 30 | | Hide(); |
| 3 | 31 | | }); |
| | 32 | |
|
| 7 | 33 | | closeButton.onClick.AddListener(() => Hide()); |
| | 34 | |
|
| 6 | 35 | | RefreshControl(); |
| 6 | 36 | | } |
| | 37 | |
|
| | 38 | | public override void Show(bool instant = false) |
| | 39 | | { |
| 2 | 40 | | base.Show(instant); |
| 2 | 41 | | gameObject.SetActive(true); |
| 2 | 42 | | } |
| | 43 | |
|
| | 44 | | public override void Hide(bool instant = false) |
| | 45 | | { |
| 4 | 46 | | base.Hide(instant); |
| 4 | 47 | | gameObject.SetActive(false); |
| 4 | 48 | | } |
| | 49 | |
|
| | 50 | | public override void RefreshControl() |
| | 51 | | { |
| 6 | 52 | | leaveButton.gameObject.SetActive((options & Options.Leave) != 0); |
| 6 | 53 | | } |
| | 54 | |
|
| | 55 | | public void SetHeaderTitle(string title) |
| | 56 | | { |
| 4 | 57 | | headerTiler.text = title; |
| 4 | 58 | | } |
| | 59 | | } |
| | 60 | | } |