< 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:22
Uncovered lines:3
Coverable lines:25
Total lines:84
Line coverage:88% (22 of 25)
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%440100%
RemoveSectionSelectorMappings()0%330100%

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    /// It will be triggered when any action is executed inside the places and events section.
 8    /// </summary>
 9    event Action OnAnyActionExecuted;
 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
 22public class PlacesAndEventsSectionComponentView : BaseComponentView, IPlacesAndEventsSectionComponentView
 23{
 24    internal const int PLACES_SUB_SECTION_INDEX = 0;
 25    internal const int EVENTS_SUB_SECTION_INDEX = 1;
 26
 27    [Header("Top Menu")]
 28    [SerializeField] internal SectionSelectorComponentView subSectionSelector;
 29
 30    [Header("Sections")]
 31    [SerializeField] internal PlacesSubSectionComponentView placesSubSection;
 32    [SerializeField] internal EventsSubSectionComponentView eventsSubSection;
 33
 34    internal bool isDefaultSubSectionLoadedByFirstTime = false;
 35
 036    public IEventsSubSectionComponentView currentEventsSubSectionComponentView => eventsSubSection;
 037    public IPlacesSubSectionComponentView currentPlacesSubSectionComponentView => placesSubSection;
 38
 39    public event Action OnAnyActionExecuted;
 40
 1241    public override void Start() { CreateSubSectionSelectorMappings(); }
 42
 043    public override void RefreshControl() { }
 44
 45    public override void Dispose()
 46    {
 1147        base.Dispose();
 48
 1149        RemoveSectionSelectorMappings();
 1150        placesSubSection.Dispose();
 1151        eventsSubSection.Dispose();
 1152    }
 53
 54    internal void CreateSubSectionSelectorMappings()
 55    {
 1056        subSectionSelector.GetSection(PLACES_SUB_SECTION_INDEX)
 57                          ?.onSelect.AddListener((isOn) =>
 58                          {
 1059                              placesSubSection.gameObject.SetActive(isOn);
 60
 1061                              if (isDefaultSubSectionLoadedByFirstTime)
 462                                  OnAnyActionExecuted?.Invoke();
 663                          });
 64
 1065        subSectionSelector.GetSection(EVENTS_SUB_SECTION_INDEX)
 66                          ?.onSelect.AddListener((isOn) =>
 67                          {
 1468                              eventsSubSection.gameObject.SetActive(isOn);
 69
 1470                              if (isDefaultSubSectionLoadedByFirstTime)
 871                                  OnAnyActionExecuted?.Invoke();
 72
 1473                              isDefaultSubSectionLoadedByFirstTime = true;
 1474                          });
 75
 1076        subSectionSelector.GetSection(EVENTS_SUB_SECTION_INDEX)?.SelectToggle(true);
 1077    }
 78
 79    internal void RemoveSectionSelectorMappings()
 80    {
 1381        subSectionSelector.GetSection(PLACES_SUB_SECTION_INDEX)?.onSelect.RemoveAllListeners();
 1382        subSectionSelector.GetSection(EVENTS_SUB_SECTION_INDEX)?.onSelect.RemoveAllListeners();
 1383    }
 84}