< Summary

Class:NFTIconComponentView
Assembly:PassportHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/Passport/NFTIcons/NFTIconComponentView.cs
Covered lines:19
Uncovered lines:31
Coverable lines:50
Total lines:118
Line coverage:38% (19 of 50)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Configure(...)0%6200%
RefreshControl()0%6200%
SetName(...)0%330100%
SetMarketplaceURI(...)0%110100%
SetImageURI(...)0%2100%
SetShowType(...)0%2100%
SetType(...)0%2100%
SetRarity(...)0%2100%
SetShowMarketplaceButton(...)0%110100%
OnFocus()0%2.032080%
OnLoseFocus()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/Passport/NFTIcons/NFTIconComponentView.cs

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using UnityEngine;
 4using UnityEngine.EventSystems;
 5using UnityEngine.UI;
 6using TMPro;
 7
 8public class NFTIconComponentView : BaseComponentView, INFTIconComponentView, IComponentModelConfig<NFTIconComponentMode
 9{
 10
 11    [SerializeField] internal ButtonComponentView marketplaceButton;
 12    [SerializeField] internal TMP_Text nftName;
 13    [SerializeField] internal TMP_Text nftNameMarketPlace;
 14    [SerializeField] internal GameObject marketplaceSection;
 15    [SerializeField] internal ImageComponentView nftImage;
 16    [SerializeField] internal ImageComponentView typeImage;
 17    [SerializeField] internal Image backgroundImage;
 18    [SerializeField] internal Image rarityBackgroundImage;
 19    [SerializeField] internal NFTTypeIconsAndColors nftTypesIcons;
 20
 21    [SerializeField] internal NFTIconComponentModel model;
 22
 023    public Button.ButtonClickedEvent onMarketplaceButtonClick => marketplaceButton?.onClick;
 24
 25    public void Configure(NFTIconComponentModel newModel)
 26    {
 027        if (model == newModel)
 028            return;
 29
 030        model = newModel;
 031        RefreshControl();
 032    }
 33
 34    public override void RefreshControl()
 35    {
 036        if (model == null)
 037            return;
 38
 039        SetName(model.name);
 040        SetShowMarketplaceButton(model.showMarketplaceButton);
 041        SetMarketplaceURI(model.marketplaceURI);
 042        SetImageURI(model.imageURI);
 043        SetShowType(model.showType);
 044        SetType(model.type);
 045        SetRarity(model.rarity);
 046    }
 47
 48    public void SetName(string name)
 49    {
 150        model.name = name;
 51
 152        if (nftName != null)
 153            nftName.text = name;
 54
 155        if(nftNameMarketPlace != null)
 156            nftNameMarketPlace.text = name;
 157    }
 58
 59    public void SetMarketplaceURI(string marketplaceURI)
 60    {
 161        model.marketplaceURI = marketplaceURI;
 162    }
 63
 64    public void SetImageURI(string imageURI)
 65    {
 066        model.imageURI = imageURI;
 67
 068        nftImage.SetImage(imageURI);
 069    }
 70
 71    public void SetShowType(bool showType)
 72    {
 073        model.showType = showType;
 74
 075        typeImage.gameObject.SetActive(showType);
 076        rarityBackgroundImage.gameObject.SetActive(showType);
 077    }
 78
 79    public void SetType(string type)
 80    {
 081        model.type = type;
 82
 083        typeImage.SetImage(nftTypesIcons.GetTypeImage(type));
 084    }
 85
 86    public void SetRarity(string rarity)
 87    {
 088        model.rarity = rarity;
 089        backgroundImage.color = nftTypesIcons.GetColor(rarity);
 090        rarityBackgroundImage.color = nftTypesIcons.GetColor(rarity);
 091    }
 92
 93    public void SetShowMarketplaceButton(bool showMarketplaceButton)
 94    {
 295        model.showMarketplaceButton = showMarketplaceButton;
 296    }
 97
 98    public override void OnFocus()
 99    {
 1100        base.OnFocus();
 101
 1102        if (!model.showMarketplaceButton)
 0103            return;
 104
 1105        marketplaceSection.SetActive(true);
 1106    }
 107
 108    public override void OnLoseFocus()
 109    {
 5110        base.OnLoseFocus();
 111
 5112        if (!model.showMarketplaceButton)
 2113            return;
 114
 3115        marketplaceSection.SetActive(false);
 3116    }
 117
 118}