< 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:108
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%
RefreshControl()0%2100%
Dispose()0%110100%
CreateSubSectionSelectorMappings()0%550100%
RemoveSectionSelectorMappings()0%440100%
GoToSubsection(...)0%220100%
SetActive(...)0%110100%

File(s)

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

#LineLine coverage
 1using System;
 2using UnityEngine;
 3
 4public interface IPlacesAndEventsSectionComponentView
 5{
 6    /// <summary>
 7    /// Highlights sub-section component.
 8    /// </summary>
 9    IHighlightsSubSectionComponentView currentHighlightsSubSectionComponentView { get; }
 10
 11    /// <summary>
 12    /// Places sub-section component.
 13    /// </summary>
 14    IPlacesSubSectionComponentView currentPlacesSubSectionComponentView { get; }
 15
 16    /// <summary>
 17    /// Events sub-section component.
 18    /// </summary>
 19    IEventsSubSectionComponentView currentEventsSubSectionComponentView { get; }
 20
 21    /// <summary>
 22    /// Open a sub-section.
 23    /// </summary>
 24    /// <param name="subSectionIndex">Sub-section index.</param>
 25    void GoToSubsection(int subSectionIndex);
 26
 27    /// <summary>
 28    /// Activates/deactivates the section.
 29    /// </summary>
 30    /// <param name="isActive"></param>
 31    void SetActive(bool isActive);
 32}
 33
 34public class PlacesAndEventsSectionComponentView : BaseComponentView, IPlacesAndEventsSectionComponentView
 35{
 36    internal const int HIGHLIGHTS_SUB_SECTION_INDEX = 0;
 37    internal const int PLACES_SUB_SECTION_INDEX = 1;
 38    internal const int EVENTS_SUB_SECTION_INDEX = 2;
 39
 40    [Header("Top Menu")]
 41    [SerializeField] internal SectionSelectorComponentView subSectionSelector;
 42
 43    [Header("Sub-Sections")]
 44    [SerializeField] internal HighlightsSubSectionComponentView highlightsSubSection;
 45    [SerializeField] internal PlacesSubSectionComponentView placesSubSection;
 46    [SerializeField] internal EventsSubSectionComponentView eventsSubSection;
 47
 48    internal bool isDefaultSubSectionLoadedByFirstTime = false;
 49
 050    public IHighlightsSubSectionComponentView currentHighlightsSubSectionComponentView => highlightsSubSection;
 051    public IPlacesSubSectionComponentView currentPlacesSubSectionComponentView => placesSubSection;
 052    public IEventsSubSectionComponentView currentEventsSubSectionComponentView => eventsSubSection;
 53
 2454    public override void Start() { CreateSubSectionSelectorMappings(); }
 55
 56    public override void RefreshControl()
 57    {
 058        highlightsSubSection.RefreshControl();
 059        placesSubSection.RefreshControl();
 060        eventsSubSection.RefreshControl();
 061    }
 62
 63    public override void Dispose()
 64    {
 2365        base.Dispose();
 66
 2367        RemoveSectionSelectorMappings();
 2368        highlightsSubSection.Dispose();
 2369        placesSubSection.Dispose();
 2370        eventsSubSection.Dispose();
 2371    }
 72
 73    internal void CreateSubSectionSelectorMappings()
 74    {
 1875        subSectionSelector.GetSection(HIGHLIGHTS_SUB_SECTION_INDEX)
 76                          ?.onSelect.AddListener((isOn) =>
 77                          {
 2678                              highlightsSubSection.gameObject.SetActive(isOn);
 79
 2680                              isDefaultSubSectionLoadedByFirstTime = true;
 2681                          });
 82
 1883        subSectionSelector.GetSection(PLACES_SUB_SECTION_INDEX)
 84                          ?.onSelect.AddListener((isOn) =>
 85                          {
 386                              placesSubSection.gameObject.SetActive(isOn);
 387                          });
 88
 1889        subSectionSelector.GetSection(EVENTS_SUB_SECTION_INDEX)
 90                          ?.onSelect.AddListener((isOn) =>
 91                          {
 392                              eventsSubSection.gameObject.SetActive(isOn);
 393                          });
 94
 1895        subSectionSelector.GetSection(HIGHLIGHTS_SUB_SECTION_INDEX)?.SelectToggle(true);
 1896    }
 97
 98    internal void RemoveSectionSelectorMappings()
 99    {
 26100        subSectionSelector.GetSection(HIGHLIGHTS_SUB_SECTION_INDEX)?.onSelect.RemoveAllListeners();
 26101        subSectionSelector.GetSection(PLACES_SUB_SECTION_INDEX)?.onSelect.RemoveAllListeners();
 26102        subSectionSelector.GetSection(EVENTS_SUB_SECTION_INDEX)?.onSelect.RemoveAllListeners();
 26103    }
 104
 6105    public void GoToSubsection(int subSectionIndex) { subSectionSelector.GetSection(subSectionIndex)?.SelectToggle(true)
 106
 4107    public void SetActive(bool isActive) { gameObject.SetActive(isActive); }
 108}