1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
9using System.Collections.ObjectModel;
10using System.ComponentModel;
23 private readonly PhotosLoader photosLoader;
24 private readonly
string? requestorFullJid;
25 private readonly
string? signatoryIdentityId;
26 private readonly
string? petitionId;
27 private readonly
byte[]? contentToSign;
36 this.photosLoader =
new PhotosLoader(this.
Photos);
52 await base.OnInitializeAsync();
54 this.AssignProperties();
63 this.photosLoader.CancelLoadPhotos();
65 await base.OnDisposeAsync();
71 public ObservableCollection<Photo>
Photos {
get; } = [];
79 private async Task Accept()
81 if (!await this.authenticationService.AuthenticateUserAsync(
AuthenticationPurpose.AcceptPetitionRequest,
true))
89 this.petitionId!,
this.requestorFullJid!,
true);
97 private async Task Decline()
102 this.contentToSign!, [], this.petitionId!, this.requestorFullJid!,
false);
110 private async Task Ignore()
118 public override Task<string>
Title => Task.FromResult(this.FullName);
124 public string? DisplayName =>
string.IsNullOrEmpty(this.Domain) ? (this.HasOrg ? this.OrgName : this.FullName) : this.Domain;
131 [DefaultValue(
false)]
132 private bool hasDomain;
140 private DateTime? created;
146 private DateTime? updated;
152 private DateTime? expires;
158 private string? legalId;
164 private string? networkId;
176 private DateTime? from;
182 private DateTime? to;
188 [NotifyPropertyChangedFor(nameof(FullName))]
189 [NotifyPropertyChangedFor(nameof(DisplayName))]
191 private string? firstName;
197 [NotifyPropertyChangedFor(nameof(FullName))]
198 [NotifyPropertyChangedFor(nameof(DisplayName))]
200 private string? middleNames;
206 [NotifyPropertyChangedFor(nameof(FullName))]
207 [NotifyPropertyChangedFor(nameof(DisplayName))]
208 private string? lastNames;
211 [NotifyPropertyChangedFor(nameof(DisplayName))]
212 private string? domain;
218 private string? personalNumber;
224 private string? address;
230 private string? address2;
236 private string? zipCode;
242 private string? area;
248 private string? city;
254 private string? region;
260 private string? countryCode;
266 private string? nationalityCode;
272 private string? gender;
278 private DateTime? birthDate;
284 [NotifyPropertyChangedFor(nameof(DisplayName))]
285 private string? orgName;
291 private string? orgNumber;
297 private string? orgDepartment;
303 private string? orgRole;
309 private string? orgAddress;
315 private string? orgAddress2;
321 private string? orgZipCode;
327 private string? orgArea;
333 private string? orgCity;
339 private string? orgRegion;
345 private string? orgCountryCode;
351 [NotifyPropertyChangedFor(nameof(DisplayName))]
358 private bool hasPhotos;
364 private string? phoneNr;
370 private string? eMail;
376 private string? deviceId;
382 private bool isApproved;
388 private string? purpose;
394 private ImageSource? firstPhotoSource;
400 private int firstPhotoRotation;
404 private void AssignProperties()
430 this.HasDomain = !
string.IsNullOrEmpty(this.Domain);
436 if (!
string.IsNullOrEmpty(BirthDayStr) &&
int.TryParse(BirthDayStr, out
int BirthDay) &&
437 !
string.IsNullOrEmpty(BirthMonthStr) &&
int.TryParse(BirthMonthStr, out
int BirthMonth) &&
438 !
string.IsNullOrEmpty(BirthYearStr) &&
int.TryParse(BirthYearStr, out
int BirthYear))
442 this.BirthDate =
new DateTime(BirthYear, BirthMonth, BirthDay);
447 this.BirthDate =
null;
463 !
string.IsNullOrEmpty(this.OrgName) ||
464 !
string.IsNullOrEmpty(this.OrgNumber) ||
465 !
string.IsNullOrEmpty(this.OrgDepartment) ||
466 !
string.IsNullOrEmpty(this.OrgRole) ||
467 !
string.IsNullOrEmpty(this.OrgAddress) ||
468 !
string.IsNullOrEmpty(this.OrgAddress2) ||
469 !
string.IsNullOrEmpty(this.OrgZipCode) ||
470 !
string.IsNullOrEmpty(this.OrgArea) ||
471 !
string.IsNullOrEmpty(this.OrgCity) ||
472 !
string.IsNullOrEmpty(this.OrgRegion) ||
473 !
string.IsNullOrEmpty(this.OrgCountryCode);
474 this.HasPhotos = this.Photos.Count > 0;
478 this.IsApproved = this.RequestorIdentity.State ==
IdentityState.Approved;
482 this.Created = DateTime.MinValue;
502 this.BirthDate =
null;
515 this.HasPhotos =
false;
519 this.IsApproved =
false;
528 if (this.IsConnected)
535 return MainThread.InvokeOnMainThreadAsync(async () =>
537 await base.XmppService_ConnectionStateChanged(Sender, NewState);
539 if (this.IsConnected)
547 private async
void ReloadPhotos()
551 this.photosLoader.CancelLoadPhotos();
555 if (Attachments is not
null)
557 Photo? First = await this.photosLoader.LoadPhotos(Attachments,
SignWith.LatestApprovedIdOrCurrentKeys);
559 this.FirstPhotoSource = First?.Source;
560 this.FirstPhotoRotation = First?.Rotation ?? 0;
573 private async Task Copy(
object Item)
577 if (Item is
string Label)
579 if (Label == this.LegalId)
588 await Clipboard.SetTextAsync(Label);
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.
A strongly-typed resource class, for looking up localized strings, etc.
static string IdCopiedSuccessfully
Looks up a localized string similar to A link to the ID was copied to the clipboard....
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.
Base class that references services in the app.
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 INetworkService NetworkService
Network service.
static IUiService UiService
Service serializing and managing UI-related tasks.
static IReportingStringLocalizer 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
ObservableCollection< Photo > Photos
The list of photos related to the identity being petitioned.
override async Task OnDisposeAsync()
Method called when the view is disposed, and will not be used more. Use this method to unregister eve...
LegalIdentity? RequestorIdentity
The identity of the requestor.
override async Task OnInitializeAsync()
Method called when view is initialized for the first time. Use this method to implement registration ...
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.
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, Attachment? Attachment)
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.