< Summary

Class:PublicationDetailsView
Assembly:BuildModeHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/Common/PublicationDetailsView.cs
Covered lines:37
Uncovered lines:5
Coverable lines:42
Total lines:125
Line coverage:88% (37 of 42)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
PublicationDetailsView()0%110100%
Create()0%110100%
Awake()0%110100%
OnDestroy()0%110100%
SetActive(...)0%110100%
Cancel()0%220100%
Publish()0%220100%
SetSceneNameValidationActive(...)0%110100%
SetSceneName(...)0%110100%
SetSceneDescription(...)0%110100%
SetPublishButtonActive(...)0%330100%
SetPublicationScreenshot(...)0%2100%
GetSceneName()0%2100%
GetSceneDescription()0%2100%
GetSceneScreenshotTexture()0%110100%
UpdateSceneNameCharCounter()0%110100%
UpdateSceneDescriptionCharCounter()0%110100%

File(s)

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

#LineLine coverage
 1using System;
 2using TMPro;
 3using UnityEngine;
 4using UnityEngine.UI;
 5
 6public interface IPublicationDetailsView
 7{
 8    event Action OnCancel;
 9    event Action<string, string> OnPublish;
 10    event Action<string> OnSceneNameChange;
 11
 12    string currentSceneName { get; }
 13
 14    void SetActive(bool isActive);
 15    void Cancel();
 16    void Publish();
 17    void SetSceneNameValidationActive(bool isActive);
 18    void SetSceneName(string newtext);
 19    void SetSceneDescription(string newtext);
 20    void SetPublishButtonActive(bool isActive);
 21    void SetPublicationScreenshot(Texture2D screenshotTexture);
 22    string GetSceneName();
 23    string GetSceneDescription();
 24    Texture2D GetSceneScreenshotTexture();
 25    void UpdateSceneNameCharCounter();
 26    void UpdateSceneDescriptionCharCounter();
 27}
 28
 29public class PublicationDetailsView : MonoBehaviour, IPublicationDetailsView
 30{
 31    public event Action OnCancel;
 32    public event Action<string, string> OnPublish;
 33    public event Action<string> OnSceneNameChange;
 34
 35    [SerializeField] internal Button cancelButton;
 36    [SerializeField] internal Button publishButton;
 37    [SerializeField] internal TMP_Text publishButtonText;
 38    [SerializeField] internal TMP_InputField sceneNameInput;
 39    [SerializeField] internal TMP_Text sceneNameValidationText;
 40    [SerializeField] internal TMP_InputField sceneDescriptionInput;
 41    [SerializeField] internal Image sceneScreenshot;
 42    [SerializeField] internal TMP_Text sceneNameCharCounterText;
 5643    [SerializeField] internal int sceneNameCharLimit = 30;
 44    [SerializeField] internal TMP_Text sceneDescriptionCharCounterText;
 5645    [SerializeField] internal int sceneDescriptionCharLimit = 140;
 46
 47    private const string VIEW_PATH = "Common/PublicationDetailsView";
 48
 049    public string currentSceneName => sceneNameInput.text;
 50
 51    internal static PublicationDetailsView Create()
 52    {
 1553        var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<PublicationDetailsView>();
 1554        view.gameObject.name = "_PublicationDetailsView";
 55
 1556        return view;
 57    }
 58
 59    private void Awake()
 60    {
 1561        cancelButton.onClick.AddListener(Cancel);
 1562        publishButton.onClick.AddListener(Publish);
 63
 1564        sceneNameInput.onValueChanged.AddListener((newText) =>
 65        {
 466            UpdateSceneNameCharCounter();
 467            OnSceneNameChange?.Invoke(newText);
 068        });
 69
 1570        sceneDescriptionInput.onValueChanged.AddListener((newText) =>
 71        {
 472            UpdateSceneDescriptionCharCounter();
 473        });
 74
 1575        sceneNameInput.characterLimit = sceneNameCharLimit;
 1576        sceneDescriptionInput.characterLimit = sceneDescriptionCharLimit;
 1577    }
 78
 79    private void OnDestroy()
 80    {
 1581        cancelButton.onClick.RemoveListener(Cancel);
 1582        publishButton.onClick.RemoveListener(Publish);
 83
 1584        sceneNameInput.onValueChanged.RemoveAllListeners();
 1585        sceneDescriptionInput.onValueChanged.RemoveAllListeners();
 1586    }
 87
 488    public void SetActive(bool isActive) { gameObject.SetActive(isActive); }
 89
 290    public void Cancel() { OnCancel?.Invoke(); }
 91
 292    public void Publish() { OnPublish?.Invoke(sceneNameInput.text, sceneDescriptionInput.text); }
 93
 494    public void SetSceneNameValidationActive(bool isActive) { sceneNameValidationText.enabled = isActive; }
 95
 96    public void SetSceneName(string newtext)
 97    {
 198        sceneNameInput.text = newtext;
 199        UpdateSceneNameCharCounter();
 1100    }
 101
 102    public void SetSceneDescription(string newtext)
 103    {
 1104        sceneDescriptionInput.text = newtext;
 1105        UpdateSceneDescriptionCharCounter();
 1106    }
 107
 108    public void SetPublishButtonActive(bool isActive)
 109    {
 2110        publishButton.interactable = isActive;
 2111        publishButtonText.color = new Color(publishButtonText.color.r, publishButtonText.color.g, publishButtonText.colo
 2112    }
 113
 0114    public void SetPublicationScreenshot(Texture2D screenshotTexture) { sceneScreenshot.sprite = Sprite.Create(screensho
 115
 0116    public string GetSceneName() { return sceneNameInput.text; }
 117
 0118    public string GetSceneDescription() { return sceneDescriptionInput.text; }
 119
 1120    public Texture2D GetSceneScreenshotTexture() { return sceneScreenshot.sprite.texture; }
 121
 12122    public void UpdateSceneNameCharCounter() { sceneNameCharCounterText.text = $"{sceneNameInput.text.Length}/{sceneName
 123
 12124    public void UpdateSceneDescriptionCharCounter() { sceneDescriptionCharCounterText.text = $"{sceneDescriptionInput.te
 125}