Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ShowPermissionViewModel.cs
1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
3using Microsoft.Maui.Controls.Shapes;
5
7{
9 {
10 #region Private Properties
11 private bool hasBeenToSettings = false;
12
13 #endregion
14
15 #region Public Properties
16
20 [ObservableProperty]
21 private string title = string.Empty;
22
26 [ObservableProperty]
27 private string description = string.Empty;
28
32 [ObservableProperty]
33 private string descriptionSecondary = string.Empty;
34
35 [ObservableProperty]
36 private Geometry? iconGeometry = Geometries.InfoCirclePath;
37
41 public double CameraIconBackgroundSize => 120.0;
42
46 public RoundRectangle CameraIconBackgroundStrokeShape => new RoundRectangle { CornerRadius = this.CameraIconBackgroundSize / 2 };
47
51 public double CameraIconSize => 60.0;
52
53 #endregion
54
55 #region Constructor
56
57 public ShowPermissionViewModel(string? title, string? description, string? descriptionSecondary, Geometry? iconGeometry = null)
58 {
59 this.Title = title ?? string.Empty;
60 this.Description = description ?? string.Empty;
61 this.DescriptionSecondary = descriptionSecondary ?? string.Empty;
62 this.IconGeometry = iconGeometry ?? Geometries.InfoCirclePath;
63 }
64
65 #endregion
66
67
68 #region Overrides
69
70 public override async Task OnInitializeAsync()
71 {
72 await base.OnInitializeAsync();
73
74 App.AppActivated += this.App_OnActivated;
75
76 }
77
78 public override Task OnDisposeAsync()
79 {
80 App.AppActivated -= this.App_OnActivated;
81
82 return base.OnDisposeAsync();
83 }
84
85 protected async void App_OnActivated(object? sender, EventArgs e)
86 {
87 try
88 {
89 if (this.hasBeenToSettings)
90 {
91 await this.Close();
92 }
93 }
94 catch (Exception)
95 {
96 //Ignore no need to handle this exception, the user needs to close popup manually
97 }
98 }
99 #endregion
100
101 #region Commands
102
103 [RelayCommand]
104 private async Task Close()
105 {
106 await ServiceRef.PopupService.PopAsync();
107 }
108
109 [RelayCommand]
110 private void GoToSettings()
111 {
112 this.hasBeenToSettings = true;
113 AppInfo.Current.ShowSettingsUI();
114 }
115 #endregion
116 }
117}
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 class containing SVG Paths for symbols used in the app.
Definition: Geometries.cs:11
static readonly Geometry InfoCirclePath
Information circle
Definition: Geometries.cs:249
Base class for popup view models/>.
double CameraIconBackgroundSize
Gets the size of the background for Camera Icon
override async Task OnInitializeAsync()
Method called when view is initialized for the first time. Use this method to implement registration ...
override Task OnDisposeAsync()
Method called when the view is disposed, and will not be used more. Use this method to unregister eve...
RoundRectangle CameraIconBackgroundStrokeShape
Gets the Readius of the background for Camera Icon