< Summary

Class:VoiceChatBarComponentView
Assembly:VoiceChatHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/VoiceChatHUD/VoiceChatBarComponentView.cs
Covered lines:32
Uncovered lines:7
Coverable lines:39
Total lines:101
Line coverage:82% (32 of 39)
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.032080%
SetTalkingMessage(...)0%660100%
PlayVoiceChatRecordingAnimation(...)0%2100%
SetVoiceChatEnabledByScene(...)0%2100%
SetAsJoined(...)0%330100%
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<VoiceChatB
 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    [SerializeField] internal GameObject joinedPanel;
 15    [SerializeField] internal ButtonComponentView startCallButton;
 16
 17    [Header("Configuration")]
 18    [SerializeField] internal VoiceChatBarComponentModel model;
 19
 20    public event Action<bool> OnJoinVoiceChat;
 21
 022    public RectTransform Transform => (RectTransform)transform;
 23
 24    public override void Awake()
 25    {
 526        base.Awake();
 27
 528        endCallButton.onClick.AddListener(() => OnJoinVoiceChat?.Invoke(false));
 529        startCallButton.onClick.AddListener(() => OnJoinVoiceChat?.Invoke(true));
 530    }
 31
 32    public void Configure(VoiceChatBarComponentModel newModel)
 33    {
 134        model = newModel;
 135        RefreshControl();
 136    }
 37
 38    public override void RefreshControl()
 39    {
 140        if (model == null)
 041            return;
 42
 143        SetTalkingMessage(model.isSomeoneTalking, model.message);
 144        SetAsJoined(model.isJoined);
 145    }
 46
 47    public void SetTalkingMessage(bool isSomeoneTalking, string message)
 48    {
 349        model.message = message;
 50
 351        if (someoneTalkingContainer != null)
 352            someoneTalkingContainer.SetActive(isSomeoneTalking);
 53
 354        if (altText != null)
 355            altText.gameObject.SetActive(!isSomeoneTalking);
 56
 357        if (isSomeoneTalking)
 58        {
 159            if (someoneTalkingText != null)
 60            {
 161                someoneTalkingText.text = message;
 162                someoneTalkingAnimator.SetBool("Talking", !string.IsNullOrEmpty(message));
 63            }
 64        }
 65        else
 66        {
 267            if (altText != null)
 268                altText.text = message;
 69        }
 270    }
 71
 072    public void PlayVoiceChatRecordingAnimation(bool recording) { voiceChatButton.SetOnRecording(recording); }
 73
 074    public void SetVoiceChatEnabledByScene(bool enabled) { voiceChatButton.SetEnabledByScene(enabled); }
 75
 76    public void SetAsJoined(bool isJoined)
 77    {
 378        model.isJoined = isJoined;
 79
 380        if (joinedPanel != null)
 381            joinedPanel.SetActive(isJoined);
 82
 383        if (startCallButton != null)
 384            startCallButton.gameObject.SetActive(!isJoined);
 385    }
 86
 87    public override void Dispose()
 88    {
 1089        base.Dispose();
 90
 1091        endCallButton.onClick.RemoveAllListeners();
 1092    }
 93
 94    internal static VoiceChatBarComponentView Create()
 95    {
 096        VoiceChatBarComponentView voiceChatBarComponentView = Instantiate(Resources.Load<GameObject>("SocialBarV1/VoiceC
 097        voiceChatBarComponentView.name = "_VoiceChatBar";
 98
 099        return voiceChatBarComponentView;
 100    }
 101}