< Summary

Class:SectionProjectView
Assembly:BuilderProjectsPanel
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/ProjectsPanelHUD/Scripts/Views/MenuSections/SectionProjectView.cs
Covered lines:17
Uncovered lines:20
Coverable lines:37
Total lines:87
Line coverage:45.9% (17 of 37)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetParent(...)0%2100%
SetActive(...)0%2100%
ResetScrollRect()0%110100%
Dispose()0%220100%
Awake()0%110100%
OnDestroy()0%110100%
OnScrollValueChanged(...)0%6200%
SetEmpty()0%2100%
SetLoading()0%2100%
SetNoSearchResult()0%2100%
SetFilled()0%110100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections;
 3using DCL.Helpers;
 4using UnityEngine;
 5using UnityEngine.UI;
 6
 7internal class SectionProjectView : MonoBehaviour, IDisposable
 8{
 9    public event Action OnScrollRectValueChanged;
 10    public event Action OnCreateProjectRequest;
 11
 12    [SerializeField] public GameObject contentContainer;
 13    [SerializeField] public GameObject contentGameObject;
 14    [SerializeField] public ScrollRect scrollRect;
 15    [SerializeField] internal GameObject emptyContainer;
 16    [SerializeField] internal GameObject loadingAnimationContainer;
 17    [SerializeField] internal GameObject noSearchResultContainer;
 18    [SerializeField] internal Button buttonNoProjectsCTA;
 19
 20    private bool isDestroyed = false;
 21
 22    public void SetParent(Transform parent)
 23    {
 024        transform.SetParent(parent);
 025        transform.ResetLocalTRS();
 026    }
 27
 028    public void SetActive(bool active) { gameObject.SetActive(active); }
 29
 830    public void ResetScrollRect() { scrollRect.verticalNormalizedPosition = 1; }
 31
 32    public void Dispose()
 33    {
 134        if (!isDestroyed)
 35        {
 136            Destroy(gameObject);
 37        }
 138    }
 39
 40    private void Awake()
 41    {
 142        buttonNoProjectsCTA.onClick.AddListener(() => OnCreateProjectRequest?.Invoke());
 143        scrollRect.onValueChanged.AddListener(OnScrollValueChanged);
 144    }
 45
 46    private void OnDestroy()
 47    {
 148        isDestroyed = true;
 149        buttonNoProjectsCTA.onClick.RemoveAllListeners();
 150        scrollRect.onValueChanged.RemoveListener(OnScrollValueChanged);
 151    }
 52
 053    private void OnScrollValueChanged(Vector2 value) { OnScrollRectValueChanged?.Invoke(); }
 54
 55    public void SetEmpty()
 56    {
 057        contentGameObject.SetActive(false);
 058        emptyContainer.SetActive(true);
 059        noSearchResultContainer.SetActive(false);
 060        loadingAnimationContainer.SetActive(false);
 061    }
 62
 63    public void SetLoading()
 64    {
 065        contentGameObject.SetActive(false);
 066        emptyContainer.SetActive(false);
 067        noSearchResultContainer.SetActive(false);
 068        loadingAnimationContainer.SetActive(true);
 069    }
 70
 71    public void SetNoSearchResult()
 72    {
 073        contentGameObject.SetActive(false);
 074        emptyContainer.SetActive(false);
 075        noSearchResultContainer.SetActive(true);
 076        loadingAnimationContainer.SetActive(false);
 077    }
 78
 79    public void SetFilled()
 80    {
 281        contentGameObject.SetActive(true);
 282        emptyContainer.SetActive(false);
 283        noSearchResultContainer.SetActive(false);
 284        loadingAnimationContainer.SetActive(false);
 285        ResetScrollRect();
 286    }
 87}