< Summary

Class:AirdroppingHUDView
Assembly:AirdroppingHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/AirdroppingHUD/AirdroppingHUDView.cs
Covered lines:44
Uncovered lines:1
Coverable lines:45
Total lines:121
Line coverage:97.7% (44 of 45)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Create()0%110100%
Initialize(...)0%110100%
ShowInitialScreen(...)0%110100%
ShowItemScreen(...)0%110100%
ShowSummaryScreen(...)0%220100%
ShowSummaryNoItemsScreen()0%110100%
CleanState()0%110100%
SetContentActive(...)0%110100%
SetVisibility(...)0%110100%
CreateItemPanel(...)0%3.043083.33%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/AirdroppingHUD/AirdroppingHUDView.cs

#LineLine coverage
 1using DCL.Helpers;
 2using TMPro;
 3using UnityEngine;
 4using UnityEngine.Events;
 5using UnityEngine.UI;
 6
 7public class AirdroppingHUDView : MonoBehaviour
 8{
 9    private const string VIEW_PATH = "AirdroppingHUD";
 10
 11    [SerializeField] internal GenericFactory collectiblesFactory;
 12    [SerializeField] internal GenericFactory erc20Factory;
 13
 14    [SerializeField] internal GameObject content;
 15
 16    [Header("Initial Screen")]
 17    [SerializeField] internal GameObject initialScreen;
 18    [SerializeField] internal TextMeshProUGUI initialScreenTitle;
 19    [SerializeField] internal TextMeshProUGUI initialScreenSubtitle;
 20    [SerializeField] internal Button initialScreenDoneButton;
 21
 22    [Header("Single Item Screen")]
 23    [SerializeField] internal GameObject singleItemScreen;
 24    [SerializeField] internal GameObject singleItemContainer;
 25    [SerializeField] internal Button singleItemDoneButton;
 26    [SerializeField] internal TextMeshProUGUI itemsLeft;
 27
 28    [Header("Summary Screen")]
 29    [SerializeField] internal GameObject summaryScreen;
 30    [SerializeField] internal GameObject summaryItemsContainer;
 31    [SerializeField] internal Button summaryDoneButton;
 32
 33    [Header("Summary No Items Screen")]
 34    [SerializeField] internal GameObject summaryNoItemsScreen;
 35    [SerializeField] internal Button summaryNoItemsDoneButton;
 36
 837    internal static AirdroppingHUDView Create() { return Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent
 38
 39    public void Initialize(UnityAction nextStateCallback)
 40    {
 841        initialScreenDoneButton.onClick.RemoveAllListeners();
 842        initialScreenDoneButton.onClick.AddListener(nextStateCallback);
 43
 844        singleItemDoneButton.onClick.RemoveAllListeners();
 845        singleItemDoneButton.onClick.AddListener(nextStateCallback);
 46
 847        summaryDoneButton.onClick.RemoveAllListeners();
 848        summaryDoneButton.onClick.AddListener(nextStateCallback);
 49
 850        summaryNoItemsDoneButton.onClick.RemoveAllListeners();
 851        summaryNoItemsDoneButton.onClick.AddListener(nextStateCallback);
 52
 853        CleanState();
 854    }
 55
 56    public void ShowInitialScreen(string title, string subtitle)
 57    {
 458        CleanState();
 459        initialScreen.SetActive(true);
 460        initialScreenTitle.text = title;
 461        initialScreenSubtitle.text = subtitle;
 462    }
 63
 64    public void ShowItemScreen(AirdroppingHUDController.ItemModel model, int itemsleft)
 65    {
 366        CleanState();
 367        singleItemScreen.SetActive(true);
 368        itemsLeft.text = itemsleft.ToString();
 369        CreateItemPanel(singleItemContainer.transform, model).SetData(model.name, model.subtitle, model.thumbnailURL);
 370    }
 71
 72    public void ShowSummaryScreen(AirdroppingHUDController.ItemModel[] items)
 73    {
 274        CleanState();
 275        summaryScreen.SetActive(true);
 1276        for (int index = 0; index < items.Length; index++)
 77        {
 478            var item = items[index];
 479            CreateItemPanel(summaryItemsContainer.transform, items[index]).SetData(item.name, item.subtitle, item.thumbn
 80        }
 281    }
 82
 83    public void ShowSummaryNoItemsScreen()
 84    {
 185        CleanState();
 186        summaryNoItemsScreen.SetActive(true);
 187    }
 88
 89    public void CleanState()
 90    {
 1991        initialScreen.SetActive(false);
 92
 1993        singleItemScreen.SetActive(false);
 1994        singleItemContainer.transform.DestroyAllChild();
 95
 1996        summaryScreen.SetActive(false);
 1997        summaryItemsContainer.transform.DestroyAllChild();
 98
 1999        summaryNoItemsScreen.SetActive(false);
 19100    }
 101
 26102    public void SetContentActive(bool active) { content.SetActive(active); }
 103
 2104    public void SetVisibility(bool active) { gameObject.SetActive(active); }
 105
 106    private AirdroppingItemPanel CreateItemPanel(Transform parent, AirdroppingHUDController.ItemModel model)
 107    {
 7108        AirdroppingItemPanel item = null;
 7109        if (model.type == "collectible")
 110        {
 7111            item = collectiblesFactory.Instantiate<AirdroppingItemPanel>(model.rarity, parent);
 112        }
 113
 7114        if (model.type == "erc20")
 115        {
 0116            item = erc20Factory.Instantiate<AirdroppingItemPanel>(model.rarity, parent);
 117        }
 118
 7119        return item;
 120    }
 121}