Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
TransferIdentityViewModel.cs
1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
6
8{
12 public partial class TransferIdentityViewModel : QrXmppViewModel, IDisposable
13 {
14 private bool isDisposed;
15 private Timer? timer;
16
21 public TransferIdentityViewModel(TransferIdentityNavigationArgs? Args)
22 : base()
23 {
24 if (Args is not null)
25 this.Uri = Args.Uri;
26 }
27
29 public override async Task OnInitializeAsync()
30 {
31 await base.OnInitializeAsync();
32
33 if (this.Uri is not null)
34 {
35 this.QrCodeWidth = 400;
36 this.QrCodeHeight = 400;
37 this.GenerateQrCode(this.Uri);
38 }
39
40 this.timer = new Timer(this.Timeout, null, 60000, 60000);
41 }
42
43 private void Timeout(object? _)
44 {
45 this.timer?.Dispose();
46 this.timer = null;
47
48 MainThread.BeginInvokeOnMainThread(async () =>
49 {
50 await this.GoBack();
51 });
52 }
53
55 public override Task OnDisposeAsync()
56 {
57 this.timer?.Dispose();
58 this.timer = null;
59
60 return base.OnDisposeAsync();
61 }
62
63 #region Properties
64
68 [ObservableProperty]
69 private string? uri;
70
71 #endregion
72
73 [RelayCommand]
74 private async Task CopyUriToClipboard()
75 {
76 await Clipboard.SetTextAsync(this.Uri);
77
78 await ServiceRef.UiService.DisplayAlert(
81 }
82
83 #region ILinkableView
84
88 public override Task<string> Title => Task.FromResult(ContactInfo.GetFriendlyName(ServiceRef.TagProfile.LegalIdentity!));
89
90 #endregion
91
95 public void Dispose()
96 {
97 this.Dispose(true);
98 GC.SuppressFinalize(this);
99 }
100
104 protected virtual void Dispose(bool disposing)
105 {
106 if (this.isDisposed)
107 return;
108
109 if (disposing)
110 {
111 this.timer?.Dispose();
112 this.timer = null;
113 }
114
115 this.isDisposed = true;
116 }
117 }
118}
A strongly-typed resource class, for looking up localized strings, etc.
static string TagValueCopiedToClipboard
Looks up a localized string similar to Tag value copied to clipboard.
static string SuccessTitle
Looks up a localized string similar to Success.
Contains information about a contact.
Definition: ContactInfo.cs:22
static async Task< string > GetFriendlyName(CaseInsensitiveString RemoteId)
Gets the friendly name of a remote identity (Legal ID or Bare JID).
Definition: ContactInfo.cs:258
Base class that references services in the app.
Definition: ServiceRef.cs:43
static IUiService UiService
Service serializing and managing UI-related tasks.
Definition: ServiceRef.cs:130
static ITagProfile TagProfile
TAG Profile service.
Definition: ServiceRef.cs:202
static IReportingStringLocalizer Localizer
Localization service
Definition: ServiceRef.cs:370
virtual async Task GoBack()
Method called when user wants to navigate to the previous screen.
override Task OnDisposeAsync()
Method called when the view is disposed, and will not be used more. Use this method to unregister eve...
override async Task OnInitializeAsync()
Method called when view is initialized for the first time. Use this method to implement registration ...
TransferIdentityViewModel(TransferIdentityNavigationArgs? Args)
Creates an instance of the TransferIdentityViewModel class.
A view model that holds the XMPP state.
void GenerateQrCode(string Uri)
Generates a QR-code
Definition: ImplTypes.g.cs:58