1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
8using System.Collections.ObjectModel;
19 private readonly PhotosLoader photosLoader;
20 private readonly
string? requestorFullJid;
21 private readonly
string? signatoryIdentityId;
22 private readonly
string? petitionId;
23 private readonly
byte[]? contentToSign;
32 this.photosLoader =
new PhotosLoader(this.
Photos);
48 await base.OnInitialize();
50 this.AssignProperties();
59 this.photosLoader.CancelLoadPhotos();
61 await base.OnDispose();
67 public ObservableCollection<Photo>
Photos {
get; } = [];
75 private async Task Accept()
85 this.petitionId!,
this.requestorFullJid!,
true);
93 private async Task Decline()
98 this.contentToSign!, [], this.petitionId!, this.requestorFullJid!,
false);
106 private async Task Ignore()
114 public override Task<string>
Title => Task.FromResult(this.FullName);
120 public string? DisplayName =>
string.IsNullOrEmpty(this.Domain) ? (this.HasOrg ? this.OrgName : this.FullName) : this.Domain;
128 private DateTime? created;
134 private DateTime? updated;
140 private DateTime? expires;
146 private string? legalId;
152 private string? networkId;
164 private DateTime? from;
170 private DateTime? to;
176 [NotifyPropertyChangedFor(nameof(FullName))]
177 [NotifyPropertyChangedFor(nameof(DisplayName))]
179 private string? firstName;
185 [NotifyPropertyChangedFor(nameof(FullName))]
186 [NotifyPropertyChangedFor(nameof(DisplayName))]
188 private string? middleNames;
194 [NotifyPropertyChangedFor(nameof(FullName))]
195 [NotifyPropertyChangedFor(nameof(DisplayName))]
196 private string? lastNames;
199 [NotifyPropertyChangedFor(nameof(DisplayName))]
200 private string? domain;
206 private string? personalNumber;
212 private string? address;
218 private string? address2;
224 private string? zipCode;
230 private string? area;
236 private string? city;
242 private string? region;
248 private string? countryCode;
254 private string? nationalityCode;
260 private string? gender;
266 private DateTime? birthDate;
272 [NotifyPropertyChangedFor(nameof(DisplayName))]
273 private string? orgName;
279 private string? orgNumber;
285 private string? orgDepartment;
291 private string? orgRole;
297 private string? orgAddress;
303 private string? orgAddress2;
309 private string? orgZipCode;
315 private string? orgArea;
321 private string? orgCity;
327 private string? orgRegion;
333 private string? orgCountryCode;
339 [NotifyPropertyChangedFor(nameof(DisplayName))]
346 private bool hasPhotos;
352 private string? phoneNr;
358 private string? eMail;
364 private string? deviceId;
370 private bool isApproved;
376 private string? purpose;
382 private ImageSource? firstPhotoSource;
388 private int firstPhotoRotation;
392 private void AssignProperties()
423 if (!
string.IsNullOrEmpty(BirthDayStr) &&
int.TryParse(BirthDayStr, out
int BirthDay) &&
424 !
string.IsNullOrEmpty(BirthMonthStr) &&
int.TryParse(BirthMonthStr, out
int BirthMonth) &&
425 !
string.IsNullOrEmpty(BirthYearStr) &&
int.TryParse(BirthYearStr, out
int BirthYear))
429 this.BirthDate =
new DateTime(BirthYear, BirthMonth, BirthDay);
434 this.BirthDate =
null;
450 !
string.IsNullOrEmpty(this.OrgName) ||
451 !
string.IsNullOrEmpty(this.OrgNumber) ||
452 !
string.IsNullOrEmpty(this.OrgDepartment) ||
453 !
string.IsNullOrEmpty(this.OrgRole) ||
454 !
string.IsNullOrEmpty(this.OrgAddress) ||
455 !
string.IsNullOrEmpty(this.OrgAddress2) ||
456 !
string.IsNullOrEmpty(this.OrgZipCode) ||
457 !
string.IsNullOrEmpty(this.OrgArea) ||
458 !
string.IsNullOrEmpty(this.OrgCity) ||
459 !
string.IsNullOrEmpty(this.OrgRegion) ||
460 !
string.IsNullOrEmpty(this.OrgCountryCode);
461 this.HasPhotos = this.Photos.Count > 0;
465 this.IsApproved = this.RequestorIdentity.State ==
IdentityState.Approved;
469 this.Created = DateTime.MinValue;
489 this.BirthDate =
null;
502 this.HasPhotos =
false;
506 this.IsApproved =
false;
515 if (this.IsConnected)
522 return MainThread.InvokeOnMainThreadAsync(async () =>
524 await base.XmppService_ConnectionStateChanged(Sender, NewState);
526 if (this.IsConnected)
534 private async
void ReloadPhotos()
538 this.photosLoader.CancelLoadPhotos();
542 if (Attachments is not
null)
544 Photo? First = await this.photosLoader.LoadPhotos(Attachments,
SignWith.LatestApprovedIdOrCurrentKeys);
546 this.FirstPhotoSource = First?.Source;
547 this.FirstPhotoRotation = First?.Rotation ?? 0;
560 private async Task Copy(
object Item)
564 if (Item is
string Label)
566 if (Label == this.LegalId)
575 await Clipboard.SetTextAsync(Label);
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.
static readonly TimeSpan XmppInit
XMPP Init timeout
static string CreateIdUri(string id)
Generates a IoT ID Uri form the specified id.
const string IotId
The IoT ID URI Scheme (iotid)
XMPP Protocol Properties.
const string PersonalNumber
Personal number
const string OrgAddress2
Organization Address line 2
const string DeviceId
Device ID
const string Country
Country
const string OrgArea
Organization Area
const string Region
Region
const string OrgRegion
Organization Region
const string Nationality
Nationality
const string ZipCode
Zip Code
const string BirthYear
Birth Year
const string OrgCity
Organization City
const string OrgRole
Organization Role
const string Phone
Phone number
const string EMail
e-Mail address
const string OrgZipCode
Organization Zip Code
const string MiddleNames
Middle names
const string BirthDay
Birth Day
const string OrgCountry
Organization Country
const string OrgDepartment
Organization Department
const string Address2
Address line 2
const string Domain
Domain name.
const string OrgAddress
Organization Address line 1
const string Address
Address line 1
const string LastNames
Last names
const string OrgNumber
Organization number
const string BirthMonth
Birth Month
const string FirstName
First name
const string Gender
Gender
const string OrgName
Organization name
A set of never changing property constants and helpful values.
const string NotAvailableValue
A generic "no value available" string.
Base class that references services in the app.
static ILogService LogService
Log service.
static INetworkService NetworkService
Network service.
static IUiService UiService
Service serializing and managing UI-related tasks.
static IStringLocalizer Localizer
Localization service
static IXmppService XmppService
The XMPP service for XMPP communication.
virtual async Task GoBack()
Method called when user wants to navigate to the previous screen.
Holds navigation parameters specific to views displaying a petition of a signature.
string? RequestorFullJid
The full Jid of the requestor.
string? PetitionId
The petition id.
string? Purpose
The purpose of the petition.
string? SignatoryIdentityId
Legal ID requested to sign ContentToSign.
LegalIdentity? RequestorIdentity
The identity of the requestor.
byte?[] ContentToSign
Digital content to sign.
The view model to bind to when displaying petitioning of a signature in a view or page.
override Task< string > Title
Title of the current view
override async Task OnDispose()
Method called when the view is disposed, and will not be used more. Use this method to unregister eve...
ObservableCollection< Photo > Photos
The list of photos related to the identity being petitioned.
LegalIdentity? RequestorIdentity
The identity of the requestor.
PetitionSignatureViewModel(PetitionSignatureNavigationArgs? Args)
Creates a new instance of the PetitionSignatureViewModel class.
override Task XmppService_ConnectionStateChanged(object? Sender, XmppState NewState)
Listens to connection state changes from the XMPP server.
override async Task OnInitialize()
Method called when view is initialized for the first time. Use this method to implement registration ...
A view model that holds the XMPP state.
void RemoveQrCode()
Removes the QR-code
void GenerateQrCode(string Uri)
Generates a QR-code
Contains a reference to an attachment assigned to a legal object.
DateTime From
From what point in time the legal identity is valid.
DateTime Updated
When the identity object was last updated
DateTime To
To what point in time the legal identity is valid.
DateTime Created
When the identity object was created
IdentityState State
Current state of identity
string Id
ID of the legal identity
Attachment[] Attachments
Attachments assigned to the legal identity.
Abstract base class of signatures
class Photo(byte[] Binary, int Rotation)
Class containing information about a photo.
AuthenticationPurpose
Purpose for requesting the user to authenticate itself.
IdentityState
Lists recognized legal identity states.
SignWith
Options on what keys to use when signing data.
XmppState
State of XMPP connection.