< Summary

Class:DCL.Builder.PublishProjectSuccesView
Assembly:BuilderPublisher
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Publisher/ProjectPublishHUD/Scripts/PublishProjectSuccesView.cs
Covered lines:0
Uncovered lines:22
Coverable lines:22
Total lines:90
Line coverage:0% (0 of 22)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
RefreshControl()0%2100%
Awake()0%2100%
Dispose()0%2100%
OkButtonPressed()0%2100%
Close()0%6200%
ProjectPublished(...)0%2100%
Hide()0%2100%
GetSubTitleText(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Publisher/ProjectPublishHUD/Scripts/PublishProjectSuccesView.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using TMPro;
 5using UnityEngine;
 6using UnityEngine.UI;
 7
 8namespace DCL.Builder
 9{
 10    public interface IPublishProjectSuccesView
 11    {
 12        /// <summary>
 13        /// Called when view is closed
 14        /// </summary>
 15        event Action OnViewClose;
 16
 17        /// <summary>
 18        /// Hide the view
 19        /// </summary>
 20        void Hide();
 21
 22        /// <summary>
 23        /// Shows the view with the project data
 24        /// </summary>
 25        /// <param name="publishedProject"></param>
 26        void ProjectPublished(BuilderScene publishedProject);
 27
 28        /// <summary>
 29        /// Dispose the view
 30        /// </summary>
 31        void Dispose();
 32    }
 33
 34    public class PublishProjectSuccesView : BaseComponentView, IPublishProjectSuccesView
 35    {
 36        private const string SUB_TITLE_TEXT =  @"{0} is now a live place in {1},{2} ready to be visited!";
 37
 38        public event Action OnViewClose;
 39
 40        [SerializeField] internal Button okButton;
 41        [SerializeField] internal TMP_Text subTitleTextView;
 42
 43        [SerializeField] internal RawImage screenshotImage;
 44
 45        [SerializeField] internal ModalComponentView modal;
 46
 047        public override void RefreshControl() { }
 48
 49        public override void Awake()
 50        {
 051            base.Awake();
 052            okButton.onClick.AddListener(OkButtonPressed);
 053            modal.OnCloseAction += Close;
 054        }
 55
 56        public override void Dispose()
 57        {
 058            base.Dispose();
 059            okButton.onClick.RemoveAllListeners();
 060            modal.OnCloseAction -= Close;
 061        }
 62
 63        internal void OkButtonPressed()
 64        {
 065            Hide();
 066            Close();
 067        }
 68
 069        public void Close() { OnViewClose?.Invoke(); }
 70
 71        public void ProjectPublished(BuilderScene publishedProject)
 72        {
 073            modal.Show();
 74
 075            subTitleTextView.text = GetSubTitleText(publishedProject);
 076            screenshotImage.texture = publishedProject.sceneScreenshotTexture;
 077        }
 78
 079        public void Hide() { modal.Hide(); }
 80
 81        internal string GetSubTitleText(BuilderScene scene)
 82        {
 083            string title = scene.manifest.project.title;
 084            string posX = scene.scene.sceneData.basePosition.x.ToString();
 085            string posY = scene.scene.sceneData.basePosition.y.ToString();
 86
 087            return string.Format(SUB_TITLE_TEXT, title, posX, posY);
 88        }
 89    }
 90}