< Summary

Class:DCL.HelpAndSupportHUD.HelpAndSupportHUDView
Assembly:HelpAndSupportHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/HelpAndSupportHUD/HelpAndSupportHUDView.cs
Covered lines:18
Uncovered lines:8
Coverable lines:26
Total lines:72
Line coverage:69.2% (18 of 26)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
Initialize()0%330100%
Create()0%110100%
SetVisibility(...)0%5.025090%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/HelpAndSupportHUD/HelpAndSupportHUDView.cs

#LineLine coverage
 1using DCL.Interface;
 2using UnityEngine;
 3using UnityEngine.UI;
 4
 5namespace DCL.HelpAndSupportHUD
 6{
 7    public class HelpAndSupportHUDView : MonoBehaviour
 8    {
 09        public bool isOpen { get; private set; } = false;
 10
 11        public event System.Action OnClose;
 12
 13        private const string PATH = "HelpAndSupportHUD";
 14        private const string VIEW_OBJECT_NAME = "_HelpAndSupportHUD";
 15        private const string JOIN_DISCORD_URL = "https://discord.com/invite/k5ydeZp";
 16        private const string FAQ_URL = "https://docs.decentraland.org/decentraland/faq/";
 17
 18        [SerializeField] private ShowHideAnimator helpAndSupportAnimator;
 19        [SerializeField] private Button joinDiscordButton;
 20        [SerializeField] private Button visitFAQButton;
 21        [SerializeField] private Button closeButton;
 22        [SerializeField] internal InputAction_Trigger closeAction;
 23
 24        private InputAction_Trigger.Triggered closeActionDelegate;
 25
 1026        private void Awake() { closeActionDelegate = (x) => SetVisibility(false); }
 27
 28        private void Initialize()
 29        {
 530            gameObject.name = VIEW_OBJECT_NAME;
 31
 532            joinDiscordButton.onClick.AddListener(() =>
 33            {
 034                WebInterface.OpenURL(JOIN_DISCORD_URL);
 035            });
 36
 537            visitFAQButton.onClick.AddListener(() =>
 38            {
 039                WebInterface.OpenURL(FAQ_URL);
 040            });
 41
 542            closeButton.onClick.AddListener(() =>
 43            {
 044                SetVisibility(false);
 045            });
 546        }
 47
 48        public static HelpAndSupportHUDView Create()
 49        {
 550            HelpAndSupportHUDView view = Instantiate(Resources.Load<GameObject>(PATH)).GetComponent<HelpAndSupportHUDVie
 551            view.Initialize();
 552            return view;
 53        }
 54
 55        public void SetVisibility(bool visible)
 56        {
 357            closeAction.OnTriggered -= closeActionDelegate;
 358            if (visible)
 59            {
 260                helpAndSupportAnimator.Show();
 261                closeAction.OnTriggered += closeActionDelegate;
 262            }
 63            else
 164                helpAndSupportAnimator.Hide();
 65
 366            if (!visible && isOpen)
 067                OnClose?.Invoke();
 68
 369            isOpen = visible;
 370        }
 71    }
 72}