< Summary

Class:MainScripts.DCL.Controllers.HUD.ToSPopupHUD.ToSPopupView
Assembly:ToSPopupHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/ToSPopupHUD/ToSPopupView.cs
Covered lines:0
Uncovered lines:24
Coverable lines:24
Total lines:84
Line coverage:0% (0 of 24)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:9
Method coverage:0% (0 of 9)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%2100%
Initialize()0%2100%
OnAcceptPressed()0%6200%
OnCancelPressed()0%6200%
Show()0%2100%
Hide()0%2100%
OnDestroy()0%2100%
Dispose()0%6200%
OnPointerClick(...)0%20400%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/ToSPopupHUD/ToSPopupView.cs

#LineLine coverage
 1using System;
 2using TMPro;
 3using UnityEngine;
 4using UnityEngine.EventSystems;
 5
 6namespace MainScripts.DCL.Controllers.HUD.ToSPopupHUD
 7{
 8    public interface IToSPopupView : IDisposable
 9    {
 10        event Action OnAccept;
 11        event Action OnCancel;
 12        event Action OnTermsOfServiceLinkPressed;
 13
 14        void Show();
 15
 16        void Hide();
 17    }
 18
 19    public class ToSPopupView : MonoBehaviour, IToSPopupView, IPointerClickHandler
 20    {
 21        public event Action OnAccept;
 22        public event Action OnCancel;
 23        public event Action OnTermsOfServiceLinkPressed;
 24
 25        private bool isDestroyed = false;
 26
 27        [SerializeField] internal ButtonComponentView agreeButton;
 28        [SerializeField] internal ButtonComponentView cancelButton;
 29        [SerializeField] internal TextMeshProUGUI tosText;
 30
 31        private void Awake()
 32        {
 033            Initialize();
 034        }
 35
 36        internal void Initialize()
 37        {
 038            agreeButton.onClick.AddListener(OnAcceptPressed);
 039            cancelButton.onClick.AddListener(OnCancelPressed);
 040        }
 41
 42        private void OnAcceptPressed()
 43        {
 044            OnAccept?.Invoke();
 045        }
 46
 47        private void OnCancelPressed()
 48        {
 049            OnCancel?.Invoke();
 050        }
 51
 52        public void Show()
 53        {
 054            gameObject.SetActive(true);
 055        }
 56
 57        public void Hide()
 58        {
 059            gameObject.SetActive(false);
 060        }
 61
 62        private void OnDestroy()
 63        {
 064            isDestroyed = true;
 065        }
 66
 67        public void Dispose()
 68        {
 069            if (!isDestroyed)
 070                Destroy(gameObject);
 071        }
 72
 73        public void OnPointerClick(PointerEventData eventData)
 74        {
 075            if (eventData.button != PointerEventData.InputButton.Left) return;
 076            int linkIndex = TMP_TextUtilities.FindIntersectingLink(tosText, eventData.position, tosText.canvas.worldCame
 077            if (linkIndex == -1)
 078                return;
 79
 80            //There should be only one link, we dont even need to get it
 081            OnTermsOfServiceLinkPressed?.Invoke();
 082        }
 83    }
 84}