< Summary

Class:DCL.Builder.BuilderMainPanelView
Assembly:BuilderProjectsPanel
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/ProjectsPanelHUD/Scripts/Views/BuilderMainPanelView.cs
Covered lines:41
Uncovered lines:19
Coverable lines:60
Total lines:184
Line coverage:68.3% (41 of 60)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
IsVisible()0%110100%
SetVisible(...)0%330100%
SetTogglOnWithoutNotify(...)0%220100%
SetMainLeftPanel()0%110100%
SetProjectSettingsLeftPanel()0%110100%
GetProjectCardView()0%2100%
GetSceneCardViewPrefab()0%110100%
GetSectionContainer()0%2100%
GetTransform()0%2100%
GetSearchBar()0%110100%
GetSettingsViewReferences()0%110100%
GetSceneCardViewContextMenu()0%110100%
GetUnpublishPopup()0%110100%
Dispose()0%220100%
Awake()0%330100%
OnDestroy()0%110100%
CloseTriggerOnOnTriggered(...)0%2.52050%
SetScenes(...)0%2100%
SceneAdded(...)0%2100%
SceneRemoved(...)0%2100%
OnSetProjects(...)0%2100%
OnProjectAdded(...)0%2100%
OnProjectRemoved(...)0%2100%
SetAsFullScreenMenuMode(...)0%4.312016.67%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/ProjectsPanelHUD/Scripts/Views/BuilderMainPanelView.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using UnityEngine;
 4using UnityEngine.UI;
 5
 6namespace DCL.Builder
 7{
 8    internal interface IBuilderMainPanelView : IDisposable
 9    {
 10        event Action OnBackToMainMenuPressed;
 11        event Action OnClosePressed;
 12        event Action OnBackPressed;
 13        event Action OnCreateProjectPressed;
 14        void SetVisible(bool visible);
 15        bool IsVisible();
 16        void SetTogglOnWithoutNotify(SectionId sectionId);
 17        void SetMainLeftPanel();
 18        void SetProjectSettingsLeftPanel();
 19        SceneCardView GetSceneCardViewPrefab();
 20        ProjectCardView GetProjectCardView();
 21        Transform GetSectionContainer();
 22        Transform GetTransform();
 23        SearchBarView GetSearchBar();
 24        LeftMenuSettingsViewReferences GetSettingsViewReferences();
 25        SceneCardViewContextMenu GetSceneCardViewContextMenu();
 26        IUnpublishPopupView GetUnpublishPopup();
 27        void SetAsFullScreenMenuMode(Transform parentTransform);
 28    }
 29
 30    internal class BuilderMainPanelView : MonoBehaviour, IBuilderMainPanelView, ISceneListener, IProjectsListener
 31    {
 32        [Header("General")]
 33        [SerializeField] internal Button closeButton;
 34        [SerializeField] internal Button backgroundButton;
 35        [SerializeField] internal Transform sectionsContainer;
 36        [SerializeField] internal SceneCardViewContextMenu contextMenu;
 37        [SerializeField] internal SearchBarView searchBarView;
 38        [SerializeField] internal ShowHideAnimator showHideAnimator;
 39        [SerializeField] internal InputAction_Trigger closeTrigger;
 40
 41        [Header("Left-Panel Section Buttons")]
 42        [SerializeField] internal LeftMenuButtonToggleView[] sectionToggles;
 43
 44        [Header("Left-Panel")]
 45        [SerializeField] internal GameObject leftPanelMain;
 46        [SerializeField] internal GameObject leftPanelProjectSettings;
 47        [SerializeField] internal Button createSceneButton;
 48        [SerializeField] internal Button importSceneButton;
 49        [SerializeField] internal Button backToMainPanelButton;
 50        [SerializeField] internal LeftMenuSettingsViewReferences settingsViewReferences;
 51
 52        [Header("Assets")]
 53        [SerializeField] internal SceneCardView sceneCardViewPrefab;
 54        [SerializeField] internal ProjectCardView projectCardView;
 55
 56        [Header("Popups")]
 57        [SerializeField] internal UnpublishPopupView unpublishPopupView;
 58
 59        public event Action OnClosePressed;
 60        public event Action OnBackPressed;
 61        public event Action OnCreateProjectPressed;
 62        public event Action OnImportScenePressed;
 63        public event Action OnBackToMainMenuPressed;
 64
 65        private int scenesCount = 0;
 66        private int projectScenesCount = 0;
 67        private bool isDestroyed = false;
 68
 169        public bool IsVisible() { return gameObject.activeSelf; }
 70
 71        void IBuilderMainPanelView.SetVisible(bool visible)
 72        {
 773            if (visible)
 74            {
 475                if (!gameObject.activeSelf)
 76                {
 477                    gameObject.SetActive(true);
 78                }
 479                showHideAnimator.Show();
 480            }
 81            else
 82            {
 383                showHideAnimator.Hide();
 84            }
 385        }
 86
 87        void IBuilderMainPanelView.SetTogglOnWithoutNotify(SectionId sectionId)
 88        {
 4089            for (int i = 0; i < sectionToggles.Length; i++)
 90            {
 1891                sectionToggles[i].SetIsOnWithoutNotify(sectionId == sectionToggles[i].openSection);
 92            }
 293        }
 94
 95        void IBuilderMainPanelView.SetMainLeftPanel()
 96        {
 197            leftPanelMain.SetActive(true);
 198            leftPanelProjectSettings.SetActive(false);
 199        }
 100
 101        void IBuilderMainPanelView.SetProjectSettingsLeftPanel()
 102        {
 1103            leftPanelMain.SetActive(false);
 1104            leftPanelProjectSettings.SetActive(true);
 1105        }
 106
 0107        ProjectCardView IBuilderMainPanelView.GetProjectCardView() { return projectCardView; }
 108
 2109        SceneCardView IBuilderMainPanelView.GetSceneCardViewPrefab() { return sceneCardViewPrefab; }
 110
 0111        Transform IBuilderMainPanelView.GetSectionContainer() { return sectionsContainer; }
 112
 0113        Transform IBuilderMainPanelView.GetTransform() { return transform; }
 114
 17115        SearchBarView IBuilderMainPanelView.GetSearchBar() { return  searchBarView; }
 116
 18117        LeftMenuSettingsViewReferences IBuilderMainPanelView.GetSettingsViewReferences() { return settingsViewReferences
 118
 18119        SceneCardViewContextMenu IBuilderMainPanelView.GetSceneCardViewContextMenu() { return contextMenu; }
 120
 17121        IUnpublishPopupView IBuilderMainPanelView.GetUnpublishPopup() { return unpublishPopupView; }
 122
 123        public void Dispose()
 124        {
 17125            if (!isDestroyed)
 126            {
 17127                Destroy(gameObject);
 128            }
 17129        }
 130
 131        private void Awake()
 132        {
 17133            name = "_BuilderProjectsPanel";
 134
 18135            closeButton.onClick.AddListener(() => OnClosePressed?.Invoke());
 17136            backgroundButton?.onClick.AddListener(() => OnClosePressed?.Invoke());
 17137            createSceneButton.onClick.AddListener(() => OnCreateProjectPressed?.Invoke());
 17138            importSceneButton.onClick.AddListener(() => OnImportScenePressed?.Invoke());
 18139            backToMainPanelButton.onClick.AddListener(() => OnBackToMainMenuPressed?.Invoke());
 17140            closeTrigger.OnTriggered += CloseTriggerOnOnTriggered;
 141
 17142            contextMenu.Hide();
 17143            gameObject.SetActive(false);
 144
 340145            for (int i = 0; i < sectionToggles.Length; i++)
 146            {
 153147                sectionToggles[i].Setup();
 148            }
 17149        }
 150
 34151        private void OnDestroy() { isDestroyed = true; }
 152
 17153        private void CloseTriggerOnOnTriggered(DCLAction_Trigger action) { OnBackPressed?.Invoke(); }
 154
 0155        void ISceneListener.SetScenes(Dictionary<string, ISceneCardView> scenes) { scenesCount = scenes.Count; }
 156
 0157        void ISceneListener.SceneAdded(ISceneCardView scene) { scenesCount++; }
 158
 0159        void ISceneListener.SceneRemoved(ISceneCardView scene) { scenesCount--; }
 160
 0161        public void OnSetProjects(Dictionary<string, IProjectCardView> projects) { projectScenesCount = projects.Count; 
 162
 0163        public void OnProjectAdded(IProjectCardView project) { projectScenesCount++; }
 164
 0165        public void OnProjectRemoved(IProjectCardView project) { projectScenesCount--; }
 166
 167        public void SetAsFullScreenMenuMode(Transform parentTransform)
 168        {
 17169            if (parentTransform == null)
 17170                return;
 171
 0172            transform.SetParent(parentTransform);
 0173            transform.localScale = Vector3.one;
 174
 0175            RectTransform rectTransform = transform as RectTransform;
 0176            rectTransform.anchorMin = Vector2.zero;
 0177            rectTransform.anchorMax = Vector2.one;
 0178            rectTransform.pivot = new Vector2(0.5f, 0.5f);
 0179            rectTransform.localPosition = Vector2.zero;
 0180            rectTransform.offsetMax = Vector2.zero;
 0181            rectTransform.offsetMin = Vector2.zero;
 0182        }
 183    }
 184}