< Summary

Class:FriendHeadForPlaceCardComponentView
Assembly:ExploreV2
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/ExploreV2/Scripts/Sections/PlacesAndEventsSection/SubSections/PlacesSubSection/PlaceCard/FriendHeadForPlaceCardComponentView.cs
Covered lines:38
Uncovered lines:3
Coverable lines:41
Total lines:113
Line coverage:92.6% (38 of 41)
Covered branches:0
Total branches:0
Covered methods:9
Total methods:9
Method coverage:100% (9 of 9)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Start()0%110100%
Configure(...)0%110100%
RefreshControl()0%2.032080%
OnFocus()0%3.033085.71%
OnLoseFocus()0%110100%
Dispose()0%330100%
SetBackgroundColor(...)0%220100%
SetUserProfile(...)0%220100%
OnFaceSnapshotLoaded(...)0%2.062075%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/ExploreV2/Scripts/Sections/PlacesAndEventsSection/SubSections/PlacesSubSection/PlaceCard/FriendHeadForPlaceCardComponentView.cs

#LineLine coverage
 1using TMPro;
 2using UnityEngine;
 3using UnityEngine.UI;
 4
 5public interface IFriendHeadForPlaceCardComponentView
 6{
 7    /// <summary>
 8    /// Set the background color for the friend.
 9    /// </summary>
 10    /// <param name="newText">New color.</param>
 11    void SetBackgroundColor(Color newColor);
 12
 13    /// <summary>
 14    /// Set the user profile information.
 15    /// </summary>
 16    /// <param name="profile">User profile.</param>
 17    void SetUserProfile(UserProfile profile);
 18}
 19
 20public class FriendHeadForPlaceCardComponentView : BaseComponentView, IFriendHeadForPlaceCardComponentView, IComponentMo
 21{
 22    [Header("Prefab References")]
 23    [SerializeField] internal ImageComponentView friendPortrait;
 24    [SerializeField] internal Image friendBackground;
 25    [SerializeField] internal TextMeshProUGUI friendName;
 26    [SerializeField] internal ShowHideAnimator friendNameShowHideAnimator;
 27
 28    [Header("Configuration")]
 29    [SerializeField] internal FriendHeadForPlaceCardComponentModel model;
 30
 31    public void Start()
 32    {
 233        friendNameShowHideAnimator.gameObject.SetActive(false);
 234    }
 35
 36    public void Configure(FriendHeadForPlaceCardComponentModel newModel)
 37    {
 938        model = newModel;
 939        RefreshControl();
 940    }
 41
 42    public override void RefreshControl()
 43    {
 944        if (model == null)
 045            return;
 46
 947        SetBackgroundColor(model.backgroundColor);
 948        SetUserProfile(model.userProfile);
 949    }
 50
 51    public override void OnFocus()
 52    {
 153        base.OnFocus();
 54
 155        if (!model.userProfile)
 056            return;
 57
 158        if (!friendNameShowHideAnimator.gameObject.activeSelf)
 159            friendNameShowHideAnimator.gameObject.SetActive(true);
 60
 161        friendNameShowHideAnimator.Show();
 162    }
 63
 64    public override void OnLoseFocus()
 65    {
 1566        base.OnLoseFocus();
 67
 1568        friendNameShowHideAnimator.Hide();
 1569    }
 70
 71    public override void Dispose()
 72    {
 2073        base.Dispose();
 74
 2075        if (model.userProfile != null)
 1476            model.userProfile.snapshotObserver.RemoveListener(OnFaceSnapshotLoaded);
 77
 2078        if (friendPortrait != null)
 1879            friendPortrait.Dispose();
 2080    }
 81
 82    public void SetBackgroundColor(Color newColor)
 83    {
 1084        model.backgroundColor = newColor;
 85
 1086        if (friendBackground != null)
 1087            friendBackground.color = newColor;
 1088    }
 89
 90    public void SetUserProfile(UserProfile profile)
 91    {
 1192        model.userProfile = profile;
 93
 1194        if (model.userProfile != null)
 95        {
 1096            friendName.text = model.userProfile.userName;
 1097            model.userProfile.snapshotObserver.RemoveListener(OnFaceSnapshotLoaded);
 1098            model.userProfile.snapshotObserver.AddListener(OnFaceSnapshotLoaded);
 99        }
 100        else
 101        {
 1102            friendName.text = "";
 103        }
 1104    }
 105
 106    internal void OnFaceSnapshotLoaded(Texture2D texture)
 107    {
 1108        if (friendPortrait == null)
 0109            return;
 110
 1111        friendPortrait.SetImage(texture);
 1112    }
 113}