< Summary

Class:RealmViewerComponentView
Assembly:ExploreV2
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/ExploreV2/Scripts/MainMenu/RealmViewer/RealmViewerComponentView.cs
Covered lines:20
Uncovered lines:4
Coverable lines:24
Total lines:83
Line coverage:83.3% (20 of 24)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Configure(...)0%110100%
RefreshControl()0%2.032080%
SetRealm(...)0%2.022083.33%
SetNumberOfUsers(...)0%2.022083.33%
RebuildLayouts()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/ExploreV2/Scripts/MainMenu/RealmViewer/RealmViewerComponentView.cs

#LineLine coverage
 1using DCL.Helpers;
 2using TMPro;
 3using UnityEngine;
 4using UnityEngine.UI;
 5
 6public interface IRealmViewerComponentView
 7{
 8    /// <summary>
 9    /// Event that will be triggered when the Logo button is clicked.
 10    /// </summary>
 11    Button.ButtonClickedEvent onLogoClick { get; }
 12
 13    /// <summary>
 14    /// Set the realm label.
 15    /// </summary>
 16    /// <param name="newRealm">New realm.</param>
 17    void SetRealm(string newRealm);
 18
 19    /// <summary>
 20    /// Set the number of users label.
 21    /// </summary>
 22    /// <param name="newNumberOfUsers">New number of users.</param>
 23    void SetNumberOfUsers(int newNumberOfUsers);
 24}
 25
 26public class RealmViewerComponentView : BaseComponentView, IRealmViewerComponentView, IComponentModelConfig<RealmViewerC
 27{
 28    [Header("Prefab References")]
 29    [SerializeField] internal HorizontalLayoutGroup horizontalLayoutGroup;
 30    [SerializeField] internal TMP_Text realm;
 31    [SerializeField] internal TMP_Text numberOfusers;
 32    [SerializeField] internal ButtonComponentView logoButton;
 33
 34    [Header("Configuration")]
 35    [SerializeField] internal RealmViewerComponentModel model;
 36
 037    public Button.ButtonClickedEvent onLogoClick => logoButton?.onClick;
 38
 39    public void Configure(RealmViewerComponentModel newModel)
 40    {
 141        model = newModel;
 142        RefreshControl();
 143    }
 44
 45    public override void RefreshControl()
 46    {
 147        if (model == null)
 048            return;
 49
 150        SetRealm(model.realmName);
 151        SetNumberOfUsers(model.numberOfUsers);
 152    }
 53
 54    public void SetRealm(string newRealm)
 55    {
 256        model.realmName = newRealm;
 57
 258        if (realm == null)
 059            return;
 60
 261        realm.text = newRealm;
 62
 263        RebuildLayouts();
 264    }
 65
 66    public void SetNumberOfUsers(int newNumberOfUsers)
 67    {
 368        model.numberOfUsers = newNumberOfUsers;
 69
 370        if (numberOfusers == null)
 071            return;
 72
 373        numberOfusers.text = ExploreV2CommonUtils.FormatNumberToString(newNumberOfUsers);
 74
 375        RebuildLayouts();
 376    }
 77
 78    internal void RebuildLayouts()
 79    {
 580        if (horizontalLayoutGroup != null)
 581            Utils.ForceRebuildLayoutImmediate(horizontalLayoutGroup.transform as RectTransform);
 582    }
 83}