< Summary

Class:ExploreV2MenuComponentView
Assembly:ExploreV2
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/ExploreV2/Scripts/MainMenu/ExploreV2Menu/ExploreV2MenuComponentView.cs
Covered lines:13
Uncovered lines:17
Coverable lines:30
Total lines:115
Line coverage:43.3% (13 of 30)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Start()0%20400%
OnDestroy()0%110100%
SetActive(...)0%110100%
CreateSectionSelectorMappings()0%220100%
RemoveSectionSelectorMappings()0%220100%
ConfigureCloseButton()0%110100%
ShowDefaultSection()0%110100%
Create()0%2100%
Dispose()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/ExploreV2/Scripts/MainMenu/ExploreV2Menu/ExploreV2MenuComponentView.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3
 4public interface IExploreV2MenuComponentView : IDisposable
 5{
 6    /// <summary>
 7    /// It will be triggered when the view is fully initialized.
 8    /// </summary>
 9    event Action OnInitialized;
 10
 11    /// <summary>
 12    /// It will be triggered when the close button is clicked.
 13    /// </summary>
 14    event Action OnCloseButtonPressed;
 15
 16    /// <summary>
 17    /// Real viewer component.
 18    /// </summary>
 19    IRealmViewerComponentView currentRealmViewer { get; }
 20
 21    /// <summary>
 22    /// Profile card component.
 23    /// </summary>
 24    IProfileCardComponentView currentProfileCard { get; }
 25
 26    /// <summary>
 27    /// Places and Events section component.
 28    /// </summary>
 29    IPlacesAndEventsSectionComponentView currentPlacesAndEventsSection { get; }
 30
 31    /// <summary>
 32    /// Returns true if the game object is activated.
 33    /// </summary>
 34    bool isActive { get; }
 35
 36    /// <summary>
 37    /// Activates/Deactivates the game object of the explore menu.
 38    /// </summary>
 39    /// <param name="isActive">True to activate it.</param>
 40    void SetActive(bool isActive);
 41}
 42
 43public class ExploreV2MenuComponentView : MonoBehaviour, IExploreV2MenuComponentView
 44{
 45    [Header("Top Menu")]
 46    [SerializeField] internal SectionSelectorComponentView sectionSelector;
 47    [SerializeField] internal ProfileCardComponentView profileCard;
 48    [SerializeField] internal RealmViewerComponentView realmViewer;
 49    [SerializeField] internal ButtonComponentView closeMenuButton;
 50    [SerializeField] internal InputAction_Trigger closeAction;
 51
 52    [Header("Sections")]
 53    [SerializeField] internal PlacesAndEventsSectionComponentView placesAndEventsSection;
 54
 055    public bool isActive => gameObject.activeSelf;
 56
 057    public GameObject go => this != null ? gameObject : null;
 058    public IRealmViewerComponentView currentRealmViewer => realmViewer;
 059    public IProfileCardComponentView currentProfileCard => profileCard;
 060    public IPlacesAndEventsSectionComponentView currentPlacesAndEventsSection => placesAndEventsSection;
 61
 62    public event Action OnInitialized;
 63    public event Action OnCloseButtonPressed;
 64
 65    private void Start()
 66    {
 067        if (sectionSelector.isFullyInitialized)
 068            CreateSectionSelectorMappings();
 69        else
 070            sectionSelector.OnFullyInitialized += CreateSectionSelectorMappings;
 71
 072        if (closeMenuButton.isFullyInitialized)
 073            ConfigureCloseButton();
 74        else
 075            closeMenuButton.OnFullyInitialized += ConfigureCloseButton;
 76
 077        OnInitialized?.Invoke();
 078    }
 79
 80    private void OnDestroy()
 81    {
 1882        sectionSelector.OnFullyInitialized -= CreateSectionSelectorMappings;
 1883        RemoveSectionSelectorMappings();
 1884        closeMenuButton.onClick.RemoveAllListeners();
 1885    }
 86
 487    public void SetActive(bool isActive) { gameObject.SetActive(isActive); }
 88
 89    internal void CreateSectionSelectorMappings()
 90    {
 1591        sectionSelector.GetSection(0)?.onSelect.AddListener((isOn) => placesAndEventsSection.gameObject.SetActive(isOn))
 92
 1493        ShowDefaultSection();
 1494    }
 95
 4996    internal void RemoveSectionSelectorMappings() { sectionSelector.GetSection(0)?.onSelect.RemoveAllListeners(); }
 97
 98    internal void ConfigureCloseButton()
 99    {
 2100        closeMenuButton.onClick.AddListener(() => OnCloseButtonPressed?.Invoke());
 1101        closeAction.OnTriggered += (action) => OnCloseButtonPressed?.Invoke();
 1102    }
 103
 30104    internal void ShowDefaultSection() { placesAndEventsSection.gameObject.SetActive(true); }
 105
 106    internal static ExploreV2MenuComponentView Create()
 107    {
 0108        ExploreV2MenuComponentView exploreV2View = Instantiate(Resources.Load<GameObject>("MainMenu/ExploreV2Menu")).Get
 0109        exploreV2View.name = "_ExploreV2";
 110
 0111        return exploreV2View;
 112    }
 113
 0114    public void Dispose() { Destroy(gameObject); }
 115}