< 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:28
Uncovered lines:10
Coverable lines:38
Total lines:135
Line coverage:73.6% (28 of 38)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Start()0%2.062075%
RefreshControl()0%2100%
Dispose()0%110100%
SetVisible(...)0%330100%
CreateSectionSelectorMappings()0%220100%
RemoveSectionSelectorMappings()0%220100%
ConfigureCloseButton()0%110100%
CloseMenu()0%220100%
OnCloseActionTriggered(...)0%110100%
Create()0%2100%

File(s)

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

#LineLine coverage
 1using ExploreV2Analytics;
 2using System;
 3using UnityEngine;
 4using UnityEngine.UI;
 5
 6public interface IExploreV2MenuComponentView : IDisposable
 7{
 8    /// <summary>
 9    /// It will be triggered when the view is fully initialized.
 10    /// </summary>
 11    event Action OnInitialized;
 12
 13    /// <summary>
 14    /// It will be triggered when the close button is clicked.
 15    /// </summary>
 16    event Action OnCloseButtonPressed;
 17
 18    /// <summary>
 19    /// It will be triggered when a section is open.
 20    /// </summary>
 21    event Action<ExploreSection> OnSectionOpen;
 22
 23    /// <summary>
 24    /// Real viewer component.
 25    /// </summary>
 26    IRealmViewerComponentView currentRealmViewer { get; }
 27
 28    /// <summary>
 29    /// Profile card component.
 30    /// </summary>
 31    IProfileCardComponentView currentProfileCard { get; }
 32
 33    /// <summary>
 34    /// Places and Events section component.
 35    /// </summary>
 36    IPlacesAndEventsSectionComponentView currentPlacesAndEventsSection { get; }
 37
 38    /// <summary>
 39    /// Shows/Hides the game object of the explore menu.
 40    /// </summary>
 41    /// <param name="isActive">True to show it.</param>
 42    void SetVisible(bool isActive);
 43}
 44
 45public class ExploreV2MenuComponentView : BaseComponentView, IExploreV2MenuComponentView
 46{
 47    internal const int EXPLORE_SECTION_INDEX = 0;
 48
 49    [Header("Top Menu")]
 50    [SerializeField] internal SectionSelectorComponentView sectionSelector;
 51    [SerializeField] internal ProfileCardComponentView profileCard;
 52    [SerializeField] internal RealmViewerComponentView realmViewer;
 53    [SerializeField] internal ButtonComponentView closeMenuButton;
 54    [SerializeField] internal InputAction_Trigger closeAction;
 55    [SerializeField] internal Button backgroundButton;
 56
 57    [Header("Sections")]
 58    [SerializeField] internal PlacesAndEventsSectionComponentView placesAndEventsSection;
 59
 060    public GameObject go => this != null ? gameObject : null;
 061    public IRealmViewerComponentView currentRealmViewer => realmViewer;
 062    public IProfileCardComponentView currentProfileCard => profileCard;
 063    public IPlacesAndEventsSectionComponentView currentPlacesAndEventsSection => placesAndEventsSection;
 64
 65    public event Action OnInitialized;
 66    public event Action OnCloseButtonPressed;
 67    public event Action<ExploreSection> OnSectionOpen;
 68
 69    public override void Start()
 70    {
 1871        CreateSectionSelectorMappings();
 1872        ConfigureCloseButton();
 73
 1874        OnInitialized?.Invoke();
 075    }
 76
 077    public override void RefreshControl() { }
 78
 79    public override void Dispose()
 80    {
 3681        base.Dispose();
 82
 3683        RemoveSectionSelectorMappings();
 3684        closeMenuButton.onClick.RemoveAllListeners();
 3685        backgroundButton.onClick.RemoveAllListeners();
 3686        closeAction.OnTriggered -= OnCloseActionTriggered;
 3687    }
 88
 89    public void SetVisible(bool isActive)
 90    {
 291        if (isActive)
 92        {
 193            Show();
 194            sectionSelector.GetSection(EXPLORE_SECTION_INDEX)?.SelectToggle(true);
 195        }
 96        else
 97        {
 198            Hide();
 199            placesAndEventsSection.gameObject.SetActive(false);
 100        }
 1101    }
 102
 103    internal void CreateSectionSelectorMappings()
 104    {
 32105        sectionSelector.GetSection(EXPLORE_SECTION_INDEX)
 106                       ?.onSelect.AddListener((isOn) =>
 107                       {
 2108                           placesAndEventsSection.gameObject.SetActive(isOn);
 109
 2110                           if (isOn)
 2111                               OnSectionOpen?.Invoke(ExploreSection.Explore);
 0112                       });
 32113    }
 114
 86115    internal void RemoveSectionSelectorMappings() { sectionSelector.GetSection(EXPLORE_SECTION_INDEX)?.onSelect.RemoveAl
 116
 117    internal void ConfigureCloseButton()
 118    {
 20119        closeMenuButton.onClick.AddListener(CloseMenu);
 20120        backgroundButton.onClick.AddListener(CloseMenu);
 20121        closeAction.OnTriggered += OnCloseActionTriggered;
 20122    }
 123
 10124    internal void CloseMenu() { OnCloseButtonPressed?.Invoke(); }
 125
 6126    internal void OnCloseActionTriggered(DCLAction_Trigger action) { CloseMenu(); }
 127
 128    internal static ExploreV2MenuComponentView Create()
 129    {
 0130        ExploreV2MenuComponentView exploreV2View = Instantiate(Resources.Load<GameObject>("MainMenu/ExploreV2Menu")).Get
 0131        exploreV2View.name = "_ExploreV2";
 132
 0133        return exploreV2View;
 134    }
 135}