1using System.Collections.ObjectModel;
2using System.Collections.Specialized;
3using System.ComponentModel;
4using CommunityToolkit.Mvvm.ComponentModel;
5using CommunityToolkit.Mvvm.Input;
28 this.parts =
new ObservableCollection<ObservablePart>();
34 #region Initialization
46 this.Description = UntrimmedDescription.Trim();
49 if (contract.
Parts is
null)
76 public ObservableCollection<ObservablePart>
Parts
79 private set => this.SetProperty(ref this.parts, value);
81 private ObservableCollection<ObservablePart> parts;
94 get => this.description;
97 if (this.SetProperty(ref this.description, value))
99 this.OnPropertyChanged(nameof(this.
Label));
103 private string description =
string.Empty;
138 bool AlreadySelected = !
string.IsNullOrEmpty(MyId) && this.
Parts.Any(p => p.LegalId == MyId);
152 if (
string.IsNullOrEmpty(MyId))
154 return this.
Parts.Any(p => p.LegalId == MyId);
159 if (
string.IsNullOrEmpty(MyId))
165 bool CurrentlySelected = this.
Parts.Any(p => p.LegalId == MyId);
166 if (value == CurrentlySelected)
171 if (this.
Parts.Count >=
this.MaxCount)
183 this.OnPropertyChanged();
193 public async Task
AddPart(
string LegalId,
bool Notify =
true,
bool AutoPetition =
true,
bool PresetFromArgs =
false)
196 if (this.
Parts.Any(p =>
string.Equals(p.LegalId, LegalId, StringComparison.OrdinalIgnoreCase)))
200 Part Part =
new() { LegalId = LegalId,
Role = this.Name };
203 IsPresetFromArgs = PresetFromArgs
208 TaskCompletionSource TaskCompletionSource =
new();
209 MainThread.BeginInvokeOnMainThread(() =>
211 this.
Parts.Add(ObservablePart);
212 this.OnPropertyChanged(nameof(this.HasReachedMaxCount));
213 this.OnPropertyChanged(nameof(this.HasReachedMinCount));
216 this.OnPropertyChanged(nameof(this.
Parts));
217 TaskCompletionSource.SetResult();
219 await TaskCompletionSource.Task;
237 if (Found is not
null)
239 await MainThread.InvokeOnMainThreadAsync(() =>
241 Found.Signature = signature;
253 if (
Part is not
null)
255 MainThread.BeginInvokeOnMainThread(() =>
257 this.
Parts.Remove(Part);
258 this.OnPropertyChanged(nameof(this.HasReachedMaxCount));
259 this.OnPropertyChanged(nameof(this.HasReachedMinCount));
262 this.OnPropertyChanged(nameof(this.
Parts));
286 [RelayCommand(AllowConcurrentExecutions =
false)]
287 private async Task AddPartFromContacts()
290 TaskCompletionSource<ContactInfoModel?> Selected =
new();
293 CanScanQrCode =
true,
303 string LegalId = Contact.
LegalId;
308 [RelayCommand(AllowConcurrentExecutions =
false)]
309 private async Task AddPartFromQr()
312 if (
string.IsNullOrEmpty(Code))
static ? string RemoveScheme(string Url)
Removes the URI Schema from an URL.
const string IotId
The IoT ID URI Scheme (iotid)
A set of never changing property constants and helpful values.
A strongly-typed resource class, for looking up localized strings, etc.
static string ScanQRCode
Looks up a localized string similar to Scan QR Code.
static string AddContactToContract
Looks up a localized string similar to Add Contact to Contract.
Base class that references services in the app.
static ILogService LogService
Log service.
static INavigationService NavigationService
The navigation service for navigating between pages.
static ITagProfile TagProfile
TAG Profile service.
static IReportingStringLocalizer Localizer
Localization service
Helper class to perform scanning of QR Codes by displaying the UI and handling async results.
static async Task< string?> ScanQrCode(string? QrTitle, string[] AllowedSchemas)
Navigates to the Scan QR Code Page, waits for scan to complete, and returns the result....
Contact Information model, including related notification information.
CaseInsensitiveString? LegalId
Legal ID of contact.
Holds navigation parameters specific to views displaying a list of contacts.
A page that displays a list of the current user's contacts.
async Task InitializeAsync(bool sendPetition=true)
Initializes the part, setting properties which needs to be set asynchronosly
An observable object that wraps a Waher.Networking.XMPP.Contracts.Role object. This allows for easier...
ObservableCollection< ObservablePart > Parts
The parts associated with the role
async Task AddPart(Part part)
Adds a part object to the role.
bool HasReachedMaxCount
If the role has reached the maximum amount of parts.
async Task AddPart(string LegalId, bool Notify=true, bool AutoPetition=true, bool PresetFromArgs=false)
Adds a part with a given LegalId to the role.
bool HasReachedMinCount
If the role has reached the minimum amount of parts.
int MinCount
Smallest amount of signatures of this role required for a legally binding contract.
bool IsSelectedByMe
If current user has selected to sign as this role. Toggling this will add/remove "Me" as a part,...
async Task InitializeAsync(Contract contract)
Initializes the role in regards to a contract. E.g Sets the description of the role,...
string Name
The name of the role
int MaxCount
Largest amount of signatures of this role required for a legally binding contract.
void RemovePart(string LegalId, bool Notify=true)
Removes a part with a given LegalId from the role.
string Description
The localized description of the role Has to be initialized with InitializeAsync
string Label
Label to display in the UI, defaults to Name if Description is not set.
async Task AddPart(ClientSignature signature)
Add a part from a signature, or mark the part as signed if it already exists.
void RemovePart(Part part)
Removes a part object from the role.
bool CanSelectMe
True if user can select themselves for this role (not at max or already selected).
Represents a digital signature on a contract.
string LegalId
ID of legal identity signing the contract.
Contains the definition of a contract
Task< string > ToPlainText(string Language)
Creates a human-readable Plain Trext document for the contract.
Part[] Parts
Defined parts for the smart contract.
HumanReadableText[] Descriptions
Discriptions of the object, in different languages.
Class defining a part in a contract
string LegalId
Legal identity of part
string Role
Role of the part in the contract
int MaxCount
Largest amount of signatures of this role required for a legally binding contract.
int MinCount
Smallest amount of signatures of this role required for a legally binding contract.
string Name
Name of the role.
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.
Task GoToAsync(string Route)
Navigates to the specified route and pushes the page onto the navigation stack.
BackMethod
Navigation Back Method