-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathLoginSelectionAuthView.cs
More file actions
155 lines (117 loc) · 5.17 KB
/
LoginSelectionAuthView.cs
File metadata and controls
155 lines (117 loc) · 5.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
using Cysharp.Threading.Tasks;
using DCL.UI;
using DCL.Utility.Extensions;
using MVC;
using System.Threading;
using UnityEngine;
using UnityEngine.UI;
namespace DCL.AuthenticationScreenFlow
{
[RequireComponent(typeof(Animator), typeof(CanvasGroup))]
public class LoginSelectionAuthView : ViewBase
{
[field: Space]
[field: SerializeField]
public Button CancelLoginButton { get; private set; } = null!;
[field: Header("PRIMARY LOGIN")]
[field: SerializeField]
public GameObject EmailOTPContainer { get; private set; } = null!;
[field: SerializeField]
public EmailInputFieldView EmailInputField { get; private set; } = null!;
[field: Header("SECONDARY LOGINS")]
[field: SerializeField]
public Button LoginMetamaskButton { get; private set; } = null!;
[field: SerializeField]
public Button LoginGoogleButton { get; private set; } = null!;
[field: SerializeField]
public Button LoginDiscordButton { get; private set; } = null!;
[field: SerializeField]
public Button LoginAppleButton { get; private set; } = null!;
[field: SerializeField]
public Button LoginXButton { get; private set; } = null!;
[field: SerializeField]
public Button LoginFortmaticButton { get; private set; } = null!;
[field: SerializeField]
public Button LoginCoinbaseButton { get; private set; } = null!;
[field: SerializeField]
public Button LoginWalletConnectButton { get; private set; } = null!;
[field: Header("OTHER OPTIONS")]
[field: SerializeField]
public Button MoreOptionsButton { get; private set; } = null!;
[field: SerializeField]
public RectTransform MoreOptionsButtonDirIcon { get; private set; } = null!;
[field: Header("ERROR POPUP")]
[field: SerializeField]
public GameObject ErrorPopupRoot { get; private set; } = null!;
[field: SerializeField]
public Button ErrorPopupRetryButton { get; private set; } = null!;
[field: SerializeField]
public Button ErrorPopupExitButton { get; private set; } = null!;
[field: SerializeField]
public Button ErrorPopupCloseButton { get; private set; } = null!;
[field: Header("RESTRICTED USER")]
[field: SerializeField]
public GameObject RestrictedUserContainer { get; private set; } = null!;
[field: SerializeField]
public Button RequestAlphaAccessButton { get; private set; } = null!;
[field: Space]
[field: SerializeField]
public Button[] UseAnotherAccountButton { get; private set; } = null!;
[Space]
[SerializeField] private GameObject moreOptionsPanel;
[Space]
[SerializeField] private Animator animator;
[SerializeField] private CanvasGroup canvasGroup;
[SerializeField] private GameObject loadingSpinner;
[SerializeField] private GameObject mainElementsPanel;
private int showAnimHash = UIAnimationHashes.OUT;
private bool areOptionsExpanded;
public void ToggleOptionsPanelExpansion()
{
areOptionsExpanded = !areOptionsExpanded;
SetOptionsPanelVisibility(areOptionsExpanded);
}
private void SetOptionsPanelVisibility(bool isExpanded)
{
MoreOptionsButtonDirIcon.localScale = new Vector3(1, isExpanded ? -1 : 1, 1);
moreOptionsPanel.SetActive(isExpanded);
}
public void Show(int animHash, bool moreOptionsExpanded)
{
showAnimHash = animHash;
ShowAsync(CancellationToken.None).Forget();
areOptionsExpanded = moreOptionsExpanded;
SetOptionsPanelVisibility(areOptionsExpanded);
SetLoadingSpinnerVisibility(false);
}
public void Hide()
{
mainElementsPanel.SetActive(false);
loadingSpinner.SetActive(false);
HideAsync(CancellationToken.None).Forget();
}
public void SetLoadingSpinnerVisibility(bool isLoading)
{
mainElementsPanel.SetActive(!isLoading);
loadingSpinner.SetActive(isLoading);
}
public void SetEmailInputFieldSpinnerActive(bool isActive) =>
EmailInputField.SetSpinnerActive(isActive);
public void SetEmailInputFieldErrorState(bool hasError) =>
EmailInputField.SetErrorState(hasError);
public override async UniTask ShowAsync(CancellationToken ct)
{
await base.ShowAsync(ct);
canvasGroup.interactable = true;
}
public override async UniTask HideAsync(CancellationToken ct, bool isInstant = false)
{
canvasGroup.interactable = false;
await base.HideAsync(ct, isInstant);
}
protected override async UniTask PlayShowAnimationAsync(CancellationToken ct) =>
await animator.PlayAndAwaitAsync(showAnimHash, showAnimHash, ct: ct);
protected override async UniTask PlayHideAnimationAsync(CancellationToken ct) =>
await animator.PlayAndAwaitAsync(UIAnimationHashes.OUT, UIAnimationHashes.OUT, ct: ct);
}
}