< Summary

Class:TermsOfServiceHUDView
Assembly:TermsOfServiceHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/TermsOfServiceHUD/TermsOfServiceHUDView.cs
Covered lines:30
Uncovered lines:0
Coverable lines:30
Total lines:78
Line coverage:100% (30 of 30)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
TermsOfServiceHUDView()0%110100%
CreateView()0%110100%
Initialize(...)0%110100%
SetVisible(...)0%220100%
SetData(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/TermsOfServiceHUD/TermsOfServiceHUDView.cs

#LineLine coverage
 1using System;
 2using TMPro;
 3using UnityEngine;
 4using UnityEngine.UI;
 5
 6public class TermsOfServiceHUDView : MonoBehaviour
 7{
 8    private const string VIEW_PATH = "TermsOfServiceHUD";
 9
 10    private const string SCENE_NAME_VAR = "$sceneName";
 111    private static readonly string TITLE = $"Terms of Service - {SCENE_NAME_VAR}";
 112    private static readonly string DESCRIPTION = $"Welcome to {SCENE_NAME_VAR}. Before you proceed, please read carefull
 13
 914    public static TermsOfServiceHUDView CreateView() => Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<
 15
 16    [SerializeField] internal GameObject content;
 17    [SerializeField] internal TextMeshProUGUI titleText;
 18    [SerializeField] internal TextMeshProUGUI descriptionText;
 19    [SerializeField] internal GameObject adultContent;
 20    [SerializeField] internal GameObject gamblingContent;
 21    [SerializeField] internal Button agreedButton;
 22    [SerializeField] internal Button declinedButton;
 23    [SerializeField] internal Toggle dontShowAgainToggle;
 24
 25    [Header("Hyperlinks")]
 26    [SerializeField] internal Button tosLinkButton;
 27    [SerializeField] internal Button privacyLinkButton;
 28    [SerializeField] internal Button emailLinkButton;
 29
 30    public void Initialize(Action<bool> agreedCallback, Action<bool> declinedCallback, Action tosClickedCallback, Action
 31    {
 932        agreedButton.onClick.RemoveAllListeners();
 1033        agreedButton.onClick.AddListener(() => agreedCallback?.Invoke(dontShowAgainToggle.isOn));
 34
 935        declinedButton.onClick.RemoveAllListeners();
 1036        declinedButton.onClick.AddListener(() => declinedCallback?.Invoke(dontShowAgainToggle.isOn));
 37
 938        tosLinkButton.onClick.RemoveAllListeners();
 939        tosLinkButton.onClick.AddListener(() => tosClickedCallback?.Invoke());
 40
 941        privacyLinkButton.onClick.RemoveAllListeners();
 942        privacyLinkButton.onClick.AddListener(() => privacyClickedCallback?.Invoke());
 43
 944        emailLinkButton.onClick.RemoveAllListeners();
 945        emailLinkButton.onClick.AddListener(() => emailClickedCallback?.Invoke());
 46
 947        SetVisible(false);
 948    }
 49
 50    public void SetVisible(bool visible)
 51    {
 1952        content.SetActive(visible);
 53
 1954        if (visible)
 55        {
 756            AudioScriptableObjects.dialogOpen.Play(true);
 757        }
 58        else
 59        {
 1260            AudioScriptableObjects.dialogClose.Play(true);
 61        }
 1262    }
 63
 64    public void SetData(string sceneName, bool hasAdultContent, bool hasGamblingContent, bool hasToS, bool hasPrivacyPol
 65    {
 766        titleText.text = TITLE.Replace(SCENE_NAME_VAR, sceneName);
 767        descriptionText.text = DESCRIPTION.Replace(SCENE_NAME_VAR, sceneName);
 68
 769        adultContent.SetActive(hasAdultContent);
 770        gamblingContent.SetActive(hasGamblingContent);
 71
 772        tosLinkButton.interactable  = hasToS;
 773        privacyLinkButton.interactable  = hasPrivacyPolicy;
 774        emailLinkButton.interactable  = hasContactEmail;
 75
 776        dontShowAgainToggle.isOn = false;
 777    }
 78}