Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SubscriptionRequestViewModel.cs
1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
5
7{
12 {
16 Accept,
17
21 Reject,
22
26 Ignore
27 }
28
33 {
34 private readonly TaskCompletionSource<PresenceRequestAction> result = new();
35
44 public SubscriptionRequestViewModel(string BareJid, string FriendlyName, string? PhotoUrl, int PhotoWidth, int PhotoHeight)
45 : base()
46 {
47 this.BareJid = BareJid;
48 this.FriendlyName = FriendlyName;
49 this.PhotoUrl = PhotoUrl;
50 this.PhotoWidth = PhotoWidth;
51 this.PhotoHeight = PhotoHeight;
52 this.HasFriendlyName = !string.IsNullOrEmpty(FriendlyName) && FriendlyName != BareJid;
53 this.HasPhoto = !string.IsNullOrEmpty(PhotoUrl);
54
55 if (this.hasFriendlyName)
56 {
57 this.PrimaryName = FriendlyName;
58 this.SecondaryName = " (" + BareJid + ")";
59 }
60 else
61 {
62 this.PrimaryName = BareJid;
63 this.SecondaryName = string.Empty;
64 }
65 }
66
70 [ObservableProperty]
71 private string bareJid;
72
76 [ObservableProperty]
77 private string friendlyName;
78
82 [ObservableProperty]
83 private string primaryName;
84
88 [ObservableProperty]
89 private string secondaryName;
90
94 [ObservableProperty]
95 private bool hasFriendlyName;
96
100 [ObservableProperty]
101 private bool hasPhoto;
102
106 [ObservableProperty]
107 private string? photoUrl;
108
112 [ObservableProperty]
113 private int photoWidth;
114
118 [ObservableProperty]
119 private int photoHeight;
120
124 public Task<PresenceRequestAction> Result => this.result.Task;
125
129 [RelayCommand]
130 private async Task Accept()
131 {
132 this.result.TrySetResult(PresenceRequestAction.Accept);
133 await ServiceRef.PopupService.PopAsync();
134 }
135
139 [RelayCommand]
140 private async Task Reject()
141 {
142 this.result.TrySetResult(PresenceRequestAction.Reject);
143 await ServiceRef.PopupService.PopAsync();
144 }
145
146 [RelayCommand]
147 private async Task Ignore()
148 {
149 this.result.TrySetResult(PresenceRequestAction.Ignore);
150 await ServiceRef.PopupService.PopAsync();
151 }
152
156 internal void Close()
157 {
158 this.result.TrySetResult(PresenceRequestAction.Ignore);
159 }
160 }
161}
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
A base class for all view models, inheriting from the BindableObject. NOTE: using this class requir...
SubscriptionRequestViewModel(string BareJid, string FriendlyName, string? PhotoUrl, int PhotoWidth, int PhotoHeight)
View model for SubscriptionRequestPopup
PresenceRequestAction
How to respond to a presence subscription request.