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