< Summary

Class:OwnersPopupView
Assembly:NFTPromptHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/NFTPromptHUD/Scripts/OwnersPopupView.cs
Covered lines:12
Uncovered lines:7
Coverable lines:19
Total lines:64
Line coverage:63.1% (12 of 19)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Show()0%110100%
Hide(...)0%220100%
SetElements(...)0%6200%
IsActive()0%110100%
Awake()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/NFTPromptHUD/Scripts/OwnersPopupView.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using UnityEngine;
 4using UnityEngine.UI;
 5
 6internal interface IOwnersPopupView
 7{
 8    event Action OnClosePopup;
 9    void Show();
 10    void Hide(bool instant);
 11    void SetElements(List<IOwnerInfoElement> elements);
 12    bool IsActive();
 13}
 14
 15internal class OwnersPopupView : MonoBehaviour, IOwnersPopupView
 16{
 17    private const int ADDRESS_MAX_CHARS = 19;
 18    private const float ELEMENT_FONT_SIZE = 17;
 19    private const float ELEMENT_HORIZONTAL_SPACING = 17;
 20
 21    [SerializeField] internal Transform ownerElementsContainer;
 22    [SerializeField] internal Button closeButton;
 23    [SerializeField] internal Button backgroundCloseButton;
 24    [SerializeField] private ShowHideAnimator showHideAnimator;
 25    [SerializeField] private ScrollRect scrollRect;
 26
 27    public event Action OnClosePopup;
 28
 29    void IOwnersPopupView.Show()
 30    {
 131        gameObject.SetActive(true);
 132        scrollRect.verticalNormalizedPosition = 1;
 133        showHideAnimator.Show();
 134    }
 35
 36    void IOwnersPopupView.Hide(bool instant)
 37    {
 238        showHideAnimator.Hide();
 239        if (instant)
 40        {
 241            gameObject.SetActive(false);
 42        }
 243    }
 44
 45    void IOwnersPopupView.SetElements(List<IOwnerInfoElement> elements)
 46    {
 047        for (int i = 0; i < elements.Count; i++)
 48        {
 049            elements[i].SetParent(ownerElementsContainer);
 050            elements[i].SetAddressLength(ADDRESS_MAX_CHARS);
 051            elements[i].SetColorIndex(i);
 052            elements[i].SetConfig(ELEMENT_FONT_SIZE, ELEMENT_HORIZONTAL_SPACING);
 053            elements[i].SetActive(true);
 54        }
 055    }
 56
 257    bool IOwnersPopupView.IsActive() { return gameObject.activeSelf; }
 58
 59    private void Awake()
 60    {
 761        closeButton.onClick.AddListener(() => OnClosePopup?.Invoke());
 762        backgroundCloseButton.onClick.AddListener(() => OnClosePopup?.Invoke());
 763    }
 64}