< 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
 231    public override void Start() { friendNameShowHideAnimator.gameObject.SetActive(false); }
 32
 33    public void Configure(BaseComponentModel newModel)
 34    {
 535        model = (FriendHeadForPlaceCardComponentModel)newModel;
 536        RefreshControl();
 537    }
 38
 39    public override void RefreshControl()
 40    {
 541        if (model == null)
 042            return;
 43
 544        SetBackgroundColor(model.backgroundColor);
 545        SetUserProfile(model.userProfile);
 546    }
 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    {
 163        base.OnLoseFocus();
 64
 165        friendNameShowHideAnimator.Hide();
 166    }
 67
 68    public override void Dispose()
 69    {
 1670        base.Dispose();
 71
 1672        if (model.userProfile != null)
 1073            model.userProfile.snapshotObserver.RemoveListener(OnFaceSnapshotLoaded);
 74
 1675        if (friendPortrait != null)
 1676            friendPortrait.Dispose();
 1677    }
 78
 79    public void SetBackgroundColor(Color newColor)
 80    {
 681        model.backgroundColor = newColor;
 82
 683        if (friendBackground != null)
 684            friendBackground.color = newColor;
 685    }
 86
 87    public void SetUserProfile(UserProfile profile)
 88    {
 789        model.userProfile = profile;
 90
 791        if (model.userProfile != null)
 92        {
 693            friendName.text = model.userProfile.userName;
 694            model.userProfile.snapshotObserver.RemoveListener(OnFaceSnapshotLoaded);
 695            model.userProfile.snapshotObserver.AddListener(OnFaceSnapshotLoaded);
 696        }
 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}