Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
AppsViewModel.cs
1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
11using EDaler;
14using System.Runtime.CompilerServices;
17using System; // For EventHandler
18
20{
21 public partial class AppsViewModel : BaseViewModel
22 {
23 private bool hasBetaFeatures;
24
25 public AppsViewModel() : base()
26 {
27 this.hasBetaFeatures = ServiceRef.TagProfile.HasBetaFeatures;
28 }
29
33 public bool HasBetaFeatures
34 {
35 get => this.hasBetaFeatures;
36 set
37 {
38 if (this.hasBetaFeatures == value)
39 return;
40 this.hasBetaFeatures = value;
41 this.OnPropertyChanged(nameof(this.HasBetaFeatures));
42 this.OnPropertyChanged(nameof(this.BetaButtonStyle));
43 }
44 }
45
49 public Style BetaButtonStyle => this.HasBetaFeatures ? AppStyles.NeuroIconButton : AppStyles.NeuroIconButtonDisabled;
50
51 [ObservableProperty]
52 private bool showBottomNavigation = true;
53
57 public override async Task OnInitializeAsync()
58 {
59 await base.OnInitializeAsync();
60 ServiceRef.TagProfile.OnPropertiesChanged += this.TagProfile_OnPropertiesChanged;
61 }
62
66 public override async Task OnDisposeAsync()
67 {
68 ServiceRef.TagProfile.OnPropertiesChanged -= this.TagProfile_OnPropertiesChanged;
69 await base.OnDisposeAsync();
70 }
71
75 private void TagProfile_OnPropertiesChanged(object? sender, EventArgs e)
76 {
77 bool profileValue = ServiceRef.TagProfile.HasBetaFeatures;
78 if (this.HasBetaFeatures != profileValue)
79 {
80 this.HasBetaFeatures = profileValue;
81 }
82 }
83
84 #region Navigation Commands
85
86 [RelayCommand]
87 private static async Task ShowContacts()
88 {
89 try
90 {
92 }
93 catch (Exception Ex)
94 {
95 ServiceRef.LogService.LogException(Ex);
96 }
97 }
98
99 [RelayCommand]
100 private static async Task ShowMyContracts()
101 {
102 try
103 {
104 MyContractsNavigationArgs Args = new(ContractsListMode.Contracts);
106 }
107 catch (Exception ex)
108 {
109 ServiceRef.LogService.LogException(ex);
110 }
111 }
112
113 [RelayCommand]
114 private static async Task ShowApplications()
115 {
116 try
117 {
119 }
120 catch (Exception Ex)
121 {
122 ServiceRef.LogService.LogException(Ex);
123 }
124 }
125
126 [ObservableProperty]
127 private bool betaFeaturePressed = false;
128
129 [RelayCommand]
130 private async Task ShowThings()
131 {
132 try
133 {
135 {
136 this.BetaFeaturePressed = true;
137 await Task.Delay(100);
138 this.BetaFeaturePressed = false;
139 }
140 else
141 {
143 }
144 }
145 catch (Exception Ex)
146 {
147 ServiceRef.LogService.LogException(Ex);
148 }
149 }
150
151 [RelayCommand]
152 private async Task ShowNewContract()
153 {
154 try
155 {
157 {
158 this.BetaFeaturePressed = true;
159 await Task.Delay(100);
160 this.BetaFeaturePressed = false;
161 }
162 else
163 {
164 MyContractsNavigationArgs Args = new(ContractsListMode.ContractTemplates);
166 }
167 }
168 catch (Exception Ex)
169 {
170 ServiceRef.LogService.LogException(Ex);
171 }
172 }
173
174 [RelayCommand]
175 private async Task ShowNewToken()
176 {
177 try
178 {
180 {
181 this.BetaFeaturePressed = true;
182 await Task.Delay(100);
183 this.BetaFeaturePressed = false;
184 }
185 else
186 {
187 MyContractsNavigationArgs Args = new(ContractsListMode.TokenCreationTemplates);
189 }
190 }
191 catch (Exception Ex)
192 {
193 ServiceRef.LogService.LogException(Ex);
194 }
195 }
196
197 [RelayCommand]
198 private async Task ShowMyTokens()
199 {
200 try
201 {
203 {
204 this.BetaFeaturePressed = true;
205 await Task.Delay(100);
206 this.BetaFeaturePressed = false;
207 }
208 else
209 {
211 }
212 }
213 catch (Exception Ex)
214 {
215 ServiceRef.LogService.LogException(Ex);
216 }
217 }
218
219 [RelayCommand]
220 private static async Task ShowId()
221 {
222 try
223 {
224 if (await ServiceRef.Provider.GetRequiredService<IAuthenticationService>().AuthenticateUserAsync(AuthenticationPurpose.ViewId))
226 }
227 catch (Exception Ex)
228 {
229 ServiceRef.LogService.LogException(Ex);
230 }
231 }
232
233 [RelayCommand]
234 public async Task ShowWallet()
235 {
236 try
237 {
239 {
240 this.BetaFeaturePressed = true;
241 await Task.Delay(100);
242 this.BetaFeaturePressed = false;
243 }
244 else
245 {
246 WalletNavigationArgs Args = new();
248 }
249 }
250 catch (Exception Ex)
251 {
252 ServiceRef.LogService.LogException(Ex);
254 }
255 }
256
257 [RelayCommand]
258 private async Task ShowWalletBottombar()
259 {
261 {
262 await this.ShowComingSoonPopup();
263 }
264 else
265 {
266 await this.ShowWallet();
267 }
268 }
269
270 [RelayCommand]
271 public async Task ViewMainPage()
272 {
273 try
274 {
276 }
277 catch (Exception Ex)
278 {
279 ServiceRef.LogService.LogException(Ex);
280 }
281 }
282
283 [ObservableProperty]
284 private bool showingComingSoonPopup = false;
285
286 [RelayCommand(AllowConcurrentExecutions = false)]
287 public async Task ShowComingSoonPopup()
288 {
289 this.ShowingComingSoonPopup = true;
290 await Task.Delay(3000);
291 this.ShowingComingSoonPopup = false;
292 }
293
294 #endregion
295 }
296}
Base class that references services in the app.
Definition: ServiceRef.cs:43
static IServiceProvider Provider
The service provider for the app. This is set before the app is started, and will be used to resolve ...
Definition: ServiceRef.cs:48
static ILogService LogService
Log service.
Definition: ServiceRef.cs:214
static IUiService UiService
Service serializing and managing UI-related tasks.
Definition: ServiceRef.cs:130
static INavigationService NavigationService
The navigation service for navigating between pages.
Definition: ServiceRef.cs:178
static ITagProfile TagProfile
TAG Profile service.
Definition: ServiceRef.cs:202
Static class that gives access to app-specific styles
Definition: AppStyles.cs:12
static Style NeuroIconButtonDisabled
Style for NeuroIconButtonDisabled
Definition: AppStyles.cs:608
A base class for all view models, inheriting from the BindableObject. NOTE: using this class requir...
A page that displays a list of the current user's contacts.
Holds navigation parameters specific to views displaying a list of contacts.
A page that displays a list of the current user's contracts.
A page to display when the user wants to view an identity.
bool HasBetaFeatures
Indicates if beta features are enabled in the profile.
Style BetaButtonStyle
Style for beta‑feature dependent buttons.
override async Task OnInitializeAsync()
Subscribes to profile property changes.
override async Task OnDisposeAsync()
Unsubscribes from profile property changes.
A page that displays a list of the current user's things.
A page that allows the user to view its tokens.
Holds navigation parameters specific to the eDaler wallet.
A page that allows the user to view the contents of its eDaler wallet, pending payments and recent ac...
bool HasBetaFeatures
If the user has Beta features enabled
Definition: ITagProfile.cs:262
Task GoToAsync(string Route)
Navigates to the specified route and pushes the page onto the navigation stack.
Task PopToRootAsync()
Pops all pages until only the root page remains on the navigation stack.
Task DisplayException(Exception Exception, string? Title=null)
Displays an alert/message box to the user.
BackMethod
Navigation Back Method
Definition: BackMethod.cs:7
AuthenticationPurpose
Purpose for requesting the user to authenticate itself.