Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DisplayAlert.cs
1using Mopups.Services;
4
6{
14 public class DisplayAlert(string Title, string Message, string? Accept, string? Cancel) : UiTask
15 {
19 public string Title { get; } = Title;
20
24 public string Message { get; } = Message;
25
29 public string? Accept { get; } = Accept;
30
34 public string? Cancel { get; } = Cancel;
35
39 public TaskCompletionSource<bool> CompletionSource { get; } = new TaskCompletionSource<bool>();
40
44 public override async Task Execute()
45 {
46 bool Result;
47
48 Page? displayedPage = ServiceRef.UiService.PopupStack.LastOrDefault() ?? App.Current?.MainPage;
49
50 if (!string.IsNullOrWhiteSpace(this.Accept) && !string.IsNullOrWhiteSpace(this.Cancel))
51 {
52 Result = await (displayedPage?.DisplayAlert(this.Title, this.Message, this.Accept, this.Cancel) ??
53 Task.FromResult(false));
54 }
55 else if (!string.IsNullOrWhiteSpace(this.Cancel))
56 {
57 await (displayedPage?.DisplayAlert(this.Title, this.Message, this.Cancel) ?? Task.CompletedTask);
58 Result = true;
59 }
60 else if (!string.IsNullOrWhiteSpace(this.Accept))
61 {
62 await (displayedPage?.DisplayAlert(this.Title, this.Message, this.Accept) ?? Task.CompletedTask);
63 Result = true;
64 }
65 else
66 {
67 await (displayedPage?.DisplayAlert(this.Title, this.Message,
68 ServiceRef.Localizer[nameof(AppResources.Ok)]) ?? Task.CompletedTask);
69
70 Result = true;
71 }
72
73 this.CompletionSource.TrySetResult(Result);
74 }
75 }
76}
The Application class, representing an instance of the Neuro-Access app.
Definition: App.xaml.cs:69
static new? App Current
Gets the current application, type casted to App.
Definition: App.xaml.cs:99
Base class that references services in the app.
Definition: ServiceRef.cs:31
static IUiService UiService
Service serializing and managing UI-related tasks.
Definition: ServiceRef.cs:55
static IStringLocalizer Localizer
Localization service
Definition: ServiceRef.cs:235
Abstract base class for UI tasks.
Definition: UiTask.cs:7