< 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:110
Line coverage:92.6% (38 of 41)
Covered branches:0
Total branches:0

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
 431    public override void Start() { friendNameShowHideAnimator.gameObject.SetActive(false); }
 32
 33    public void Configure(BaseComponentModel newModel)
 34    {
 935        model = (FriendHeadForPlaceCardComponentModel)newModel;
 936        RefreshControl();
 937    }
 38
 39    public override void RefreshControl()
 40    {
 941        if (model == null)
 042            return;
 43
 944        SetBackgroundColor(model.backgroundColor);
 945        SetUserProfile(model.userProfile);
 946    }
 47
 48    public override void OnFocus()
 49    {
 150        base.OnFocus();
 51
 152        if (!model.userProfile)
 053            return;
 54
 155        if (!friendNameShowHideAnimator.gameObject.activeSelf)
 156            friendNameShowHideAnimator.gameObject.SetActive(true);
 57
 158        friendNameShowHideAnimator.Show();
 159    }
 60
 61    public override void OnLoseFocus()
 62    {
 1563        base.OnLoseFocus();
 64
 1565        friendNameShowHideAnimator.Hide();
 1566    }
 67
 68    public override void Dispose()
 69    {
 2070        base.Dispose();
 71
 2072        if (model.userProfile != null)
 1473            model.userProfile.snapshotObserver.RemoveListener(OnFaceSnapshotLoaded);
 74
 2075        if (friendPortrait != null)
 1876            friendPortrait.Dispose();
 2077    }
 78
 79    public void SetBackgroundColor(Color newColor)
 80    {
 1081        model.backgroundColor = newColor;
 82
 1083        if (friendBackground != null)
 1084            friendBackground.color = newColor;
 1085    }
 86
 87    public void SetUserProfile(UserProfile profile)
 88    {
 1189        model.userProfile = profile;
 90
 1191        if (model.userProfile != null)
 92        {
 1093            friendName.text = model.userProfile.userName;
 1094            model.userProfile.snapshotObserver.RemoveListener(OnFaceSnapshotLoaded);
 1095            model.userProfile.snapshotObserver.AddListener(OnFaceSnapshotLoaded);
 1096        }
 97        else
 98        {
 199            friendName.text = "";
 100        }
 1101    }
 102
 103    internal void OnFaceSnapshotLoaded(Texture2D texture)
 104    {
 1105        if (friendPortrait == null)
 0106            return;
 107
 1108        friendPortrait.SetImage(texture);
 1109    }
 110}