Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
TransactionEventItem.cs
1using System.Globalization;
2using CommunityToolkit.Mvvm.ComponentModel;
3using CommunityToolkit.Mvvm.Input;
4using EDaler;
10using AccountEventModel = EDaler.AccountEvent;
11
13{
23 public partial class TransactionEventItem(AccountEventModel accountEvent, string friendlyName, string currency, string? transactionType)
24 {
25 private readonly AccountEventModel accountEvent = accountEvent;
26 private readonly string friendlyName = friendlyName;
27 private readonly string currency = currency;
28 private readonly string? transactionType = transactionType;
29
30 public decimal Balance => this.accountEvent.Balance;
31 public decimal Reserved => this.accountEvent.Reserved;
32 public decimal Change => this.accountEvent.Change;
33 public DateTime Timestamp => this.accountEvent.Timestamp;
34 public Guid TransactionId => this.accountEvent.TransactionId;
35 public string Remote => this.accountEvent.Remote;
36 public string FriendlyName => this.friendlyName;
37 public string Message => this.accountEvent.Message;
38 public bool HasMessage => !string.IsNullOrEmpty(this.accountEvent.Message);
39 public string Currency => this.currency;
40 public string? TransactionType => ServiceRef.Localizer[nameof(AppResources.Transfer)].Value;
41
45 public Color ChangeColor => this.Change >= 0 ? AppColors.TnPSuccessContent : AppColors.ContentPrimary;
46
47 public string TimestampStr
48 {
49 get
50 {
51 DateTime Dt = this.Timestamp.ToLocalTime();
52 DateTime Now = DateTime.Now;
53 TimeSpan Span = Now - Dt;
54
55 string TimeString;
56
57 if (Span.TotalMinutes < 1)
58 TimeString = ServiceRef.Localizer[nameof(AppResources.Now)].Value;
59 else if (Span.TotalHours < 1)
60 TimeString = ServiceRef.Localizer[nameof(AppResources.MinutesAgoFormat), false, (int)Span.TotalMinutes];
61 else if (Span.TotalDays < 1)
62 TimeString = ServiceRef.Localizer[nameof(AppResources.HoursAgoFormat), false, (int)Span.TotalHours];
63 else
64 TimeString = Dt.ToString("m", CultureInfo.CurrentCulture);
65 return TimeString;
66 }
67 }
68
69 public string ReservedSuffix => this.accountEvent.Reserved == 0 ? string.Empty : "+" + NeuroAccessMaui.UI.Converters.MoneyToString.ToString(this.accountEvent.Reserved);
70
71 public bool IsReserved => this.accountEvent.Reserved != 0;
72
76 [RelayCommand]
77 public async Task OpenDetailsAsync()
78 {
79 TransactionPopup Popup = new(this);
80 await ServiceRef.PopupService.PushAsync(Popup);
81 }
82 }
83}
Account event
Definition: AccountEvent.cs:16
Contains information about a balance.
Definition: Balance.cs:11
Balance(DateTime Timestamp, decimal Amount, decimal Reserved, CaseInsensitiveString Currency, AccountEvent Event)
Contains information about a balance.
Definition: Balance.cs:26
A strongly-typed resource class, for looking up localized strings, etc.
static string Transfer
Looks up a localized string similar to Transfer.
static string MinutesAgoFormat
Looks up a localized string similar to {0} minutes ago.
static string HoursAgoFormat
Looks up a localized string similar to {0} hours ago.
static string Now
Looks up a localized string similar to Now.
Base class that references services in the app.
Definition: ServiceRef.cs:43
static IPopupService PopupService
Popup service for presenting application popups.
Definition: ServiceRef.cs:142
static IReportingStringLocalizer Localizer
Localization service
Definition: ServiceRef.cs:370
Static class that gives access to app-specific themed colors. All colors are fetched directly from th...
Definition: AppColors.cs:8
static string ToString(decimal Money)
Converts a monetary value to a string, removing any round-off errors.
partial class TransactionEventItem(AccountEventModel accountEvent, string friendlyName, string currency, string? transactionType)
Presentation model for a transaction event in history (no notification support).