< 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:25
Uncovered lines:7
Coverable lines:32
Total lines:110
Line coverage:78.1% (25 of 32)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
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 currentHighlightsSubSectionComponentView { get; }
 9
 10    /// <summary>
 11    /// Places sub-section component.
 12    /// </summary>
 13    IPlacesSubSectionComponentView currentPlacesSubSectionComponentView { get; }
 14
 15    /// <summary>
 16    /// Events sub-section component.
 17    /// </summary>
 18    IEventsSubSectionComponentView currentEventsSubSectionComponentView { 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    internal bool isDefaultSubSectionLoadedByFirstTime = false;
 48
 49    public override void Start() =>
 1250        CreateSubSectionSelectorMappings();
 51
 052    public IHighlightsSubSectionComponentView currentHighlightsSubSectionComponentView => highlightsSubSection;
 053    public IPlacesSubSectionComponentView currentPlacesSubSectionComponentView => placesSubSection;
 054    public IEventsSubSectionComponentView currentEventsSubSectionComponentView => eventsSubSection;
 55
 56    public void GoToSubsection(int subSectionIndex) =>
 357        subSectionSelector.GetSection(subSectionIndex)?.SelectToggle(reselectIfAlreadyOn: true);
 58
 59    public void SetActive(bool isActive) =>
 260        gameObject.SetActive(isActive);
 61
 62    public override void RefreshControl()
 63    {
 064        highlightsSubSection.RefreshControl();
 065        placesSubSection.RefreshControl();
 066        eventsSubSection.RefreshControl();
 067    }
 68
 69    public override void Dispose()
 70    {
 2371        base.Dispose();
 72
 2373        RemoveSectionSelectorMappings();
 2374        highlightsSubSection.Dispose();
 2375        placesSubSection.Dispose();
 2376        eventsSubSection.Dispose();
 2377    }
 78
 79    internal void CreateSubSectionSelectorMappings()
 80    {
 1881        subSectionSelector.GetSection(HIGHLIGHTS_SUB_SECTION_INDEX)
 82                          ?.onSelect.AddListener((isOn) =>
 83                          {
 2684                              highlightsSubSection.gameObject.SetActive(isOn);
 85
 2686                              isDefaultSubSectionLoadedByFirstTime = true;
 2687                          });
 88
 1889        subSectionSelector.GetSection(PLACES_SUB_SECTION_INDEX)
 90                          ?.onSelect.AddListener((isOn) =>
 91                          {
 392                              placesSubSection.gameObject.SetActive(isOn);
 393                          });
 94
 1895        subSectionSelector.GetSection(EVENTS_SUB_SECTION_INDEX)
 96                          ?.onSelect.AddListener((isOn) =>
 97                          {
 398                              eventsSubSection.gameObject.SetActive(isOn);
 399                          });
 100
 18101        subSectionSelector.GetSection(HIGHLIGHTS_SUB_SECTION_INDEX)?.SelectToggle(reselectIfAlreadyOn: true);
 18102    }
 103
 104    internal void RemoveSectionSelectorMappings()
 105    {
 26106        subSectionSelector.GetSection(HIGHLIGHTS_SUB_SECTION_INDEX)?.onSelect.RemoveAllListeners();
 26107        subSectionSelector.GetSection(PLACES_SUB_SECTION_INDEX)?.onSelect.RemoveAllListeners();
 26108        subSectionSelector.GetSection(EVENTS_SUB_SECTION_INDEX)?.onSelect.RemoveAllListeners();
 26109    }
 110}