< Summary

Class:SignupHUD.SignupHUDController
Assembly:SignupHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/SignupHUD/SignupHUDController.cs
Covered lines:41
Uncovered lines:2
Coverable lines:43
Total lines:85
Line coverage:95.3% (41 of 43)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
CreateView()0%110100%
Initialize(...)0%22090.91%
OnSignupVisibleChanged(...)0%110100%
StartSignupProcess()0%220100%
OnNameScreenNext(...)0%220100%
OnEditAvatar()0%220100%
OnTermsOfServiceAgreed()0%110100%
OnTermsOfServiceBack()0%110100%
SetVisibility(...)0%330100%
Dispose()0%2.012088.89%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/SignupHUD/SignupHUDController.cs

#LineLine coverage
 1using DCL;
 2using DCL.Interface;
 3
 4namespace SignupHUD
 5{
 6    public class SignupHUDController : IHUD
 7    {
 8        internal ISignupHUDView view;
 9
 10        internal string name;
 11        internal string email;
 2112        internal BaseVariable<bool> signupVisible => DataStore.i.HUDs.signupVisible;
 13        internal IHUD avatarEditorHUD;
 14
 115        internal virtual ISignupHUDView CreateView() => SignupHUDView.CreateView();
 16
 17        public void Initialize(IHUD avatarEditorHUD)
 18        {
 919            view = CreateView();
 20
 921            if (view == null)
 022                return;
 23
 924            this.avatarEditorHUD = avatarEditorHUD;
 25
 926            signupVisible.OnChange += OnSignupVisibleChanged;
 927            signupVisible.Set(false);
 28
 929            view.OnNameScreenNext += OnNameScreenNext;
 930            view.OnEditAvatar += OnEditAvatar;
 931            view.OnTermsOfServiceAgreed += OnTermsOfServiceAgreed;
 932            view.OnTermsOfServiceBack += OnTermsOfServiceBack;
 933        }
 34
 435        private void OnSignupVisibleChanged(bool current, bool previous) { SetVisibility(current); }
 36
 37        internal void StartSignupProcess()
 38        {
 439            name = null;
 440            email = null;
 441            view?.ShowNameScreen();
 442        }
 43
 44        internal void OnNameScreenNext(string newName, string newEmail)
 45        {
 146            name = newName;
 147            email = newEmail;
 148            view?.ShowTermsOfServiceScreen();
 149        }
 50
 51        internal void OnEditAvatar()
 52        {
 153            signupVisible.Set(false);
 154            avatarEditorHUD?.SetVisibility(true);
 155        }
 56
 57        internal void OnTermsOfServiceAgreed()
 58        {
 159            WebInterface.SendPassport(name, email);
 160            DataStore.i.common.isSignUpFlow.Set(false);
 161            signupVisible.Set(false);
 162        }
 63
 264        internal void OnTermsOfServiceBack() { StartSignupProcess(); }
 65
 66        public void SetVisibility(bool visible)
 67        {
 368            view?.SetVisibility(visible);
 369            if (visible)
 270                StartSignupProcess();
 371        }
 72
 73        public void Dispose()
 74        {
 175            signupVisible.OnChange -= OnSignupVisibleChanged;
 176            if (view == null)
 077                return;
 178            view.OnNameScreenNext -= OnNameScreenNext;
 179            view.OnEditAvatar -= OnEditAvatar;
 180            view.OnTermsOfServiceAgreed -= OnTermsOfServiceAgreed;
 181            view.OnTermsOfServiceBack -= OnTermsOfServiceBack;
 182            view.Dispose();
 183        }
 84    }
 85}