1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
45 this.IdentityApplicationSent = ServiceRef.TagProfile.IdentityApplication is not
null;
48 this.HasLegalIdentity = ServiceRef.TagProfile.LegalIdentity is not
null &&
49 ServiceRef.TagProfile.LegalIdentity.State ==
IdentityState.Approved;
51 ServiceRef.XmppService.IdentityApplicationChanged += this.XmppService_IdentityApplicationChanged;
52 ServiceRef.XmppService.LegalIdentityChanged += this.XmppService_LegalIdentityChanged;
53 ServiceRef.TagProfile.OnPropertiesChanged += this.TagProfile_OnPropertiesChanged;
55 await base.OnInitialize();
56 this.NotifyCommandsCanExecuteChanged();
61 ServiceRef.XmppService.IdentityApplicationChanged -= this.XmppService_IdentityApplicationChanged;
62 ServiceRef.XmppService.LegalIdentityChanged -= this.XmppService_LegalIdentityChanged;
63 ServiceRef.TagProfile.OnPropertiesChanged -= this.TagProfile_OnPropertiesChanged;
65 return base.OnDispose();
68 private Task XmppService_IdentityApplicationChanged(
object? Sender, LegalIdentityEventArgs e)
70 MainThread.BeginInvokeOnMainThread(() =>
72 this.IdentityApplicationSent = ServiceRef.TagProfile.IdentityApplication is not
null;
75 return Task.CompletedTask;
78 private Task XmppService_LegalIdentityChanged(
object Sender, LegalIdentityEventArgs e)
80 MainThread.BeginInvokeOnMainThread(() =>
82 this.HasLegalIdentity = ServiceRef.TagProfile.LegalIdentity is not
null &&
83 ServiceRef.TagProfile.LegalIdentity.State ==
IdentityState.Approved;
86 return Task.CompletedTask;
89 private void TagProfile_OnPropertiesChanged(
object? sender, EventArgs e)
91 MainThread.BeginInvokeOnMainThread(() =>
99 await base.OnAppearing();
103 bool IdApplicationSent = ServiceRef.TagProfile.IdentityApplication is not
null;
104 if (this.IdentityApplicationSent != IdApplicationSent)
105 this.IdentityApplicationSent = IdApplicationSent;
107 this.OnPropertyChanged(nameof(this.IdentityApplicationSent));
113 return MainThread.InvokeOnMainThreadAsync(async () =>
115 await base.XmppService_ConnectionStateChanged(Sender, NewState);
117 this.NotifyCommandsCanExecuteChanged();
124 base.SetIsBusy(IsBusy);
125 this.NotifyCommandsCanExecuteChanged();
128 private void NotifyCommandsCanExecuteChanged()
130 this.ApplyPersonalIdCommand.NotifyCanExecuteChanged();
131 this.ApplyOrganizationalIdCommand.NotifyCanExecuteChanged();
132 this.BuyEDalerCommand.NotifyCanExecuteChanged();
146 private bool identityApplicationSent;
152 private bool hasLegalIdentity;
158 private bool hasWallet;
165 private async Task ViewIdApplication()
185 private async Task ApplyPersonalId()
202 private async Task ApplyOrganizationalId()
219 private async Task BuyEDaler()
226 if (ServiceProviders.Length == 0)
233 List<IBuyEDalerServiceProvider> ServiceProviders2 = [];
235 ServiceProviders2.AddRange(ServiceProviders);
236 ServiceProviders2.Add(
new EmptyBuyEDalerServiceProvider());
238 ServiceProvidersNavigationArgs e =
new(ServiceProviders2.ToArray(),
243 if (e.ServiceProvider is
null)
258 else if (
string.IsNullOrEmpty(
ServiceProvider.BuyEDalerTemplateContractId))
260 TaskCompletionSource<decimal?> Result =
new();
265 decimal? Amount = await Result.Task;
266 if (!Amount.HasValue)
269 if (Amount.Value > 0)
276 if (Amount.HasValue && Amount.Value > 0)
278 ServiceRef.TagProfile.HasWallet =
true;
279 await this.OpenWallet();
286 Dictionary<CaseInsensitiveString, object> Parameters =
new()
288 {
"Visibility",
"CreatorAndParts" },
291 {
"TrustProvider", e2.TrustProviderId }
298 IDictionary<CaseInsensitiveString, object>[] Options = await
OptionsTransaction.Wait();
301 MainThread.BeginInvokeOnMainThread(async () => await ContractOptionsPage.ShowContractOptions(Options));
313 private Task OpenWallet()
Contains information about a balance.
CaseInsensitiveString Currency
Currency of amount.
Represents a transaction in the eDaler network.
The Application class, representing an instance of the Neuro-Access app.
static Task< bool > AuthenticateUser(AuthenticationPurpose Purpose, bool Force=false)
Authenticates the user using the configured authentication method.
Base class that references services in the app.
static ILogService LogService
Log service.
static IUiService UiService
Service serializing and managing UI-related tasks.
static ITagProfile TagProfile
TAG Profile service.
static IStringLocalizer Localizer
Localization service
static IContractOrchestratorService ContractOrchestratorService
Contract orchestrator service.
static IXmppService XmppService
The XMPP service for XMPP communication.
The view model to bind to for when displaying the applications page.
override async Task OnInitialize()
Method called when view is initialized for the first time. Use this method to implement registration ...
override void SetIsBusy(bool IsBusy)
Sets the IsBusy property.
override async Task OnAppearing()
Method called when view is appearing on the screen.
override Task XmppService_ConnectionStateChanged(object? Sender, XmppState NewState)
Listens to connection state changes from the XMPP server.
ApplicationsViewModel()
Creates an instance of the ApplicationsViewModel class.
bool CanExecuteCommands
Used to find out if a command can execute
override Task OnDispose()
Method called when the view is disposed, and will not be used more. Use this method to unregister eve...
Page allowing the user to apply for a Personal ID.
View model for the AppShell.
Holds navigation parameters specific to buying eDaler.
A page that allows the user to buy eDaler.
Holds navigation parameters specific to an eDaler balance event.
A page that displays information about eDaler received.
A page that allows the user to view its tokens.
A view model that holds the XMPP state.
Contains information about a service provider.
string Type
Type of service provider.
string Id
ID of service provider.
Interface for information about a service provider that users can use to buy eDaler.
Page CurrentPage
Current page
Task DisplayException(Exception Exception, string? Title=null)
Displays an alert/message box to the user.
Task GoToAsync(string Route, BackMethod BackMethod=BackMethod.Inherited, string? UniqueId=null)
Navigates the AppShell to the specified route, with page arguments to match.
Interface for pages that can receive contract options from an asynchronous process.
BackMethod
Navigation Back Method
class OptionsTransaction(string TransactionId)
Maintains the status of an ongoing retrieval of payment options.
class PaymentTransaction(string TransactionId, string Currency)
Maintains the status of an ongoing payment transaction.
class ApplyIdNavigationArgs(bool Personal, bool ReusePhoto)
Navigation arguments for the ApplyIdPage and ApplyIdViewModel.
AuthenticationPurpose
Purpose for requesting the user to authenticate itself.
IdentityState
Lists recognized legal identity states.
XmppState
State of XMPP connection.