Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
BiometricsViewModel.cs
1using System.ComponentModel;
2using System.Globalization;
3using CommunityToolkit.Mvvm.ComponentModel;
4using CommunityToolkit.Mvvm.Input;
5using CommunityToolkit.Mvvm.Messaging;
13
15{
16 public partial class BiometricsViewModel() : BaseRegistrationViewModel(RegistrationStep.Biometrics)
17 {
19 protected override async Task OnInitialize()
20 {
21 await base.OnInitialize();
22
23 LocalizationManager.Current.PropertyChanged += this.Localization_Changed;
24 }
25
27 protected override async Task OnDispose()
28 {
29 LocalizationManager.Current.PropertyChanged -= this.Localization_Changed;
30
31 await base.OnDispose();
32 }
33
34
35 private void Localization_Changed(object? Sender, PropertyChangedEventArgs e)
36 {
37 this.OnPropertyChanged(nameof(this.DetailText));
38 this.OnPropertyChanged(nameof(this.WhatIsX));
39 }
40
41 private readonly BiometricMethod biometricMethod = ServiceRef.PlatformSpecific.GetBiometricMethod();
42
46 public double AuthenticationBackgroundSize => 120.0;
47
51 public double AuthenticationBackgroundCornerRadius => this.AuthenticationBackgroundSize / 2;
55 public double AuthenticationIconSize => 60.0;
56
60 public bool IsFingerprint => this.biometricMethod is BiometricMethod.Fingerprint or BiometricMethod.TouchId or BiometricMethod.Unknown;
61
65 public bool IsFace => this.biometricMethod is BiometricMethod.Face or BiometricMethod.FaceId or BiometricMethod.Unknown;
66
70 public string DetailText
71 {
72 get
73 {
74
75 string methodName = this.biometricMethod switch
76 {
77 BiometricMethod.TouchId => ServiceRef.Localizer[nameof(AppResources.TouchId)],
78 BiometricMethod.FaceId => ServiceRef.Localizer[nameof(AppResources.FaceId)],
79 _ => ServiceRef.Localizer[nameof(AppResources.BiometricAuthentication)].ToString().ToLower(CultureInfo.CurrentUICulture)
80 };
81
82 return ServiceRef.Localizer[nameof(AppResources.OnboardingBiometricsPageDetails), methodName];
83 }
84 }
85
90 public string WhatIsX
91 {
92 get
93 {
94 string subject = this.biometricMethod switch
95 {
96 BiometricMethod.TouchId => ServiceRef.Localizer[nameof(AppResources.TouchId)],
97 BiometricMethod.FaceId => ServiceRef.Localizer[nameof(AppResources.FaceId)],
98 _ => ServiceRef.Localizer[nameof(AppResources.BiometricAuthentication)].ToString().ToLower(CultureInfo.CurrentUICulture)
99 };
100
101 return ServiceRef.Localizer[nameof(AppResources.WhatIsX), subject];
102 }
103 }
104
105 [RelayCommand]
106 private async Task ShowBiometricsInfo()
107 {
108 string message = this.biometricMethod switch
109 {
110 BiometricMethod.FaceId => ServiceRef.Localizer[nameof(AppResources.FaceIdInfo)],
111 BiometricMethod.TouchId => ServiceRef.Localizer[nameof(AppResources.TouchIdInfo)],
112 _ => ServiceRef.Localizer[nameof(AppResources.BiometricAuthenticationInfo)]
113 };
114
115 ShowInfoPopup infoPage = new(this.WhatIsX, message);
116 await ServiceRef.UiService.PushAsync(infoPage);
117 }
118
119 [RelayCommand]
120 private void Later()
121 {
122 GoToRegistrationStep(RegistrationStep.Finalize);
123 }
124
125 [RelayCommand]
126 private void Enable()
127 {
128 ServiceRef.TagProfile.AuthenticationMethod = AuthenticationMethod.Fingerprint;
129 GoToRegistrationStep(RegistrationStep.Finalize);
130 }
131 }
132}
Base class that references services in the app.
Definition: ServiceRef.cs:31
static IUiService UiService
Service serializing and managing UI-related tasks.
Definition: ServiceRef.cs:55
static IStringLocalizer Localizer
Localization service
Definition: ServiceRef.cs:235
AuthenticationMethod
How the user authenticates itself with the App.
RegistrationStep
The different steps of a TAG Profile registration journey.
BiometricMethod
Enum representing the device biometric method for authentication.