< Summary

Class:CatalogAssetPackListView
Assembly:BuilderInWorldCatalog
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Scripts/Catalog/UI/CatalogAssetPackListView.cs
Covered lines:1
Uncovered lines:34
Coverable lines:35
Total lines:78
Line coverage:2.8% (1 of 35)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
CatalogAssetPackListView()0%110100%
AddAdapters()0%42600%
RemoveAdapters()0%20400%
SetCategoryStyle()0%2100%
SetAssetPackStyle()0%2100%
SceneAssetPackClick(...)0%6200%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Scripts/Catalog/UI/CatalogAssetPackListView.cs

#LineLine coverage
 1using DCL.Configuration;
 2using UnityEngine;
 3
 4public class CatalogAssetPackListView : ListView<CatalogItemPack>
 5{
 6    public GameObject categoryListView;
 7    public GameObject assetPackListView;
 8    public DynamicScrollSensitivity dynamicScrollSensitivity;
 9
 10    public Transform categoryContentTransform;
 11    public CatalogAssetPackAdapter categoryAssetPackItemAdapterPrefab;
 12    public CatalogAssetPackAdapter catalogAssetPackItemAdapterPrefab;
 13    public System.Action<CatalogItemPack> OnCatalogPackClick;
 14
 3615    bool useAssetPackStyle = true;
 16
 17    public override void AddAdapters()
 18    {
 019        base.AddAdapters();
 20
 021        Transform transformToUse = contentPanelTransform;
 022        CatalogAssetPackAdapter prefabToUse = catalogAssetPackItemAdapterPrefab;
 23
 024        if (!useAssetPackStyle)
 25        {
 026            transformToUse = categoryContentTransform;
 027            prefabToUse = categoryAssetPackItemAdapterPrefab;
 028            categoryListView.SetActive(true);
 029            assetPackListView.SetActive(false);
 030        }
 31        else
 32        {
 033            categoryListView.SetActive(false);
 034            assetPackListView.SetActive(true);
 35        }
 36
 037        if (contentPanelTransform == null)
 038            return;
 39
 040        foreach (CatalogItemPack catalogItemPack in contentList)
 41        {
 42            //TODO: SmartItems This quit all the smart items from the catalog
 043            if (catalogItemPack.id == BIWSettings.SMART_ITEM_ASSETS_PACK_ID)
 44                continue;
 45
 046            CatalogAssetPackAdapter adapter = Instantiate(prefabToUse, transformToUse).GetComponent<CatalogAssetPackAdap
 047            adapter.SetContent(catalogItemPack);
 048            adapter.OnCatalogItemPackClick += SceneAssetPackClick;
 49        }
 50
 051        if (dynamicScrollSensitivity != null)
 052            dynamicScrollSensitivity.RecalculateSensitivity();
 53
 054        AudioScriptableObjects.listItemAppear.ResetPitch();
 055    }
 56
 57    public override void RemoveAdapters()
 58    {
 059        Transform transformToUse = contentPanelTransform;
 060        if (!useAssetPackStyle)
 061            transformToUse = categoryContentTransform;
 62
 063        for (int i = 0; i < transformToUse.childCount; i++)
 64        {
 065            GameObject toRemove = transformToUse.GetChild(i).gameObject;
 066            Destroy(toRemove);
 67        }
 68
 069        if (dynamicScrollSensitivity != null)
 070            dynamicScrollSensitivity.RecalculateSensitivity();
 071    }
 72
 073    public void SetCategoryStyle() { useAssetPackStyle = false; }
 74
 075    public void SetAssetPackStyle() { useAssetPackStyle = true; }
 76
 077    void SceneAssetPackClick(CatalogItemPack sceneAssetPack) { OnCatalogPackClick?.Invoke(sceneAssetPack); }
 78}