< Summary

Class:DCL.Backpack.InfoCardComponentView
Assembly:BackpackEditorHUDV2
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/InfoCard/InfoCardComponentView.cs
Covered lines:72
Uncovered lines:9
Coverable lines:81
Total lines:183
Line coverage:88.8% (72 of 81)
Covered branches:0
Total branches:0
Covered methods:17
Total methods:17
Method coverage:100% (17 of 17)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Start()0%110100%
RefreshControl()0%22092.86%
SetVRMBlockedTag(...)0%110100%
SetName(...)0%110100%
SetDescription(...)0%110100%
SetCategory(...)0%2.022083.33%
SetNftImage(...)0%2.152066.67%
SetRarity(...)0%110100%
SetHidesList(...)0%330100%
SetRemovesList(...)0%110100%
SetIsEquipped(...)0%110100%
SetWearableId(...)0%110100%
Equip(...)0%2.152066.67%
UnEquip(...)0%2.152066.67%
SetHiddenBy(...)0%3.183072.73%
SetVisible(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/InfoCard/InfoCardComponentView.cs

#LineLine coverage
 1using DCL.Helpers;
 2using System;
 3using System.Collections.Generic;
 4using TMPro;
 5using UIComponents.Scripts.Components;
 6using UnityEngine;
 7using UnityEngine.UI;
 8
 9namespace DCL.Backpack
 10{
 11    public class InfoCardComponentView : BaseComponentView<InfoCardComponentModel>, IInfoCardComponentView
 12    {
 13        [SerializeField] internal NftTypeIconSO typeIcons;
 14        [SerializeField] internal NftRarityBackgroundSO rarityBackgrounds;
 15        [SerializeField] internal NftRarityBackgroundSO rarityNftBackgrounds;
 16        [SerializeField] internal TMP_Text wearableName;
 17        [SerializeField] internal TMP_Text wearableDescription;
 18        [SerializeField] internal Image categoryImage;
 19        [SerializeField] internal Button equipButton;
 20        [SerializeField] internal Button unEquipButton;
 21        [SerializeField] internal Button viewMore;
 22        [SerializeField] internal Image background;
 23        [SerializeField] internal Image nftBackground;
 24        [SerializeField] internal ImageComponentView nftImage;
 25        [SerializeField] internal RectTransform dynamicSection;
 26        [SerializeField] internal DynamicListComponentView hidesList;
 27        [SerializeField] internal DynamicListComponentView hiddenByDynamicList;
 28        [SerializeField] internal Image vrmBlockedTag;
 29
 30        public event Action OnEquipWearable;
 31        public event Action OnUnEquipWearable;
 32        public event Action OnViewMore;
 33
 134        internal InfoCardComponentModel Model => model;
 35
 36        public void Start()
 37        {
 238            equipButton.onClick.RemoveAllListeners();
 239            equipButton.onClick.AddListener(() => OnEquipWearable?.Invoke());
 240            unEquipButton.onClick.RemoveAllListeners();
 241            unEquipButton.onClick.AddListener(() => OnUnEquipWearable?.Invoke());
 242            viewMore.onClick.RemoveAllListeners();
 243            viewMore.onClick.AddListener(() => OnViewMore?.Invoke());
 244        }
 45
 46        public override void RefreshControl()
 47        {
 148            if (model == null)
 049                return;
 50
 151            SetName(model.name);
 152            SetDescription(model.description);
 153            SetCategory(model.category);
 154            SetRarity(model.rarity);
 155            SetIsEquipped(model.isEquipped);
 156            SetRemovesList(model.removeList);
 157            SetHidesList(model.hideList);
 158            SetHiddenBy(model.hiddenBy);
 159            SetNftImage(model.imageUri);
 160            SetWearableId(model.wearableId);
 161            SetVRMBlockedTag(model.blockVrmExport);
 162        }
 63
 64        private void SetVRMBlockedTag(bool vrmBlocked)
 65        {
 166            vrmBlockedTag.gameObject.SetActive(vrmBlocked);
 167        }
 68
 69        public void SetName(string nameText)
 70        {
 271            model.name = nameText;
 272            wearableName.text = nameText;
 273        }
 74
 75        public void SetDescription(string description)
 76        {
 277            model.description = description;
 278            wearableDescription.text = description;
 279        }
 80
 81        public void SetCategory(string category)
 82        {
 283            model.category = category;
 84
 285            var categoryIcon = typeIcons.GetTypeImage(category);
 286            if (categoryIcon == null)
 087                return;
 88
 289            categoryImage.sprite = categoryIcon;
 290        }
 91
 92        public void SetNftImage(string imageUri)
 93        {
 194            model.imageUri = imageUri;
 95
 196            if (string.IsNullOrEmpty(imageUri))
 97            {
 198                nftImage.SetImage(Texture2D.grayTexture);
 199                return;
 100            }
 101
 0102            nftImage.SetImage(imageUri);
 0103        }
 104
 105        public void SetRarity(string rarity)
 106        {
 1107            model.rarity = rarity;
 1108            background.sprite = rarityBackgrounds.GetRarityImage(rarity);
 1109            nftBackground.sprite = rarityNftBackgrounds.GetRarityImage(rarity);
 1110        }
 111
 112        public void SetHidesList(List<string> hideList)
 113        {
 1114            model.hideList = hideList;
 1115            hidesList.RemoveIcons();
 116
 1117            hidesList.gameObject.SetActive(hideList.Count != 0);
 4118            foreach (string hideCategory in hideList)
 119            {
 1120                var categoryIcon = typeIcons.GetTypeImage(hideCategory);
 1121                if (categoryIcon == null)
 122                    continue;
 123
 1124                hidesList.AddIcon(categoryIcon);
 125            }
 126
 1127            Utils.ForceRebuildLayoutImmediate(dynamicSection);
 1128        }
 129
 130        public void SetRemovesList(List<string> removeList)
 131        {
 1132            model.removeList = removeList;
 1133        }
 134
 135        public void SetIsEquipped(bool isEquipped)
 136        {
 1137            model.isEquipped = isEquipped;
 138
 1139            equipButton.gameObject.SetActive(!isEquipped);
 1140            unEquipButton.gameObject.SetActive(model.unEquipAllowed && isEquipped);
 1141        }
 142
 143        private void SetWearableId(string wearableId)
 144        {
 1145            model.wearableId = wearableId;
 1146        }
 147
 148        public void Equip(string wearableId)
 149        {
 3150            if(model.wearableId == wearableId)
 0151                SetIsEquipped(true);
 3152        }
 153
 154        public void UnEquip(string wearableId)
 155        {
 7156            if(model.wearableId == wearableId)
 0157                SetIsEquipped(false);
 7158        }
 159
 160        public void SetHiddenBy(string hiddenBy)
 161        {
 1162            model.hiddenBy = hiddenBy;
 163
 1164            if (string.IsNullOrEmpty(hiddenBy))
 165            {
 0166                hiddenByDynamicList.gameObject.SetActive(false);
 0167                return;
 168            }
 169
 1170            hiddenByDynamicList.gameObject.SetActive(true);
 1171            hiddenByDynamicList.RemoveIcons();
 172
 1173            var categoryIcon = typeIcons.GetTypeImage(hiddenBy);
 1174            if (categoryIcon == null)
 0175                return;
 176
 1177            hiddenByDynamicList.AddIcon(categoryIcon);
 1178        }
 179
 180        public void SetVisible(bool visible) =>
 40181            gameObject.SetActive(visible);
 182    }
 183}