1using System.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
8using CommunityToolkit.Mvvm.ComponentModel;
16using System.Globalization;
29using Microsoft.Extensions.DependencyInjection;
31using System.Threading;
45 bool themeLoaded =
false;
49 private bool reviewEventSubscribed;
51 public string BannerUri =>
52 Application.Current?.UserAppTheme
switch
54 AppTheme.Dark => this.BannerUriDark,
55 AppTheme.Light => this.BannerUriLight,
56 _ => this.BannerUriLight
57 } ?? this.BannerUriLight;
64 Application.Current.RequestedThemeChanged += (
_, __) =>
65 OnPropertyChanged(nameof(BannerUri));
72 await base.OnAppearingAsync();
77 await this.LoadLatestKycStateAsync();
92 await
ServiceRef.ThemeService.ThemeLoaded.Task;
93 MainThread.BeginInvokeOnMainThread(() =>
95 this.ThemeLoaded =
true;
96 this.OnPropertyChanged(nameof(this.BannerUri));
98 await
ServiceRef.IntentService.ProcessQueuedIntentsAsync();
111 ServiceRef.XmppService.IdentityApplicationChanged += this.XmppService_IdentityApplicationChanged;
112 ServiceRef.XmppService.LegalIdentityChanged += this.XmppService_LegalIdentityChanged;
113 ServiceRef.TagProfile.OnPropertiesChanged += this.TagProfile_OnPropertiesChanged;
114 ServiceRef.TagProfile.Changed += this.TagProfile_PropertyChanged;
115 if (!this.reviewEventSubscribed)
117 ServiceRef.KycService.ApplicationReviewUpdated += this.KycService_ApplicationReviewUpdated;
118 this.reviewEventSubscribed =
true;
121 this.notificationService.OnNotificationAdded += this.NotificationService_OnNotificationAdded;
122 await this.RefreshUnreadNotificationsAsync();
127 ServiceRef.XmppService.IdentityApplicationChanged -= this.XmppService_IdentityApplicationChanged;
128 ServiceRef.XmppService.LegalIdentityChanged -= this.XmppService_LegalIdentityChanged;
129 ServiceRef.TagProfile.OnPropertiesChanged -= this.TagProfile_OnPropertiesChanged;
130 ServiceRef.TagProfile.Changed -= this.TagProfile_PropertyChanged;
131 if (this.reviewEventSubscribed)
133 ServiceRef.KycService.ApplicationReviewUpdated -= this.KycService_ApplicationReviewUpdated;
134 this.reviewEventSubscribed =
false;
136 this.notificationService.OnNotificationAdded -= this.NotificationService_OnNotificationAdded;
137 return base.OnDisappearingAsync();
140 private void TagProfile_OnPropertiesChanged(
object? Sender, EventArgs e)
142 Task.Run(this.LoadLatestKycStateAsync);
145 private void TagProfile_PropertyChanged(
object? sender, PropertyChangedEventArgs e)
147 if (
string.IsNullOrEmpty(e.PropertyName) ||
151 MainThread.BeginInvokeOnMainThread(() =>
153 this.OnPropertyChanged(nameof(this.HasPersonalIdentity));
154 this.OnPropertyChanged(nameof(this.HasPendingIdentity));
155 this.OnPropertyChanged(nameof(this.ShowApplyIdBox));
156 this.OnPropertyChanged(nameof(this.ShowPendingIdBox));
157 this.OnPropertyChanged(nameof(this.ShowRejectedIdBox));
158 this.OnPropertyChanged(nameof(this.ShowInfoBubble));
159 this.OnPropertyChanged(nameof(this.ShowIdButtonText));
164 private async Task XmppService_IdentityApplicationChanged(
object? Sender, EventArgs e)
167 await this.LoadLatestKycStateAsync();
170 private async Task XmppService_LegalIdentityChanged(
object? Sender, EventArgs e)
172 await this.LoadLatestKycStateAsync();
177 await base.OnInitializeAsync();
179 await this.OnIsConnectedChanged();
182 protected override async
void OnPropertyChanged(PropertyChangedEventArgs e)
184 base.OnPropertyChanged(e);
186 switch (e.PropertyName)
188 case nameof(this.IsConnected):
189 await this.OnIsConnectedChanged();
194 private async Task OnIsConnectedChanged()
210 this.ScanQrCodeCommand.NotifyCanExecuteChanged();
217 public bool HasPendingIdentity => this.CheckPendingIdentity();
219 public bool ShowInfoBubble => this.ShowApplyIdBox || this.ShowPendingIdBox || this.ShowRejectedIdBox;
220 public bool ShowApplyIdBox => !(
ServiceRef.
TagProfile.
LegalIdentity?.HasApprovedPersonalInformation() ??
false) && !this.CheckPendingIdentity() && !this.CheckRejectedIdentity();
222 public bool ShowPendingIdBox => this.CheckPendingIdentity();
223 public bool ShowRejectedIdBox => this.CheckRejectedIdentity();
225 private bool CheckPendingIdentity()
231 private bool CheckRejectedIdentity()
239 return this.RefreshUnreadNotificationsAsync();
242 private async Task RefreshUnreadNotificationsAsync()
248 States =
new List<NotificationState>
251 NotificationState.Delivered
255 IReadOnlyList<NotificationRecord> Records = await this.notificationService.GetAsync(Query, CancellationToken.None);
256 MainThread.BeginInvokeOnMainThread(() =>
258 this.UnreadNotificationCount = Records.Count;
276 private int unreadNotificationCount;
278 partial
void OnUnreadNotificationCountChanged(
int value)
280 this.OnPropertyChanged(nameof(this.HasUnreadNotifications));
283 private async Task LoadLatestKycStateAsync()
287 KycReference? LatestReference = await FindMostRecentReferenceAsync();
291 MainThread.BeginInvokeOnMainThread(() =>
293 this.OnPropertyChanged(nameof(this.HasPersonalIdentity));
294 this.OnPropertyChanged(nameof(this.HasPendingIdentity));
295 this.OnPropertyChanged(nameof(this.ShowPendingIdBox));
296 this.OnPropertyChanged(nameof(this.ShowApplyIdBox));
297 this.OnPropertyChanged(nameof(this.ShowRejectedIdBox));
298 this.OnPropertyChanged(nameof(this.ShowInfoBubble));
299 this.OnPropertyChanged(nameof(this.ShowIdButtonText));
310 this.latestApplicationReview = e.
Review;
311 MainThread.BeginInvokeOnMainThread(() =>
313 this.OnPropertyChanged(nameof(this.ShowInfoBubble));
314 this.OnPropertyChanged(nameof(this.ShowPendingIdBox));
315 this.OnPropertyChanged(nameof(this.ShowRejectedIdBox));
316 this.OnPropertyChanged(nameof(this.ShowApplyIdBox));
317 this.OnPropertyChanged(nameof(this.ShowIdButtonText));
321 private static async Task<KycReference?> FindMostRecentReferenceAsync()
324 if (IdentityApplication is not
null)
329 if (Match is not
null)
341 return All.OrderByDescending(r => r.UpdatedUtc).FirstOrDefault();
351 public bool CanScanQrCode =>
true;
353 [RelayCommand(CanExecute = nameof(CanScanQrCode))]
354 private async Task ScanQrCode()
356 await MainThread.InvokeOnMainThreadAsync(async () =>
358 await Services.UI.QR.QrCode.ScanQrCodeAndHandleResult();
362 [RelayCommand(AllowConcurrentExecutions =
false)]
363 public async Task ViewId()
376 [RelayCommand(AllowConcurrentExecutions =
false)]
377 public async Task OpenNotifications()
389 [RelayCommand(AllowConcurrentExecutions =
false)]
390 public async Task GoToApplyIdentity()
404 public async Task ViewApps()
417 private bool showingNoWalletPopup =
false;
419 [RelayCommand(AllowConcurrentExecutions =
false)]
420 public async Task OpenWallet()
429 this.ShowingNoWalletPopup =
true;
430 await Task.Delay(5000);
431 this.ShowingNoWalletPopup =
false;
436 internal static async Task ShowWallet()
455 private static async Task ShowSettings()
Image identifiers for branding.
const string BannerLargeLight
The default branding image.
Runtime setting key names.
const string PushNotificationAsked
Push-notification asked.
static readonly TimeSpan XmppConnect
XMPP Connect timeout
A set of never changing property constants and helpful values.
A strongly-typed resource class, for looking up localized strings, etc.
static string ShowIDShort
Looks up a localized string similar to Show ID.
static string ShowAccount
Looks up a localized string similar to Show account.
Captures the result of an application review returned from backend services.
Event arguments emitted when a KYC application review changes.
ApplicationReview? Review
Gets the review payload.
Contains a local reference to a KYC process.
ApplicationReview? ApplicationReview
Latest backend review for this application, if any.
IdentityState? CreatedIdentityState
Last known state of the created identity (if any), for quick status tagging offline.
string? CreatedIdentityId
The legal ID of the created identity (if any).
Query options for retrieving notifications.
Event args for notification record events.
Base class that references services in the app.
static IAuthenticationService AuthenticationService
Authentication service.
static IServiceProvider Provider
The service provider for the app. This is set before the app is started, and will be used to resolve ...
static ILogService LogService
Log service.
static IUiService UiService
Service serializing and managing UI-related tasks.
static INavigationService NavigationService
The navigation service for navigating between pages.
static ITagProfile TagProfile
TAG Profile service.
static IReportingStringLocalizer Localizer
Localization service
static IXmppService XmppService
The XMPP service for XMPP communication.
static IPermissionService PermissionService
Permission Service
static ISettingsService SettingsService
Settings service.
A page to display when the user wants to view an identity.
Main page for viewing apps.
override async Task OnAppearingAsync()
Method called when view is appearing on the screen.
bool HasUnreadNotifications
Gets a value indicating whether there are unread notifications.
override async Task OnInitializeAsync()
Method called when view is initialized for the first time. Use this method to implement registration ...
override Task< string > Title
Title of the current view
override Task OnDisappearingAsync()
Method called when view is disappearing from the screen.
Main page for App settings.
A view model that holds the XMPP state.
Holds navigation parameters specific to the eDaler wallet.
A page that allows the user to view the contents of its eDaler wallet, pending payments and recent ac...
IdentityState State
Current state of identity
string Id
ID of the legal identity
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static Task< IEnumerable< object > > Find(string Collection, params string[] SortOrder)
Finds objects in a given collection.
This filter selects objects that have a named field equal to a given value.
Interface for the redesigned notification service.
Task SaveState(string Key, string State)
Saves State with the given key.
Task< bool > RestoreBoolState(string Key, bool DefaultValueIfNotFound=default)
Restores State for the specified key.
The TAG Profile is the heart of the digital identity for a specific user/device. Use this instance to...
Task SetLegalIdentity(LegalIdentity? Identity, bool RemoveOldAttachments)
Sets the legal identity of the profile.
bool HasBetaFeatures
If the user has Beta features enabled
LegalIdentity? IdentityApplication
Any current Identity application.
bool LegalIdentityNeedsRefreshing()
If the current ITagProfile needs to have its legal identity refreshed, because it can have missed off...
LegalIdentity? LegalIdentity
The legal identity of the current user/profile.
Task GoToAsync(string Route)
Navigates to the specified route and pushes the page onto the navigation stack.
Task DisplayException(Exception Exception, string? Title=null)
Displays an alert/message box to the user.
NotificationState
Notification lifecycle state.
BackMethod
Navigation Back Method
AuthenticationPurpose
Purpose for requesting the user to authenticate itself.
IdentityState
Lists recognized legal identity states.