< Summary

Class:VoiceChatBarComponentView
Assembly:VoiceChatHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/VoiceChatHUD/VoiceChatBarComponentView.cs
Covered lines:27
Uncovered lines:7
Coverable lines:34
Total lines:91
Line coverage:79.4% (27 of 34)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
Configure(...)0%110100%
RefreshControl()0%2.062075%
Show(...)0%110100%
Hide(...)0%110100%
SetTalkingMessage(...)0%660100%
PlayVoiceChatRecordingAnimation(...)0%2100%
SetVoiceChatEnabledByScene(...)0%2100%
Dispose()0%110100%
Create()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/VoiceChatHUD/VoiceChatBarComponentView.cs

#LineLine coverage
 1using System;
 2using TMPro;
 3using UnityEngine;
 4
 5public class VoiceChatBarComponentView : BaseComponentView, IVoiceChatBarComponentView, IComponentModelConfig
 6{
 7    [Header("Prefab References")]
 8    [SerializeField] internal VoiceChatButton voiceChatButton;
 9    [SerializeField] internal GameObject someoneTalkingContainer;
 10    [SerializeField] internal TMP_Text someoneTalkingText;
 11    [SerializeField] internal TMP_Text altText;
 12    [SerializeField] internal Animator someoneTalkingAnimator;
 13    [SerializeField] internal ButtonComponentView endCallButton;
 14
 15    [Header("Configuration")]
 16    [SerializeField] internal VoiceChatBarComponentModel model;
 17
 18    public event Action<bool> OnMuteVoiceChat;
 19    public event Action OnLeaveVoiceChat;
 20
 021    public RectTransform Transform => (RectTransform)transform;
 22
 23    public override void Awake()
 24    {
 525        base.Awake();
 26
 527        endCallButton.onClick.AddListener(() => OnLeaveVoiceChat?.Invoke());
 528    }
 29
 30    public void Configure(BaseComponentModel newModel)
 31    {
 132        model = (VoiceChatBarComponentModel)newModel;
 133        RefreshControl();
 134    }
 35
 36    public override void RefreshControl()
 37    {
 138        if (model == null)
 039            return;
 40
 141        SetTalkingMessage(model.isSomeoneTalking, model.message);
 142    }
 43
 244    public override void Show(bool instant = false) { gameObject.SetActive(true); }
 45
 246    public override void Hide(bool instant = false) { gameObject.SetActive(false); }
 47
 48    public void SetTalkingMessage(bool isSomeoneTalking, string message)
 49    {
 350        model.message = message;
 51
 352        if (someoneTalkingContainer != null)
 353            someoneTalkingContainer.SetActive(isSomeoneTalking);
 54
 355        if (altText != null)
 356            altText.gameObject.SetActive(!isSomeoneTalking);
 57
 358        if (isSomeoneTalking)
 59        {
 160            if (someoneTalkingText != null)
 61            {
 162                someoneTalkingText.text = message;
 163                someoneTalkingAnimator.SetBool("Talking", !string.IsNullOrEmpty(message));
 64            }
 165        }
 66        else
 67        {
 268            if (altText != null)
 269                altText.text = message;
 70        }
 271    }
 72
 073    public void PlayVoiceChatRecordingAnimation(bool recording) { voiceChatButton.SetOnRecording(recording); }
 74
 075    public void SetVoiceChatEnabledByScene(bool enabled) { voiceChatButton.SetEnabledByScene(enabled); }
 76
 77    public override void Dispose()
 78    {
 1079        base.Dispose();
 80
 1081        endCallButton.onClick.RemoveAllListeners();
 1082    }
 83
 84    internal static VoiceChatBarComponentView Create()
 85    {
 086        VoiceChatBarComponentView voiceChatBarComponentView = Instantiate(Resources.Load<GameObject>("SocialBarV1/VoiceC
 087        voiceChatBarComponentView.name = "_VoiceChatBar";
 88
 089        return voiceChatBarComponentView;
 90    }
 91}