< 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:19
Uncovered lines:8
Coverable lines:27
Total lines:74
Line coverage:70.3% (19 of 27)
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.91%

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://dcl.gg/discord";
 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
 826        private void Awake() { closeActionDelegate = (x) => SetVisibility(false); }
 27
 28        private void Initialize()
 29        {
 430            gameObject.name = VIEW_OBJECT_NAME;
 31
 432            joinDiscordButton.onClick.AddListener(() =>
 33            {
 034                WebInterface.OpenURL(JOIN_DISCORD_URL);
 035            });
 36
 437            visitFAQButton.onClick.AddListener(() =>
 38            {
 039                WebInterface.OpenURL(FAQ_URL);
 040            });
 41
 442            closeButton.onClick.AddListener(() =>
 43            {
 044                SetVisibility(false);
 045            });
 446        }
 47
 48        public static HelpAndSupportHUDView Create()
 49        {
 450            HelpAndSupportHUDView view = Instantiate(Resources.Load<GameObject>(PATH)).GetComponent<HelpAndSupportHUDVie
 451            view.Initialize();
 452            return view;
 53        }
 54
 55        public void SetVisibility(bool visible)
 56        {
 357            DataStore.i.exploreV2.isSomeModalOpen.Set(visible);
 58
 359            closeAction.OnTriggered -= closeActionDelegate;
 360            if (visible)
 61            {
 262                helpAndSupportAnimator.Show();
 263                closeAction.OnTriggered += closeActionDelegate;
 264            }
 65            else
 166                helpAndSupportAnimator.Hide();
 67
 368            if (!visible && isOpen)
 069                OnClose?.Invoke();
 70
 371            isOpen = visible;
 372        }
 73    }
 74}