< Summary

Class:BuildModeConfirmationModalView
Assembly:BuildModeHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/Common/BuildModeConfirmationModalView.cs
Covered lines:19
Uncovered lines:0
Coverable lines:19
Total lines:72
Line coverage:100% (19 of 19)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Create()0%110100%
Awake()0%110100%
OnDestroy()0%110100%
IsActive()0%110100%
SetActive(...)0%110100%
SetTitle(...)0%110100%
SetSubTitle(...)0%110100%
SetCancelButtonText(...)0%110100%
SetConfirmButtonText(...)0%110100%
CancelExit()0%220100%
ConfirmExit()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/Common/BuildModeConfirmationModalView.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3using UnityEngine.UI;
 4
 5public interface IBuildModeConfirmationModalView
 6{
 7    event Action OnCancelExit;
 8    event Action OnConfirmExit;
 9
 10    bool IsActive();
 11    void SetActive(bool isActive);
 12    void SetTitle(string text);
 13    void SetSubTitle(string text);
 14    void SetCancelButtonText(string text);
 15    void SetConfirmButtonText(string text);
 16    void CancelExit();
 17    void ConfirmExit();
 18}
 19
 20public class BuildModeConfirmationModalView : MonoBehaviour, IBuildModeConfirmationModalView
 21{
 22    public event Action OnCancelExit;
 23    public event Action OnConfirmExit;
 24
 25    [SerializeField] internal TMPro.TMP_Text title;
 26    [SerializeField] internal TMPro.TMP_Text subTitle;
 27    [SerializeField] internal TMPro.TMP_Text cancelButtonText;
 28    [SerializeField] internal TMPro.TMP_Text confirmButtonText;
 29    [SerializeField] internal Button closeButton;
 30    [SerializeField] internal Button cancelButton;
 31    [SerializeField] internal Button confirmButton;
 32
 33    private const string VIEW_PATH = "Common/BuildModeConfirmationModalView";
 34
 35    internal static BuildModeConfirmationModalView Create()
 36    {
 1037        var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<BuildModeConfirmationModalView>();
 1038        view.gameObject.name = "_ExitFromBiWModalView";
 39
 1040        return view;
 41    }
 42
 43    private void Awake()
 44    {
 1045        closeButton.onClick.AddListener(CancelExit);
 1046        cancelButton.onClick.AddListener(CancelExit);
 1047        confirmButton.onClick.AddListener(ConfirmExit);
 1048    }
 49
 50    private void OnDestroy()
 51    {
 1052        closeButton.onClick.RemoveListener(CancelExit);
 1053        cancelButton.onClick.RemoveListener(CancelExit);
 1054        confirmButton.onClick.RemoveListener(ConfirmExit);
 1055    }
 56
 257    public bool IsActive() { return gameObject.activeSelf; }
 58
 459    public void SetActive(bool isActive) { gameObject.SetActive(isActive); }
 60
 261    public void SetTitle(string text) { title.text = text; }
 62
 263    public void SetSubTitle(string text) { subTitle.text = text; }
 64
 265    public void SetCancelButtonText(string text) { cancelButtonText.text = text; }
 66
 267    public void SetConfirmButtonText(string text) { confirmButtonText.text = text; }
 68
 269    public void CancelExit() { OnCancelExit?.Invoke(); }
 70
 271    public void ConfirmExit() { OnConfirmExit?.Invoke(); }
 72}