< Summary

Class:PrivateChatWindowHUDView
Assembly:PrivateChatWindowHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/PrivateChatWindow/PrivateChatWindowHUDView.cs
Covered lines:16
Uncovered lines:12
Coverable lines:28
Total lines:78
Line coverage:57.1% (16 of 28)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
OnEnable()0%110100%
Create(...)0%110100%
Initialize(...)0%110100%
ChatHUDView_OnSendMessage(...)0%12300%
OnMinimizeButtonPressed()0%2.152066.67%
OnCloseButtonPressed()0%6200%
ConfigureTitle(...)0%110100%
ConfigureAvatarSnapshot(...)0%2100%
ConfigureUserId(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/PrivateChatWindow/PrivateChatWindowHUDView.cs

#LineLine coverage
 1using TMPro;
 2using UnityEngine;
 3using UnityEngine.Events;
 4using UnityEngine.UI;
 5using DCL.Interface;
 6
 7public class PrivateChatWindowHUDView : MonoBehaviour
 8{
 9    const string VIEW_PATH = "PrivateChatWindow";
 10
 11    public Button backButton;
 12    public Button minimizeButton;
 13    public Button closeButton;
 14    public JumpInButton jumpInButton;
 15    public ChatHUDView chatHudView;
 16    public PrivateChatWindowHUDController controller;
 17    public TMP_Text windowTitleText;
 18    public RawImage profilePictureImage;
 19
 20    public event System.Action OnPressBack;
 21    public event System.Action OnMinimize;
 22    public event System.Action OnClose;
 23    public UnityAction<ChatMessage> OnSendMessage;
 24
 025    public string userId { get; internal set; }
 26
 1627    void Awake() { chatHudView.OnSendMessage += ChatHUDView_OnSendMessage; }
 28
 3229    void OnEnable() { DCL.Helpers.Utils.ForceUpdateLayout(transform as RectTransform); }
 30
 31    public static PrivateChatWindowHUDView Create(PrivateChatWindowHUDController controller)
 32    {
 833        var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<PrivateChatWindowHUDView>();
 834        view.Initialize(controller);
 835        return view;
 36    }
 37
 38    private void Initialize(PrivateChatWindowHUDController controller)
 39    {
 840        this.controller = controller;
 841        this.minimizeButton.onClick.AddListener(OnMinimizeButtonPressed);
 842        this.closeButton.onClick.AddListener(OnCloseButtonPressed);
 1243        this.backButton.onClick.AddListener(() => { OnPressBack?.Invoke(); });
 844    }
 45
 46    public void ChatHUDView_OnSendMessage(ChatMessage message)
 47    {
 048        if (string.IsNullOrEmpty(message.body))
 049            return;
 50
 051        message.messageType = ChatMessage.Type.PRIVATE;
 052        message.recipient = controller.conversationUserName;
 53
 054        OnSendMessage?.Invoke(message);
 055    }
 56
 57    public void OnMinimizeButtonPressed()
 58    {
 159        controller.SetVisibility(false);
 160        OnMinimize?.Invoke();
 061    }
 62
 63    public void OnCloseButtonPressed()
 64    {
 065        controller.SetVisibility(false);
 066        OnClose?.Invoke();
 067    }
 68
 1469    public void ConfigureTitle(string targetUserName) { windowTitleText.text = targetUserName; }
 70
 071    public void ConfigureAvatarSnapshot(Texture2D texture) { profilePictureImage.texture = texture; }
 72
 73    public void ConfigureUserId(string userId)
 74    {
 775        this.userId = userId;
 776        jumpInButton.Initialize(FriendsController.i, userId);
 777    }
 78}