< Summary

Class:DCL.Builder.GenericPopUpView
Assembly:BIWCommonHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/CommonHUD/Scripts/GenericPopUp/GenericPopUpView.cs
Covered lines:0
Uncovered lines:39
Coverable lines:39
Total lines:91
Line coverage:0% (0 of 39)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%2100%
ShowPopUpWithoutTitle(...)0%2100%
Dispose()0%2100%
RemoveAllListener()0%2100%
Show(...)0%2100%
Hide(...)0%2100%
SetSubtitleText(...)0%2100%
SetOkButtonText(...)0%2100%
SetCancelButtonText(...)0%2100%
RefreshControl()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/CommonHUD/Scripts/GenericPopUp/GenericPopUpView.cs

#LineLine coverage
 1using System;
 2using TMPro;
 3using UnityEngine;
 4using UnityEngine.UI;
 5
 6namespace DCL.Builder
 7{
 8    public class GenericPopUpView : BaseComponentView, IGenericPopUp
 9    {
 10        public event Action OnOkPressed;
 11        public event Action OnCancelPressed;
 12
 13        [SerializeField] internal Button cancelButton;
 14        [SerializeField] internal Button okButton;
 15
 16        [SerializeField] internal TextMeshProUGUI subtitleText;
 17
 18        [SerializeField] internal TextMeshProUGUI okButtonText;
 19        [SerializeField] internal TextMeshProUGUI cancelButtonText;
 20
 21        [SerializeField] internal ModalComponentView modalView;
 22        [SerializeField] internal ShowHideAnimator showHideAnimator;
 23
 24        public override void Awake()
 25        {
 026            base.Awake();
 027            cancelButton.onClick.AddListener( () =>
 28            {
 029                Hide();
 030                OnCancelPressed?.Invoke();
 031            });
 032            okButton.onClick.AddListener( () =>
 33            {
 034                Hide();
 035                OnOkPressed?.Invoke();
 036            });
 37
 038            showHideAnimator.OnWillFinishHide += (x) =>
 39            {
 040                gameObject.SetActive(false);
 041            };
 042        }
 43
 44        public void ShowPopUpWithoutTitle(string subtitle, string okButtonText, string cancelButtonText, Action OnOk, Ac
 45        {
 046            RemoveAllListener();
 047            SetSubtitleText(subtitle);
 048            SetOkButtonText(okButtonText);
 049            SetCancelButtonText(cancelButtonText);
 050            Show();
 51
 052            OnOkPressed += () => OnOk?.Invoke();
 53
 054            OnCancelPressed += () => OnCancel?.Invoke();
 055        }
 56
 57        public override void Dispose()
 58        {
 059            base.Dispose();
 060            cancelButton.onClick.RemoveAllListeners();
 061            okButton.onClick.RemoveAllListeners();
 062        }
 63
 64        public void RemoveAllListener()
 65        {
 066            OnOkPressed = null;
 067            OnCancelPressed = null;
 068        }
 69
 70        public override void Show(bool instant = false)
 71        {
 072            gameObject.SetActive(true);
 073            base.Show(instant);
 074            modalView.Show(instant);
 075        }
 76
 77        public override void Hide(bool instant = false)
 78        {
 079            base.Hide(instant);
 080            modalView.Hide(instant);
 081        }
 82
 083        public void SetSubtitleText(string text) { subtitleText.text = text; }
 84
 085        public void SetOkButtonText(string text) { okButtonText.text = text; }
 86
 087        public void SetCancelButtonText(string text) { cancelButtonText.text = text; }
 88
 089        public override void RefreshControl() { }
 90    }
 91}