< Summary

Class:DCL.Builder.LeftMenuHandler
Assembly:BuilderProjectsPanel
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/ProjectsPanelHUD/Scripts/Handlers/LeftMenuHandler.cs
Covered lines:31
Uncovered lines:4
Coverable lines:35
Total lines:81
Line coverage:88.5% (31 of 35)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
LeftMenuHandler(...)0%110100%
Dispose()0%110100%
SetToPreviousMainPanel()0%2.062075%
OnToggleOn(...)0%2100%
OnOpenSectionId(...)0%440100%
OnSceneSettingsBackPressed()0%110100%
SetMainLeftPanel()0%2.032080%
SetSettingsLeftPanel()0%2.032080%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/ProjectsPanelHUD/Scripts/Handlers/LeftMenuHandler.cs

#LineLine coverage
 1using System;
 2
 3namespace DCL.Builder
 4{
 5    internal class LeftMenuHandler : IDisposable
 6    {
 7        private readonly IBuilderMainPanelView view;
 8        private readonly ISectionsController sectionsController;
 9
 10        private bool isMainPanel = false;
 11        private SectionId lastMainSectionId;
 12
 1713        public LeftMenuHandler(IBuilderMainPanelView view, ISectionsController sectionsController)
 14        {
 1715            this.view = view;
 1716            this.sectionsController = sectionsController;
 17
 1718            view.OnBackToMainMenuPressed += OnSceneSettingsBackPressed;
 19
 1720            sectionsController.OnOpenSectionId += OnOpenSectionId;
 1721            LeftMenuButtonToggleView.OnToggleOn += OnToggleOn;
 1722        }
 23
 24        public void Dispose()
 25        {
 1726            view.OnBackToMainMenuPressed -= OnSceneSettingsBackPressed;
 27
 1728            sectionsController.OnOpenSectionId -= OnOpenSectionId;
 1729            LeftMenuButtonToggleView.OnToggleOn -= OnToggleOn;
 1730        }
 31
 32        public void SetToPreviousMainPanel()
 33        {
 134            if (isMainPanel)
 035                return;
 36
 137            sectionsController.OpenSection(lastMainSectionId);
 138        }
 39
 040        void OnToggleOn(LeftMenuButtonToggleView toggle) { sectionsController.OpenSection(toggle.openSection); }
 41
 42        void OnOpenSectionId(SectionId sectionId)
 43        {
 244            view.SetTogglOnWithoutNotify(sectionId);
 45
 246            bool isMainPanelSection = sectionId == SectionId.SCENES ||
 47                                      sectionId == SectionId.PROJECTS ||
 48                                      sectionId == SectionId.LAND;
 49
 250            if (isMainPanelSection)
 51            {
 152                lastMainSectionId = sectionId;
 153                SetMainLeftPanel();
 154            }
 55            else
 56            {
 157                SetSettingsLeftPanel();
 58            }
 159        }
 60
 261        void OnSceneSettingsBackPressed() { SetToPreviousMainPanel(); }
 62
 63        void SetMainLeftPanel()
 64        {
 165            if (isMainPanel)
 066                return;
 67
 168            isMainPanel = true;
 169            view.SetMainLeftPanel();
 170        }
 71
 72        void SetSettingsLeftPanel()
 73        {
 174            if (!isMainPanel)
 075                return;
 76
 177            isMainPanel = false;
 178            view.SetProjectSettingsLeftPanel();
 179        }
 80    }
 81}