< Summary

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

Metrics

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

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.Builder;
 5using UnityEngine;
 6
 7public interface INewProjectFlowView
 8{
 9    /// <summary>
 10    /// This will set the title and description of the new project. Order param: Title - Description
 11    /// </summary>
 12    event Action<string, string> OnTittleAndDescriptionSet;
 13
 14    /// <summary>
 15    /// Set the size of the new project. Order param: Rows - Columns
 16    /// </summary>
 17    event Action<int, int> OnSizeSet;
 18
 19    /// <summary>
 20    /// This will show the first step of the new project flow
 21    /// </summary>
 22    void ShowNewProjectTitleAndDescrition();
 23
 24    /// <summary>
 25    /// This will reset the view to the initial values
 26    /// </summary>
 27    void Reset();
 28
 29    /// <summary>
 30    /// Hide the view
 31    /// </summary>
 32    void Hide();
 33
 34    /// <summary>
 35    /// This will return true if the new project windows is active
 36    /// </summary>
 37    /// <returns></returns>
 38    bool IsActive();
 39
 40    void Dispose();
 41}
 42
 43public class NewProjectFlowView : MonoBehaviour, INewProjectFlowView
 44{
 45    public event Action<string, string> OnTittleAndDescriptionSet;
 46    public event Action<int, int> OnSizeSet;
 47
 48    [SerializeField] private NewProjectFirstStepView newProjectFirstStepView;
 49    [SerializeField] private NewProjectSecondStepView newProjectSecondStepView;
 50
 51    [SerializeField] private ModalComponentView modal;
 52    [SerializeField] private CarouselComponentView carrousel;
 53
 54    internal int currentStep = 0;
 55
 56    private void Awake()
 57    {
 058        name = "_BuilderNewProjectFlowView";
 059        newProjectFirstStepView.OnBackPressed += BackPressed;
 060        newProjectSecondStepView.OnBackPressed += BackPressed;
 61
 062        newProjectFirstStepView.OnNextPressed += SetTittleAndDescription;
 063        newProjectSecondStepView.OnNextPressed += SetSize;
 064    }
 65
 66    private void OnDestroy()
 67    {
 068        Dispose();
 069    }
 70
 71    public void ShowNewProjectTitleAndDescrition()
 72    {
 073        gameObject.SetActive(true);
 074        modal.Show();
 075    }
 76
 77    public void Reset()
 78    {
 079        currentStep = 0;
 080        carrousel.ResetCarousel();
 081    }
 82
 83    public void Hide()
 84    {
 085        modal.Hide();
 086    }
 87
 88    public bool IsActive()
 89    {
 090        return modal.isVisible;
 91    }
 92
 93    public void Dispose()
 94    {
 095        newProjectFirstStepView.OnBackPressed += BackPressed;
 096        newProjectSecondStepView.OnBackPressed += BackPressed;
 97
 098        newProjectFirstStepView.OnNextPressed -= SetTittleAndDescription;
 099        newProjectSecondStepView.OnNextPressed -= SetSize;
 0100    }
 101
 102    internal void SetSize(int rows, int colums)
 103    {
 1104        NextPressed();
 1105        OnSizeSet?.Invoke(rows, colums);
 1106    }
 107
 108    internal void SetTittleAndDescription(string title, string description)
 109    {
 1110        NextPressed();
 1111        OnTittleAndDescriptionSet?.Invoke(title, description);
 1112    }
 113
 114    internal void NextPressed()
 115    {
 3116        if (currentStep >= 2)
 0117            return;
 118
 3119        currentStep++;
 3120        carrousel.GoToNextItem();
 3121    }
 122
 123    internal void BackPressed()
 124    {
 1125        if (currentStep == 0)
 0126            Hide();
 127        else
 128        {
 1129            currentStep--;
 1130            carrousel.GoToPreviousItem();
 131        }
 1132    }
 133}