< Summary

Class:NewProjectFlowView
Assembly:BuilderProjectsPanel
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/ProjectsPanelHUD/Scripts/NewProject/NewProjectFlowView.cs
Covered lines:28
Uncovered lines:14
Coverable lines:42
Total lines:146
Line coverage:66.6% (28 of 42)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
OnDestroy()0%110100%
ShowNewProjectTitleAndDescrition()0%2100%
Reset()0%2100%
Hide()0%2100%
IsActive()0%2100%
Dispose()0%110100%
SetSize(...)0%220100%
SetTittleAndDescription(...)0%220100%
NextPressed()0%2.032080%
BackPressed()0%2.312057.14%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using DCL;
 5using DCL.Builder;
 6using UnityEngine;
 7
 8public interface INewProjectFlowView
 9{
 10    /// <summary>
 11    /// Called when the view has hide
 12    /// </summary>
 13    event Action OnViewHide;
 14
 15    /// <summary>
 16    /// This will set the title and description of the new project. Order param: Title - Description
 17    /// </summary>
 18    event Action<string, string> OnTittleAndDescriptionSet;
 19
 20    /// <summary>
 21    /// Set the size of the new project. Order param: Rows - Columns
 22    /// </summary>
 23    event Action<int, int> OnSizeSet;
 24
 25    /// <summary>
 26    /// This will show the first step of the new project flow
 27    /// </summary>
 28    void ShowNewProjectTitleAndDescrition();
 29
 30    /// <summary>
 31    /// This will reset the view to the initial values
 32    /// </summary>
 33    void Reset();
 34
 35    /// <summary>
 36    /// Hide the view
 37    /// </summary>
 38    void Hide();
 39
 40    /// <summary>
 41    /// This will return true if the new project windows is active
 42    /// </summary>
 43    /// <returns></returns>
 44    bool IsActive();
 45
 46    void Dispose();
 47}
 48
 49public class NewProjectFlowView : MonoBehaviour, INewProjectFlowView
 50{
 51    public event Action OnViewHide;
 52    public event Action<string, string> OnTittleAndDescriptionSet;
 53    public event Action<int, int> OnSizeSet;
 54
 55    [SerializeField] private NewProjectFirstStepView newProjectFirstStepView;
 56    [SerializeField] private NewProjectSecondStepView newProjectSecondStepView;
 57
 58    [SerializeField] private ModalComponentView modal;
 59    [SerializeField] private CarouselComponentView carrousel;
 60
 61    internal int currentStep = 0;
 62
 63    private void Awake()
 64    {
 465        name = "_BuilderNewProjectFlowView";
 466        newProjectFirstStepView.OnBackPressed += BackPressed;
 467        newProjectSecondStepView.OnBackPressed += BackPressed;
 68
 469        newProjectFirstStepView.OnNextPressed += SetTittleAndDescription;
 470        newProjectSecondStepView.OnNextPressed += SetSize;
 71
 472        modal.OnCloseAction += () => OnViewHide?.Invoke();
 473    }
 74
 75    private void OnDestroy()
 76    {
 477        Dispose();
 478    }
 79
 80    public void ShowNewProjectTitleAndDescrition()
 81    {
 082        gameObject.SetActive(true);
 083        newProjectFirstStepView.ResetInputs();
 084        modal.Show();
 085    }
 86
 87    public void Reset()
 88    {
 089        currentStep = 0;
 090        carrousel.ResetCarousel();
 091    }
 92
 93    public void Hide()
 94    {
 095        modal.Hide();
 096    }
 97
 98    public bool IsActive()
 99    {
 0100        return modal.isVisible;
 101    }
 102
 103    public void Dispose()
 104    {
 4105        newProjectFirstStepView.OnBackPressed += BackPressed;
 4106        newProjectSecondStepView.OnBackPressed += BackPressed;
 107
 4108        newProjectFirstStepView.OnNextPressed -= SetTittleAndDescription;
 4109        newProjectSecondStepView.OnNextPressed -= SetSize;
 4110    }
 111
 112    internal void SetSize(int rows, int colums)
 113    {
 1114        NextPressed();
 1115        OnSizeSet?.Invoke(rows, colums);
 1116    }
 117
 118    internal void SetTittleAndDescription(string title, string description)
 119    {
 1120        NextPressed();
 1121        OnTittleAndDescriptionSet?.Invoke(title, description);
 1122    }
 123
 124    internal void NextPressed()
 125    {
 3126        if (currentStep >= 2)
 0127            return;
 128
 3129        currentStep++;
 3130        carrousel.GoToNextItem();
 3131    }
 132
 133    internal void BackPressed()
 134    {
 1135        if (currentStep == 0)
 136        {
 0137            Hide();
 0138            DataStore.i.builderInWorld.areShortcutsBlocked.Set(false);
 0139        }
 140        else
 141        {
 1142            currentStep--;
 1143            carrousel.GoToPreviousItem();
 144        }
 1145    }
 146}