< 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:14
Uncovered lines:23
Coverable lines:37
Total lines:96
Line coverage:37.8% (14 of 37)
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%
SetType(...)0%2100%
SetRarity(...)0%2100%
OnFocus()0%110100%
OnLoseFocus()0%110100%

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 NFTTypeIconsAndColors nftTypesIcons;
 19
 20    [SerializeField] internal NFTIconComponentModel model;
 21
 022    public Button.ButtonClickedEvent onMarketplaceButtonClick => marketplaceButton?.onClick;
 23
 24    public void Configure(NFTIconComponentModel newModel)
 25    {
 026        if (model == newModel)
 027            return;
 28
 029        model = newModel;
 030        RefreshControl();
 031    }
 32
 33    public override void RefreshControl()
 34    {
 035        if (model == null)
 036            return;
 37
 038        SetName(model.name);
 039        SetMarketplaceURI(model.marketplaceURI);
 040        SetImageURI(model.imageURI);
 041        SetType(model.type);
 042        SetRarity(model.rarity);
 043    }
 44
 45    public void SetName(string name)
 46    {
 147        model.name = name;
 48
 149        if (nftName != null)
 150            nftName.text = name;
 51
 152        if(nftNameMarketPlace != null)
 153            nftNameMarketPlace.text = name;
 154    }
 55
 56    public void SetMarketplaceURI(string marketplaceURI)
 57    {
 158        model.marketplaceURI = marketplaceURI;
 159    }
 60
 61    public void SetImageURI(string imageURI)
 62    {
 063        model.imageURI = imageURI;
 64
 065        nftImage.SetImage(imageURI);
 066    }
 67
 68    public void SetType(string type)
 69    {
 070        model.type = type;
 71
 072        typeImage.SetImage(nftTypesIcons.GetTypeImage(type));
 073    }
 74
 75    public void SetRarity(string rarity)
 76    {
 077        model.rarity = rarity;
 78
 079        backgroundImage.color = nftTypesIcons.GetColor(rarity);
 080    }
 81
 82    public override void OnFocus()
 83    {
 184        base.OnFocus();
 85
 186        marketplaceSection.SetActive(true);
 187    }
 88
 89    public override void OnLoseFocus()
 90    {
 591        base.OnLoseFocus();
 92
 593        marketplaceSection.SetActive(false);
 594    }
 95
 96}