< Summary

Class:PlacesAndEventsSectionComponentView
Assembly:ExploreV2
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/ExploreV2/Scripts/Sections/PlacesAndEventsSection/PlacesAndEventsSectionComponentView.cs
Covered lines:26
Uncovered lines:7
Coverable lines:33
Total lines:107
Line coverage:78.7% (26 of 33)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
Start()0%110100%
GoToSubsection(...)0%220100%
SetActive(...)0%110100%
RefreshControl()0%2100%
Dispose()0%110100%
CreateSubSectionSelectorMappings()0%550100%
RemoveSectionSelectorMappings()0%440100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/ExploreV2/Scripts/Sections/PlacesAndEventsSection/PlacesAndEventsSectionComponentView.cs

#LineLine coverage
 1using UnityEngine;
 2
 3public interface IPlacesAndEventsSectionComponentView
 4{
 5    /// <summary>
 6    /// Highlights sub-section component.
 7    /// </summary>
 8    IHighlightsSubSectionComponentView HighlightsSubSectionView { get; }
 9
 10    /// <summary>
 11    /// Places sub-section component.
 12    /// </summary>
 13    IPlacesSubSectionComponentView PlacesSubSectionView { get; }
 14
 15    /// <summary>
 16    /// Events sub-section component.
 17    /// </summary>
 18    IEventsSubSectionComponentView EventsSubSectionView { get; }
 19
 20    /// <summary>
 21    /// Open a sub-section.
 22    /// </summary>
 23    /// <param name="subSectionIndex">Sub-section index.</param>
 24    void GoToSubsection(int subSectionIndex);
 25
 26    /// <summary>
 27    /// Activates/deactivates the section.
 28    /// </summary>
 29    /// <param name="isActive"></param>
 30    void SetActive(bool isActive);
 31}
 32
 33public class PlacesAndEventsSectionComponentView : BaseComponentView, IPlacesAndEventsSectionComponentView
 34{
 35    internal const int HIGHLIGHTS_SUB_SECTION_INDEX = 0;
 36    internal const int PLACES_SUB_SECTION_INDEX = 1;
 37    internal const int EVENTS_SUB_SECTION_INDEX = 2;
 38
 39    [Header("Top Menu")]
 40    [SerializeField] internal SectionSelectorComponentView subSectionSelector;
 41
 42    [Header("Sub-Sections")]
 43    [SerializeField] internal HighlightsSubSectionComponentView highlightsSubSection;
 44    [SerializeField] internal PlacesSubSectionComponentView placesSubSection;
 45    [SerializeField] internal EventsSubSectionComponentView eventsSubSection;
 46
 47    private Canvas canvas;
 48
 49    public override void Awake()
 50    {
 4551        base.Awake();
 4552        canvas = GetComponent<Canvas>();
 4553    }
 54
 55    public override void Start()
 56    {
 4457        CreateSubSectionSelectorMappings();
 4458        SetActive(false);
 4459    }
 60
 061    public IHighlightsSubSectionComponentView HighlightsSubSectionView => highlightsSubSection;
 062    public IPlacesSubSectionComponentView PlacesSubSectionView => placesSubSection;
 063    public IEventsSubSectionComponentView EventsSubSectionView => eventsSubSection;
 64
 65    public void GoToSubsection(int subSectionIndex) =>
 366        subSectionSelector.GetSection(subSectionIndex)?.SelectToggle(reselectIfAlreadyOn: true);
 67
 68    public void SetActive(bool isActive) =>
 4669        canvas.enabled = isActive;
 70
 71    public override void RefreshControl()
 72    {
 073        highlightsSubSection.RefreshControl();
 074        placesSubSection.RefreshControl();
 075        eventsSubSection.RefreshControl();
 076    }
 77
 78    public override void Dispose()
 79    {
 5680        base.Dispose();
 81
 5682        RemoveSectionSelectorMappings();
 5683        highlightsSubSection.Dispose();
 5684        placesSubSection.Dispose();
 5685        eventsSubSection.Dispose();
 5686    }
 87
 88    internal void CreateSubSectionSelectorMappings()
 89    {
 5090        subSectionSelector.GetSection(HIGHLIGHTS_SUB_SECTION_INDEX)?.onSelect.AddListener(highlightsSubSection.SetActive
 5091        subSectionSelector.GetSection(PLACES_SUB_SECTION_INDEX)?.onSelect.AddListener(placesSubSection.SetActive);
 5092        subSectionSelector.GetSection(EVENTS_SUB_SECTION_INDEX)?.onSelect.AddListener(eventsSubSection.SetActive);
 93
 5094        placesSubSection.SetActive(false);
 5095        eventsSubSection.SetActive(false);
 5096        highlightsSubSection.SetActive(false);
 97
 5098        subSectionSelector.GetSection(HIGHLIGHTS_SUB_SECTION_INDEX)?.SelectToggle(reselectIfAlreadyOn: true);
 5099    }
 100
 101    internal void RemoveSectionSelectorMappings()
 102    {
 59103        subSectionSelector.GetSection(HIGHLIGHTS_SUB_SECTION_INDEX)?.onSelect.RemoveAllListeners();
 59104        subSectionSelector.GetSection(PLACES_SUB_SECTION_INDEX)?.onSelect.RemoveAllListeners();
 59105        subSectionSelector.GetSection(EVENTS_SUB_SECTION_INDEX)?.onSelect.RemoveAllListeners();
 59106    }
 107}