Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
RegistrationPage.xaml.cs
1using CommunityToolkit.Maui.Layouts;
2using CommunityToolkit.Mvvm.Messaging;
3using Microsoft.Maui.Controls.PlatformConfiguration;
4using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;
8
10{
11 public partial class RegistrationPage
12 {
13 private bool registeredRegistrationPageMessage = false;
14 private bool registeredKeyboardSizeMessage = false;
15
17 {
18 this.InitializeComponent();
19 this.ContentPageModel = ViewModel;
20 ViewModel.SetPagesContainer([
21 this.LoadingView,
22 //this.RequestPurposeView,
23 this.GetStartedView,
24 this.NameEntryView,
25 this.ValidatePhoneView,
26 this.ValidateEmailView,
27 this.ChooseProviderView,
28 this.CreateAccountView,
29 this.DefinePasswordView,
30 this.BiometricsView,
31 this.FinalizeView,
32 this.ContactSupportView
33 ]);
34
35 // We need to register this handlere before the LoadingView is initialised
36 WeakReferenceMessenger.Default.Register<RegistrationPageMessage>(this, this.HandleRegistrationPageMessage);
37 this.registeredRegistrationPageMessage = true;
38
39 StateContainer.SetCurrentState(this.GridWithAnimation, "Loading");
40 }
41
43 {
44 if (this.registeredRegistrationPageMessage)
45 {
46 WeakReferenceMessenger.Default.Unregister<RegistrationPageMessage>(this);
47 this.registeredRegistrationPageMessage = false;
48 }
49 }
50
52 protected override async Task OnAppearingAsync()
53 {
54 await base.OnAppearingAsync();
55
56 if (!this.registeredKeyboardSizeMessage)
57 {
58 WeakReferenceMessenger.Default.Register<KeyboardSizeMessage>(this, this.HandleKeyboardSizeMessage);
59 this.registeredKeyboardSizeMessage = true;
60 }
61 }
62
64 protected override async Task OnDisappearingAsync()
65 {
66 if (this.registeredKeyboardSizeMessage)
67 {
68 WeakReferenceMessenger.Default.Unregister<KeyboardSizeMessage>(this);
69 this.registeredKeyboardSizeMessage = false;
70 }
71
72 await base.OnDisappearingAsync();
73 }
74
75 private async void HandleRegistrationPageMessage(object Recipient, RegistrationPageMessage Message)
76 {
77 RegistrationStep NewStep = Message.Step;
78
79 if (NewStep == RegistrationStep.Complete)
80 {
81 if (ServiceRef.PlatformSpecific.CanProhibitScreenCapture)
82 ServiceRef.PlatformSpecific.ProhibitScreenCapture = true; // Prohibut screen capture in normal operation.
83
84 await App.SetMainPageAsync();
85 return;
86 }
87
88 string NewState = NewStep.ToString();
89
90 if (ServiceRef.PlatformSpecific.CanProhibitScreenCapture)
91 ServiceRef.PlatformSpecific.ProhibitScreenCapture = true; // Allows user to record onboarding process, for troubleshooting purposes
92
93 await this.Dispatcher.DispatchAsync(async () =>
94 {
95 try
96 {
97 string OldState = StateContainer.GetCurrentState(this.GridWithAnimation);
98
99 if (!string.Equals(OldState, NewState, StringComparison.OrdinalIgnoreCase))
100 {
101 DateTime Start = DateTime.Now;
102
103 while (!StateContainer.GetCanStateChange(this.GridWithAnimation) && DateTime.Now.Subtract(Start).TotalSeconds < 2)
104 await Task.Delay(100);
105
106 await StateContainer.ChangeStateWithAnimation(this.GridWithAnimation, NewState, CancellationToken.None);
107
108 if (Recipient is RegistrationPage RegistrationPage)
109 {
110 RegistrationViewModel ViewModel = RegistrationPage.ViewModel<RegistrationViewModel>();
111 await ViewModel.DoAssignProperties(NewStep);
112 }
113 }
114 }
115 catch (Exception ex)
116 {
117 ServiceRef.LogService.LogException(ex);
118 }
119 });
120 }
121
122 private async void HandleKeyboardSizeMessage(object Recipient, KeyboardSizeMessage Message)
123 {
124 await this.Dispatcher.DispatchAsync(() =>
125 {
126 double Bottom = 0;
127 if (DeviceInfo.Platform == DevicePlatform.iOS)
128 {
129 Thickness SafeInsets = this.On<iOS>().SafeAreaInsets();
130 Bottom = SafeInsets.Bottom;
131 Thickness Margin = new(0, 0, 0, Message.KeyboardSize - Bottom);
132 this.TheMainGrid.Margin = Margin;
133 }
134
135
136 });
137 }
138 }
139}
The Application class, representing an instance of the Neuro-Access app.
Definition: App.xaml.cs:69
static Task SetMainPageAsync()
Switches the application to the main experience.
Definition: App.xaml.cs:666
Base class that references services in the app.
Definition: ServiceRef.cs:31
static ILogService LogService
Log service.
Definition: ServiceRef.cs:91
void SetPagesContainer(List< BaseRegistrationView > Items)
Adds sub-views
RegistrationStep
The different steps of a TAG Profile registration journey.
class KeyboardSizeMessage(float KeyboardSize)
Keyboard size change message
Definition: Messages.cs:19
class RegistrationPageMessage(RegistrationStep Step)
RegistrationPage view change message
Definition: Messages.cs:8