| | 1 | | using DCL.Helpers; |
| | 2 | | using DCL.Interface; |
| | 3 | | using TMPro; |
| | 4 | | using UnityEngine; |
| | 5 | | using UnityEngine.UI; |
| | 6 | |
|
| | 7 | | public class OpenUrlView : BaseComponentView |
| | 8 | | { |
| | 9 | | [SerializeField] internal Button closeButton; |
| | 10 | | [SerializeField] internal Button continueButton; |
| | 11 | | [SerializeField] internal Button cancelButton; |
| | 12 | | [SerializeField] internal TextMeshProUGUI domainText; |
| | 13 | | [SerializeField] internal TextMeshProUGUI urlText; |
| | 14 | | private string currentUrl; |
| | 15 | |
|
| | 16 | | public void Start() |
| | 17 | | { |
| 0 | 18 | | closeButton.onClick.AddListener(() => SetVisibility(false)); |
| 0 | 19 | | cancelButton.onClick.AddListener(() => SetVisibility(false)); |
| 0 | 20 | | continueButton.onClick.AddListener(OpenLink); |
| 0 | 21 | | } |
| | 22 | |
|
| | 23 | | public override void RefreshControl() |
| | 24 | | { |
| 0 | 25 | | } |
| | 26 | |
|
| | 27 | | private void OpenLink() |
| | 28 | | { |
| 0 | 29 | | Utils.UnlockCursor(); |
| 0 | 30 | | WebInterface.OpenURL(currentUrl); |
| 0 | 31 | | AnalyticsHelper.SendExternalLinkAnalytic(currentUrl); |
| 0 | 32 | | SetVisibility(true); |
| 0 | 33 | | } |
| | 34 | |
|
| | 35 | | public void SetUrlInfo(string url, string domain) |
| | 36 | | { |
| 0 | 37 | | currentUrl = url; |
| 0 | 38 | | urlText.text = url; |
| 0 | 39 | | domainText.text = domain; |
| 0 | 40 | | } |
| | 41 | |
|
| | 42 | | public void SetVisibility(bool visible) |
| | 43 | | { |
| 0 | 44 | | if (visible) |
| | 45 | | { |
| 0 | 46 | | gameObject.SetActive(true); |
| 0 | 47 | | Show(); |
| | 48 | | } |
| | 49 | | else |
| 0 | 50 | | Hide(); |
| 0 | 51 | | } |
| | 52 | | } |