< Summary

Class:DCL.Builder.NewProjectFirstStepView
Assembly:BuilderProjectsPanel
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/ProjectsPanelHUD/Scripts/NewProject/NewProjectFirstStepView.cs
Covered lines:29
Uncovered lines:5
Coverable lines:34
Total lines:82
Line coverage:85.2% (29 of 34)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
RefreshControl()0%2100%
Dispose()0%110100%
ResetInputs()0%2100%
NextPressed()0%3.043083.33%
BackPressed()0%220100%
EnableNextButton()0%330100%
DisableNextButton()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/ProjectsPanelHUD/Scripts/NewProject/NewProjectFirstStepView.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using TMPro;
 5using UnityEngine;
 6
 7namespace DCL.Builder
 8{
 9    public class NewProjectFirstStepView : BaseComponentView
 10    {
 11        public event Action OnBackPressed;
 12        public event Action<string, string> OnNextPressed;
 13
 14        [SerializeField] internal LimitInputField titleInputField;
 15        [SerializeField] private LimitInputField descriptionInputField;
 16
 17        [SerializeField] internal ButtonComponentView nextButton;
 18        [SerializeField] private ButtonComponentView backButton;
 19
 20        // Start is called before the first frame update
 21        public override void Awake()
 22        {
 1223            base.Awake();
 24
 1225            titleInputField.OnLimitReached += DisableNextButton;
 1226            titleInputField.OnEmptyValue += DisableNextButton;
 1227            titleInputField.OnInputAvailable += EnableNextButton;
 28
 1229            descriptionInputField.OnLimitReached += DisableNextButton;
 1230            descriptionInputField.OnInputAvailable += EnableNextButton;
 31
 1232            backButton.onClick.AddListener(BackPressed);
 1233            nextButton.onClick.AddListener(NextPressed);
 34
 1235            DisableNextButton();
 1236        }
 37
 038        public override void RefreshControl() { }
 39
 40        public override void Dispose()
 41        {
 1242            base.Dispose();
 1243            titleInputField.OnLimitReached -= DisableNextButton;
 1244            titleInputField.OnEmptyValue -= DisableNextButton;
 1245            titleInputField.OnInputAvailable -= EnableNextButton;
 46
 1247            descriptionInputField.OnLimitReached -= DisableNextButton;
 1248            descriptionInputField.OnInputAvailable -= EnableNextButton;
 49
 1250            backButton.onClick.RemoveListener(BackPressed);
 1251            nextButton.onClick.RemoveListener(NextPressed);
 1252        }
 53
 54        public void ResetInputs()
 55        {
 056            titleInputField.SetText("");
 057            descriptionInputField.SetText("");
 058        }
 59
 60        internal void NextPressed()
 61        {
 162            if (!nextButton.IsInteractable())
 063                return;
 64
 165            string title = titleInputField.GetValue();
 166            string description = descriptionInputField.GetValue();
 67
 168            OnNextPressed?.Invoke(title, description);
 169        }
 70
 271        internal void BackPressed() { OnBackPressed?.Invoke(); }
 72
 73        internal void EnableNextButton()
 74        {
 375            if(titleInputField.IsInputAvailable() && descriptionInputField.IsInputAvailable())
 376                nextButton.SetInteractable(true);
 377        }
 78
 3079        internal void DisableNextButton() { nextButton.SetInteractable(false); }
 80
 81    }
 82}