| | 1 | | using DCL; |
| | 2 | | using DCL.Interface; |
| | 3 | |
|
| | 4 | | namespace SignupHUD |
| | 5 | | { |
| | 6 | | public class SignupHUDController : IHUD |
| | 7 | | { |
| | 8 | | internal ISignupHUDView view; |
| | 9 | |
|
| | 10 | | internal string name; |
| | 11 | | internal string email; |
| 21 | 12 | | internal BaseVariable<bool> signupVisible => DataStore.i.HUDs.signupVisible; |
| | 13 | | internal IHUD avatarEditorHUD; |
| | 14 | | private readonly NewUserExperienceAnalytics newUserExperienceAnalytics; |
| | 15 | |
|
| 1 | 16 | | internal virtual ISignupHUDView CreateView() => SignupHUDView.CreateView(); |
| | 17 | |
|
| 0 | 18 | | public SignupHUDController() |
| | 19 | | { |
| | 20 | |
|
| 0 | 21 | | } |
| | 22 | |
|
| 0 | 23 | | public SignupHUDController(IAnalytics analytics) |
| | 24 | | { |
| 0 | 25 | | newUserExperienceAnalytics = new NewUserExperienceAnalytics(analytics); |
| 0 | 26 | | } |
| | 27 | |
|
| | 28 | | public void Initialize(IHUD avatarEditorHUD) |
| | 29 | | { |
| 9 | 30 | | view = CreateView(); |
| | 31 | |
|
| 9 | 32 | | if (view == null) |
| 0 | 33 | | return; |
| | 34 | |
|
| 9 | 35 | | this.avatarEditorHUD = avatarEditorHUD; |
| | 36 | |
|
| 9 | 37 | | signupVisible.OnChange += OnSignupVisibleChanged; |
| 9 | 38 | | signupVisible.Set(false); |
| | 39 | |
|
| 9 | 40 | | view.OnNameScreenNext += OnNameScreenNext; |
| 9 | 41 | | view.OnEditAvatar += OnEditAvatar; |
| 9 | 42 | | view.OnTermsOfServiceAgreed += OnTermsOfServiceAgreed; |
| 9 | 43 | | view.OnTermsOfServiceBack += OnTermsOfServiceBack; |
| 9 | 44 | | } |
| | 45 | |
|
| 4 | 46 | | private void OnSignupVisibleChanged(bool current, bool previous) { SetVisibility(current); } |
| | 47 | |
|
| | 48 | | internal void StartSignupProcess() |
| | 49 | | { |
| 4 | 50 | | name = null; |
| 4 | 51 | | email = null; |
| 4 | 52 | | view?.ShowNameScreen(); |
| 4 | 53 | | } |
| | 54 | |
|
| | 55 | | internal void OnNameScreenNext(string newName, string newEmail) |
| | 56 | | { |
| 1 | 57 | | name = newName; |
| 1 | 58 | | email = newEmail; |
| 1 | 59 | | view?.ShowTermsOfServiceScreen(); |
| 1 | 60 | | } |
| | 61 | |
|
| | 62 | | internal void OnEditAvatar() |
| | 63 | | { |
| 1 | 64 | | signupVisible.Set(false); |
| 1 | 65 | | avatarEditorHUD?.SetVisibility(true); |
| 1 | 66 | | } |
| | 67 | |
|
| | 68 | | internal void OnTermsOfServiceAgreed() |
| | 69 | | { |
| 1 | 70 | | WebInterface.SendPassport(name, email); |
| 1 | 71 | | DataStore.i.common.isSignUpFlow.Set(false); |
| 1 | 72 | | signupVisible.Set(false); |
| 1 | 73 | | newUserExperienceAnalytics?.SendTermsOfServiceAcceptedNux(); |
| 0 | 74 | | } |
| | 75 | |
|
| 2 | 76 | | internal void OnTermsOfServiceBack() { StartSignupProcess(); } |
| | 77 | |
|
| | 78 | | public void SetVisibility(bool visible) |
| | 79 | | { |
| 3 | 80 | | view?.SetVisibility(visible); |
| 3 | 81 | | if (visible) |
| 2 | 82 | | StartSignupProcess(); |
| 3 | 83 | | } |
| | 84 | |
|
| | 85 | | public void Dispose() |
| | 86 | | { |
| 1 | 87 | | signupVisible.OnChange -= OnSignupVisibleChanged; |
| 1 | 88 | | if (view == null) |
| 0 | 89 | | return; |
| 1 | 90 | | view.OnNameScreenNext -= OnNameScreenNext; |
| 1 | 91 | | view.OnEditAvatar -= OnEditAvatar; |
| 1 | 92 | | view.OnTermsOfServiceAgreed -= OnTermsOfServiceAgreed; |
| 1 | 93 | | view.OnTermsOfServiceBack -= OnTermsOfServiceBack; |
| 1 | 94 | | view.Dispose(); |
| 1 | 95 | | } |
| | 96 | | } |
| | 97 | | } |