< Summary

Class:NFTItemToggle
Assembly:AvatarEditorHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/AvatarEditorHUD/Scripts/NFTItemToggle.cs
Covered lines:21
Uncovered lines:10
Coverable lines:31
Total lines:74
Line coverage:67.7% (21 of 31)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
Initialize(...)0%110100%
SetSelection(...)0%220100%
OnDestroy()0%110100%
ShowInfo()0%12300%
HideInfo()0%220100%
ToggleInfo()0%6200%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/AvatarEditorHUD/Scripts/NFTItemToggle.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3using UnityEngine.UI;
 4
 5public class NFTItemToggle : ItemToggle
 6{
 7    [SerializeField] internal NFTItemInfo nftItemInfo;
 8    [SerializeField] internal Button infoButton;
 9    [SerializeField] internal Button closeInfoButton;
 10    [SerializeField] internal Button sellButton;
 11    [SerializeField] internal GameObject smartItemBadge;
 12
 13    private static event Action OnHideAllInfos;
 14
 15    protected override void Awake()
 16    {
 1817        base.Awake();
 18
 1819        OnHideAllInfos += HideInfo;
 20
 1821        HideInfo();
 1822        infoButton.onClick.AddListener(ToggleInfo);
 1823        closeInfoButton.onClick.AddListener(HideInfo);
 1824        sellButton.onClick.AddListener(CallOnSellClicked);
 1825    }
 26
 27    public override void Initialize(WearableItem w, bool isSelected, int amount)
 28    {
 3629        base.Initialize(w, isSelected, amount);
 3630        nftItemInfo.SetModel(NFTItemInfo.Model.FromWearableItem(wearableItem));
 3631        smartItemBadge.SetActive(w.IsSmart());
 3632    }
 33
 34    protected override void SetSelection(bool isSelected)
 35    {
 5636        base.SetSelection(isSelected);
 5637        OnHideAllInfos?.Invoke();
 3838    }
 39
 40    protected override void OnDestroy()
 41    {
 1842        OnHideAllInfos -= HideInfo;
 1843        base.OnDestroy();
 1844    }
 45
 46    private void ShowInfo()
 47    {
 048        if (!nftItemInfo.gameObject.activeSelf)
 049            AudioScriptableObjects.dialogOpen.Play(true);
 50
 051        OnHideAllInfos?.Invoke();
 052        nftItemInfo.SetActive(true);
 053    }
 54
 55    private void HideInfo()
 56    {
 5657        if (nftItemInfo.gameObject.activeSelf)
 1858            AudioScriptableObjects.dialogClose.Play(true);
 59
 5660        nftItemInfo.SetActive(false);
 5661    }
 62
 63    private void ToggleInfo()
 64    {
 065        if (nftItemInfo.gameObject.activeSelf)
 66        {
 067            HideInfo();
 068        }
 69        else
 70        {
 071            ShowInfo();
 72        }
 073    }
 74}